adiwg-mdtranslator 2.6.0 → 2.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +23 -1
  3. data/Rakefile +1 -0
  4. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_contact.rb +10 -0
  5. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_keyword.rb +6 -6
  6. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialDomain.rb +100 -86
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_timePeriod.rb +3 -0
  8. data/lib/adiwg/mdtranslator/readers/fgdc/readme.md +4 -0
  9. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_contact.rb +157 -157
  10. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_body.rb +4 -7
  11. data/lib/adiwg/mdtranslator/version.rb +7 -1
  12. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_address.rb +87 -0
  13. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_citation.rb +172 -0
  14. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_contact.rb +164 -0
  15. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateRange.rb +73 -0
  16. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateSingle.rb +54 -0
  17. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_description.rb +49 -0
  18. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_fgdc.rb +60 -0
  19. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_geologicAge.rb +78 -0
  20. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_geologicRange.rb +54 -0
  21. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_identification.rb +152 -0
  22. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_keyword.rb +99 -0
  23. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_phone.rb +73 -0
  24. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_publisher.rb +67 -0
  25. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_series.rb +47 -0
  26. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_spatialDomain.rb +200 -0
  27. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_status.rb +63 -0
  28. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_timePeriod.rb +102 -0
  29. data/lib/adiwg/mdtranslator/writers/fgdc/fgdc_writer.rb +49 -0
  30. data/lib/adiwg/mdtranslator/writers/fgdc/readme.md +22 -0
  31. data/lib/adiwg/mdtranslator/writers/fgdc/version.rb +15 -0
  32. data/lib/adiwg/mdtranslator/writers/html/version.rb +3 -2
  33. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_fcFeatureCatalogue.rb +1 -1
  34. data/lib/adiwg/mdtranslator/writers/iso19110/iso19110_writer.rb +3 -1
  35. data/lib/adiwg/mdtranslator/writers/iso19110/version.rb +15 -0
  36. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_miMetadata.rb +1 -1
  37. data/lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer.rb +29 -27
  38. data/lib/adiwg/mdtranslator/writers/iso19115_2/version.rb +15 -0
  39. data/lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb +4 -2
  40. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_mdJson.rb +1 -0
  41. data/lib/adiwg/mdtranslator/writers/mdJson/version.rb +3 -5
  42. data/lib/adiwg/mdtranslator/writers/sbJson/sbJson_writer.rb +1 -1
  43. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_budget.rb +21 -9
  44. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_sbJson.rb +21 -3
  45. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_tag.rb +27 -7
  46. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_webLink.rb +17 -4
  47. data/lib/adiwg/mdtranslator/writers/sbJson/version.rb +1 -4
  48. data/lib/adiwg/mdtranslator.rb +5 -4
  49. metadata +24 -2
