adiwg-mdtranslator 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +51 -1
  3. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +33 -2
  4. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_attribute.rb +68 -35
  5. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_codeSet.rb +66 -0
  6. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entity.rb +7 -1
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityOverview.rb +10 -1
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_enumerated.rb +38 -19
  9. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_range.rb +68 -19
  10. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_transferInfo.rb +3 -0
  11. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_reader.rb +4 -2
  12. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_domain.rb +87 -79
  13. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entity.rb +150 -115
  14. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entityAttribute.rb +184 -113
  15. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_valueRange.rb +56 -0
  16. data/lib/adiwg/mdtranslator/version.rb +7 -1
  17. data/lib/adiwg/mdtranslator/writers/html/sections/html_body.rb +3 -3
  18. data/lib/adiwg/mdtranslator/writers/html/sections/html_dataDictionary.rb +6 -6
  19. data/lib/adiwg/mdtranslator/writers/html/sections/html_domain.rb +74 -38
  20. data/lib/adiwg/mdtranslator/writers/html/sections/html_ellipsoidParameters.rb +68 -0
  21. data/lib/adiwg/mdtranslator/writers/html/sections/html_entity.rb +130 -76
  22. data/lib/adiwg/mdtranslator/writers/html/sections/html_entityAttribute.rb +78 -0
  23. data/lib/adiwg/mdtranslator/writers/html/sections/html_identifier.rb +1 -1
  24. data/lib/adiwg/mdtranslator/writers/html/sections/html_obliqueLinePoint.rb +37 -0
  25. data/lib/adiwg/mdtranslator/writers/html/sections/html_projectionParameters.rb +229 -0
  26. data/lib/adiwg/mdtranslator/writers/html/sections/html_referenceSystemParameters.rb +65 -0
  27. data/lib/adiwg/mdtranslator/writers/html/sections/html_spatialReference.rb +19 -1
  28. data/lib/adiwg/mdtranslator/writers/html/sections/html_verticalDatumParameters.rb +69 -0
  29. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_address.rb +103 -103
  30. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_citation.rb +185 -0
  31. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_date.rb +60 -0
  32. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_definitionReference.rb +45 -0
  33. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_domain.rb +107 -0
  34. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_fcFeatureCatalogue.rb +187 -187
  35. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_featureAttribute.rb +123 -117
  36. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_featureType.rb +155 -141
  37. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_gcoDateTime.rb +48 -0
  38. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_listedValue.rb +54 -55
  39. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_mdIdentifier.rb +56 -0
  40. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_series.rb +63 -0
  41. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_attributeGroup.rb +51 -50
  42. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_citation.rb +181 -180
  43. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_crs.rb +96 -0
  44. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_ellipsoidParameters.rb +62 -0
  45. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_keyword.rb +54 -54
  46. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_miMetadata.rb +301 -298
  47. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_obliqueLinePoint.rb +53 -0
  48. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_projectionParameters.rb +229 -0
  49. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_referenceSystem.rb +49 -32
  50. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_domain.rb +5 -2
  51. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_entity.rb +7 -1
  52. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_entityAttribute.rb +18 -2
  53. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_valueRange.rb +28 -0
  54. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_budget.rb +33 -13
  55. metadata +22 -4
  56. data/lib/adiwg/mdtranslator/readers/mdJson/version.rb +0 -16
