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.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +58 -1
  3. data/adiwg-mdtranslator.gemspec +2 -2
  4. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +66 -2
  5. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +7 -0
  6. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_keyword.rb +36 -3
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialDomain.rb +21 -0
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonClass.rb +70 -0
  9. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonSystem.rb +132 -0
  10. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonomy.rb +65 -0
  11. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_boundingBox.rb +116 -86
  12. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geographicExtent.rb +91 -83
  13. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_codelists.rb +22 -12
  14. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_contact.rb +7 -9
  15. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_extent.rb +1 -0
  16. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_relatedItem.rb +24 -13
  17. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_webLinkDocument.rb +4 -5
  18. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_webLinkGraphic.rb +3 -4
  19. data/lib/adiwg/mdtranslator/version.rb +2 -1
  20. data/lib/adiwg/mdtranslator/writers/html/sections/html_boundingBox.rb +22 -4
  21. data/lib/adiwg/mdtranslator/writers/html/sections/html_geographicExtent.rb +8 -0
  22. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_boundingBox.rb +5 -1
  23. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_geographicExtent.rb +4 -2
  24. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_codelists.rb +2 -0
  25. 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
- # Stan Smith 2016-12-01 original script
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
- module Mdtranslator
9
- module Readers
10
- module MdJson
11
-
12
- module BoundingBox
13
-
14
- def self.unpack(hBBox, responseObj)
15
-
16
- # return nil object if input is empty
17
- if hBBox.empty?
18
- responseObj[:readerExecutionMessages] << 'boundingBox object is empty'
19
- responseObj[:readerExecutionPass] = false
20
- return nil
21
- end
22
-
23
- # instance classes needed in script
24
- intMetadataClass = InternalMetadata.new
25
- intBBox = intMetadataClass.newBoundingBox
26
-
27
- # bounding box - west longitude (required)
28
- if hBBox.has_key?('westLongitude')
29
- intBBox[:westLongitude] = hBBox['westLongitude']
30
- end
31
- if intBBox[:westLongitude].nil? || intBBox[:westLongitude] == ''
32
- responseObj[:readerExecutionMessages] << 'boundingBox west boundary is missing'
33
- responseObj[:readerExecutionPass] = false
34
- return nil
35
- end
36
- if intBBox[:westLongitude].abs > 180
37
- responseObj[:readerExecutionMessages] << 'boundingBox longitude must be between -180 and +180'
38
- responseObj[:readerExecutionPass] = false
39
- return nil
40
- end
41
-
42
- # bounding box - east longitude (required)
43
- if hBBox.has_key?('eastLongitude')
44
- intBBox[:eastLongitude] = hBBox['eastLongitude']
45
- end
46
- if intBBox[:eastLongitude].nil? || intBBox[:eastLongitude] == ''
47
- responseObj[:readerExecutionMessages] << 'boundingBox east boundary is missing'
48
- responseObj[:readerExecutionPass] = false
49
- return nil
50
- end
51
- if intBBox[:eastLongitude].abs > 180
52
- responseObj[:readerExecutionMessages] << 'boundingBox longitude must be between -180 and +180'
53
- responseObj[:readerExecutionPass] = false
54
- return nil
55
- end
56
-
57
- # bounding box - south latitude (required)
58
- if hBBox.has_key?('southLatitude')
59
- intBBox[:southLatitude] = hBBox['southLatitude']
60
- end
61
- if intBBox[:southLatitude].nil? || intBBox[:southLatitude] == ''
62
- responseObj[:readerExecutionMessages] << 'boundingBox south boundary is missing'
63
- responseObj[:readerExecutionPass] = false
64
- return nil
65
- end
66
- if intBBox[:southLatitude].abs > 90
67
- responseObj[:readerExecutionMessages] << 'boundingBox latitude must be between -90 and +90'
68
- responseObj[:readerExecutionPass] = false
69
- return nil
70
- end
71
- # bounding box - north latitude (required)
72
- if hBBox.has_key?('northLatitude')
73
- intBBox[:northLatitude] = hBBox['northLatitude']
74
- end
75
- if intBBox[:northLatitude].nil? || intBBox[:northLatitude] == ''
76
- responseObj[:readerExecutionMessages] << 'boundingBox north boundary is missing'
77
- responseObj[:readerExecutionPass] = false
78
- return nil
79
- end
80
- if intBBox[:northLatitude].abs > 90
81
- responseObj[:readerExecutionMessages] << 'boundingBox latitude must be between -90 and +90'
82
- responseObj[:readerExecutionPass] = false
83
- return nil
84
- end
85
-
86
- return intBBox
87
-
88
- end
89
-
90
- end
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
- end
94
- end
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
- # Stan Smith 2016-12-01 original script
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
- module Mdtranslator
13
- module Readers
14
- module MdJson
15
-
16
- module GeographicExtent
17
-
18
- def self.unpack(hGeoExt, responseObj)
19
-
20
- # return nil object if input is empty
21
- if hGeoExt.empty?
22
- responseObj[:readerExecutionMessages] << 'geographicExtent object is empty'
23
- responseObj[:readerExecutionPass] = false
24
- return nil
25
- end
26
-
27
- # instance classes needed in script
28
- intMetadataClass = InternalMetadata.new
29
- intGeoExt = intMetadataClass.newGeographicExtent
30
-
31
- # geographic extent - contains data
32
- if hGeoExt.has_key?('containsData')
33
- if hGeoExt['containsData'] === false
34
- intGeoExt[:containsData] = hGeoExt['containsData']
35
- end
36
- end
37
-
38
- # geographic extent - identifier
39
- if hGeoExt.has_key?('identifier')
40
- unless hGeoExt['identifier'].empty?
41
- hReturn = Identifier.unpack(hGeoExt['identifier'], responseObj)
42
- unless hReturn.nil?
43
- intGeoExt[:identifier] = hReturn
44
- end
45
- end
46
- end
47
-
48
- # geographic extent - bounding box
49
- if hGeoExt.has_key?('boundingBox')
50
- unless hGeoExt['boundingBox'].empty?
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
- # geographic extent - geographic elements
59
- if hGeoExt.has_key?('geographicElement')
60
- hGeoExt['geographicElement'].each do |hElement|
61
- hReturn = GeoJson.unpack(hElement, responseObj)
62
- unless hReturn.nil?
63
- intGeoExt[:geographicElements] << hReturn
64
- end
65
- end
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
- # test for completeness
81
- if intGeoExt[:identifier].empty? &&
82
- intGeoExt[:boundingBox].empty? &&
83
- intGeoExt[:geographicElements].empty?
84
- responseObj[:readerExecutionMessages] <<
85
- 'geographicExtent must have at least one identifier, boundingBox, or geographic element'
86
- responseObj[:readerExecutionPass] = false
87
- return nil
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
- return intGeoExt
91
-
92
- end
93
- end
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
- end
97
- end
102
+
103
+ end
104
+ end
105
+ end
98
106
  end