@@ -0,0 +1,99 @@
1
+ # FGDC <<Class>> Keyword
2
+ # FGDC CSDGM writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-26 original script
6
+
7
+ module ADIWG
8
+ module Mdtranslator
9
+ module Writers
10
+ module Fgdc
11
+
12
+ class Keyword
13
+
14
+ def initialize(xml, hResponseObj)
15
+ @xml = xml
16
+ @hResponseObj = hResponseObj
17
+ end
18
+
19
+ def writeXML(aKeywords)
20
+
21
+ # array of keyword sets
22
+ aKeywords.each do |hKeySet|
23
+
24
+ # find all the keyword set parts
25
+ type = hKeySet[:keywordType]
26
+ thesaurusName = nil
27
+ thesaurus = hKeySet[:thesaurus]
28
+ unless thesaurus.empty?
29
+ thesaurusName = thesaurus[:title]
30
+ end
31
+ aKeywords = hKeySet[:keywords]
32
+ if thesaurusName.nil?
33
+ @hResponseObj[:writerPass] = false
34
+ @hResponseObj[:writerMessages] << 'keyword set is missing thesaurus name'
35
+ end
36
+
37
+ # keyword 1.6.1 (theme) - theme keywords
38
+ if type == 'theme'
39
+ @xml.tag!('theme') do
40
+ @xml.tag!('themekt', thesaurusName)
41
+ aKeywords.each do |hKeyword|
42
+ keyword = hKeyword[:keyword]
43
+ unless keyword.nil?
44
+ @xml.tag!('themekey', keyword)
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ # keyword 1.6.2 (place) - place keywords
51
+ if type == 'place'
52
+ @xml.tag!('place') do
53
+ @xml.tag!('placekt', thesaurusName)
54
+ aKeywords.each do |hKeyword|
55
+ keyword = hKeyword[:keyword]
56
+ unless keyword.nil?
57
+ @xml.tag!('placekey', keyword)
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ # keyword 1.6.3 (stratum) - stratum keywords
64
+ if type == 'stratum'
65
+ @xml.tag!('stratum') do
66
+ @xml.tag!('stratkt', thesaurusName)
67
+ aKeywords.each do |hKeyword|
68
+ keyword = hKeyword[:keyword]
69
+ unless keyword.nil?
70
+ @xml.tag!('stratkey', keyword)
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ # keyword 1.6.4 (temporal) - temporal keywords
77
+ if type == 'temporal'
78
+ @xml.tag!('temporal') do
79
+ @xml.tag!('tempkt', thesaurusName)
80
+ aKeywords.each do |hKeyword|
81
+ keyword = hKeyword[:keyword]
82
+ unless keyword.nil?
83
+ @xml.tag!('tempkey', keyword)
84
+ end
85
+ end
86
+ end
87
+ end
88
+
89
+ # other keywordType(s) not transferred to FGDC
90
+
91
+ end
92
+
93
+ end # writeXML
94
+ end # Status
95
+
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,73 @@
1
+ # FGDC <<Class>> Phone
2
+ # FGDC CSDGM writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-28 original script
6
+
7
+ module ADIWG
8
+ module Mdtranslator
9
+ module Writers
10
+ module Fgdc
11
+
12
+ class Phone
13
+
14
+ def initialize(xml, hResponseObj)
15
+ @xml = xml
16
+ @hResponseObj = hResponseObj
17
+ end
18
+
19
+ def writeXML(aPhones)
20
+
21
+ # phone 10.5 (cntvoice) - voice phone [] (required)
22
+ # <- hPhone[:phoneNumber] where hPhone[:phoneServiceTypes] = 'voice'
23
+ haveVoice = false
24
+ aPhones.each do |hPhone|
25
+ if hPhone[:phoneServiceTypes].include?('voice')
26
+ unless hPhone[:phoneNumber].nil?
27
+ @xml.tag!('cntvoice', hPhone[:phoneNumber])
28
+ haveVoice = true
29
+ end
30
+ end
31
+ end
32
+ unless haveVoice
33
+ @hResponseObj[:writerPass] = false
34
+ @hResponseObj[:writerMessages] << 'Contact is missing voice phone'
35
+ end
36
+
37
+ # phone 10.6 (cnttdd) - tty phone []
38
+ # <- hPhone[:phoneNumber] where hPhone[:phoneServiceTypes] = 'tty'
39
+ haveTTY = false
40
+ aPhones.each do |hPhone|
41
+ if hPhone[:phoneServiceTypes].include?('tty')
42
+ unless hPhone[:phoneNumber].nil?
43
+ @xml.tag!('cnttdd', hPhone[:phoneNumber])
44
+ haveTTY = true
45
+ end
46
+ end
47
+ end
48
+ if !haveTTY && @hResponseObj[:writerShowTags]
49
+ @xml.tag!('cnttdd')
50
+ end
51
+
52
+ # phone 10.7 (cntfax) - fax phone []
53
+ # <- hPhone[:phoneNumber] where hPhone[:phoneServiceTypes] = ['fax' | 'facsimile']
54
+ haveFax = false
55
+ aPhones.each do |hPhone|
56
+ if hPhone[:phoneServiceTypes].include?('fax') || hPhone[:phoneServiceTypes].include?('facsimile')
57
+ unless hPhone[:phoneNumber].nil?
58
+ @xml.tag!('cntfax', hPhone[:phoneNumber])
59
+ haveFax = true
60
+ end
61
+ end
62
+ end
63
+ if !haveFax && @hResponseObj[:writerShowTags]
64
+ @xml.tag!('cntfax')
65
+ end
66
+
67
+ end # writeXML
68
+ end # Phone
69
+
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,67 @@
1
+ # FGDC <<Class>> Publisher
2
+ # FGDC CSDGM writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-21 original script
6
+
7
+ module ADIWG
8
+ module Mdtranslator
9
+ module Writers
10
+ module Fgdc
11
+
12
+ class Publisher
13
+
14
+ def initialize(xml, hResponseObj)
15
+ @xml = xml
16
+ @hResponseObj = hResponseObj
17
+ end
18
+
19
+ def writeXML(hContact)
20
+
21
+ # publication 8.8.1 (pubplace) - publication place
22
+ # <- hContact[:addresses][:description] (required)
23
+ place = ''
24
+ unless hContact[:addresses].empty?
25
+ hAddress = hContact[:addresses][0]
26
+ unless hAddress.empty?
27
+ description = hAddress[:description]
28
+ city = hAddress[:city]
29
+ state = hAddress[:adminArea]
30
+ country = hAddress[:country]
31
+ place = ''
32
+ place += city unless city.nil?
33
+ place += ', ' + state unless state.nil?
34
+ place += ', ' + country unless country.nil?
35
+ if place.empty?
36
+ unless description.nil?
37
+ place = description
38
+ end
39
+ end
40
+ end
41
+ unless place.empty?
42
+ @xml.tag!('pubplace', place)
43
+ end
44
+ end
45
+ if place == ''
46
+ @hResponseObj[:writerPass] = false
47
+ @hResponseObj[:writerMessages] << 'Publisher is missing place of publication'
48
+ end
49
+
50
+ # publication 8.8.2 (publish) - publisher name
51
+ # <- hContact[:name] (required)
52
+ name = hContact[:name]
53
+ unless name.nil?
54
+ @xml.tag!('publish', name)
55
+ end
56
+ if name.nil?
57
+ @hResponseObj[:writerPass] = false
58
+ @hResponseObj[:writerMessages] << 'Publisher is missing name of publisher'
59
+ end
60
+
61
+ end # writeXML
62
+ end # Series
63
+
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,47 @@
1
+ # FGDC <<Class>> Series
2
+ # FGDC CSDGM writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-21 original script
6
+
7
+ module ADIWG
8
+ module Mdtranslator
9
+ module Writers
10
+ module Fgdc
11
+
12
+ class Series
13
+
14
+ def initialize(xml, hResponseObj)
15
+ @xml = xml
16
+ @hResponseObj = hResponseObj
17
+ end
18
+
19
+ def writeXML(hSeries)
20
+
21
+ # series 8.7.1 (sername) - series name
22
+ # <- hCitation[:series][:seriesName] (required)
23
+ unless hSeries[:seriesName].nil?
24
+ @xml.tag!('sername', hSeries[:seriesName])
25
+ end
26
+ if hSeries[:seriesName].nil?
27
+ @hResponseObj[:writerPass] = false
28
+ @hResponseObj[:writerMessages] << 'Series is missing name'
29
+ end
30
+
31
+ # series 8.7.2 (issue) - series issue
32
+ # <- hCitation[:series][:seriesIssue] (required)
33
+ unless hSeries[:seriesIssue].nil?
34
+ @xml.tag!('issue', hSeries[:seriesIssue])
35
+ end
36
+ if hSeries[:seriesIssue].nil?
37
+ @hResponseObj[:writerPass] = false
38
+ @hResponseObj[:writerMessages] << 'Series is missing issue'
39
+ end
40
+
41
+ end # writeXML
42
+ end # Series
43
+
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,200 @@
1
+ # FGDC <<Class>> SpatialDomain
2
+ # FGDC CSDGM writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-25 original script
6
+
7
+ module ADIWG
8
+ module Mdtranslator
9
+ module Writers
10
+ module Fgdc
11
+
12
+ class SpatialDomain
13
+
14
+ def initialize(xml, hResponseObj)
15
+ @xml = xml
16
+ @hResponseObj = hResponseObj
17
+ end
18
+
19
+ def writeXML(aExtents)
20
+
21
+ # spatial domain section is no required under bio extension rules
22
+
23
+ # look for geographic description - take first
24
+ # <- geographicExtent[:description]
25
+ geoDescription = ''
26
+ aExtents.each do |hExtent|
27
+ unless hExtent.empty?
28
+ hExtent[:geographicExtents].each do |hGeoExtent|
29
+ unless hGeoExtent.empty?
30
+ unless hGeoExtent[:description].nil?
31
+ geoDescription = hGeoExtent[:description]
32
+ break
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ # look for bounding box - take first
40
+ # <- geographicExtent[:boundingBox]
41
+ hBBox = {}
42
+ aExtents.each do |hExtent|
43
+ unless hExtent.empty?
44
+ hExtent[:geographicExtents].each do |hGeoExtent|
45
+ unless hGeoExtent.empty?
46
+ unless hGeoExtent[:boundingBox].empty?
47
+ hBBox = hGeoExtent[:boundingBox]
48
+ break
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ # look for bounding polygon
56
+ # <- geographicExtent[:geographicElements]
57
+ # polygon must be in FeatureCollection with properties description of 'FGDC bounding polygon'
58
+ aBPoly = []
59
+ aExtents.each do |hExtent|
60
+ unless hExtent.empty?
61
+ hExtent[:geographicExtents].each do |hGeoExtent|
62
+ unless hGeoExtent.empty?
63
+ unless hGeoExtent[:geographicElements].empty?
64
+ hGeoExtent[:geographicElements].each do |hGeoElement|
65
+ if hGeoElement[:type] == 'FeatureCollection'
66
+ hGeoElement[:features].each do |hFeature|
67
+ if hFeature[:geometryObject][:type] == 'Polygon'
68
+ unless hFeature[:properties].empty?
69
+ if hFeature[:properties][:description] == 'FGDC bounding polygon'
70
+ aBPoly << hFeature[:geometryObject][:coordinates]
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+
83
+ # spatial domain 1.5 (spdom)
84
+ unless geoDescription.empty? && hBBox.empty? && hBPoly.empty?
85
+ @xml.tag!('spdom') do
86
+
87
+ # spatial domain bio (descgeog) - geographic description (required)
88
+ unless geoDescription.empty?
89
+ @xml.tag!('descgeog', geoDescription)
90
+ end
91
+ if geoDescription.empty?
92
+ @hResponseObj[:writerPass] = false
93
+ @hResponseObj[:writerMessages] << 'Spatial Domain section is missing geographic description'
94
+ end
95
+
96
+ # spatial domain 1.5.1 (bounding) - bounding box (required)
97
+ unless hBBox.empty?
98
+ @xml.tag!('bounding') do
99
+
100
+ # bounding box 1.5.1.1 (westbc) - west bounding coordinate
101
+ @xml.tag!('westbc', hBBox[:westLongitude])
102
+
103
+ # bounding box 1.5.1.2 (eastbc) - east bounding coordinate
104
+ @xml.tag!('eastbc', hBBox[:eastLongitude])
105
+
106
+ # bounding box 1.5.1.3 (northbc) - north bounding coordinate
107
+ @xml.tag!('northbc', hBBox[:northLatitude])
108
+
109
+ # bounding box 1.5.1.4 (southbc) - south bounding coordinate
110
+ @xml.tag!('southbc', hBBox[:southLatitude])
111
+
112
+ # altitude bounding bio extension
113
+ unless hBBox[:minimumAltitude].nil? && hBBox[:maximumAltitude].nil? && hBBox[:unitsOfAltitude].nil?
114
+ @xml.tag!('boundalt') do
115
+
116
+ # altitude bounding (altmin) - minimum altitude (required)
117
+ unless hBBox[:minimumAltitude].nil?
118
+ @xml.tag!('altmin', hBBox[:minimumAltitude])
119
+ end
120
+ if hBBox[:minimumAltitude].nil?
121
+ @hResponseObj[:writerPass] = false
122
+ @hResponseObj[:writerMessages] << 'Altitude Bounding Box missing minimum altitude'
123
+ end
124
+
125
+ # altitude bounding (altmax) - maximum altitude (required)
126
+ unless hBBox[:maximumAltitude].nil?
127
+ @xml.tag!('altmax', hBBox[:minimumAltitude])
128
+ end
129
+ if hBBox[:maximumAltitude].nil?
130
+ @hResponseObj[:writerPass] = false
131
+ @hResponseObj[:writerMessages] << 'Altitude Bounding Box missing maximum altitude'
132
+ end
133
+
134
+ # altitude bounding (altunit) - units of altitude
135
+ unless hBBox[:unitsOfAltitude].nil?
136
+ @xml.tag!('altunit', hBBox[:unitsOfAltitude])
137
+ end
138
+ if hBBox[:unitsOfAltitude].nil? && @hResponseObj[:writerShowTags]
139
+ @xml.tag!('altunit')
140
+ end
141
+
142
+ end
143
+ end
144
+ if hBBox[:minimumAltitude].nil? && hBBox[:maximumAltitude].nil? &&
145
+ hBBox[:unitsOfAltitude].nil? && @hResponseObj[:writerShowTags]
146
+ @xml.tag!('boundalt')
147
+ end
148
+ end
149
+ end
150
+ if hBBox.empty?
151
+ @hResponseObj[:writerPass] = false
152
+ @hResponseObj[:writerMessages] << 'Spatial Domain section is missing bounding box'
153
+ end
154
+
155
+ # spatial domain 1.5.2 (dsgpoly) - bounding polygon [] (required)
156
+ unless aBPoly.empty?
157
+ @xml.tag!('dsgpoly') do
158
+ aBPoly.each do |aPoly|
159
+
160
+ # outer polygon 1.5.2.1 (dsgpolyo) - (required)
161
+ unless aPoly.empty?
162
+ @xml.tag!('dsgpolyo') do
163
+ aPoly[0].each do |aCoord|
164
+ @xml.tag!('grngpoin') do
165
+ @xml.tag!('grnglat', aCoord[0])
166
+ @xml.tag!('grnglon', aCoord[1])
167
+ end
168
+ end
169
+ end
170
+ end
171
+
172
+ # outer polygon 1.5.2.2 (dsgpolyx)
173
+ aPoly.delete_at(0)
174
+ unless aPoly.empty?
175
+ aPoly.each do |aExclude|
176
+ @xml.tag!('dsgpolyx') do
177
+ aExclude.each do |aCoord|
178
+ @xml.tag!('grngpoin') do
179
+ @xml.tag!('grnglat', aCoord[0])
180
+ @xml.tag!('grnglon', aCoord[1])
181
+ end
182
+ end
183
+ end
184
+ end
185
+ end
186
+
187
+ end
188
+ end
189
+ end
190
+
191
+ end
192
+ end
193
+
194
+ end # writeXML
195
+ end # Status
196
+
197
+ end
198
+ end
199
+ end
200
+ end
@@ -0,0 +1,63 @@
1
+ # FGDC <<Class>> Status
2
+ # FGDC CSDGM writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-25 original script
6
+
7
+ module ADIWG
8
+ module Mdtranslator
9
+ module Writers
10
+ module Fgdc
11
+
12
+ class Status
13
+
14
+ def initialize(xml, hResponseObj)
15
+ @xml = xml
16
+ @hResponseObj = hResponseObj
17
+ end
18
+
19
+ def writeXML(hResourceInfo)
20
+
21
+ status = nil
22
+ status = hResourceInfo[:status][0] unless hResourceInfo[:status].empty?
23
+ frequency = nil
24
+ frequency = hResourceInfo[:resourceMaintenance][0][:frequency] unless hResourceInfo[:resourceMaintenance].empty?
25
+
26
+ # status 1.4 (status) - resource status
27
+ unless status.nil? && frequency.nil?
28
+ @xml.tag!('status') do
29
+
30
+ # status 1.4.1 (progress) - status (required)
31
+ # <- hResourceInfo[:status][0]
32
+ unless status.nil?
33
+ @xml.tag!('progress', status)
34
+ end
35
+ if status.nil?
36
+ @hResponseObj[:writerPass] = false
37
+ @hResponseObj[:writerMessages] << 'Status section missing progress'
38
+ end
39
+
40
+ # status 1.4.2 (update) - maintenance and update frequency (required)
41
+ # <- hResourceInfo[:resourceMaintenance][:frequency]
42
+ unless frequency.nil?
43
+ @xml.tag!('update', frequency)
44
+ end
45
+ if frequency.nil?
46
+ @hResponseObj[:writerPass] = false
47
+ @hResponseObj[:writerMessages] << 'Status section missing maintenance frequency'
48
+ end
49
+
50
+ end
51
+ end
52
+ if status.nil? && frequency.nil?
53
+ @hResponseObj[:writerPass] = false
54
+ @hResponseObj[:writerMessages] << 'Identification section missing status section'
55
+ end
56
+
57
+ end # writeXML
58
+ end # Status
59
+
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,102 @@
1
+ # FGDC <<Class>> TimePeriod
2
+ # FGDC CSDGM writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-22 original script
6
+
7
+ require_relative 'class_dateSingle'
8
+ require_relative 'class_dateRange'
9
+ require_relative 'class_geologicAge'
10
+ require_relative 'class_geologicRange'
11
+
12
+ module ADIWG
13
+ module Mdtranslator
14
+ module Writers
15
+ module Fgdc
16
+
17
+ class TimePeriod
18
+
19
+ def initialize(xml, hResponseObj)
20
+ @xml = xml
21
+ @hResponseObj = hResponseObj
22
+ end
23
+
24
+ def writeXML(hTimePeriod)
25
+
26
+ # classes used
27
+ singDateClass = DateSingle.new(@xml, @hResponseObj)
28
+ rangeDateClass = DateRange.new(@xml, @hResponseObj)
29
+ geologicAgeClass = GeologicAge.new(@xml, @hResponseObj)
30
+ geologicRangeClass = GeologicRange.new(@xml, @hResponseObj)
31
+
32
+ hStartDate = hTimePeriod[:startDateTime]
33
+ hEndDate = hTimePeriod[:endDateTime]
34
+ hStartGeoAge = hTimePeriod[:startGeologicAge]
35
+ hEndGeoAge = hTimePeriod[:endGeologicAge]
36
+
37
+ dateCount = 0
38
+ ageCount = 0
39
+ dateCount += 1 unless hStartDate.empty?
40
+ dateCount += 1 unless hEndDate.empty?
41
+ ageCount += 1 unless hStartGeoAge.empty?
42
+ ageCount += 1 unless hEndGeoAge.empty?
43
+
44
+ if dateCount + ageCount == 0
45
+ @hResponseObj[:writerPass] = false
46
+ @hResponseObj[:writerMessages] << 'Time Period missing date item'
47
+ end
48
+
49
+ if dateCount > 0 && ageCount > 0
50
+ @hResponseObj[:writerPass] = false
51
+ @hResponseObj[:writerMessages] << 'Time Period must be either conventional or geologic time, not both'
52
+ end
53
+
54
+ # single date
55
+ if dateCount == 1
56
+ @xml.tag!('timeinfo') do
57
+ if hStartDate.empty?
58
+ singDateClass.writeXML(hEndDate)
59
+ else
60
+ singDateClass.writeXML(hStartDate)
61
+ end
62
+ end
63
+ end
64
+
65
+ # date range
66
+ if dateCount == 2
67
+ @xml.tag!('timeinfo') do
68
+ rangeDateClass.writeXML(hStartDate, hEndDate)
69
+ end
70
+ end
71
+
72
+ # single geologic age
73
+ if ageCount == 1
74
+ @xml.tag!('timeinfo') do
75
+ @xml.tag!('sngdate') do
76
+ @xml.tag!('geolage') do
77
+ if hStartGeoAge.empty?
78
+ geologicAgeClass.writeXML(hEndGeoAge)
79
+ else
80
+ geologicAgeClass.writeXML(hStartGeoAge)
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+
87
+ # geologic age range
88
+ if ageCount == 2
89
+ @xml.tag!('timeinfo') do
90
+ @xml.tag!('rngdates') do
91
+ geologicRangeClass.writeXML(hStartGeoAge,hEndGeoAge )
92
+ end
93
+ end
94
+ end
95
+
96
+ end # writeXML
97
+ end # TimePeriod
98
+
99
+ end
100
+ end
101
+ end
102
+ end