adiwg-mdtranslator 2.16.1 → 2.18.0rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -2
  3. data/Rakefile +1 -0
  4. data/adiwg-mdtranslator.gemspec +1 -1
  5. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +8 -3
  6. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_attribute.rb +6 -2
  7. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_attribute.rb +12 -0
  8. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_contact.rb +11 -0
  9. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_georectifiedRepresentation.rb +9 -0
  10. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_georeferenceableRepresentation.rb +9 -0
  11. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_gridRepresentation.rb +10 -0
  12. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_processStep.rb +3 -14
  13. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_processing.rb +4 -5
  14. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_rangeElementDescription.rb +38 -0
  15. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_vectorRepresentation.rb +10 -0
  16. data/lib/adiwg/mdtranslator/version.rb +3 -1
  17. data/lib/adiwg/mdtranslator/writers/html/sections/html_algorithm.rb +48 -0
  18. data/lib/adiwg/mdtranslator/writers/html/sections/html_attribute.rb +12 -0
  19. data/lib/adiwg/mdtranslator/writers/html/sections/html_georectifiedRepresentation.rb +12 -0
  20. data/lib/adiwg/mdtranslator/writers/html/sections/html_georeferenceableRepresentation.rb +13 -0
  21. data/lib/adiwg/mdtranslator/writers/html/sections/html_gridRepresentation.rb +13 -0
  22. data/lib/adiwg/mdtranslator/writers/html/sections/html_nominalResolution.rb +51 -0
  23. data/lib/adiwg/mdtranslator/writers/html/sections/html_processReport.rb +47 -0
  24. data/lib/adiwg/mdtranslator/writers/html/sections/html_processStep.rb +35 -8
  25. data/lib/adiwg/mdtranslator/writers/html/sections/html_processing.rb +89 -0
  26. data/lib/adiwg/mdtranslator/writers/html/sections/html_rangeElementDescription.rb +40 -0
  27. data/lib/adiwg/mdtranslator/writers/html/sections/html_source.rb +25 -0
  28. data/lib/adiwg/mdtranslator/writers/html/sections/html_vectorRepresentation.rb +13 -0
  29. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_algorithm.rb +61 -0
  30. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_georectified.rb +9 -0
  31. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_georeferenceable.rb +10 -0
  32. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_grid.rb +11 -1
  33. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_identifier.rb +2 -2
  34. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_individual.rb +22 -0
  35. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_leProcessStep.rb +167 -0
  36. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_leSource.rb +150 -0
  37. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_liProcessStep.rb +130 -0
  38. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_liSource.rb +126 -0
  39. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_lineage.rb +5 -4
  40. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_nominalResolution.rb +61 -0
  41. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_organization.rb +22 -0
  42. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_partyIdentifier.rb +92 -0
  43. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_processReport.rb +66 -0
  44. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_processStep.rb +22 -101
  45. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_processing.rb +110 -0
  46. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_rangeElementDescription.rb +45 -0
  47. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_sampleDimension.rb +8 -0
  48. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_source.rb +19 -95
  49. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_vectorRepresentation.rb +9 -0
  50. data/lib/adiwg/mdtranslator/writers/iso19115_1/iso19115_1_writer_messages_eng.yml +11 -0
  51. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_algorithm.rb +61 -0
  52. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_leProcessStep.rb +153 -0
  53. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_leSource.rb +134 -0
  54. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_liProcessStep.rb +126 -0
  55. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_liSource.rb +114 -0
  56. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_lineage.rb +13 -11
  57. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_nominalResolution.rb +61 -0
  58. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_processReport.rb +66 -0
  59. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_processStep.rb +22 -96
  60. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_processing.rb +110 -0
  61. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_source.rb +20 -82
  62. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_taxonomy.rb +2 -2
  63. data/lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer_messages_eng.yml +9 -0
  64. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_attribute.rb +1 -0
  65. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_contact.rb +1 -0
  66. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_georectifiedRepresentation.rb +1 -0
  67. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_georeferenceableRepresentation.rb +1 -0
  68. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_gridRepresentation.rb +1 -0
  69. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processStep.rb +0 -1
  70. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processing.rb +1 -1
  71. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_vectorRepresentation.rb +1 -0
  72. metadata +36 -12
