Class: ADIWG::Mdtranslator::Writers::Iso19115_2::LI_Source

Inherits:
Object
  • Object
show all
Defined in:
lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_liSource.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ LI_Source

Returns a new instance of LI_Source.



25
26
27
28
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_liSource.rb', line 25

def initialize(xml, hResponseObj)
   @xml = xml
   @hResponseObj = hResponseObj
end

Instance Method Details

#writeXML(hSource, inContext = nil) ⇒ Object



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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_liSource.rb', line 30

def writeXML(hSource, inContext = nil)

   # classes used
   fractionClass = MD_RepresentativeFraction.new(@xml, @hResponseObj)
   systemClass = MD_ReferenceSystem.new(@xml, @hResponseObj)
   citationClass = CI_Citation.new(@xml, @hResponseObj)
   stepClass = ProcessStep.new(@xml, @hResponseObj)

   # source - id
   attributes = {}
   s = hSource[:sourceId]
   unless s.nil?
      attributes = { id: s.gsub(/[^0-9A-Za-z]/,'') }
   end

   outContext = 'source'
   outContext = outContext + ' ' + hSource[:sourceId].to_s unless hSource[:sourceId].nil?
   outContext = inContext + ' ' + outContext unless inContext.nil?

   @xml.tag!('gmd:LI_Source', attributes) do

      # source - description
      unless hSource[:description].nil?
         @xml.tag!('gmd:description') do
            @xml.tag!('gco:CharacterString', hSource[:description])
         end
      end
      if hSource[:description].nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:description')
      end

      # source - scale denominator {MD_RepresentativeFraction}
      hResolution = hSource[:spatialResolution]
      unless hResolution[:scaleFactor].nil?
         @xml.tag!('gmd:scaleDenominator') do
            fractionClass.writeXML(hResolution[:scaleFactor])
         end
      end
      if hResolution[:scaleFactor].nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:scaleDenominator')
      end

      # source - reference system {MD_ReferenceSystem}
      hSystem = hSource[:referenceSystem]
      unless hSystem.empty?
         @xml.tag!('gmd:sourceReferenceSystem') do
            systemClass.writeXML(hSystem)
         end
      end
      if hSystem.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:sourceReferenceSystem')
      end

      # source - citation {CI_Citation}
      hCitation = hSource[:sourceCitation]
      unless hCitation.empty?
         @xml.tag!('gmd:sourceCitation') do
            citationClass.writeXML(hCitation, outContext)
         end
      end
      if hCitation.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:sourceCitation')
      end

      # source - extent [] {EX_Extent} (not implemented)

      # source - source step [] {ProcessStep}
      aSteps = hSource[:sourceSteps]
      aSteps.each do |hStep|
         @xml.tag!('gmd:sourceStep') do
            stepClass.writeXML(hStep)
         end
      end
      if aSteps.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:sourceStep')
      end

   end # gmd:LI_Source tag
end