@@ -58,7 +58,8 @@ handle_entities_csw <- function(handler, source, config, handle = TRUE){
58
58
# type
59
59
if (length(rec $ hierarchyLevel )> 0 ) entity $ setType(key = " generic" , type = rec $ hierarchyLevel [[1 ]]$ attrs $ codeListValue )
60
60
# language
61
- entity $ setLanguage(if (is(rec $ language ," ISOLanguage" )) rec $ language $ attrs $ codeListValue else rec $ language )
61
+ lang = if (is(rec $ language ," ISOLanguage" )) rec $ language $ attrs $ codeListValue else rec $ language
62
+ entity $ setLanguage(if (! is.na(lang )) lang else " eng" )
62
63
# srid
63
64
if (length(rec $ referenceSystemInfo )> 0 ){
64
65
code = rec $ referenceSystemInfo [[1 ]]$ referenceSystemIdentifier $ code
@@ -170,7 +171,7 @@ handle_entities_csw <- function(handler, source, config, handle = TRUE){
170
171
entity $ setDescription(" edition" , rec $ identificationInfo [[1 ]]$ citation $ edition )
171
172
}
172
173
status = rec $ identificationInfo [[1 ]]$ status
173
- if (length(status )> 0 ) entity $ setDescription(" status" , status [[1 ]]$ attrs $ codeListValue )
174
+ if (length(status )> 0 ) if (nzchar( status [[ 1 ]] $ attrs $ codeListValue )) entity $ setDescription(" status" , status [[1 ]]$ attrs $ codeListValue )
174
175
# subject
175
176
entity $ subjects = lapply(rec $ identificationInfo [[1 ]]$ descriptiveKeywords , function (dk ){
176
177
subject = geoflow_subject $ new()
@@ -234,6 +235,7 @@ handle_entities_csw <- function(handler, source, config, handle = TRUE){
234
235
if (is(constraint , " ISOLegalConstraints" )){
235
236
# use constraints
236
237
use_values = lapply(constraint $ useConstraints , function (x ){x $ attrs $ codeListValue })
238
+ use_values = use_values [use_values != " " ]
237
239
if (length(use_values )> 0 ){
238
240
for (use_value in use_values ){
239
241
use_right = geoflow_right $ new()
@@ -244,6 +246,7 @@ handle_entities_csw <- function(handler, source, config, handle = TRUE){
244
246
}
245
247
# access constraints
246
248
access_values = lapply(constraint $ accessConstraints , function (x ){x $ attrs $ codeListValue })
249
+ access_values = access_values [access_values != " " ]
247
250
if (length(access_values )> 0 ){
248
251
for (access_value in access_values ){
249
252
access_right = geoflow_right $ new()
@@ -379,6 +382,31 @@ handle_entities_csw <- function(handler, source, config, handle = TRUE){
379
382
}
380
383
}
381
384
385
+ # data
386
+ if (! is.null(rec $ distributionInfo ))
387
+ tro = rec $ distributionInfo $ transferOptions
388
+ if (! is.null(tro )){
389
+ onLine = tro [[1 ]]$ onLine
390
+ if (length(onLine )> 0 ){
391
+ onLineToDownload = onLine [sapply(onLine , function (x ){x $ protocol == " WWW:DOWNLOAD-1.0-http--download" })]
392
+ if (length(onLineToDownload )> 0 ){
393
+ g_data = geoflow_data $ new()
394
+ onLineToDownload = onLineToDownload [[1 ]]
395
+ outres = onLineToDownload $ name
396
+ attr(outres , " uri" ) = onLineToDownload $ linkage $ value
397
+ g_data $ setSource(outres )
398
+ g_data $ sourceType = switch (mime :: guess_type(onLineToDownload $ linkage $ value ),
399
+ " text/csv" = " csv" ,
400
+ " application/zip" = " zip" ,
401
+ " application/x-qgis" = " shp" ,
402
+ " application/geopackage+sqlite3" = " gpkg" ,
403
+ " application/x-netcdf" = " nc" ,
404
+ " image/tiff" = " geotiff"
405
+ )
406
+ entity $ setData(g_data )
407
+ }
408
+ }
409
+ }
382
410
return (entity )
383
411
})
384
412
0 commit comments