@@ -0,0 +1,185 @@
1
+ # ISO <<Class>> CI_Citation
2
+ # 19110 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-02 original script.
6
+
7
+ require_relative 'class_codelist'
8
+ require_relative 'class_responsibleParty'
9
+ require_relative 'class_date'
10
+ require_relative 'class_mdIdentifier'
11
+ require_relative 'class_series'
12
+
13
+ module ADIWG
14
+ module Mdtranslator
15
+ module Writers
16
+ module Iso19110
17
+
18
+ class CI_Citation
19
+
20
+ def initialize(xml, hResponseObj)
21
+ @xml = xml
22
+ @hResponseObj = hResponseObj
23
+ end
24
+
25
+ def writeXML(hCitation)
26
+
27
+ unless hCitation.empty?
28
+
29
+ # classes used
30
+ codelistClass = MD_Codelist.new(@xml, @hResponseObj)
31
+ rPartyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
32
+ dateClass = CI_Date.new(@xml, @hResponseObj)
33
+ idClass = MD_Identifier.new(@xml, @hResponseObj)
34
+ seriesClass = CI_Series.new(@xml, @hResponseObj)
35
+
36
+ @xml.tag!('gmd:CI_Citation') do
37
+
38
+ # citation - title (required)
39
+ s = hCitation[:title]
40
+ if s.nil?
41
+ @xml.tag!('gmd:title', {'gco:nilReason' => 'missing'})
42
+ else
43
+ @xml.tag!('gmd:title') do
44
+ @xml.tag!('gco:CharacterString', s)
45
+ end
46
+ end
47
+
48
+ # citation - alternate title []
49
+ aTitles = hCitation[:alternateTitles]
50
+ aTitles.each do |title|
51
+ @xml.tag!('gmd:alternateTitle') do
52
+ @xml.tag!('gco:CharacterString', title)
53
+ end
54
+ end
55
+ if aTitles.empty? && @hResponseObj[:writerShowTags]
56
+ @xml.tag!('gmd:alternateTitle')
57
+ end
58
+
59
+ # citation - date [] (required)
60
+ aDate = hCitation[:dates]
61
+ aDate.each do |hDate|
62
+ @xml.tag!('gmd:date') do
63
+ dateClass.writeXML(hDate)
64
+ end
65
+ end
66
+ if aDate.empty?
67
+ @xml.tag!('gmd:date', {'gco:nilReason' => 'missing'})
68
+ end
69
+
70
+ # citation - edition
71
+ s = hCitation[:edition]
72
+ unless s.nil?
73
+ @xml.tag!('gmd:edition') do
74
+ @xml.tag!('gco:CharacterString', s)
75
+ end
76
+ end
77
+ if s.nil? && @hResponseObj[:writerShowTags]
78
+ @xml.tag!('gmd:edition')
79
+ end
80
+
81
+ # citation - resource identifier []
82
+ # do not process ISBN and ISSN as MD_identifier(s)
83
+ # ... these are written separately in ISO 19115-x
84
+ isbn = ''
85
+ issn = ''
86
+ aIds = hCitation[:identifiers]
87
+ aIds.each do |hIdentifier|
88
+ unless hIdentifier[:namespace].nil?
89
+ if hIdentifier[:namespace].downcase == 'isbn'
90
+ isbn = hIdentifier[:identifier]
91
+ elsif hIdentifier[:namespace].downcase == 'issn'
92
+ issn = hIdentifier[:identifier]
93
+ end
94
+ end
95
+ if issn == '' && isbn == ''
96
+ @xml.tag!('gmd:identifier') do
97
+ idClass.writeXML(hIdentifier)
98
+ end
99
+ end
100
+ end
101
+ if aIds.empty? && @hResponseObj[:writerShowTags]
102
+ @xml.tag!('gmd:identifier')
103
+ end
104
+
105
+ # citation - cited responsible party [{CI_ResponsibleParty}]
106
+ # contacts are grouped by role in the internal object
107
+ # output a separate <gmd:contact> for each role:contact pairing
108
+ aRParties = hCitation[:responsibleParties]
109
+ aRParties.each do |hRParty|
110
+ role = hRParty[:roleName]
111
+ aParties = hRParty[:parties]
112
+ aParties.each do |hParty|
113
+ @xml.tag!('gmd:citedResponsibleParty') do
114
+ rPartyClass.writeXML(role, hParty)
115
+ end
116
+ end
117
+ end
118
+ if aRParties.empty? && @hResponseObj[:writerShowTags]
119
+ @xml.tag!('gmd:citedResponsibleParty')
120
+ end
121
+
122
+ # citation - presentation forms [{CI_PresentationFormCode}]
123
+ aPresForms = hCitation[:presentationForms]
124
+ aPresForms.each do |presForm|
125
+ @xml.tag!('gmd:presentationForm') do
126
+ codelistClass.writeXML('gmd', 'iso_presentationForm', presForm)
127
+ end
128
+ end
129
+ if aPresForms.empty? && @hResponseObj[:writerShowTags]
130
+ @xml.tag!('gmd:presentationForm')
131
+ end
132
+
133
+ # citation - series {CI_Series}
134
+ hSeries = hCitation[:series]
135
+ unless hSeries.empty?
136
+ @xml.tag!('gmd:series') do
137
+ seriesClass.writeXML(hSeries)
138
+ end
139
+ end
140
+ if hSeries.empty? && @hResponseObj[:writerShowTags]
141
+ @xml.tag!('gmd:series')
142
+ end
143
+
144
+ # citation - other citation details
145
+ aOther = hCitation[:otherDetails]
146
+ unless aOther.empty?
147
+ other = aOther[0]
148
+ @xml.tag!('gmd:otherCitationDetails') do
149
+ @xml.tag!('gco:CharacterString', other)
150
+ end
151
+ end
152
+ if aOther.empty? && @hResponseObj[:writerShowTags]
153
+ @xml.tag!('gmd:otherCitationDetails')
154
+ end
155
+
156
+ # citation - ISBN
157
+ unless isbn == ''
158
+ @xml.tag!('gmd:ISBN') do
159
+ @xml.tag!('gco:CharacterString', isbn)
160
+ end
161
+ end
162
+ if isbn == '' && @hResponseObj[:writerShowTags]
163
+ @xml.tag!('gmd:ISBN')
164
+ end
165
+
166
+ # citation - ISSN
167
+ unless issn == ''
168
+ @xml.tag!('gmd:ISSN') do
169
+ @xml.tag!('gco:CharacterString', issn)
170
+ end
171
+ end
172
+ if issn == '' && @hResponseObj[:writerShowTags]
173
+ @xml.tag!('gmd:ISSN')
174
+ end
175
+
176
+ end
177
+ end
178
+
179
+ end # write XML
180
+ end # CI_Citation
181
+
182
+ end
183
+ end
184
+ end
185
+ end
@@ -0,0 +1,60 @@
1
+ # ISO <<Class>> CI_Date
2
+ # 19115-2 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-02 original script
6
+
7
+ require_relative 'class_codelist'
8
+ require_relative 'class_gcoDateTime'
9
+
10
+ module ADIWG
11
+ module Mdtranslator
12
+ module Writers
13
+ module Iso19110
14
+
15
+ class CI_Date
16
+
17
+ def initialize(xml, hResponseObj)
18
+ @xml = xml
19
+ @hResponseObj = hResponseObj
20
+ end
21
+
22
+ def writeXML(hDate)
23
+
24
+ # classes used
25
+ codelistClass = MD_Codelist.new(@xml, @hResponseObj)
26
+ gcoDateTimeClass = GcoDateTime.new(@xml, @hResponseObj)
27
+
28
+ date = hDate[:date]
29
+ dateType = hDate[:dateType]
30
+
31
+ @xml.tag!('gmd:CI_Date') do
32
+
33
+ # date - date (required)
34
+ unless date.nil?
35
+ @xml.tag!('gmd:date') do
36
+ gcoDateTimeClass.writeXML(hDate)
37
+ end
38
+ end
39
+ if date.nil?
40
+ @xml.tag!('gmd:date', {'gco:nilReason' => 'missing'})
41
+ end
42
+
43
+ # date - date type (required)
44
+ unless dateType.nil?
45
+ @xml.tag!('gmd:dateType') do
46
+ codelistClass.writeXML('gmd', 'iso_dateType', dateType)
47
+ end
48
+ end
49
+ if dateType.nil?
50
+ @xml.tag!('gmd:dateType', {'gco:nilReason' => 'missing'})
51
+ end
52
+
53
+ end # CI_Date tag
54
+ end # write XML
55
+ end # CI_Date class
56
+
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,45 @@
1
+ # ISO <<Class>> FC_DefinitionReference
2
+ # 19110 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2017-11-02 original script.
6
+
7
+ require_relative 'class_citation'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Writers
12
+ module Iso19110
13
+
14
+ class FC_DefinitionReference
15
+
16
+ def initialize(xml, hResponseObj)
17
+ @xml = xml
18
+ @hResponseObj = hResponseObj
19
+ end
20
+
21
+ def writeXML(hReference)
22
+
23
+ # classes used
24
+ citationClass = CI_Citation.new(@xml, @hResponseObj)
25
+
26
+ unless hReference.empty?
27
+ @xml.tag!('gfc:FC_DefinitionReference') do
28
+ @xml.tag!('gfc:definitionSource') do
29
+ @xml.tag!('gfc:FC_DefinitionSource') do
30
+ @xml.tag!('gfc:source') do
31
+ citationClass.writeXML(hReference)
32
+ end
33
+ end
34
+ end
35
+
36
+ end
37
+ end
38
+
39
+ end # write XML
40
+ end # FC_DefinitionReference
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,107 @@
1
+ # ISO <<Class>> <<abstract>>
2
+ # writer output in XML
3
+ # to define the domain of an attribute
4
+
5
+ # History:
6
+ # Stan Smith 2017-11-02 original script
7
+
8
+ require_relative 'class_listedValue'
9
+ require_relative 'class_definitionReference'
10
+
11
+ module ADIWG
12
+ module Mdtranslator
13
+ module Writers
14
+ module Iso19110
15
+
16
+ class Domain
17
+
18
+ def initialize(xml, responseObj)
19
+ @xml = xml
20
+ @hResponseObj = responseObj
21
+ end
22
+
23
+ def writeXML(hDomain)
24
+
25
+ # classes used
26
+ listClass = FC_ListedValue.new(@xml, @hResponseObj)
27
+ defRefClass = FC_DefinitionReference.new(@xml, @hResponseObj)
28
+
29
+ # if have domainItems treat as enumerated list
30
+ aItems = hDomain[:domainItems]
31
+ unless aItems.empty?
32
+ aItems.each do |hItem|
33
+ @xml.tag!('gfc:listedValue') do
34
+ listClass.writeXML(hItem)
35
+ end
36
+ end
37
+ return
38
+ end
39
+
40
+ # if have domainReference treat as codeList reference
41
+ hCitation = hDomain[:domainReference]
42
+ unless hCitation.empty?
43
+ @xml.tag!('gfc:listedValue') do
44
+ @xml.tag!('gfc:FC_ListedValue') do
45
+
46
+ # label
47
+ if hDomain[:domainName].nil?
48
+ @xml.tag!('gfc:label', {'gco:nilReason' => 'missing'})
49
+ else
50
+ @xml.tag!('gfc:label') do
51
+ @xml.tag!('gco:CharacterString', hDomain[:domainName])
52
+ end
53
+ end
54
+
55
+ # definition
56
+ unless hDomain[:domainDescription].nil?
57
+ @xml.tag!('gfc:definition') do
58
+ @xml.tag!('gco:CharacterString', hDomain[:domainDescription])
59
+ end
60
+ end
61
+ if hDomain[:domainDescription].empty? && @hResponseObj[:writerShowTags]
62
+ @xml.tag!('gfc:definition')
63
+ end
64
+
65
+ # definition reference
66
+ @xml.tag!('gfc:definitionReference') do
67
+ defRefClass.writeXML(hCitation)
68
+ end
69
+
70
+ end
71
+ end
72
+ return
73
+ end
74
+
75
+ # if have definition only treat as unrepresentable domain
76
+ @xml.tag!('gfc:listedValue') do
77
+ @xml.tag!('gfc:FC_ListedValue') do
78
+
79
+ # label
80
+ if hDomain[:domainName].nil?
81
+ @xml.tag!('gfc:label', {'gco:nilReason' => 'missing'})
82
+ else
83
+ @xml.tag!('gfc:label') do
84
+ @xml.tag!('gco:CharacterString', hDomain[:domainName])
85
+ end
86
+ end
87
+
88
+ # definition
89
+ unless hDomain[:domainDescription].nil?
90
+ @xml.tag!('gfc:definition') do
91
+ @xml.tag!('gco:CharacterString', hDomain[:domainDescription])
92
+ end
93
+ end
94
+ if hDomain[:domainDescription].empty? && @hResponseObj[:writerShowTags]
95
+ @xml.tag!('gfc:definition')
96
+ end
97
+
98
+ end
99
+ end
100
+
101
+ end # writeXML
102
+ end # FC_ListedValue class
103
+
104
+ end
105
+ end
106
+ end
107
+ end
@@ -2,12 +2,12 @@
2
2
  # writer output in XML
