#' An S4 class to represent the spatial extent of a dataset
#'
#' @slot wkt The extent as WKT
#' @slot gml The extent as GML
setClass (
Class = "SpatialExtent",
representation = representation(
wkt = "character",
gml = "character"
),
validity = function(object){
cat("~~~ SpatialExtent: inspector ~~~ \n")
wkt <- object@wkt
gml <- object@gml
#TODO: Validate!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11
if(FALSE){
#TODO: Escribir mensaje de error
stop ("[SpatialExtent: validation] .....")
}else{}
return(TRUE)
}
)
#*******************************************************
#CONSTRUCTOR
setMethod (
f="initialize",
signature="SpatialExtent",
definition=function(.Object,wkt,gml){
cat ("~~~~~ SpatialExtent: initializator ~~~~~ \n")
if(length(wkt) == 1){
.Object@wkt <- wkt
}else{
.Object@wkt <- character(0)
}
if(length(gml) == 1){
.Object@gml <- gml
}else{
.Object@gml <- character(0)
}
validObject(.Object)# call of the inspector
return(.Object)
}
)
#CONSTRUCTOR (USER FRIENDLY)
spatialExtent <- function(wkt, gml){
cat ("~~~~~ SpatialExtent: constructor ~~~~~ \n")
new (Class="SpatialExtent", wkt = wkt, gml = gml)
}
#*******************************************************
#ACCESSORS
setGeneric("getWkt",function(object){standardGeneric ("getWkt")})
setMethod("getWkt","SpatialExtent",
function(object){
return(object@wkt)
}
)
setGeneric("getGml",function(object){standardGeneric ("getGml")})
setMethod("getGml","SpatialExtent",
function(object){
return(object@gml)
}
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.