Skip to content

Commit

Permalink
implement #374
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Nov 9, 2023
1 parent 3e91fd0 commit 719f614
Show file tree
Hide file tree
Showing 12 changed files with 302 additions and 15 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: geoflow
Version: 0.20230906
Date: 2023-09-06
Version: 0.20231109
Date: 2023-11-09
Title: Tools to Orchestrate Geospatial (Meta)Data Management Workflows and Manage FAIR Services
Description: An engine to facilitate the orchestration and execution of metadata-driven data management workflows, in compliance with FAIR
(Findable, Accessible, Interoperable and Reusable) data management principles. By means of a pivot metadata model, relying on the DublinCore standard (<https://dublincore.org/>),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export(check_packages)
export(closeWorkflow)
export(create_geoflow_data_from_dbi)
export(debugWorkflow)
export(describeOGCRelation)
export(enrich_text_from_entity)
export(executeWorkflow)
export(executeWorkflowJob)
Expand Down
8 changes: 8 additions & 0 deletions R/geoflow_action.R
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,18 @@ register_actions <- function(){
enrich_with_relations = list(def = "When enabled, enrichs entity with OGC relations", class = "logical", default = TRUE),
enrich_with_relation_wms = list(def = "When enabled, enrichs entity with a base WMS link relation", class = "logical", default = TRUE),
enrich_with_relation_wms_thumbnail = list(def = "When enabled, enrichs entity with a WMS-based thumbnail relation", class = "logical", default = TRUE),
describe_wms_relation_with_category = list(def = "When enabled, the WMS main relation description will be appended with the mention 'Map access'", class = "logical", default = TRUE),
describe_wms_relation_with_ogc_service_description = list(def = "When enabled, the WMS main relation description will be appended with the mention 'OGC Web Map Service (WMS)'", class = "logical", default = TRUE),
enrich_with_relation_wfs = list(def = "When enabled, enrichs entity with a base WFS link relation (applies to 'vector' only)", class = "logical", default = TRUE),
enrich_with_relation_wfs_download_links = list(def = "When enabled, enrichs entity with WFS format-specific (GML, GeoJSON, SHAPE-ZIP, CSV) links for download purpose (applies to 'vector' only).", class = "logical", default = TRUE),
describe_wfs_relation_with_category = list(def = "When enabled, the WFS relations description will be appended with the mention 'Data (features) access' for the base WFS link or 'Data download' in case of download links", class = "logical", default = TRUE),
describe_wfs_relation_with_ogc_service_description = list(def = "When enabled, the WFS relations description will be appended with the mention 'OGC Web Feature Service (WFS)'", class = "logical", default = TRUE),
describe_wfs_relation_with_format = list(def = "When enabled, the WFS download relations description will be appended with the mention of the download format", class = "logical", default = TRUE),
enrich_with_relation_wcs = list(def = "When enabled, enrichs entity with a base WCS link relation (applies to 'grid' only)", class = "logical", default = TRUE),
enrich_with_relation_wcs_download_links = list(def = "When enabled, enrichs entity with WCS format-specific links for download purpose (applies to 'grid' only). Only GeoTIFF at now.", class = "logical", default = TRUE),
describe_wcs_relation_with_category = list(def = "When enabled, the WCS relations description will be appended with the mention 'Data (coverage) access' for the base WCS link or 'Data download' in case of download links", class = "logical", default = TRUE),
describe_wcs_relation_with_ogc_service_description = list(def = "When enabled, the WCS relations description will be appended with the mention 'OGC Web Coverage Service (WCS)'", class = "logical", default = TRUE),
describe_wcs_relation_with_format = list(def = "When enabled, the WCS download relations description will be appended with the mention of the download format", class = "logical", default = TRUE),
overwrite_upload = list(def = "When set to TRUE (default), in case a layer already exists, data upload will be re-done (if upload is set to true in entity Data).", class = "logical", default = TRUE),
overwrite_layer = list(def = "When set to TRUE (default), in case a layer already exists, layer will be republished.", class = "logical", default = TRUE),
overwrite = list(def = "When set to TRUE (default), in case a layer already exists, data upload will be re-done (if upload is set to true in entity Data), and layer will be re-published. This option preveals over options 'overwrite_upload' and 'overwrite_layer'", class = "logical", default = TRUE)
Expand Down
76 changes: 75 additions & 1 deletion R/geoflow_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ geoflow_data <- R6Class("geoflow_data",
store = NULL,
#'@field layername layer name
layername = NULL,
#'@field layertitle layer title
layertitle = NULL,
#'@field layerdesc layer description
layerdesc = NULL,
#'@field layeruri layer URI
#'layeruri layer URI
layeruri = NULL,
#'@field styles styles
styles = list(),
#'@field styleUpload upload styles
Expand Down Expand Up @@ -222,10 +229,21 @@ geoflow_data <- R6Class("geoflow_data",
}

#layername (if any)
#not mandatory, can be used for subset layers
if(!is.null(data_props$layername)){
self$setLayername(data_props$layername$values[[1]])
}
#layertitle (if any)
if(!is.null(data_props$layertitle)){
self$setLayertitle(data_props$layertitle$values[[1]])
}
#layerdesc (if any)
if(!is.null(data_props$layerdesc)){
self$setLayerdesc(data_props$layerdesc$values[[1]])
}
#layeruri (if any)
if(!is.null(data_props$layeruri)){
self$setLayeruri(data_props$layeruri$values[[1]])
}

#sql
if(!is.null(data_props$sql)){
Expand Down Expand Up @@ -411,6 +429,8 @@ geoflow_data <- R6Class("geoflow_data",

#datadir
if(any(sapply(data_props, function(x){x$key=="dir"}))){
accessor <- NULL
accessor_software <- NULL
data_dir <- data_props$dir$values[[1]]
self$dir <- data_dir
ext_data_files <- list()
Expand Down Expand Up @@ -470,7 +490,31 @@ geoflow_data <- R6Class("geoflow_data",
ext_data_files <-ext_data_files[!endsWith(ext_data_files,".sld")]
}

#detect presence of data files register
data_files_register <- NULL
data_files_register_file = ext_data_files[basename(ext_data_files) == "register.csv"]
if(length(data_files_register_file)>0){
data_files_register_file = data_files_register_file[1]
target_register_file = data_files_register_file
if(!is.null(accessor)){
target_register_file <- file.path(tempdir(), "register.csv")
accessor$download(
resource = data_files_register_file,
file = "register.csv",
path = target_register_file,
software = accessor_software,
unzip = FALSE
)
}
data_files_register = as.data.frame(readr::read_csv(target_register_file))
register_colnames = c("code","uri","label","definition")
if(!all(register_colnames %in% colnames(data_files_register))){
stop("A data files register has been found but doesn't follow the standard structure (code,uri,label,definition)")
}
}

#geoflow build children
ext_data_files = ext_data_files[basename(ext_data_files) != "register.csv"]
if(length(ext_data_files)>0){
self$data <- lapply(ext_data_files, function(data_file){
ext_data <- self$clone(deep = TRUE) #clone parent geoflow_data to inherit all needed properties
Expand All @@ -497,6 +541,7 @@ geoflow_data <- R6Class("geoflow_data",
ext_data$setSourceType(sourceType)
}
if((is.null(self$uploadType) || self$uploadType == "other") && !is.null(sourceType)){
print(sourceType)
if(sourceType != "zip") ext_data$setUploadType(sourceType)
if(!is.null(ext_data$uploadType)) if(ext_data$uploadType == "geotiff") ext_data$setSpatialRepresentationType("grid")
}
Expand All @@ -507,6 +552,17 @@ geoflow_data <- R6Class("geoflow_data",
if(!hasStoreDeclared) ext_data$setStore(ext_data_name)
ext_data$setLayername(ext_data_name)

#inherit layer metadata from data file register (if any)
if(!is.null(data_files_register)){
register_entry = data_files_register[data_files_register$code == ext_data_name,]
if(nrow(register_entry)>0){
register_entry = register_entry[1L,]
if(!is.na(register_entry$uri)) ext_data$setLayeruri(register_entry$uri)
if(!is.na(register_entry$label)) ext_data$setLayertitle(register_entry$label)
if(!is.na(register_entry$definition)) ext_data$setLayerdesc(register_entry$definition)
}
}

if(self$styleUpload){
#we add all sld files to each child so they can be downloaded if needed
if(length(ext_sld_files)>0) for(ext_sld_file in ext_sld_files) {
Expand Down Expand Up @@ -718,6 +774,24 @@ geoflow_data <- R6Class("geoflow_data",
self$layername <- layername
},

#'@description Sets a layer title, object of class \code{character}. If available, used as target layer title in SDI-related action.
#'@param layertitle layertitle
setLayertitle = function(layertitle){
self$layertitle = layertitle
},

#'@description Sets a layer description, object of class \code{character}. If available, used as target layer description/abstract in SDI-related actions.
#'@param layerdesc layerdesc
setLayerdesc = function(layerdesc){
self$layerdesc = layerdesc
},

#'@description Sets a layer URI, object of class \code{character}. If available, used as annotating URI for layer metadata (eg. in ISO 19115 action).
#'@param layeruri layeruri
setLayeruri = function(layeruri){
self$layeruri = layeruri
},

#'@description Adds a style name, object of class \code{character}. Used as layer style name(s) for GeoServer action.
#'@param style style
addStyle = function(style){
Expand Down
2 changes: 1 addition & 1 deletion R/geoflow_data_accessor.R
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ register_data_accessors <- function(){
stop(errMsg)
}
cat(sprintf("[geoflow] OCS data accessor: Download data '%s' from '%s' to '%s'\n", file, resource, path))
software$downloadFile(relPath = dirname(resource), filename = basename(resource), outdir = getwd())
software$downloadFile(relPath = dirname(resource), filename = basename(resource), outdir = dirname(path))
if(unzip & endsWith(path, "zip")){
utils::unzip(zipfile = path, exdir = getwd(), unzip = getOption("unzip"))
}
Expand Down
72 changes: 64 additions & 8 deletions R/geoflow_entity.R
Original file line number Diff line number Diff line change
Expand Up @@ -1485,7 +1485,14 @@ geoflow_entity <- R6Class("geoflow_entity",
new_wms <- geoflow_relation$new()
new_wms$setKey("wms")
new_wms$setName(layername)
new_wms$setDescription(sprintf("%s - Map access - OGC Web Map Service (WMS)",layername))
new_wms$setDescription(
describeOGCRelation(
self, data_object, service = "WMS", download = FALSE, format = NULL,
handle_category = geosapi_action$getOption("describe_wms_relation_with_category"),
handle_ogc_service_description = geosapi_action$getOption("describe_wms_relation_with_ogc_service_description"),
handle_format = FALSE
)
)
new_wms$setLink(sprintf("%s/%s/ows?service=WMS",
geoserver_base_url,
config$software$output$geoserver_config$properties$workspace))
Expand All @@ -1502,7 +1509,14 @@ geoflow_entity <- R6Class("geoflow_entity",
new_wfs <- geoflow_relation$new()
new_wfs$setKey("wfs")
new_wfs$setName(layername)
new_wfs$setDescription(sprintf("%s - Data (features) access - OGC Web Feature Service (WFS)", layername))
new_wfs$setDescription(
describeOGCRelation(
self, data_object, service = "WFS", download = FALSE, format = NULL,
handle_category = geosapi_action$getOption("describe_wfs_relation_with_category"),
handle_ogc_service_description = geosapi_action$getOption("describe_wfs_relation_with_ogc_service_description"),
handle_format = FALSE
)
)
new_wfs$setLink(sprintf("%s/%s/ows?service=WFS",
geoserver_base_url,
config$software$output$geoserver_config$properties$workspace))
Expand All @@ -1517,7 +1531,14 @@ geoflow_entity <- R6Class("geoflow_entity",
new_wfs_gml <- geoflow_relation$new()
new_wfs_gml$setKey("download")
new_wfs_gml$setName(layername)
new_wfs_gml$setDescription(sprintf("%s - Data download - OGC Web Feature Service (WFS) - GML format", layername))
new_wfs_gml$setDescription(
describeOGCRelation(
self, data_object, service = "WFS", download = TRUE, format = "GML",
handle_category = geosapi_action$getOption("describe_wfs_relation_with_category"),
handle_ogc_service_description = geosapi_action$getOption("describe_wfs_relation_with_ogc_service_description"),
handle_format = geosapi_action$getOption("describe_wfs_relation_with_format")
)
)
new_wfs_gml$setLink(sprintf("%s/%s/ows?service=WFS&request=GetFeature&version=1.0.0&typeName=%s",
geoserver_base_url,
config$software$output$geoserver_config$properties$workspace,
Expand All @@ -1528,7 +1549,14 @@ geoflow_entity <- R6Class("geoflow_entity",
new_wfs_geojson <- geoflow_relation$new()
new_wfs_geojson$setKey("download")
new_wfs_geojson$setName(layername)
new_wfs_geojson$setDescription(sprintf("%s - Data download - OGC Web Feature Service (WFS) - GeoJSON format", layername))
new_wfs_geojson$setDescription(
describeOGCRelation(
self, data_object, service = "WFS", download = TRUE, format = "GeoJSON",
handle_category = geosapi_action$getOption("describe_wfs_relation_with_category"),
handle_ogc_service_description = geosapi_action$getOption("describe_wfs_relation_with_ogc_service_description"),
handle_format = geosapi_action$getOption("describe_wfs_relation_with_format")
)
)
new_wfs_geojson$setLink(sprintf("%s/%s/ows?service=WFS&request=GetFeature&version=1.0.0&typeName=%s&outputFormat=json",
geoserver_base_url,
config$software$output$geoserver_config$properties$workspace,
Expand All @@ -1539,7 +1567,14 @@ geoflow_entity <- R6Class("geoflow_entity",
new_wfs_shp <- geoflow_relation$new()
new_wfs_shp$setKey("download")
new_wfs_shp$setName(layername)
new_wfs_shp$setDescription(sprintf("%s - Data download - OGC Web Feature Service (WFS) - ESRI Shapefile format", layername))
new_wfs_shp$setDescription(
describeOGCRelation(
self, data_object, service = "WFS", download = TRUE, format = "ESRI Shapefile",
handle_category = geosapi_action$getOption("describe_wfs_relation_with_category"),
handle_ogc_service_description = geosapi_action$getOption("describe_wfs_relation_with_ogc_service_description"),
handle_format = geosapi_action$getOption("describe_wfs_relation_with_format")
)
)
new_wfs_shp$setLink(sprintf("%s/%s/ows?service=WFS&request=GetFeature&version=1.0.0&typeName=%s&outputFormat=SHAPE-ZIP",
geoserver_base_url,
config$software$output$geoserver_config$properties$workspace,
Expand All @@ -1550,7 +1585,14 @@ geoflow_entity <- R6Class("geoflow_entity",
new_wfs_csv <- geoflow_relation$new()
new_wfs_csv$setKey("download")
new_wfs_csv$setName(layername)
new_wfs_csv$setDescription(sprintf("%s - Data download - OGC Web Feature Service (WFS) - CSV format", layername))
new_wfs_csv$setDescription(
describeOGCRelation(
self, data_object, service = "WFS", download = TRUE, format = "CSV",
handle_category = geosapi_action$getOption("describe_wfs_relation_with_category"),
handle_ogc_service_description = geosapi_action$getOption("describe_wfs_relation_with_ogc_service_description"),
handle_format = geosapi_action$getOption("describe_wfs_relation_with_format")
)
)
new_wfs_csv$setLink(sprintf("%s/%s/ows?service=WFS&request=GetFeature&version=1.0.0&typeName=%s&outputFormat=CSV",
geoserver_base_url,
config$software$output$geoserver_config$properties$workspace,
Expand All @@ -1569,7 +1611,14 @@ geoflow_entity <- R6Class("geoflow_entity",
new_wcs <- geoflow_relation$new()
new_wcs$setKey("wcs")
new_wcs$setName(layername)
new_wcs$setDescription(sprintf("%s - Data (Coverage) access - OGC Web Coverage Service (WCS)", layername))
new_wcs$setDescription(
describeOGCRelation(
self, data_object, service = "WCS", download = FALSE, format = NULL,
handle_category = geosapi_action$getOption("describe_wcs_relation_with_category"),
handle_ogc_service_description = geosapi_action$getOption("describe_wcs_relation_with_ogc_service_description"),
handle_format = FALSE
)
)
new_wcs$setLink(sprintf("%s/%s/ows?service=WCS",
geoserver_base_url,
config$software$output$geoserver_config$properties$workspace))
Expand All @@ -1585,7 +1634,14 @@ geoflow_entity <- R6Class("geoflow_entity",
new_wcs_geotiff <- geoflow_relation$new()
new_wcs_geotiff$setKey("download")
new_wcs_geotiff$setName(layername)
new_wcs_geotiff$setDescription(sprintf("%s - Data download - OGC Web Coverage Service (WCS) - GeoTIFF format", layername))
new_wcs_geotiff$setDescription(
describeOGCRelation(
self, data_object, service = "WCS", download = TRUE, format = "GeoTIFF",
handle_category = geosapi_action$getOption("describe_wcs_relation_with_category"),
handle_ogc_service_description = geosapi_action$getOption("describe_wcs_relation_with_ogc_service_description"),
handle_format = geosapi_action$getOption("describe_wcs_relation_with_format")
)
)
new_wcs_geotiff$setLink(sprintf("%s/%s/ows?service=WCS&request=GetCoverage&version=2.0.1&CoverageId=%s&format=image/geotiff",
geoserver_base_url,
config$software$output$geoserver_config$properties$workspace,
Expand Down
Loading

0 comments on commit 719f614

Please sign in to comment.