3
3
 
4
4
  # History:
5
- # Stan Smith 2017-01-20 refactored for mdJson/mdTranslator 2.0
6
- # Stan Smith 2015-07-14 refactored to eliminate namespace globals $WriterNS and $IsoNS
7
- # Stan Smith 2015-07-14 refactored to make iso19110 independent of iso19115_2 classes
8
- # Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj)
9
- # Stan Smith 2014-12-29 set builder object '@xml' into string 'metadata'
10
- # Stan Smith 2014-12-15 refactored to handle namespacing readers and writers
5
+ # Stan Smith 2017-01-20 refactored for mdJson/mdTranslator 2.0
6
+ # Stan Smith 2015-07-14 refactored to eliminate namespace globals $WriterNS and $IsoNS
7
+ # Stan Smith 2015-07-14 refactored to make iso19110 independent of iso19115_2 classes
8
+ # Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj)
9
+ # Stan Smith 2014-12-29 set builder object '@xml' into string 'metadata'
10
+ # Stan Smith 2014-12-15 refactored to handle namespacing readers and writers
11
11
  # Stan Smith 2013-12-01 original script
12
12
 
13
13
  require_relative 'class_locale'
@@ -15,190 +15,190 @@ require_relative 'class_responsibleParty'
15
15
  require_relative 'class_featureType'