@@ -6,6 +6,7 @@
6
6
 
7
7
  require_relative 'class_codelist'
8
8
  require_relative 'class_geometricObjects'
9
+ require_relative 'class_scope'
9
10
 
10
11
  module ADIWG
11
12
  module Mdtranslator
@@ -24,12 +25,20 @@ module ADIWG
24
25
  # classes used
25
26
  codelistClass = MD_Codelist.new(@xml, @hResponseObj)
26
27
  geoObjClass = MD_GeometricObjects.new(@xml, @hResponseObj)
28
+ scopeClass = MD_Scope.new(@xml, @hResponseObj)
27
29
 
28
30
  outContext = 'vector representation'
29
31
  outContext = inContext + ' vector representation' unless inContext.nil?
30
32
 
31
33
  @xml.tag!('msr:MD_VectorSpatialRepresentation') do
32
34
 
35
+ # vector representation - scope
36
+ hVector[:scope].each do |scope|
37
+ @xml.tag!('msr:scope') do
38
+ scopeClass.writeXML(scope, inContext)
39
+ end
40
+ end
41
+
33
42
  # vector representation - topology level
34
43
  unless hVector[:topologyLevel].nil?
35
44
  @xml.tag!('msr:topologyLevel') do
@@ -130,3 +130,14 @@ messageList:
130
130
  - {id: 400, message: "invalid topic category"}
131
131
 
132
132
  - {id: 410, message: "temporal extent must have a TimeInstant or TimePeriod"}
