Skip to content

Commit

Permalink
#25 support bounding polygon creation from entity data features
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Oct 21, 2019
1 parent aa0cf20 commit 05f9c7d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: geoflow
Version: 0.0.9004
Date: 2019-10-19
Date: 2019-10-21
Title: R engine to orchestrate and run geospatial (meta)data workflows
Authors@R: c(
person("Emmanuel", "Blondel", role = c("aut", "cre"), email = "emmanuel.blondel1@gmail.com", comment = c(ORCID = "0000-0002-5870-5762")),
Expand Down
2 changes: 1 addition & 1 deletion R/geoflow.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#' Package: \tab geoflow\cr
#' Type: \tab Package\cr
#' Version: \tab 0.0.9004\cr
#' Date: \tab 2019-10-19\cr
#' Date: \tab 2019-10-21\cr
#' License: \tab MIT\cr
#' LazyLoad: \tab yes\cr
#' }
Expand Down
4 changes: 3 additions & 1 deletion R/geoflow_action.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ register_actions <- function(){
options = list(
doi = list(desc = "Add entity DOI - if defined - as metadata identifier and online resource", default = FALSE),
inspire = list(desc = "Validates ISO 19139 metadata with INSPIRE reference validator", default = FALSE),
logo = list(desc = "Add configure profile logo(s) - if defined - as metadata thumbnail(s)", default = FALSE)
logo = list(desc = "Add configure profile logo(s) - if defined - as metadata thumbnail(s)", default = FALSE),
addfeatures = list(desc = "Add entity data features - if defined - as metadata bounding polygon(s)", default = FALSE),
featureId = list(desc = "ID of entity data features used to identify bounding polygon(s) with option 'addfeatures'", default = NA)
)
),
geoflow_action$new(
Expand Down
19 changes: 17 additions & 2 deletions R/geoflow_action_geometa_create_iso_19115.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ geometa_create_iso_19115 <- function(entity, config, options){
stop("This action requires the 'geometa' package")
}

#features if any
features <- entity$data$features

#options
inspire <- if(!is.null(options$inspire)) options$inspire else FALSE
logo <- if(!is.null(options$logo)) options$logo else FALSE
doi <- if(!is.null(options$doi)) options$doi else FALSE
addfeatures <- if(!is.null(options$addfeatures)) options$addfeatures else FALSE
featureid <- if(!is.null(options$featureid)){ options$featureid } else { if(!is.null(features)) colnames(features)[1] else NULL}

#metadata creation
#-----------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -227,7 +232,17 @@ geometa_create_iso_19115 <- function(entity, config, options){
if(!is.null(entity$spatial_extent)){
sf_bbox <- entity$spatial_extent
bbox <- ISOGeographicBoundingBox$new(minx = sf_bbox$xmin, miny = sf_bbox$ymin, maxx = sf_bbox$xmax, maxy = sf_bbox$ymax)
extent$setGeographicElement(bbox)
extent$addGeographicElement(bbox)
}
#bounding polygons (if any features & 'addfeatures' option is enabled)
if(!is.null(features) && addfeatures){
bp <- ISOBoundingPolygon$new()
for(i in 1:nrow(features)){
geom <- GMLAbstractGeometry$fromSimpleFeatureGeometry(features[i,]$geometry[[1]])
geom$attrs["gml:id"] <- paste0("fid.",as.character(features[i,][featureid])[1])
bp$polygon <- c(bp$polygon, geom)
}
extent$addGeographicElement(bp)
}
#temporal extent
if(!is.null(entity$temporal_extent)){
Expand All @@ -240,7 +255,7 @@ geometa_create_iso_19115 <- function(entity, config, options){
gmltimeperiod <- GMLTimePeriod$new(beginPosition = entity$temporal_extent$start, endPosition = entity$temporal_extent$end)
time$setTimePeriod(gmltimeperiod)
}
extent$setTemporalElement(time)
extent$addTemporalElement(time)
}
ident$setExtent(extent)

Expand Down
2 changes: 1 addition & 1 deletion man/geoflow.Rd

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

0 comments on commit 05f9c7d

Please sign in to comment.