16
16
 
17
17
  module ADIWG
18
- module Mdtranslator
19
- module Writers
20
- module Iso19110
21
-
22
- class FC_FeatureCatalogue
23
-
24
- def initialize(xml, responseObj)
25
- @xml = xml
26
- @hResponseObj = responseObj
27
- end
28
-
29
- def writeXML(intObj)
30
-
31
- # classes used
32
- localeClass = PT_Locale.new(@xml, @hResponseObj)
33
- rPartyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
34
- featureClass = FC_FeatureType.new(@xml, @hResponseObj)
35
-
36
- hDictionary = intObj[:dataDictionaries][0]
37
- hCitation = hDictionary[:citation]
38
- aEntities = hDictionary[:entities]
39
- version = @hResponseObj[:translatorVersion]
40
-
41
- # document head
42
- metadata = @xml.instruct! :xml, encoding: 'UTF-8'
43
- @xml.comment!('ISO 19110 METADATA')
44
- @xml.comment!('Metadata file was constructed using the ADIwg mdTranslator, http://mdtranslator.adiwg.org')
45
- @xml.comment!('mdTranslator software is an open-source project of the Alaska Data Integration working group (ADIwg)')
46
- @xml.comment!('mdTranslator and other metadata tools are available at https://github.com/adiwg')
47
- @xml.comment!('ADIwg is not responsible for the content of this metadata record')
48
- @xml.comment!('This metadata record was generated by mdTranslator ' + version + ' at ' + Time.now.to_s)
49
-
50
- # FC_FeatureCatalogue
51
- @xml.tag!('gfc:FC_FeatureCatalogue',
52
- {'xmlns:gmi' => 'http://www.isotc211.org/2005/gmi',
53
- 'xmlns:gmd' => 'http://www.isotc211.org/2005/gmd',
54
- 'xmlns:gco' => 'http://www.isotc211.org/2005/gco',
55
- 'xmlns:gml' => 'http://www.opengis.net/gml/3.2',
56
- 'xmlns:gsr' => 'http://www.isotc211.org/2005/gsr',
57
- 'xmlns:gss' => 'http://www.isotc211.org/2005/gss',
58
- 'xmlns:gst' => 'http://www.isotc211.org/2005/gst',
59
- 'xmlns:gmx' => 'http://www.isotc211.org/2005/gmx',
60
- 'xmlns:gfc' => 'http://www.isotc211.org/2005/gfc',
61
- 'xmlns:xlink' => 'http://www.w3.org/1999/xlink',
62
- 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
63
- 'xsi:schemaLocation' => 'http://www.isotc211.org/2005/gfc ftp://ftp.ncddc.noaa.gov/pub/Metadata/Online_ISO_Training/Intro_to_ISO/schemas/ISObio/gfc/gfc.xsd'}) do
64
-
65
- # local schema for development
66
- # 'xsi:schemaLocation' => 'http://www.isotc211.org/2005/gfc C:\Users\StanSmith\Projects\ISO\19115\NOAA\schema\gfc\gfc.xsd'}) do
67
-
68
- # remote schema for publication
69
- # 'xsi:schemaLocation' => 'http://www.isotc211.org/2005/gfc ftp://ftp.ncddc.noaa.gov/pub/Metadata/Online_ISO_Training/Intro_to_ISO/schemas/ISObio/gfc/gfc.xsd'}) do
70
-
71
- # feature catalogue - name, version, version date are
72
- # are taken from citation
73
- name = hCitation[:title]
74
- version = hCitation[:edition]
75
- hDate = {}
76
- aDates = hCitation[:dates]
77
- unless aDates.empty?
78
- hDate = aDates[0]
79
- end
80
-
81
- # feature catalogue - name (required)
82
- unless name.nil?
83
- @xml.tag!('gmx:name') do
84
- @xml.tag!('gco:CharacterString', name)
85
- end
86
- end
87
- if name.nil?
88
- @xml.tag!('gmx:name', {'gco:nilReason' => 'missing'})
89
- end
90
-
91
- # feature catalogue - scope (required) []
92
- aScopes = hDictionary[:subjects]
93
- aScopes.each do |scope|
94
- @xml.tag!('gmx:scope') do
95
- @xml.tag!('gco:CharacterString', scope)
96
- end
97
- end
98
- if aScopes.empty? && @hResponseObj[:writerShowTags]
99
- @xml.tag!('gmx:scope', {'gco:nilReason' => 'missing'})
100
- end
101
-
102
- # feature catalogue - field of application []
103
- aUses = hDictionary[:recommendedUses]
104
- aUses.each do |use|
105
- @xml.tag!('gmx:fieldOfApplication') do
106
- @xml.tag!('gco:CharacterString', use)
107
- end
108
- end
109
- if aUses.empty? && @hResponseObj[:writerShowTags]
110
- @xml.tag!('gmx:fieldOfApplication')
111
- end
112
-
113
- # feature catalogue - version number (required)
114
- unless version.nil?
115
- @xml.tag!('gmx:versionNumber') do
116
- @xml.tag!('gco:CharacterString', version)
117
- end
118
- end
119
- if version.nil?
120
- @xml.tag!('gmx:versionNumber', {'gco:nilReason' => 'missing'})
121
- end
122
-
123
- # feature catalogue - version date (required)
124
- sDate = nil
125
- unless hDate.empty?
126
- dateTime = hDate[:date]
127
- dateRes = hDate[:dateResolution]
128
- unless dateTime.nil?
129
- sDate = AdiwgDateTimeFun.stringDateFromDateTime(dateTime, dateRes)
130
- end
131
- end
132
- unless sDate.nil?
133
- @xml.tag!('gmx:versionDate') do
134
- @xml.tag!('gco:Date', sDate)
135
- end
136
- end
137
- if sDate.nil?
138
- @xml.tag!('gmx:versionDate', {'gco:nilReason' => 'missing'})
139
- end
140
-
141
- # feature catalogue - locale []
142
- aLocales = hDictionary[:locales]
143
- aLocales.each do |hLocale|
144
- unless hLocale.empty?
145
- @xml.tag!('gmx:locale') do
146
- localeClass.writeXML(hLocale)
147
- end
148
- end
149
- end
150
- if aLocales.empty? && @hResponseObj[:writerShowTags]
151
- @xml.tag!('gmx:locale')
152
- end
153
-
154
- # feature catalogue - producer (required) {CI_ResponsibleParty}
155
- hParty = hDictionary[:responsibleParty]
156
- unless hParty.empty?
157
- role = hParty[:roleName]
158
- aParties = hParty[:parties]
159
- unless aParties.empty?
160
- party = aParties[0]
161
- @xml.tag!('gfc:producer') do
162
- rPartyClass.writeXML(role, party)
163
- end
164
- end
165
- end
166
- if hParty.empty? && @hResponseObj[:writerShowTags]
167
- @xml.tag!('gfc:producer')
168
- end
169
-
170
- # feature catalogue - functional language
171
- s = hDictionary[:dictionaryFormat]
172
- unless s.nil?
173
- @xml.tag!('gfc:functionalLanguage') do
174
- @xml.tag!('gco:CharacterString', s)
175
- end
176
- end
177
- if s.nil? && @hResponseObj[:writerShowTags]
178
- @xml.tag!('gfc:functionalLanguage')
179
- end
180
-
181
- # feature catalogue - feature type (required)
182
- # use feature type to represent date entities
183
- unless aEntities.empty?
184
- aEntities.each do |hEntity|
185
- @xml.tag!('gfc:featureType') do
186
- featureClass.writeXML(hEntity)
187
- end
188
- end
189
- end
190
- if aEntities.empty?
191
- @xml.tag!('gfc:featureType', {'gco:nilReason' => 'missing'})
192
- end
193
-
194
- return metadata
18
+ module Mdtranslator
19
+ module Writers
20
+ module Iso19110
21
+
22
+ class FC_FeatureCatalogue
23
+
24
+ def initialize(xml, responseObj)
25
+ @xml = xml
26
+ @hResponseObj = responseObj
27
+ end
28
+
29
+ def writeXML(intObj)
30
+
31
+ # classes used
32
+ localeClass = PT_Locale.new(@xml, @hResponseObj)
33
+ rPartyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
34
+ featureClass = FC_FeatureType.new(@xml, @hResponseObj)
35
+
36
+ hDictionary = intObj[:dataDictionaries][0]
37
+ hCitation = hDictionary[:citation]
38
+ aEntities = hDictionary[:entities]
39
+ version = @hResponseObj[:translatorVersion]
40
+
41
+ # document head
42
+ metadata = @xml.instruct! :xml, encoding: 'UTF-8'
43
+ @xml.comment!('ISO 19110 METADATA')
44
+ @xml.comment!('Metadata file was constructed using the ADIwg mdTranslator, http://mdtranslator.adiwg.org')
45
+ @xml.comment!('mdTranslator software is an open-source project of the Alaska Data Integration working group (ADIwg)')
46
+ @xml.comment!('mdTranslator and other metadata tools are available at https://github.com/adiwg')
47
+ @xml.comment!('ADIwg is not responsible for the content of this metadata record')
48
+ @xml.comment!('This metadata record was generated by mdTranslator ' + version + ' at ' + Time.now.to_s)
49
+
50
+ # FC_FeatureCatalogue
51
+ @xml.tag!('gfc:FC_FeatureCatalogue',
52
+ {'xmlns:gmi' => 'http://www.isotc211.org/2005/gmi',
53
+ 'xmlns:gmd' => 'http://www.isotc211.org/2005/gmd',
54
+ 'xmlns:gco' => 'http://www.isotc211.org/2005/gco',
55
+ 'xmlns:gml' => 'http://www.opengis.net/gml/3.2',
56
+ 'xmlns:gsr' => 'http://www.isotc211.org/2005/gsr',
57
+ 'xmlns:gss' => 'http://www.isotc211.org/2005/gss',
58
+ 'xmlns:gst' => 'http://www.isotc211.org/2005/gst',
59
+ 'xmlns:gmx' => 'http://www.isotc211.org/2005/gmx',
60
+ 'xmlns:gfc' => 'http://www.isotc211.org/2005/gfc',
61
+ 'xmlns:xlink' => 'http://www.w3.org/1999/xlink',
62
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
63
+ 'xsi:schemaLocation' => 'http://www.isotc211.org/2005/gfc ftp://ftp.ncddc.noaa.gov/pub/Metadata/Online_ISO_Training/Intro_to_ISO/schemas/ISObio/gfc/gfc.xsd'}) do
64
+
65
+ # local schema for development
66
+ # 'xsi:schemaLocation' => 'http://www.isotc211.org/2005/gfc C:\Users\StanSmith\Projects\ISO\19115\NOAA\schema\gfc\gfc.xsd'}) do
67
+
68
+ # remote schema for publication
69
+ # 'xsi:schemaLocation' => 'http://www.isotc211.org/2005/gfc ftp://ftp.ncddc.noaa.gov/pub/Metadata/Online_ISO_Training/Intro_to_ISO/schemas/ISObio/gfc/gfc.xsd'}) do
70
+
71
+ # feature catalogue - name, version, version date are
72
+ # are taken from citation
73
+ name = hCitation[:title]
74
+ version = hCitation[:edition]
75
+ hDate = {}
76
+ aDates = hCitation[:dates]
77
+ unless aDates.empty?
78
+ hDate = aDates[0]
79
+ end
80
+
81
+ # feature catalogue - name (required)
82
+ unless name.nil?
83
+ @xml.tag!('gmx:name') do
84
+ @xml.tag!('gco:CharacterString', name)
195
85
  end
