adiwg-mdtranslator 2.3.2 → 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +58 -1
- data/adiwg-mdtranslator.gemspec +2 -2
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +66 -2
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +7 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_keyword.rb +36 -3
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialDomain.rb +21 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonClass.rb +70 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonSystem.rb +132 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonomy.rb +65 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_boundingBox.rb +116 -86
- data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geographicExtent.rb +91 -83
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_codelists.rb +22 -12
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_contact.rb +7 -9
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_extent.rb +1 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_relatedItem.rb +24 -13
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_webLinkDocument.rb +4 -5
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_webLinkGraphic.rb +3 -4
- data/lib/adiwg/mdtranslator/version.rb +2 -1
- data/lib/adiwg/mdtranslator/writers/html/sections/html_boundingBox.rb +22 -4
- data/lib/adiwg/mdtranslator/writers/html/sections/html_geographicExtent.rb +8 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_boundingBox.rb +5 -1
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_geographicExtent.rb +4 -2
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_codelists.rb +2 -0
- metadata +10 -7
@@ -0,0 +1,65 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc taxonomy
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-09-20 original script
|
6
|
+
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
|
+
require_relative 'module_keyword'
|
10
|
+
require_relative 'module_taxonSystem'
|
11
|
+
require_relative 'module_taxonClass'
|
12
|
+
|
13
|
+
module ADIWG
|
14
|
+
module Mdtranslator
|
15
|
+
module Readers
|
16
|
+
module Fgdc
|
17
|
+
|
18
|
+
module Taxonomy
|
19
|
+
|
20
|
+
def self.unpack(xTaxonomy, hResourceInfo, hResponseObj)
|
21
|
+
|
22
|
+
# instance classes needed in script
|
23
|
+
intMetadataClass = InternalMetadata.new
|
24
|
+
hTaxonomy = intMetadataClass.newTaxonomy
|
25
|
+
|
26
|
+
# taxonomy bio.1 (keywtax) - taxonomic keywords {keyword}
|
27
|
+
# -> resourceInfo.keywords
|
28
|
+
xKeywords = xTaxonomy.xpath('./keywtax')
|
29
|
+
unless xKeywords.empty?
|
30
|
+
Keyword.unpack(xKeywords, hResourceInfo, hResponseObj)
|
31
|
+
end
|
32
|
+
|
33
|
+
# taxonomy bio.2 (taxonsys) - taxonomic system
|
34
|
+
xSystem = xTaxonomy.xpath('./taxonsys')
|
35
|
+
unless xSystem.empty?
|
36
|
+
TaxonSystem.unpack(xSystem, hTaxonomy, hResponseObj)
|
37
|
+
end
|
38
|
+
|
39
|
+
# taxonomy bio.3 (taxongen) - general taxonomic coverage
|
40
|
+
# -> resourceInfo.taxonomy.generalScope
|
41
|
+
general = xTaxonomy.xpath('./taxongen').text
|
42
|
+
unless general.empty?
|
43
|
+
hTaxonomy[:generalScope] = general
|
44
|
+
end
|
45
|
+
|
46
|
+
# taxonomy bio.4 (taxoncl) - taxonomic classification
|
47
|
+
# -> resourceInfo.taxonomy.taxonClass
|
48
|
+
xTaxClass = xTaxonomy.xpath('./taxoncl')
|
49
|
+
unless xTaxClass.empty?
|
50
|
+
hTaxonClass = TaxonClass.unpack(xTaxClass, hResponseObj)
|
51
|
+
unless hTaxonClass.nil?
|
52
|
+
hTaxonomy[:taxonClass] = hTaxonClass
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
return hTaxonomy
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -2,94 +2,124 @@
|
|
2
2
|
# Reader - ADIwg JSON to internal data structure
|
3
3
|
|
4
4
|
# History:
|
5
|
-
#
|
5
|
+
# Stan Smith 2017-09-28 add altitude to support fgdc
|
6
|
+
# Stan Smith 2016-12-01 original script
|
6
7
|
|
7
8
|
module ADIWG
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
9
|
+
module Mdtranslator
|
10
|
+
module Readers
|
11
|
+
module MdJson
|
12
|
+
|
13
|
+
module BoundingBox
|
14
|
+
|
15
|
+
def self.unpack(hBBox, responseObj)
|
16
|
+
|
17
|
+
# return nil object if input is empty
|
18
|
+
if hBBox.empty?
|
19
|
+
responseObj[:readerExecutionMessages] << 'boundingBox object is empty'
|
20
|
+
responseObj[:readerExecutionPass] = false
|
21
|
+
return nil
|
22
|
+
end
|
23
|
+
|
24
|
+
# instance classes needed in script
|
25
|
+
intMetadataClass = InternalMetadata.new
|
26
|
+
intBBox = intMetadataClass.newBoundingBox
|
27
|
+
|
28
|
+
# bounding box - west longitude (required)
|
29
|
+
if hBBox.has_key?('westLongitude')
|
30
|
+
intBBox[:westLongitude] = hBBox['westLongitude']
|
31
|
+
end
|
32
|
+
if intBBox[:westLongitude].nil? || intBBox[:westLongitude] == ''
|
33
|
+
responseObj[:readerExecutionMessages] << 'boundingBox west boundary is missing'
|
34
|
+
responseObj[:readerExecutionPass] = false
|
35
|
+
return nil
|
36
|
+
end
|
37
|
+
if intBBox[:westLongitude].abs > 180
|
38
|
+
responseObj[:readerExecutionMessages] << 'boundingBox longitude must be between -180 and +180'
|
39
|
+
responseObj[:readerExecutionPass] = false
|
40
|
+
return nil
|
41
|
+
end
|
42
|
+
|
43
|
+
# bounding box - east longitude (required)
|
44
|
+
if hBBox.has_key?('eastLongitude')
|
45
|
+
intBBox[:eastLongitude] = hBBox['eastLongitude']
|
46
|
+
end
|
47
|
+
if intBBox[:eastLongitude].nil? || intBBox[:eastLongitude] == ''
|
48
|
+
responseObj[:readerExecutionMessages] << 'boundingBox east boundary is missing'
|
49
|
+
responseObj[:readerExecutionPass] = false
|
50
|
+
return nil
|
51
|
+
end
|
52
|
+
if intBBox[:eastLongitude].abs > 180
|
53
|
+
responseObj[:readerExecutionMessages] << 'boundingBox longitude must be between -180 and +180'
|
54
|
+
responseObj[:readerExecutionPass] = false
|
55
|
+
return nil
|
56
|
+
end
|
57
|
+
|
58
|
+
# bounding box - south latitude (required)
|
59
|
+
if hBBox.has_key?('southLatitude')
|
60
|
+
intBBox[:southLatitude] = hBBox['southLatitude']
|
61
|
+
end
|
62
|
+
if intBBox[:southLatitude].nil? || intBBox[:southLatitude] == ''
|
63
|
+
responseObj[:readerExecutionMessages] << 'boundingBox south boundary is missing'
|
64
|
+
responseObj[:readerExecutionPass] = false
|
65
|
+
return nil
|
66
|
+
end
|
67
|
+
if intBBox[:southLatitude].abs > 90
|
68
|
+
responseObj[:readerExecutionMessages] << 'boundingBox latitude must be between -90 and +90'
|
69
|
+
responseObj[:readerExecutionPass] = false
|
70
|
+
return nil
|
71
|
+
end
|
72
|
+
|
73
|
+
# bounding box - north latitude (required)
|
74
|
+
if hBBox.has_key?('northLatitude')
|
75
|
+
intBBox[:northLatitude] = hBBox['northLatitude']
|
76
|
+
end
|
77
|
+
if intBBox[:northLatitude].nil? || intBBox[:northLatitude] == ''
|
78
|
+
responseObj[:readerExecutionMessages] << 'boundingBox north boundary is missing'
|
79
|
+
responseObj[:readerExecutionPass] = false
|
80
|
+
return nil
|
81
|
+
end
|
82
|
+
if intBBox[:northLatitude].abs > 90
|
83
|
+
responseObj[:readerExecutionMessages] << 'boundingBox latitude must be between -90 and +90'
|
84
|
+
responseObj[:readerExecutionPass] = false
|
85
|
+
return nil
|
86
|
+
end
|
87
|
+
|
88
|
+
# bounding box - minimum altitude
|
89
|
+
if hBBox.has_key?('minimumAltitude')
|
90
|
+
unless hBBox['minimumAltitude'].nil? || hBBox['minimumAltitude'] == ''
|
91
|
+
intBBox[:minimumAltitude] = hBBox['minimumAltitude']
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# bounding box - maximum altitude
|
96
|
+
if hBBox.has_key?('maximumAltitude')
|
97
|
+
unless hBBox['maximumAltitude'].nil? || hBBox['maximumAltitude'] == ''
|
98
|
+
intBBox[:maximumAltitude] = hBBox['maximumAltitude']
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
# bounding box - altitude units of measure
|
103
|
+
if hBBox.has_key?('unitsOfAltitude')
|
104
|
+
unless hBBox['unitsOfAltitude'].nil? || hBBox['unitsOfAltitude'] == ''
|
105
|
+
intBBox[:unitsOfAltitude] = hBBox['unitsOfAltitude']
|
106
|
+
end
|
107
|
+
end
|
108
|
+
unless intBBox[:minimumAltitude].nil? && intBBox[:maximumAltitude].nil?
|
109
|
+
if intBBox[:unitsOfAltitude].nil? || intBBox[:unitsOfAltitude] == ''
|
110
|
+
responseObj[:readerExecutionMessages] << 'boundingBox altitude unit of measure is missing'
|
111
|
+
responseObj[:readerExecutionPass] = false
|
112
|
+
return nil
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
return intBBox
|
117
|
+
|
118
|
+
end
|
91
119
|
|
92
120
|
end
|
93
|
-
|
94
|
-
|
121
|
+
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
95
125
|
end
|
@@ -2,97 +2,105 @@
|
|
2
2
|
# Reader - ADIwg JSON to internal data structure
|
3
3
|
|
4
4
|
# History:
|
5
|
-
#
|
5
|
+
# Stan Smith 2017-09-28 added description element to support fgdc
|
6
|
+
# Stan Smith 2016-12-01 original script
|
6
7
|
|
7
8
|
require_relative 'module_identifier'
|
8
9
|
require_relative 'module_boundingBox'
|
9
10
|
require_relative 'module_geoJson'
|
10
11
|
|
11
12
|
module ADIWG
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
hReturn = BoundingBox.unpack(hGeoExt['boundingBox'], responseObj)
|
52
|
-
unless hReturn.nil?
|
53
|
-
intGeoExt[:boundingBox] = hReturn
|
54
|
-
end
|
55
|
-
end
|
13
|
+
module Mdtranslator
|
14
|
+
module Readers
|
15
|
+
module MdJson
|
16
|
+
|
17
|
+
module GeographicExtent
|
18
|
+
|
19
|
+
def self.unpack(hGeoExt, responseObj)
|
20
|
+
|
21
|
+
# return nil object if input is empty
|
22
|
+
if hGeoExt.empty?
|
23
|
+
responseObj[:readerExecutionMessages] << 'geographicExtent object is empty'
|
24
|
+
responseObj[:readerExecutionPass] = false
|
25
|
+
return nil
|
26
|
+
end
|
27
|
+
|
28
|
+
# instance classes needed in script
|
29
|
+
intMetadataClass = InternalMetadata.new
|
30
|
+
intGeoExt = intMetadataClass.newGeographicExtent
|
31
|
+
|
32
|
+
# geographic extent - description
|
33
|
+
if hGeoExt.has_key?('description')
|
34
|
+
if hGeoExt['description'] != ''
|
35
|
+
intGeoExt[:description] = hGeoExt['description']
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# geographic extent - contains data
|
40
|
+
if hGeoExt.has_key?('containsData')
|
41
|
+
if hGeoExt['containsData'] === false
|
42
|
+
intGeoExt[:containsData] = hGeoExt['containsData']
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# geographic extent - identifier
|
47
|
+
if hGeoExt.has_key?('identifier')
|
48
|
+
unless hGeoExt['identifier'].empty?
|
49
|
+
hReturn = Identifier.unpack(hGeoExt['identifier'], responseObj)
|
50
|
+
unless hReturn.nil?
|
51
|
+
intGeoExt[:identifier] = hReturn
|
56
52
|
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
# save native GeoJson
|
69
|
-
if hGeoExt.has_key?('geographicElement')
|
70
|
-
unless hGeoExt['geographicElement'].empty?
|
71
|
-
intGeoExt[:nativeGeoJson] = hGeoExt['geographicElement']
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# compute bbox for extent
|
76
|
-
unless intGeoExt[:geographicElements].empty?
|
77
|
-
intGeoExt[:computedBbox] = AdiwgCoordinates.computeBbox(intGeoExt[:geographicElements])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# geographic extent - bounding box
|
57
|
+
if hGeoExt.has_key?('boundingBox')
|
58
|
+
unless hGeoExt['boundingBox'].empty?
|
59
|
+
hReturn = BoundingBox.unpack(hGeoExt['boundingBox'], responseObj)
|
60
|
+
unless hReturn.nil?
|
61
|
+
intGeoExt[:boundingBox] = hReturn
|
78
62
|
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# geographic extent - geographic elements
|
67
|
+
if hGeoExt.has_key?('geographicElement')
|
68
|
+
hGeoExt['geographicElement'].each do |hElement|
|
69
|
+
hReturn = GeoJson.unpack(hElement, responseObj)
|
70
|
+
unless hReturn.nil?
|
71
|
+
intGeoExt[:geographicElements] << hReturn
|
88
72
|
end
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# save native GeoJson
|
77
|
+
if hGeoExt.has_key?('geographicElement')
|
78
|
+
unless hGeoExt['geographicElement'].empty?
|
79
|
+
intGeoExt[:nativeGeoJson] = hGeoExt['geographicElement']
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# compute bbox for extent
|
84
|
+
unless intGeoExt[:geographicElements].empty?
|
85
|
+
intGeoExt[:computedBbox] = AdiwgCoordinates.computeBbox(intGeoExt[:geographicElements])
|
86
|
+
end
|
87
|
+
|
88
|
+
# test for completeness
|
89
|
+
if intGeoExt[:identifier].empty? &&
|
90
|
+
intGeoExt[:boundingBox].empty? &&
|
91
|
+
intGeoExt[:geographicElements].empty?
|
92
|
+
responseObj[:readerExecutionMessages] <<
|
93
|
+
'geographicExtent must have at least one identifier, boundingBox, or geographic element'
|
94
|
+
responseObj[:readerExecutionPass] = false
|
95
|
+
return nil
|
96
|
+
end
|
97
|
+
|
98
|
+
return intGeoExt
|
99
|
+
|
100
|
+
end
|
95
101
|
end
|
96
|
-
|
97
|
-
|
102
|
+
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
98
106
|
end
|