-
Notifications
You must be signed in to change notification settings - Fork 5
/
GMLLinearRing.R
49 lines (49 loc) · 1.44 KB
/
GMLLinearRing.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#' GMLLinearRing
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO GML LinearRing
#' @return Object of \code{\link{R6Class}} for modelling an GML LinearRing
#' @format \code{\link{R6Class}} object.
#'
#' @field posList
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(xml, m)}}{
#' This method is used to instantiate a GML LinearRing
#' }
#' }
#'
#' @note Experimental
#'
#' @references
#' ISO 19136:2007 Geographic Information -- Geographic Markup Language.
#' http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=32554
#'
#' OGC Geography Markup Language. http://www.opengeospatial.org/standards/gml
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
GMLLinearRing <- R6Class("GMLLinearRing",
inherit = GMLAbstractRing,
private = list(
xmlElement = "LinearRing",
xmlNamespacePrefix = "GML"
),
public = list(
attrs = list("gml:id" = NA),
posList = matrix(NA_real_, 2, 2),
initialize = function(xml = NULL, m){
super$initialize(xml, element = private$xmlElement, wrap = TRUE)
if(is.null(xml)){
if(!is(m, "matrix")) stop("Input 'matrix' object should be a 'matrix'")
m.dims <- dim(m)
if(m.dims[1]<4) stop("Input 'matrix' object should contain 4 or more coordinate tuples")
if(!all(m[1L,] == m[m.dims[1],])) stop("First and last coordinates should be coincident")
self$posList <- m
}
}
)
)