86
+ end
87
+ if name.nil?
88
+ @xml.tag!('gmx:name', {'gco:nilReason' => 'missing'})
89
+ end
90
+
91
+ # feature catalogue - scope (required) []
92
+ aScopes = hDictionary[:subjects]
93
+ aScopes.each do |scope|
94
+ @xml.tag!('gmx:scope') do
95
+ @xml.tag!('gco:CharacterString', scope)
96
+ end
97
+ end
98
+ if aScopes.empty? && @hResponseObj[:writerShowTags]
99
+ @xml.tag!('gmx:scope', {'gco:nilReason' => 'missing'})
100
+ end
101
+
102
+ # feature catalogue - field of application []
103
+ aUses = hDictionary[:recommendedUses]
104
+ aUses.each do |use|
105
+ @xml.tag!('gmx:fieldOfApplication') do
106
+ @xml.tag!('gco:CharacterString', use)
107
+ end
108
+ end
109
+ if aUses.empty? && @hResponseObj[:writerShowTags]
110
+ @xml.tag!('gmx:fieldOfApplication')
111
+ end
112
+
113
+ # feature catalogue - version number (required)
114
+ unless version.nil?
115
+ @xml.tag!('gmx:versionNumber') do
116
+ @xml.tag!('gco:CharacterString', version)
117
+ end
118
+ end
119
+ if version.nil?
120
+ @xml.tag!('gmx:versionNumber', {'gco:nilReason' => 'missing'})
121
+ end
122
+
123
+ # feature catalogue - version date (required)
124
+ sDate = nil
125
+ unless hDate.empty?
126
+ dateTime = hDate[:date]
127
+ dateRes = hDate[:dateResolution]
128
+ unless dateTime.nil?
129
+ sDate = AdiwgDateTimeFun.stringDateFromDateTime(dateTime, dateRes)
130
+ end
131
+ end
132
+ unless sDate.nil?
133
+ @xml.tag!('gmx:versionDate') do
134
+ @xml.tag!('gco:Date', sDate)
135
+ end
136
+ end
137
+ if sDate.nil?
138
+ @xml.tag!('gmx:versionDate', {'gco:nilReason' => 'missing'})
139
+ end
140
+
141
+ # feature catalogue - locale []
142
+ aLocales = hDictionary[:locales]
143
+ aLocales.each do |hLocale|
144
+ unless hLocale.empty?
145
+ @xml.tag!('gmx:locale') do
146
+ localeClass.writeXML(hLocale)
147
+ end
148
+ end
149
+ end
150
+ if aLocales.empty? && @hResponseObj[:writerShowTags]
151
+ @xml.tag!('gmx:locale')
152
+ end
153
+
154
+ # feature catalogue - producer (required) {CI_ResponsibleParty}
155
+ hParty = hDictionary[:responsibleParty]
156
+ unless hParty.empty?
157
+ role = hParty[:roleName]
158
+ aParties = hParty[:parties]
159
+ unless aParties.empty?
160
+ party = aParties[0]
161
+ @xml.tag!('gfc:producer') do
162
+ rPartyClass.writeXML(role, party)
163
+ end
164
+ end
165
+ end
166
+ if hParty.empty? && @hResponseObj[:writerShowTags]
167
+ @xml.tag!('gfc:producer')
168
+ end
169
+
170
+ # feature catalogue - functional language
171
+ s = hDictionary[:dictionaryFormat]
172
+ unless s.nil?
173
+ @xml.tag!('gfc:functionalLanguage') do
174
+ @xml.tag!('gco:CharacterString', s)
175
+ end
176
+ end
177
+ if s.nil? && @hResponseObj[:writerShowTags]
178
+ @xml.tag!('gfc:functionalLanguage')
179
+ end
180
+
181
+ # feature catalogue - feature type (required)
182
+ # use feature type to represent date entities
183
+ unless aEntities.empty?
184
+ aEntities.each do |hEntity|
185
+ @xml.tag!('gfc:featureType') do
186
+ featureClass.writeXML(hEntity)
187
+ end
188
+ end
189
+ end
190
+ if aEntities.empty?
191
+ @xml.tag!('gfc:featureType', {'gco:nilReason' => 'missing'})
192
+ end
196
193
 
197
- end
194
+ return metadata
195
+ end
198
196
 
199
- end
197
+ end
200
198
 
201
199
  end
202
- end
203
- end
200
+
201
+ end
202
+ end
203
+ end
204
204
  end