-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
170 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
) | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
|
||
}) |