Class: ADIWG::Mdtranslator::Writers::Iso19115_2::MD_Georectified

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ MD_Georectified

Returns a new instance of MD_Georectified.



19
20
21
22
23
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_georectified.rb', line 19

def initialize(xml, hResponseObj)
   @xml = xml
   @hResponseObj = hResponseObj
   @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_2
end

Instance Method Details

#writeXML(hGeoRec) ⇒ Object



25
26
27
28
29
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
109
110
111
112
113
114
115
116
117
118
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_georectified.rb', line 25

def writeXML(hGeoRec)

   # classes used
   gridClass = Grid.new(@xml, @hResponseObj)
   pointClass = Point.new(@xml, @hResponseObj)

   @xml.tag!('gmd:MD_Georectified') do

      # georectified - add grid info
      hGrid = hGeoRec[:gridRepresentation]
      gridClass.writeXML(hGrid, 'georectified representation')

      # georectified - checkpoint availability
      s = hGeoRec[:checkPointAvailable]
      @xml.tag!('gmd:checkPointAvailability') do
         @xml.tag!('gco:Boolean', s)
      end

      # georectified - checkpoint description
      s = hGeoRec[:checkPointDescription]
      unless s.nil?
         @xml.tag!('gmd:checkPointDescription') do
            @xml.tag!('gco:CharacterString', s)
         end
      end
      if s.nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:checkPointDescription')
      end

      # georectified - corner points (required)
      # note: 2 - 4 points are required, but XSD only allows 1
      # ... coordinates are flattened into one multi-dimensional point
      aCoords = hGeoRec[:cornerPoints]
      unless aCoords.empty?
         aCoords = aCoords.flatten
         hPoint = {}
         hPoint[:type] = 'Point'
         hPoint[:coordinates] = aCoords
         @xml.tag!('gmd:cornerPoints') do
            pointClass.writeXML(hPoint, {}, nil)
         end
      end
      if aCoords.empty?
         @NameSpace.issueWarning(170, 'gmd:cornerPoints', 'spatial representation')
      end

      # georectified - center point
      aCoords = hGeoRec[:centerPoint]
      unless aCoords.empty?
         hPoint = {}
         hPoint[:type] = 'Point'
         hPoint[:coordinates] = aCoords
         @xml.tag!('gmd:centerPoint') do
            pointClass.writeXML(hPoint, {}, nil)
         end
      end
      if aCoords.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:centerPoint')
      end

      # georectified - point in pixel (required)
      s = hGeoRec[:pointInPixel]
      if s.nil?
         @NameSpace.issueWarning(171, 'gmd:pointInPixel', 'spatial representation')
      else
         @xml.tag!('gmd:pointInPixel') do
            @xml.tag!('gmd:MD_PixelOrientationCode', s)
         end
      end

      # georectified - transformation dimension description
      s = hGeoRec[:transformationDimensionDescription]
      unless s.nil?
         @xml.tag!('gmd:transformationDimensionDescription') do
            @xml.tag!('gco:CharacterString', s)
         end
      end
      if s.nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:transformationDimensionDescription')
      end

      # georectified - transformation dimension mapping
      s = hGeoRec[:transformationDimensionMapping]
      unless s.nil?
         @xml.tag!('gmd:transformationDimensionMapping') do
            @xml.tag!('gco:CharacterString', s)
         end
      end
      if s.nil? && @hResponseObj[:writerShowTags]
         @xml.tag!('gmd:transformationDimensionMapping')
      end

   end # gmd:MD_Georectified tag
end