Skip to content

Commit

Permalink
#153 MI_GCP --> ISOImageryGCP
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Jun 9, 2019
1 parent 0bd4973 commit 40f4d3c
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 7 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export(ISOImageryCoverageDescription)
export(ISOImageryCoverageResult)
export(ISOImageryEnvironmentalRecord)
export(ISOImageryEvent)
export(ISOImageryGCP)
export(ISOImageryGCPCollection)
export(ISOImageryGeometryType)
export(ISOImageryImageDescription)
Expand Down
10 changes: 6 additions & 4 deletions R/ISOAbstractObject.R
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,9 @@ ISOAbstractObject <- R6Class("ISOAbstractObject",
}
}
}else{
xmlNamespacePrefix <- "GML"
if(startsWith(nsPrefix,"gml")) xmlNamespacePrefix <- toupper(nsPrefix)
#xmlNamespacePrefix <- "GML"
#if(startsWith(nsPrefix,"gml")) xmlNamespacePrefix <- toupper(nsPrefix)
xmlNamespacePrefix <- self$getClass()$private_fields$xmlNamespacePrefix
gmlElem <- GMLElement$new(element = fieldName, xmlNamespacePrefix = xmlNamespacePrefix)
gmlElem$decode(xml = childElement)
if(is(self[[fieldName]], "list")){
Expand All @@ -554,8 +555,9 @@ ISOAbstractObject <- R6Class("ISOAbstractObject",
}
}
}else{
xmlNamespacePrefix <- "GML"
if(startsWith(nsPrefix,"gml")) xmlNamespacePrefix <- toupper(nsPrefix)
#xmlNamespacePrefix <- "GML"
#if(startsWith(nsPrefix,"gml")) xmlNamespacePrefix <- toupper(nsPrefix)
xmlNamespacePrefix <- self$getClass()$private_fields$xmlNamespacePrefix
gmlElem <- GMLElement$new(element = fieldName, xmlNamespacePrefix = xmlNamespacePrefix)
gmlElem$decode(xml = childElement)
if(is(self[[fieldName]], "list")){
Expand Down
72 changes: 72 additions & 0 deletions R/ISOImageryGCP.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#' ISOImageryGCPCollection
#'
#' @docType class
#' @importFrom R6 R6Class
#' @export
#' @keywords ISO imagery gcp collection
#' @return Object of \code{\link{R6Class}} for modelling an ISO imagery gcp collection
#' @format \code{\link{R6Class}} object.
#'
#' @section Methods:
#' \describe{
#' \item{\code{new(xml)}}{
#' This method is used to instantiate an \code{\link{ISOImageryGCPCollection}}
#' }
#' \item{\code{setCollectionIdentification(id)}}{
#' Set the identifier, object of class \code{integer}
#' }
#' \item{\code{setCollectionName(name, locales)}}{
#' Sets a name (object of class "character"). Locale names can be
#' specified as \code{list} with the \code{locales} argument.
#' }
#' \item{\code{setCoordinateReferenceSystem(crs)}}{
#' Sets the crs, object of class \code{\link{ISOReferenceSystem}}
#' }
#' \item{\code{addGCP(gcp)}}{
#' Adds a GCP, object of class \code{\link{ISOImageryGCP}}
#' }
#' \item{\code{delGCP(gcp)}}{
#' Deletes a GCP, object of class \code{\link{ISOImageryGCP}}
#' }
#' }
#'
#' @examples
#' md <- ISOImageryGCP$new()
#' require(sf)
#' pt <- sf::st_point(c(1,1))
#' md$setGeographicCoordinates(sfg = pt)
#' xml <- md$encode()
#'
#' @references
#' ISO 19115-2:2009 - Geographic information -- Metadata Part 2: Extensions for imagery and gridded data
#'
#' @author Emmanuel Blondel <emmanuel.blondel1@@gmail.com>
#'
ISOImageryGCP <- R6Class("ISOImageryGCP",
inherit = GMLAbstractObject,
private = list(
xmlElement = "MI_GCP",
xmlNamespacePrefix = "GMI"
),
public = list(
geographicCoordinates = matrix(NA_real_, 1, 2),
initialize = function(xml = NULL){
super$initialize(xml = xml)
},

#setGeographicCoordinates
setGeographicCoordinates = function(sfg = NULL, m = NULL){
if(!is.null(sfg)){
if(!is(sfg, c("sfg","POINT"))) stop("Input 'sfg' object should be a 'point'")
m <- as.matrix(sfg)
}else if(!is.null(m)){
if(!is.matrix(m)){
stop("The argument 'm' should a matrix")
}
}
self$geographicCoordinates <- GMLElement$create(element = "geographicCoordinates", xmlNamespacePrefix = "GMI")
self$geographicCoordinates$pos <- GMLElement$create(element = "pos", value = m)
}
)
)

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ We thank in advance people that use ``geometa`` for citing it in their work / pu
|:------------------------------------|:-----------------------------------------------------------------------------------|:---------|:-------------------------------------------------------------------------------------------------------------------------------|---------:|-------:|
|ISO/TC211 19110:2005 |Geographic Information - Methodology for feature cataloguing |GFC |[![ISO/TC211 19110:2005](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa) | 17| 0|
|ISO/TC211 19115-1:2003 |Geographic Information - Metadata |GMD |[![ISO/TC211 19115-1:2003](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa) | 132| 0|
|ISO/TC211 19115-2:2009 |Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data |GMI |[![ISO/TC211 19115-2:2009](https://img.shields.io/badge/-82%25-33cc7a.svg)](https://github.com/eblondel/geometa) | 33| 7|
|ISO/TC211 19115-2:2009 |Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data |GMI |[![ISO/TC211 19115-2:2009](https://img.shields.io/badge/-85%25-33cc7a.svg)](https://github.com/eblondel/geometa) | 34| 6|
|ISO/TC211 19119:2005 |Geographic Information - Service Metadata |SRV |[![ISO/TC211 19119:2005](https://img.shields.io/badge/-37%25-ff0c0c.svg)](https://github.com/eblondel/geometa) | 7| 12|
|ISO/TC211 19139:2007 |Geographic Metadata XML Schema |GMX |[![ISO/TC211 19139:2007](https://img.shields.io/badge/-8%25-ad0f0f.svg)](https://github.com/eblondel/geometa) | 5| 61|
|ISO/TS 19103:2005 |Geographic Common extensible markup language |GCO |[![ISO/TS 19103:2005](https://img.shields.io/badge/-100%25-4a4ea8.svg)](https://github.com/eblondel/geometa) | 22| 0|
Expand Down
2 changes: 1 addition & 1 deletion inst/extdata/coverage/geometa_coverage_inventory.csv
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_CoverageDescription","ISOImageryCoverageDescription",TRUE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_EnvironmentalRecord","ISOImageryEnvironmentalRecord",TRUE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_Event","ISOImageryEvent",TRUE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_GCP","<missing>",FALSE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_GCP","ISOImageryGCP",TRUE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_GCPCollection","ISOImageryGCPCollection",TRUE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_GeometryTypeCode","ISOImageryGeometryType",TRUE
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI","MI_Georectified","<missing>",FALSE
Expand Down
2 changes: 1 addition & 1 deletion inst/extdata/coverage/geometa_coverage_summary.csv
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"Standard","Title","Namespace","Supported","Missing","Coverage"
"ISO/TC211 19110:2005","Geographic Information - Methodology for feature cataloguing","GFC",17,0,100
"ISO/TC211 19115-1:2003","Geographic Information - Metadata","GMD",132,0,100
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI",33,7,82.5
"ISO/TC211 19115-2:2009","Geographic Information - Metadata - Part 2: Extensions for imagery and gridded data","GMI",34,6,85
"ISO/TC211 19119:2005","Geographic Information - Service Metadata","SRV",7,12,36.84
"ISO/TC211 19139:2007","Geographic Metadata XML Schema","GMX",5,61,7.58
"ISO/TS 19103:2005","Geographic Common extensible markup language","GCO",22,0,100
Expand Down
59 changes: 59 additions & 0 deletions man/ISOImageryGCP.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions tests/testthat/test_ISOImageryGCP.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# test_ISOImageryGCP.R
# Author: Emmanuel Blondel <emmanuel.blondel1@gmail.com>
#
# Description: Unit tests for ISOImageryGCP.R
#=======================
require(geometa, quietly = TRUE)
require(sf, quietly = TRUE)
require(testthat)

context("ISOImageryGCP")

test_that("encoding",{

#encoding
md <- ISOImageryGCP$new()
pt <- sf::st_point(c(0,0))
md$setGeographicCoordinates(sfg = pt)

expect_is(md, "ISOImageryGCP")
xml <- md$encode()
expect_is(xml, "XMLInternalNode")

#decoding
md2 <- ISOImageryGCP$new(xml = xml)
xml2 <- md2$encode()

expect_true(ISOAbstractObject$compare(md, md2))

})

0 comments on commit 40f4d3c

Please sign in to comment.