@@ -36,16 +36,25 @@ handle_entities_csw <- function(handler, source, config, handle = TRUE){
36
36
contact $ setFirstName(ind_parts [1 ])
37
37
contact $ setLastName(ind_parts [2 ])
38
38
}
39
- if (! is.null(rp $ contactInfo $ address $ deliveryPoint )) if (! is.na(rp $ contactInfo $ address $ deliveryPoint )) contact $ setPostalAddress(rp $ contactInfo $ address $ deliveryPoint )
40
- if (! is.null(rp $ contactInfo $ address $ postalCode )) if (! is.na(rp $ contactInfo $ address $ postalCode )) contact $ setPostalCode(rp $ contactInfo $ address $ postalCode )
41
- if (! is.null(rp $ contactInfo $ address $ city )) if (! is.na(rp $ contactInfo $ address $ city )) contact $ setCity(rp $ contactInfo $ address $ city )
42
- if (! is.null(rp $ contactInfo $ address $ country )) if (! is.na(rp $ contactInfo $ address $ country )) contact $ setCountry(rp $ contactInfo $ address $ country )
43
- if (! is.null(rp $ contactInfo $ address $ electronicMailAddress )) if (! is.na(rp $ contactInfo $ address $ electronicMailAddress )) contact $ setEmail(rp $ contactInfo $ address $ electronicMailAddress )
44
- if (! is.null(rp $ contactInfo $ phone $ voice )) if (! is.na(rp $ contactInfo $ phone $ voice )) contact $ setVoice(rp $ contactInfo $ phone $ voice )
45
- if (! is.null(rp $ contactInfo $ phone $ facsimile )) if (! is.na(rp $ contactInfo $ phone $ facsimile )) contact $ setFacsimile(rp $ contactInfo $ phone $ facsimile )
46
- if (! is.null(rp $ contactInfo $ onlineResource $ name )) if (! is.na(rp $ contactInfo $ onlineResource $ name )) contact $ setWebsiteName(rp $ contactInfo $ onlineResource $ name )
47
- if (is(rp $ contactInfo $ onlineResource $ linkage , " ISOURL" )){
48
- contact $ setWebsiteUrl(rp $ contactInfo $ onlineResource $ linkage $ value )
39
+ if (length(rp $ contactInfo $ address )> 0 ){
40
+ address = rp $ contactInfo $ address [[1 ]]
41
+ if (! is.null(address $ deliveryPoint )) if (! is.na(address $ deliveryPoint )) contact $ setPostalAddress(address $ deliveryPoint )
42
+ if (! is.null(address $ postalCode )) if (! is.na(address $ postalCode )) contact $ setPostalCode(address $ postalCode )
43
+ if (! is.null(address $ city )) if (! is.na(address $ city )) contact $ setCity(address $ city )
44
+ if (! is.null(address $ country )) if (! is.na(address $ country )) contact $ setCountry(address $ country )
45
+ if (! is.null(address $ electronicMailAddress )) if (! is.na(address $ electronicMailAddress )) contact $ setEmail(address $ electronicMailAddress )
46
+ }
47
+ if (length(rp $ contactInfo $ phone )> 0 ){
48
+ phone = rp $ contactInfo $ phone [[1 ]]
49
+ if (! is.null(phone $ voice )) if (! is.na(phone $ voice )) contact $ setVoice(phone $ voice )
50
+ if (! is.null(phone $ facsimile )) if (! is.na(phone $ facsimile )) contact $ setFacsimile(phone $ facsimile )
51
+ }
52
+ if (length(rp $ contactInfo $ onlineResource )> 0 ){
53
+ or = rp $ contactInfo $ onlineResource [[1 ]]
54
+ if (! is.null(or $ name )) if (! is.na(or $ name )) contact $ setWebsiteName(or $ name )
55
+ if (is(or $ linkage , " ISOURL" )){
56
+ contact $ setWebsiteUrl(or $ linkage $ value )
57
+ }
49
58
}
50
59
contact $ setRole(rp $ role $ attrs $ codeListValue )
51
60
return (contact $ clone(deep = TRUE ))
@@ -58,11 +67,19 @@ handle_entities_csw <- function(handler, source, config, handle = TRUE){
58
67
# type
59
68
if (length(rec $ hierarchyLevel )> 0 ) entity $ setType(key = " generic" , type = rec $ hierarchyLevel [[1 ]]$ attrs $ codeListValue )
60
69
# language
61
- lang = if (is(rec $ language ," ISOLanguage" )) rec $ language $ attrs $ codeListValue else rec $ language
70
+ lang = if (is(rec $ language ," ISOLanguage" )){
71
+ rec $ language $ attrs $ codeListValue
72
+ }else if (is(rec $ language , " ISOElementSequence" )){
73
+ langXML = XML :: xmlParse(rec $ language $ value )
74
+ XML :: xmlGetAttr(XML :: xmlChildren(langXML )[[1 ]], " codeListValue" )
75
+ }else {
76
+ rec $ language
77
+ }
62
78
entity $ setLanguage(if (! is.na(lang )) lang else " eng" )
63
79
# srid
64
80
if (length(rec $ referenceSystemInfo )> 0 ){
65
81
code = rec $ referenceSystemInfo [[1 ]]$ referenceSystemIdentifier $ code
82
+ code = regmatches(code ,regexpr(" EPSG:[0-9]+" ,code ))
66
83
code_parts = unlist(strsplit(code , " /" ))
67
84
code = code_parts [length(code_parts )]
68
85
code_parts = unlist(strsplit(code , " :" ))
@@ -101,7 +118,9 @@ handle_entities_csw <- function(handler, source, config, handle = TRUE){
101
118
# creator
102
119
# metadata contacts
103
120
for (poc in rec $ contact ) if (length(poc )> 1 ){
104
- entity $ addContact(createContactFromResponsibleParty(poc ))
121
+ contact_metadata = createContactFromResponsibleParty(poc )
122
+ contact_metadata $ setRole(" metadata" )
123
+ entity $ addContact(contact_metadata )
105
124
}
106
125
107
126
# metadata date
@@ -220,9 +239,11 @@ handle_entities_csw <- function(handler, source, config, handle = TRUE){
220
239
if (is(time_extent $ extent , " GMLTimeInstant" )){
221
240
entity $ temporal_extent = list (instant = time_extent $ extent $ timePosition $ value )
222
241
}else if (is(time_extent $ extent , " GMLTimePeriod" )){
242
+ start = time_extent $ extent $ beginPosition $ value
243
+ end = time_extent $ extent $ endPosition $ value
223
244
entity $ temporal_extent = list (
224
- start = time_extent $ extent $ beginPosition $ value ,
225
- end = time_extent $ extent $ endPosition $ value
245
+ start = if (regexpr( " " , start ) > 0 ) as.POSIXct( start ) else as.Date( start ) ,
246
+ end = if (regexpr( " " , end ) > 0 ) as.POSIXct( end ) else as.Date( end )
226
247
)
227
248
}
228
249
}
0 commit comments