133
+
134
+ - {id: 420, message: "algorithm citation is missing"}
135
+ - {id: 421, message: "algorithm description is missing"}
136
+
137
+ - {id: 430, message: "processing identifier is missing"}
138
+
139
+ - {id: 440, message: "process step report name is missing"}
140
+
141
+ - {id: 450, message: "nominal resolution is missing"}
142
+
143
+
@@ -0,0 +1,61 @@
1
+ # ISO <<Class>> LE_Algorithm
2
+ # 19115-2 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 201-09-25 original script.
6
+
7
+ require_relative '../iso19115_2_writer'
8
+ require_relative 'class_citation'
9
+
10
+ module ADIWG
11
+ module Mdtranslator
12
+ module Writers
13
+ module Iso19115_2
14
+
15
+ class LE_Algorithm
16
+
17
+ def initialize(xml, hResponseObj)
18
+ @xml = xml
19
+ @hResponseObj = hResponseObj
20
+ @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_2
21
+ end
22
+
23
+ def writeXML(hAlgorithm, inContext = nil)
24
+
25
+ # classes used
26
+ citationClass = CI_Citation.new(@xml, @hResponseObj)
27
+
28
+ outContext = 'algorithm'
29
+ outContext = inContext + ' ' + outContext unless inContext.nil?
30
+
31
+ @xml.tag!('gmi:LE_Algorithm') do
32
+
33
+ # algorithm - citation {CI_Citation} (required)
34
+ hCitation = hAlgorithm[:citation]
35
+ unless hCitation.empty?
36
+ @xml.tag!('gmi:citation') do
37
+ citationClass.writeXML(hCitation, outContext)
38
+ end
39
+ end
40
+ if hCitation.empty?
41
+ @NameSpace.issueWarning(390, 'gmi:citation', outContext)
42
+ end
43
+
44
+ # algorithm - description (required)
45
+ unless hAlgorithm[:description].nil?
46
+ @xml.tag!('gmi:description') do
47
+ @xml.tag!('gco:CharacterString', hAlgorithm[:description])
48
+ end
49
+ end
50
+ if hAlgorithm[:description].nil?
51
+ @NameSpace.issueWarning(391, 'gmi:description', outContext)
52
+ end
53
+
54
+ end # gmi:LE_Algorithm tag
55
+ end # writeXML
56
+ end # LE_Algorithm class
57
+
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,153 @@
1
+ # ISO <<Class>> LE_ProcessStep
2
+ # 19115-2 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2019-09-25 original script.
6
+
7
+ require_relative '../iso19115_2_writer'
8
+ require_relative 'class_responsibleParty'
9
+ require_relative 'class_source'
10
+ require_relative 'class_processing'
11
+ require_relative 'class_processReport'
12
+
13
+ module ADIWG
14
+ module Mdtranslator
15
+ module Writers
16
+ module Iso19115_2
17
+
18
+ class LE_ProcessStep
19
+
20
+ def initialize(xml, hResponseObj)
21
+ @xml = xml
22
+ @hResponseObj = hResponseObj
23
+ @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_2
24
+ end
25
+
26
+ def writeXML(hStep, inContext = nil)
27
+
28
+ # classes used
29
+ partyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
30
+ sourceClass = Source.new(@xml, @hResponseObj)
31
+ processingClass = LE_Processing.new(@xml, @hResponseObj)
32
+ reportClass = LE_ProcessStepReport.new(@xml, @hResponseObj)
33
+
34
+ outContext = 'process step'
35
+ outContext = outContext + ' ' + hStep[:stepId].to_s unless hStep[:stepId].nil?
36
+ outContext = inContext + ' ' + outContext unless inContext.nil?
37
+
38
+ # process step - id
39
+ attributes = {}
40
+ s = hStep[:stepId]
41
+ unless s.nil?
42
+ attributes = { id: s.gsub(/[^0-9A-Za-z]/,'') }
43
+ end
44
+
45
+ @xml.tag!('gmi:LE_ProcessStep', attributes) do
46
+
47
+ # process step - description (required)
48
+ unless hStep[:description].nil?
49
+ @xml.tag!('gmd:description') do
50
+ @xml.tag!('gco:CharacterString', hStep[:description])
51
+ end
52
+ end
53
+ if hStep[:description].nil?
54
+ @NameSpace.issueWarning(260, 'gmd:description', outContext)
55
+ end
56
+
57
+ # process step - rationale
58
+ unless hStep[:rationale].nil?
59
+ @xml.tag!('gmd:rationale') do
60
+ @xml.tag!('gco:CharacterString', hStep[:rationale])
61
+ end
62
+ end
63
+ if hStep[:rationale].nil? && @hResponseObj[:writerShowTags]
64
+ @xml.tag!('gmd:rationale')
65
+ end
66
+
67
+ # process step - datetime
68
+ hPeriod = hStep[:timePeriod]
69
+ unless hPeriod.empty?
70
+ hDate = hPeriod[:startDateTime]
71
+ if hDate.empty?
72
+ hDate = hPeriod[:endDateTime]
73
+ end
74
+ date = hDate[:dateTime]
75
+ dateResolution = hDate[:dateResolution]
76
+ s = AdiwgDateTimeFun.stringDateTimeFromDateTime(date, dateResolution)
77
+ if s != 'ERROR'
78
+ @xml.tag!('gmd:dateTime') do
79
+ @xml.tag!('gco:DateTime', s)
80
+ end
81
+ end
82
+ end
83
+ if hPeriod.empty? && @hResponseObj[:writerShowTags]
84
+ @xml.tag!('gmd:dateTime')
85
+ end
86
+
87
+ # process step - processor [] {CI_ResponsibleParty}
88
+ aParties = hStep[:processors]
89
+ aParties.each do |hRParty|
90
+ role = hRParty[:roleName]
91
+ aParties = hRParty[:parties]
92
+ aParties.each do |hParty|
93
+ @xml.tag!('gmd:processor') do
94
+ partyClass.writeXML(role, hParty, outContext)
95
+ end
96
+ end
97
+ end
98
+ if aParties.empty? && @hResponseObj[:writerShowTags]
99
+ @xml.tag!('gmd:processor')
100
+ end
101
+
102
+ # process step - source [] {Source}
103
+ aSources = hStep[:stepSources]
104
+ aSources.each do |hSource|
105
+ @xml.tag!('gmd:source') do
106
+ sourceClass.writeXML(hSource)
107
+ end
108
+ end
109
+ if aSources.empty? && @hResponseObj[:writerShowTags]
110
+ @xml.tag!('gmd:source')
111
+ end
112
+
113
+ # process step - processing information {LE_Processing}
114
+ hProcessing = hStep[:processingInformation]
115
+ unless hProcessing.empty?
116
+ @xml.tag!('gmi:processingInformation') do
117
+ processingClass.writeXML(hProcessing, outContext)
118
+ end
119
+ end
120
+ if hProcessing.empty? && @hResponseObj[:writerShowTags]
121
+ @xml.tag!('gmi:processingInformation')
122
+ end
123
+
124
+ # process step - output [] {Source}
125
+ aOutput = hStep[:stepProducts]
126
+ aOutput.each do |hSource|
127
+ @xml.tag!('gmi:output') do
128
+ sourceClass.writeXML(hSource)
129
+ end
130
+ end
131
+ if aOutput.empty? && @hResponseObj[:writerShowTags]
132
+ @xml.tag!('gmi:output')
133
+ end
134
+
135
+ # process step - report [] {LE_ProcessStepReport}
136
+ aReports = hStep[:reports]
137
+ aReports.each do |hReport|
138
+ @xml.tag!('gmi:report') do
139
+ reportClass.writeXML(hReport)
140
+ end
141
+ end
142
+ if aReports.empty? && @hResponseObj[:writerShowTags]
143
+ @xml.tag!('gmi:report')
144
+ end
145
+
146
+ end # gmd:LE_ProcessStep tag
147
+ end # writeXML
148
+ end # LE_ProcessStep class
149
+
150
+ end
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,134 @@
1
+ # ISO <<Class>> LE_Source
2
+ # 19115-2 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2019-09-25 original script.
6
+
7
+ require_relative 'class_fraction'
8
+ require_relative 'class_referenceSystem'
9
+ require_relative 'class_citation'
10
+ require_relative 'class_processStep'
11
+ require_relative 'class_rsIdentifier'
12
+ require_relative 'class_nominalResolution'
13
+
14
+ module ADIWG
15
+ module Mdtranslator
16
+ module Writers
17
+ module Iso19115_2
18
+
19
+ class LE_Source
20
+
21
+ def initialize(xml, hResponseObj)
22
+ @xml = xml
23
+ @hResponseObj = hResponseObj
24
+ end
25
+
26
+ def writeXML(hSource, inContext = nil)
27
+
28
+ # classes used
29
+ fractionClass = MD_RepresentativeFraction.new(@xml, @hResponseObj)
30
+ systemClass = MD_ReferenceSystem.new(@xml, @hResponseObj)
31
+ citationClass = CI_Citation.new(@xml, @hResponseObj)
32
+ stepClass = ProcessStep.new(@xml, @hResponseObj)
33
+ identifierClass = RS_Identifier.new(@xml, @hResponseObj)
34
+ resolutionClass = LE_NominalResolution.new(@xml, @hResponseObj)
35
+
36
+ # source - id
37
+ attributes = {}
38
+ s = hSource[:sourceId]
39
+ unless s.nil?
40
+ attributes = { id: s.gsub(/[^0-9A-Za-z]/,'') }
41
+ end
42
+
43
+ outContext = 'source'
44
+ outContext = outContext + ' ' + hSource[:sourceId].to_s unless hSource[:sourceId].nil?
45
+ outContext = inContext + ' ' + outContext unless inContext.nil?
46
+
47
+ @xml.tag!('gmi:LE_Source', attributes) do
48
+
49
+ # source - description
50
+ unless hSource[:description].nil?
51
+ @xml.tag!('gmd:description') do
52
+ @xml.tag!('gco:CharacterString', hSource[:description])
53
+ end
54
+ end
55
+ if hSource[:description].nil? && @hResponseObj[:writerShowTags]
56
+ @xml.tag!('gmd:description')
57
+ end
58
+
59
+ # source - scale denominator {MD_RepresentativeFraction}
60
+ hResolution = hSource[:spatialResolution]
61
+ unless hResolution[:scaleFactor].nil?
62
+ @xml.tag!('gmd:scaleDenominator') do
63
+ fractionClass.writeXML(hResolution[:scaleFactor])
64
+ end
65
+ end
66
+ if hResolution[:scaleFactor].nil? && @hResponseObj[:writerShowTags]
67
+ @xml.tag!('gmd:scaleDenominator')
68
+ end
69
+
70
+ # source - reference system {MD_ReferenceSystem}
71
+ hSystem = hSource[:referenceSystem]
72
+ unless hSystem.empty?
73
+ @xml.tag!('gmd:sourceReferenceSystem') do
74
+ systemClass.writeXML(hSystem)
75
+ end
76
+ end
77
+ if hSystem.empty? && @hResponseObj[:writerShowTags]
78
+ @xml.tag!('gmd:sourceReferenceSystem')
79
+ end
80
+
81
+ # source - citation {CI_Citation}
82
+ hCitation = hSource[:sourceCitation]
83
+ unless hCitation.empty?
84
+ @xml.tag!('gmd:sourceCitation') do
85
+ citationClass.writeXML(hCitation, outContext)
86
+ end
87
+ end
88
+ if hCitation.empty? && @hResponseObj[:writerShowTags]
89
+ @xml.tag!('gmd:sourceCitation')
90
+ end
91
+
92
+ # source - extent [] {EX_Extent} (not implemented)
93
+
94
+ # source - source step [] {ProcessStep}
95
+ aSteps = hSource[:sourceSteps]
96
+ aSteps.each do |hStep|
97
+ @xml.tag!('gmd:sourceStep') do
98
+ stepClass.writeXML(hStep)
99
+ end
100
+ end
101
+ if aSteps.empty? && @hResponseObj[:writerShowTags]
102
+ @xml.tag!('gmd:sourceStep')
103
+ end
104
+
105
+ # source - processed level {RS_Identifier}
106
+ hProcess = hSource[:processedLevel]
107
+ unless hProcess.empty?
108
+ @xml.tag!('gmi:processedLevel') do
109
+ identifierClass.writeXML(hProcess, outContext)
110
+ end
111
+ end
112
+ if hProcess.empty? && @hResponseObj[:writerShowTags]
113
+ @xml.tag!('gmi:processedLevel')
114
+ end
115
+
116
+ # source - resolution {LE_NominalResolution}
117
+ hNominal = hSource[:resolution]
118
+ unless hNominal.empty?
119
+ @xml.tag!('gmi:resolution') do
120
+ resolutionClass.writeXML(hNominal, outContext)
121
+ end
122
+ end
123
+ if hNominal.empty? && @hResponseObj[:writerShowTags]
124
+ @xml.tag!('gmi:resolution')
125
+ end
126
+
127
+ end # gmd:LE_Source tag
128
+ end # writeXML
129
+ end # LE_Source class
130
+
131
+ end
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,126 @@
1
+ # ISO <<Class>> LI_ProcessStep
2
+ # 19115-2 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2018-04-10 add error and warning messaging
6
+ # Stan Smith 2017-08-30 added support for step sources
7
+ # Stan Smith 2016-12-13 refactored for mdTranslator/mdJson 2.0
8
+ # Stan Smith 2015-07-14 refactored to eliminate namespace globals $WriterNS and $IsoNS
9
+ # Stan Smith 2015-07-14 refactored to make iso19110 independent of iso19115_2 classes
10
+ # Stan Smith 2015-06-22 replace global ($response) with passed in object (hResponseObj)
11
+ # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
12
+ # Stan Smith 2014-07-09 modify require statements to function in RubyGem structure
13
+ # Stan Smith 2013-11-20 original script.
14
+
15
+ require_relative '../iso19115_2_writer'
16
+ require_relative 'class_responsibleParty'
17
+ require_relative 'class_source'
18
+
19
+ module ADIWG
20
+ module Mdtranslator
21
+ module Writers
22
+ module Iso19115_2
23
+
24
+ class LI_ProcessStep
25
+
26
+ def initialize(xml, hResponseObj)
27
+ @xml = xml
28
+ @hResponseObj = hResponseObj
29
+ @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_2
30
+ end
31
+
32
+ def writeXML(hStep, inContext = nil)
33
+
34
+ # classes used
35
+ partyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
36
+ sourceClass = Source.new(@xml, @hResponseObj)
37
+
38
+ outContext = 'process step'
39
+ outContext = outContext + ' ' + hStep[:stepId].to_s unless hStep[:stepId].nil?
40
+ outContext = inContext + ' ' + outContext unless inContext.nil?
41
+
42
+ # process step - id
43
+ attributes = {}
44
+ s = hStep[:stepId]
45
+ unless s.nil?
46
+ attributes = { id: s.gsub(/[^0-9A-Za-z]/,'') }
47
+ end
48
+
49
+ @xml.tag!('gmd:LI_ProcessStep', attributes) do
50
+
51
+ # process step - description (required)
52
+ s = hStep[:description]
53
+ unless s.nil?
54
+ @xml.tag!('gmd:description') do
55
+ @xml.tag!('gco:CharacterString', s)
56
+ end
57
+ end
58
+ if s.nil?
59
+ @NameSpace.issueWarning(260, 'gmd:description', outContext)
60
+ end
61
+
62
+ # process step - rationale
63
+ s = hStep[:rationale]
64
+ unless s.nil?
65
+ @xml.tag!('gmd:rationale') do
66
+ @xml.tag!('gco:CharacterString', s)
67
+ end
68
+ end
69
+ if s.nil? && @hResponseObj[:writerShowTags]
70
+ @xml.tag!('gmd:rationale')
71
+ end
72
+
73
+ # process step - datetime
74
+ hPeriod = hStep[:timePeriod]
75
+ unless hPeriod.empty?
76
+ hDate = hPeriod[:startDateTime]
77
+ if hDate.empty?
78
+ hDate = hPeriod[:endDateTime]
79
+ end
80
+ date = hDate[:dateTime]
81
+ dateResolution = hDate[:dateResolution]
82
+ s = AdiwgDateTimeFun.stringDateTimeFromDateTime(date, dateResolution)
83
+ if s != 'ERROR'
84
+ @xml.tag!('gmd:dateTime') do
85
+ @xml.tag!('gco:DateTime', s)
86
+ end
87
+ end
88
+ end
89
+ if hPeriod.empty? && @hResponseObj[:writerShowTags]
90
+ @xml.tag!('gmd:dateTime')
91
+ end
92
+
93
+ # process step - processor [] {CI_ResponsibleParty}
94
+ aParties = hStep[:processors]
95
+ aParties.each do |hRParty|
96
+ role = hRParty[:roleName]
97
+ aParties = hRParty[:parties]
98
+ aParties.each do |hParty|
99
+ @xml.tag!('gmd:processor') do
100
+ partyClass.writeXML(role, hParty, outContext)
101
+ end
102
+ end
103
+ end
104
+ if aParties.empty? && @hResponseObj[:writerShowTags]
105
+ @xml.tag!('gmd:processor')
106
+ end
107
+
108
+ # process step - source [] {Source}
109
+ aSources = hStep[:stepSources]
110
+ aSources.each do |hSource|
111
+ @xml.tag!('gmd:source') do
112
+ sourceClass.writeXML(hSource)
113
+ end
114
+ end
115
+ if aSources.empty? && @hResponseObj[:writerShowTags]
116
+ @xml.tag!('gmd:source')
117
+ end
118
+
119
+ end # gmd:LI_ProcessStep tag
120
+ end # writeXML
121
+ end # LI_ProcessStep class
122
+
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,114 @@
1
+ # ISO <<Class>> LI_Source
2
+ # 19115-2 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2016-12-07 refactored for mdTranslator/mdJson 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 (hResponseObj)
9
+ # Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
10
+ # Stan Smith 2014-07-09 modify require statements to function in RubyGem structure
11
+ # Stan Smith 2013-11-20 original script.
12
+
13
+ require_relative 'class_fraction'
14
+ require_relative 'class_referenceSystem'
15
+ require_relative 'class_citation'
16
+ require_relative 'class_processStep'
17
+
18
+ module ADIWG
19
+ module Mdtranslator
20
+ module Writers
21
+ module Iso19115_2
22
+
23
+ class LI_Source
24
+
25
+ def initialize(xml, hResponseObj)
26
+ @xml = xml
27
+ @hResponseObj = hResponseObj
28
+ end
29
+
30
+ def writeXML(hSource, inContext = nil)
31
+
32
+ # classes used
33
+ fractionClass = MD_RepresentativeFraction.new(@xml, @hResponseObj)
34
+ systemClass = MD_ReferenceSystem.new(@xml, @hResponseObj)
35
+ citationClass = CI_Citation.new(@xml, @hResponseObj)
36
+ stepClass = ProcessStep.new(@xml, @hResponseObj)
37
+
38
+ # source - id
39
+ attributes = {}
40
+ s = hSource[:sourceId]
41
+ unless s.nil?
42
+ attributes = { id: s.gsub(/[^0-9A-Za-z]/,'') }
43
+ end
44
+
45
+ outContext = 'source'
46
+ outContext = outContext + ' ' + hSource[:sourceId].to_s unless hSource[:sourceId].nil?
47
+ outContext = inContext + ' ' + outContext unless inContext.nil?
48
+
49
+ @xml.tag!('gmd:LI_Source', attributes) do
50
+
51
+ # source - description
52
+ unless hSource[:description].nil?
53
+ @xml.tag!('gmd:description') do
54
+ @xml.tag!('gco:CharacterString', hSource[:description])
55
+ end
56
+ end
57
+ if hSource[:description].nil? && @hResponseObj[:writerShowTags]
58
+ @xml.tag!('gmd:description')
59
+ end
60
+
61
+ # source - scale denominator {MD_RepresentativeFraction}
62
+ hResolution = hSource[:spatialResolution]
63
+ unless hResolution[:scaleFactor].nil?
64
+ @xml.tag!('gmd:scaleDenominator') do
65
+ fractionClass.writeXML(hResolution[:scaleFactor])
66
+ end
67
+ end
68
+ if hResolution[:scaleFactor].nil? && @hResponseObj[:writerShowTags]
69
+ @xml.tag!('gmd:scaleDenominator')
70
+ end
71
+
72
+ # source - reference system {MD_ReferenceSystem}
73
+ hSystem = hSource[:referenceSystem]
74
+ unless hSystem.empty?
75
+ @xml.tag!('gmd:sourceReferenceSystem') do
76
+ systemClass.writeXML(hSystem)
77
+ end
78
+ end
79
+ if hSystem.empty? && @hResponseObj[:writerShowTags]
80
+ @xml.tag!('gmd:sourceReferenceSystem')
81
+ end
82
+
83
+ # source - citation {CI_Citation}
84
+ hCitation = hSource[:sourceCitation]
85
+ unless hCitation.empty?
86
+ @xml.tag!('gmd:sourceCitation') do
87
+ citationClass.writeXML(hCitation, outContext)
88
+ end
89
+ end
90
+ if hCitation.empty? && @hResponseObj[:writerShowTags]
91
+ @xml.tag!('gmd:sourceCitation')
92
+ end
93
+
94
+ # source - extent [] {EX_Extent} (not implemented)
95
+
96
+ # source - source step [] {ProcessStep}
97
+ aSteps = hSource[:sourceSteps]
98
+ aSteps.each do |hStep|
99
+ @xml.tag!('gmd:sourceStep') do
100
+ stepClass.writeXML(hStep)
101
+ end
102
+ end
103
+ if aSteps.empty? && @hResponseObj[:writerShowTags]
104
+ @xml.tag!('gmd:sourceStep')
105
+ end
106
+
107
+ end # gmd:LI_Source tag
108
+ end # writeXML
109
+ end # LI_Source class
110
+
111
+ end
112
+ end
113
+ end
114
+ end