1# Author: Robert J. Hijmans
2# Date :  July 2019
3# Version 1.0
4# License GPL v3
5
6setMethod("lines", signature(x="SpatExtent"),
7	function(x, col, ...)  {
8		e <- as.vector(x)
9		p <- rbind(c(e[1],e[3]), c(e[1],e[4]), c(e[2],e[4]), c(e[2],e[3]), c(e[1],e[3]))
10		if (missing(col)) col <- "black"
11		graphics::lines(p, col=col[1], ...)
12	}
13)
14
15setMethod("plot", signature(x="SpatExtent", y="missing"),
16	function(x, ...)  {
17		test <- try(x$valid, silent=TRUE)
18		if (inherits(test, "try-error")) {
19			error("plot", "invalid SpatExtent")
20		}
21		plot(as.polygons(x), ...)
22	}
23)
24
25setMethod("points", signature(x="SpatExtent"),
26	function(x, col, ...)  {
27		e <- as.vector(x)
28		p <- rbind(c(e[1],e[3]), c(e[1],e[4]), c(e[2],e[4]), c(e[2],e[3]), c(e[1],e[3]))
29		if (missing(col)) col <- "black"
30		col <- .getCols(4, col)
31		if (is.null(col)) col <- "black"
32		graphics::points(p, col=col, ...)
33	}
34)
35
36