# Class Boundaries: store and manipulate extents of CRS ------------------------
# Virtual class NullCRS --------------------------------------------------------
# Used to allow flexibility in slot crs of class Boundaries.
setClassUnion("NullCRS", c("NULL", "CRS"))
# Definition -------------------------------------------------------------------
setClass("Boundaries",
slots = list(
proj = "Extent",
wgs84 = "Extent",
crs = "NullCRS"),
prototype = list(
proj = extent(c(0, 0, 0, 0)),
wgs84 = extent(c(0, 0, 0, 0)),
crs = new("CRS", projargs = NA_character_)))
# Validator --------------------------------------------------------------------
.validBoundaries.crs <- function(crs)
{
.validCRS(crs)
}
.validBoundaries <- function(object)
{
txt <- .validBoundaries.crs(object@crs)
txt <- txt[nchar(txt) > 0L]
if (length(txt)) {
res <- txt
} else {
res <- TRUE
}
res
}
setValidity("Boundaries", .validBoundaries)
# Helpers and lambda functions -------------------------------------------------
# None.
# Tests ------------------------------------------------------------------------
getClass("Boundaries")
new("Geocodes", coords = data.table(a = 1, y = 2, z = 3),
keys = c("lol", "lol"), crs = CRS("+init=epsg:4", FALSE))
new("Geocodes", coords = data.table(x = c(1, 2), y = c(3, 4)),
keys = c("R1", "R2"), crs = CRS("+init=epsg:4326"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.