adiwg-mdtranslator 2.1.2 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +402 -0
- data/adiwg-mdtranslator.gemspec +1 -1
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +7 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_contact.rb +196 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_dateTime.rb +8 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_fgdc.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +80 -26
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_keyword.rb +13 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_lineage.rb +58 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_process.rb +101 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_quality.rb +21 -1
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_security.rb +48 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_source.rb +83 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_timePeriod.rb +10 -1
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_allocation.rb +92 -71
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_funding.rb +49 -43
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_processStep.rb +113 -90
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_sbJson.rb +2 -1
- data/lib/adiwg/mdtranslator/version.rb +2 -1
- data/lib/adiwg/mdtranslator/writers/html/sections/html_allocation.rb +23 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_funding.rb +9 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_processStep.rb +37 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_processStep.rb +103 -91
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_allocation.rb +7 -1
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_funding.rb +4 -2
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processStep.rb +6 -2
- metadata +11 -5
|
@@ -28,6 +28,14 @@ module ADIWG
|
|
|
28
28
|
return nil
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
# remove invalid date and time input strings
|
|
32
|
+
unless date =~ /^[0-9\-]*$/
|
|
33
|
+
return nil
|
|
34
|
+
end
|
|
35
|
+
unless time =~ /^[0-9:]*$/
|
|
36
|
+
time = ''
|
|
37
|
+
end
|
|
38
|
+
|
|
31
39
|
# convert date from fgdc to iso format
|
|
32
40
|
year = date.byteslice(0,4)
|
|
33
41
|
month = date.byteslice(4,2)
|
|
@@ -54,7 +54,7 @@ module ADIWG
|
|
|
54
54
|
# metadata (dataqual 2) - data quality
|
|
55
55
|
xDataQual = xMetadata.xpath('./dataqual')
|
|
56
56
|
unless xDataQual.empty?
|
|
57
|
-
Quality.unpack(xDataQual, hResponseObj)
|
|
57
|
+
Quality.unpack(xDataQual, hMetadata, hResponseObj)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
# metadata (spdoinfo 3) - spatial data organization
|
|
@@ -11,6 +11,8 @@ require_relative 'module_timePeriod'
|
|
|
11
11
|
require_relative 'module_timeInstant'
|
|
12
12
|
require_relative 'module_spatialDomain'
|
|
13
13
|
require_relative 'module_keyword'
|
|
14
|
+
require_relative 'module_contact'
|
|
15
|
+
require_relative 'module_security'
|
|
14
16
|
|
|
15
17
|
module ADIWG
|
|
16
18
|
module Mdtranslator
|
|
@@ -26,16 +28,13 @@ module ADIWG
|
|
|
26
28
|
|
|
27
29
|
# useful parts
|
|
28
30
|
hMetadata = intObj[:metadata]
|
|
29
|
-
hMetadataInfo = hMetadata[:metadataInfo]
|
|
30
31
|
hResourceInfo = hMetadata[:resourceInfo]
|
|
31
32
|
|
|
32
33
|
# identification information 1.1 (citation) - citation (required)
|
|
33
34
|
xCitation = xIdInfo.xpath('./citation')
|
|
34
35
|
unless xCitation.empty?
|
|
35
36
|
hCitation = Citation.unpack(xCitation, hResponseObj)
|
|
36
|
-
unless hCitation.nil?
|
|
37
|
-
hResourceInfo[:citation] = hCitation
|
|
38
|
-
end
|
|
37
|
+
hResourceInfo[:citation] = hCitation unless hCitation.nil?
|
|
39
38
|
end
|
|
40
39
|
|
|
41
40
|
# identification information 1.2 (descript) - description (required)
|
|
@@ -44,21 +43,15 @@ module ADIWG
|
|
|
44
43
|
|
|
45
44
|
# description 1.2.1 (abstract) - abstract
|
|
46
45
|
abstract = xDescription.xpath('./abstract').text
|
|
47
|
-
unless abstract.empty?
|
|
48
|
-
hResourceInfo[:abstract] = abstract
|
|
49
|
-
end
|
|
46
|
+
hResourceInfo[:abstract] = abstract unless abstract.empty?
|
|
50
47
|
|
|
51
48
|
# description 1.2.2 (purpose) - purpose
|
|
52
49
|
purpose = xDescription.xpath('./purpose').text
|
|
53
|
-
unless purpose.empty?
|
|
54
|
-
hResourceInfo[:purpose] = purpose
|
|
55
|
-
end
|
|
50
|
+
hResourceInfo[:purpose] = purpose unless purpose.empty?
|
|
56
51
|
|
|
57
52
|
# description 1.2.3 (supplinf) - supplemental information
|
|
58
53
|
supplemental = xDescription.xpath('./supplinf').text
|
|
59
|
-
unless supplemental.empty?
|
|
60
|
-
hResourceInfo[:supplementalInfo] = supplemental
|
|
61
|
-
end
|
|
54
|
+
hResourceInfo[:supplementalInfo] = supplemental unless supplemental.empty?
|
|
62
55
|
|
|
63
56
|
end
|
|
64
57
|
|
|
@@ -68,9 +61,7 @@ module ADIWG
|
|
|
68
61
|
|
|
69
62
|
# time period for single date and date range
|
|
70
63
|
hTimePeriod = TimePeriod.unpack(xTimePeriod, hResponseObj)
|
|
71
|
-
unless hTimePeriod.nil?
|
|
72
|
-
hResourceInfo[:timePeriod] = hTimePeriod
|
|
73
|
-
end
|
|
64
|
+
hResourceInfo[:timePeriod] = hTimePeriod unless hTimePeriod.nil?
|
|
74
65
|
|
|
75
66
|
# time period multiple date time pairs 9.1.2 (mdattim)
|
|
76
67
|
axMultiple = xTimePeriod.xpath('./timeinfo/mdattim/sngdate')
|
|
@@ -89,9 +80,7 @@ module ADIWG
|
|
|
89
80
|
hExtent[:temporalExtents] << hTempExtent
|
|
90
81
|
end
|
|
91
82
|
end
|
|
92
|
-
unless hExtent[:temporalExtents].empty?
|
|
93
|
-
hResourceInfo[:extents] << hExtent
|
|
94
|
-
end
|
|
83
|
+
hResourceInfo[:extents] << hExtent unless hExtent[:temporalExtents].empty?
|
|
95
84
|
end
|
|
96
85
|
|
|
97
86
|
end
|
|
@@ -102,9 +91,7 @@ module ADIWG
|
|
|
102
91
|
|
|
103
92
|
# status 1.4.1 (progress) - state of resource
|
|
104
93
|
progress = xStatus.xpath('./progress').text
|
|
105
|
-
unless progress.empty?
|
|
106
|
-
hResourceInfo[:status] << progress
|
|
107
|
-
end
|
|
94
|
+
hResourceInfo[:status] << progress unless progress.empty?
|
|
108
95
|
|
|
109
96
|
# status 1.4.2 (update) - maintenance frequency
|
|
110
97
|
update = xStatus.xpath('./update').text
|
|
@@ -120,20 +107,87 @@ module ADIWG
|
|
|
120
107
|
xDomain = xIdInfo.xpath('./spdom')
|
|
121
108
|
unless xDomain.empty?
|
|
122
109
|
hExtent = SpatialDomain.unpack(xDomain, hResponseObj)
|
|
123
|
-
unless hExtent.nil?
|
|
124
|
-
hResourceInfo[:extents] << hExtent
|
|
125
|
-
end
|
|
110
|
+
hResourceInfo[:extents] << hExtent unless hExtent.nil?
|
|
126
111
|
end
|
|
127
112
|
|
|
128
113
|
# identification information 1.6 (keywords) - keywords
|
|
129
114
|
xKeywords = xIdInfo.xpath('./keywords')
|
|
130
115
|
unless xKeywords.empty?
|
|
131
|
-
Keyword.unpack(xKeywords, hResourceInfo
|
|
116
|
+
Keyword.unpack(xKeywords, hResourceInfo, hResponseObj)
|
|
132
117
|
end
|
|
133
118
|
|
|
134
119
|
# identification information 1.7 (accconst) - access constraints
|
|
135
120
|
# identification information 1.8 (useconst) - use constraints
|
|
121
|
+
accessCon = xIdInfo.xpath('./accconst').text
|
|
122
|
+
useCon = xIdInfo.xpath('./useconst').text
|
|
123
|
+
hConstraint = intMetadataClass.newConstraint
|
|
124
|
+
hConstraint[:type] = 'legal'
|
|
125
|
+
hLegal = intMetadataClass.newLegalConstraint
|
|
126
|
+
|
|
127
|
+
hLegal[:otherCons] << accessCon unless accessCon.empty?
|
|
128
|
+
hLegal[:otherCons] << useCon unless useCon.empty?
|
|
129
|
+
unless hLegal[:otherCons].empty?
|
|
130
|
+
hConstraint[:legalConstraint] = hLegal
|
|
131
|
+
hResourceInfo[:constraints] << hConstraint
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# identification information 1.9 (ptcontac) - point of contact
|
|
135
|
+
xContact = xIdInfo.xpath('./ptcontac')
|
|
136
|
+
unless xContact.empty?
|
|
137
|
+
hResponsibility = Contact.unpack(xContact, hResponseObj)
|
|
138
|
+
unless hResponsibility.nil?
|
|
139
|
+
hResponsibility[:roleName] = 'pointOfContact'
|
|
140
|
+
hResourceInfo[:pointOfContacts] << hResponsibility
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# identification information 1.10 (browse) - browse graphic []
|
|
145
|
+
axBrowse = xIdInfo.xpath('./browse')
|
|
146
|
+
unless axBrowse.empty?
|
|
147
|
+
axBrowse.each do |xBrowse|
|
|
148
|
+
browseName = xBrowse.xpath('./browsen').text
|
|
149
|
+
browseDesc = xBrowse.xpath('./browsed').text
|
|
150
|
+
browseType = xBrowse.xpath('./browset').text
|
|
151
|
+
hGraphic = intMetadataClass.newGraphic
|
|
152
|
+
hGraphic[:graphicName] = browseName unless browseName.empty?
|
|
153
|
+
hGraphic[:graphicDescription] = browseDesc unless browseDesc.empty?
|
|
154
|
+
hGraphic[:graphicType] = browseType unless browseType.empty?
|
|
155
|
+
hResourceInfo[:graphicOverviews] << hGraphic
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# identification information 1.11 (datacred) - data credit
|
|
160
|
+
credits = xIdInfo.xpath('./datacred').text
|
|
161
|
+
unless credits.empty?
|
|
162
|
+
hResourceInfo[:credits] << credits
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# identification information 1.12 (secinfo) - security information
|
|
166
|
+
xSecurity = xIdInfo.xpath('./secinfo')
|
|
167
|
+
unless xSecurity.empty?
|
|
168
|
+
hConstraint = Security.unpack(xSecurity, hResponseObj)
|
|
169
|
+
hResourceInfo[:constraints] << hConstraint unless hConstraint.nil?
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# identification information 1.13 (native) - native dataset environment
|
|
173
|
+
native = xIdInfo.xpath('./native').text
|
|
174
|
+
unless native.empty?
|
|
175
|
+
hResourceInfo[:environmentDescription] = native
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# identification information 1.14 (crossref) - cross reference {associatedResource}
|
|
179
|
+
xCitation = xIdInfo.xpath('./crossref')
|
|
180
|
+
unless xCitation.empty?
|
|
181
|
+
hCitation = Citation.unpack(xCitation, hResponseObj)
|
|
182
|
+
unless hCitation.empty?
|
|
183
|
+
hAssociatedResource = intMetadataClass.newAssociatedResource
|
|
184
|
+
hAssociatedResource[:associationType] = 'crossReference'
|
|
185
|
+
hAssociatedResource[:resourceCitation] = hCitation
|
|
186
|
+
hMetadata[:associatedResources] << hAssociatedResource
|
|
187
|
+
end
|
|
188
|
+
end
|
|
136
189
|
|
|
190
|
+
return intObj
|
|
137
191
|
|
|
138
192
|
end
|
|
139
193
|
|
|
@@ -14,7 +14,9 @@ module ADIWG
|
|
|
14
14
|
|
|
15
15
|
module Keyword
|
|
16
16
|
|
|
17
|
-
def self.unpack(xKeywords,
|
|
17
|
+
def self.unpack(xKeywords, hResourceInfo, hResponseObj)
|
|
18
|
+
|
|
19
|
+
aKeywords = hResourceInfo[:keywords]
|
|
18
20
|
|
|
19
21
|
# instance classes needed in script
|
|
20
22
|
intMetadataClass = InternalMetadata.new
|
|
@@ -47,6 +49,15 @@ module ADIWG
|
|
|
47
49
|
end
|
|
48
50
|
end
|
|
49
51
|
|
|
52
|
+
# if keyword thesaurus is 'ISO 19115 Topic Category'
|
|
53
|
+
# convert to ISO topic categories
|
|
54
|
+
if hKeyword[:thesaurus][:title] == 'ISO 19115 Topic Category'
|
|
55
|
+
hKeyword[:keywords].each do |hKeyObj|
|
|
56
|
+
hResourceInfo[:topicCategories] << hKeyObj[:keyword]
|
|
57
|
+
end
|
|
58
|
+
hKeyword = {}
|
|
59
|
+
end
|
|
60
|
+
|
|
50
61
|
unless hKeyword.empty?
|
|
51
62
|
aKeywords << hKeyword
|
|
52
63
|
end
|
|
@@ -124,7 +135,7 @@ module ADIWG
|
|
|
124
135
|
end
|
|
125
136
|
end
|
|
126
137
|
|
|
127
|
-
# kewords 1.6.4 (
|
|
138
|
+
# kewords 1.6.4 (temporal) - temporal keywords {keyword}
|
|
128
139
|
axTemporal = xKeywords.xpath('./temporal')
|
|
129
140
|
unless axTemporal.empty?
|
|
130
141
|
axTemporal.each do |xTemporal|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Reader - fgdc to internal data structure
|
|
2
|
+
# unpack fgdc lineage
|
|
3
|
+
|
|
4
|
+
# History:
|
|
5
|
+
# Stan Smith 2017-08-28 original script
|
|
6
|
+
|
|
7
|
+
require 'nokogiri'
|
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
|
9
|
+
require_relative 'module_source'
|
|
10
|
+
require_relative 'module_process'
|
|
11
|
+
|
|
12
|
+
module ADIWG
|
|
13
|
+
module Mdtranslator
|
|
14
|
+
module Readers
|
|
15
|
+
module Fgdc
|
|
16
|
+
|
|
17
|
+
module Lineage
|
|
18
|
+
|
|
19
|
+
def self.unpack(xLineage, hResourceInfo, hResponseObj)
|
|
20
|
+
|
|
21
|
+
# instance classes needed in script
|
|
22
|
+
intMetadataClass = InternalMetadata.new
|
|
23
|
+
hLineage = intMetadataClass.newLineage
|
|
24
|
+
|
|
25
|
+
# data quality 2.5 (lineage) - lineage
|
|
26
|
+
unless xLineage.empty?
|
|
27
|
+
|
|
28
|
+
# lineage 2.5.1 (srcinfo) - source information []
|
|
29
|
+
axSource = xLineage.xpath('./srcinfo')
|
|
30
|
+
unless axSource.empty?
|
|
31
|
+
axSource.each do |xSource|
|
|
32
|
+
hSource = Source.unpack(xSource, hResourceInfo[:spatialResolutions], hResponseObj)
|
|
33
|
+
hLineage[:dataSources] << hSource
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# lineage 2.5.2 (procstep) - process step []
|
|
38
|
+
axProcess = xLineage.xpath('./procstep')
|
|
39
|
+
unless axProcess.empty?
|
|
40
|
+
axProcess.each do |xProcess|
|
|
41
|
+
hProcess = Process.unpack(xProcess, hLineage, hResponseObj)
|
|
42
|
+
hLineage[:processSteps] << hProcess
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
return hLineage
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
return nil
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Reader - fgdc to internal data structure
|
|
2
|
+
# unpack fgdc process
|
|
3
|
+
|
|
4
|
+
# History:
|
|
5
|
+
# Stan Smith 2017-08-28 original script
|
|
6
|
+
|
|
7
|
+
require 'nokogiri'
|
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
|
9
|
+
require_relative 'module_dateTime'
|
|
10
|
+
require_relative 'module_contact'
|
|
11
|
+
|
|
12
|
+
module ADIWG
|
|
13
|
+
module Mdtranslator
|
|
14
|
+
module Readers
|
|
15
|
+
module Fgdc
|
|
16
|
+
|
|
17
|
+
module Process
|
|
18
|
+
|
|
19
|
+
def self.unpack(xProcess, hLineage, hResponseObj)
|
|
20
|
+
|
|
21
|
+
# instance classes needed in script
|
|
22
|
+
intMetadataClass = InternalMetadata.new
|
|
23
|
+
hProcess = intMetadataClass.newProcessStep
|
|
24
|
+
|
|
25
|
+
# process 2.5.2.1 (procdesc) - process description
|
|
26
|
+
description = xProcess.xpath('./procdesc').text
|
|
27
|
+
unless description.empty?
|
|
28
|
+
hProcess[:description] = description
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# process 2.5.2.2 (srcused) - source used citation abbreviation []
|
|
32
|
+
axUsed = xProcess.xpath('./srcused')
|
|
33
|
+
unless axUsed.empty?
|
|
34
|
+
axUsed.each do |xUsed|
|
|
35
|
+
usedSrc = xUsed.text
|
|
36
|
+
unless usedSrc.empty?
|
|
37
|
+
hLineage[:dataSources].each do |hSource|
|
|
38
|
+
unless hSource[:sourceCitation].empty?
|
|
39
|
+
hSource[:sourceCitation][:alternateTitles].each do |altTitle|
|
|
40
|
+
if usedSrc == altTitle
|
|
41
|
+
hProcess[:stepSources] << hSource
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
# process 2.5.2.3/2.5.2.4 (procdate/proctime) - procedure date/time {date} (required) {time} (optional)
|
|
51
|
+
procDate = xProcess.xpath('./procdate').text
|
|
52
|
+
procTime = xProcess.xpath('./proctime').text
|
|
53
|
+
unless procDate.empty?
|
|
54
|
+
hDateTime = DateTime.unpack(procDate, procTime, hResponseObj)
|
|
55
|
+
unless hDateTime.nil?
|
|
56
|
+
hTimePeriod = intMetadataClass.newTimePeriod
|
|
57
|
+
hTimePeriod[:description] = 'Step completion dateTime'
|
|
58
|
+
hTimePeriod[:endDateTime] = hDateTime
|
|
59
|
+
hProcess[:timePeriod] = hTimePeriod
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# process 2.5.2.5 (srcprod) - source produced citation abbreviation []
|
|
64
|
+
axProduct = xProcess.xpath('./srcprod')
|
|
65
|
+
unless axProduct.empty?
|
|
66
|
+
axProduct.each do |xProduct|
|
|
67
|
+
prodSrc = xProduct.text
|
|
68
|
+
unless prodSrc.empty?
|
|
69
|
+
hLineage[:dataSources].each do |hSource|
|
|
70
|
+
unless hSource[:sourceCitation].empty?
|
|
71
|
+
hSource[:sourceCitation][:alternateTitles].each do |altTitle|
|
|
72
|
+
if prodSrc == altTitle
|
|
73
|
+
hProcess[:stepProducts] << hSource
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# process 2.5.2.6 (proccont) - process contact {contact}
|
|
83
|
+
xContact = xProcess.xpath('./proccont')
|
|
84
|
+
unless xContact.empty?
|
|
85
|
+
hResponsibility = Contact.unpack(xContact, hResponseObj)
|
|
86
|
+
unless hResponsibility.nil?
|
|
87
|
+
hResponsibility[:roleName] = 'processor'
|
|
88
|
+
hProcess[:processors] << hResponsibility
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
return hProcess
|
|
93
|
+
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
require 'nokogiri'
|
|
8
8
|
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
|
9
|
+
require_relative 'module_lineage'
|
|
9
10
|
|
|
10
11
|
module ADIWG
|
|
11
12
|
module Mdtranslator
|
|
@@ -14,9 +15,28 @@ module ADIWG
|
|
|
14
15
|
|
|
15
16
|
module Quality
|
|
16
17
|
|
|
17
|
-
def self.unpack(xDataQual, hResponseObj)
|
|
18
|
+
def self.unpack(xDataQual, hMetadata, hResponseObj)
|
|
18
19
|
|
|
20
|
+
hResourceInfo = hMetadata[:resourceInfo]
|
|
19
21
|
|
|
22
|
+
# data quality 2.1 (attracc) - attribute accuracy (not implemented)
|
|
23
|
+
|
|
24
|
+
# data quality 2.2 (logic) - logical consistency (not implemented)
|
|
25
|
+
|
|
26
|
+
# data quality 2.3 (complete) - completion report (not implemented)
|
|
27
|
+
|
|
28
|
+
# data quality 2.4 (position) - positional accuracy (not implemented)
|
|
29
|
+
|
|
30
|
+
# data quality 2.5 (lineage) - lineage
|
|
31
|
+
xLineage = xDataQual.xpath('./lineage')
|
|
32
|
+
unless xLineage.empty?
|
|
33
|
+
hLineage = Lineage.unpack(xLineage, hResourceInfo, hResponseObj)
|
|
34
|
+
unless hLineage.nil?
|
|
35
|
+
hMetadata[:lineageInfo] << hLineage
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
return hMetadata
|
|
20
40
|
|
|
21
41
|
end
|
|
22
42
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Reader - fgdc to internal data structure
|
|
2
|
+
# unpack fgdc security
|
|
3
|
+
|
|
4
|
+
# History:
|
|
5
|
+
# Stan Smith 2017-08-25 original script
|
|
6
|
+
|
|
7
|
+
require 'nokogiri'
|
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
|
9
|
+
|
|
10
|
+
module ADIWG
|
|
11
|
+
module Mdtranslator
|
|
12
|
+
module Readers
|
|
13
|
+
module Fgdc
|
|
14
|
+
|
|
15
|
+
module Security
|
|
16
|
+
|
|
17
|
+
def self.unpack(xSecurity, hResponseObj)
|
|
18
|
+
|
|
19
|
+
# instance classes needed in script
|
|
20
|
+
intMetadataClass = InternalMetadata.new
|
|
21
|
+
hConstraint = intMetadataClass.newConstraint
|
|
22
|
+
hConstraint[:type] = 'security'
|
|
23
|
+
hSecurity = intMetadataClass.newSecurityConstraint
|
|
24
|
+
|
|
25
|
+
# series 1.12.1 (secsys) - security system name
|
|
26
|
+
system = xSecurity.xpath('./secsys').text
|
|
27
|
+
hSecurity[:classSystem] = system unless system.empty?
|
|
28
|
+
|
|
29
|
+
# series 1.12.2 (secclass) - security class
|
|
30
|
+
secClass = xSecurity.xpath('./secclass').text
|
|
31
|
+
hSecurity[:classCode] = secClass unless secClass.empty?
|
|
32
|
+
|
|
33
|
+
# series 1.12.3 (sechandl) - security handling instructions
|
|
34
|
+
secHand = xSecurity.xpath('./sechandl').text
|
|
35
|
+
hSecurity[:handling] = secHand unless secHand.empty?
|
|
36
|
+
|
|
37
|
+
hConstraint[:securityConstraint] = hSecurity
|
|
38
|
+
|
|
39
|
+
return hConstraint
|
|
40
|
+
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Reader - fgdc to internal data structure
|
|
2
|
+
# unpack fgdc source
|
|
3
|
+
|
|
4
|
+
# History:
|
|
5
|
+
# Stan Smith 2017-08-28 original script
|
|
6
|
+
|
|
7
|
+
require 'nokogiri'
|
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
|
9
|
+
require_relative 'module_citation'
|
|
10
|
+
require_relative 'module_timePeriod'
|
|
11
|
+
|
|
12
|
+
module ADIWG
|
|
13
|
+
module Mdtranslator
|
|
14
|
+
module Readers
|
|
15
|
+
module Fgdc
|
|
16
|
+
|
|
17
|
+
module Source
|
|
18
|
+
|
|
19
|
+
def self.unpack(xSource, aSpatialResolutions, hResponseObj)
|
|
20
|
+
|
|
21
|
+
# instance classes needed in script
|
|
22
|
+
intMetadataClass = InternalMetadata.new
|
|
23
|
+
hSource = intMetadataClass.newDataSource
|
|
24
|
+
|
|
25
|
+
# source 2.5.1.1 (srccite) - source citation {citation}
|
|
26
|
+
xCitation = xSource.xpath('./srccite')
|
|
27
|
+
unless xCitation.empty?
|
|
28
|
+
hCitation = Citation.unpack(xCitation, hResponseObj)
|
|
29
|
+
hSource[:sourceCitation] = hCitation
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# source 2.5.1.2 (srcscale) - source scale denominator
|
|
33
|
+
scale = xSource.xpath('./srcscale').text
|
|
34
|
+
unless scale.empty?
|
|
35
|
+
hResolution = intMetadataClass.newSpatialResolution
|
|
36
|
+
hResolution[:scaleFactor] = scale.to_i
|
|
37
|
+
aSpatialResolutions << hResolution
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# source 2.5.1.3 (typesrc) - type of source media
|
|
41
|
+
type = xSource.xpath('./typesrc').text
|
|
42
|
+
unless type.empty?
|
|
43
|
+
hSource[:description] = type
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# source 2.5.1.4 (srctime) - source time period {scope < temporalExtent}
|
|
47
|
+
xTimePeriod = xSource.xpath('./srctime')
|
|
48
|
+
unless xTimePeriod.empty?
|
|
49
|
+
hTimePeriod = TimePeriod.unpack(xTimePeriod, hResponseObj)
|
|
50
|
+
unless hTimePeriod.nil?
|
|
51
|
+
hScope = intMetadataClass.newScope
|
|
52
|
+
hExtent = intMetadataClass.newExtent
|
|
53
|
+
hTempExtent = intMetadataClass.newTemporalExtent
|
|
54
|
+
hTempExtent[:timePeriod] = hTimePeriod
|
|
55
|
+
hExtent[:temporalExtents] << hTempExtent
|
|
56
|
+
hScope[:scopeCode] = 'dataset'
|
|
57
|
+
hScope[:extents] << hExtent
|
|
58
|
+
hSource[:scope] = hScope
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# source 2.5.1.5 (srccitea) - source citation abbreviation
|
|
63
|
+
citationAbb = xSource.xpath('./srccitea').text
|
|
64
|
+
unless citationAbb.empty?
|
|
65
|
+
hSource[:sourceCitation][:alternateTitles] << citationAbb
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# source 2.5.1.6 (srccontr) - source contribution
|
|
69
|
+
contribution = xSource.xpath('./srccontr').text
|
|
70
|
+
unless contribution.empty?
|
|
71
|
+
hSource[:description] = contribution
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
return hSource
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -23,7 +23,16 @@ module ADIWG
|
|
|
23
23
|
|
|
24
24
|
# time period 9 (timeinfo) - time period information
|
|
25
25
|
xTimeInfo = xTimePeriod.xpath('./timeinfo')
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
# current may have different element tags depending on timePeriod source
|
|
28
|
+
current = nil?
|
|
29
|
+
xFoundIt = xTimePeriod.at('./current')
|
|
30
|
+
if xFoundIt.nil?
|
|
31
|
+
xFoundIt = xTimePeriod.at('./srccurr')
|
|
32
|
+
end
|
|
33
|
+
unless xFoundIt.nil?
|
|
34
|
+
current = xFoundIt.text
|
|
35
|
+
end
|
|
27
36
|
|
|
28
37
|
unless xTimeInfo.empty?
|
|
29
38
|
|