Class: EX_BoundingPolygon

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

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ EX_BoundingPolygon

Returns a new instance of EX_BoundingPolygon.



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

def initialize(xml)
  @xml = xml
end

Instance Method Details

#writeXML(hGeoElement) ⇒ Object



24
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
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_boundingPolygon.rb', line 24

def writeXML(hGeoElement)

  # classes used by MD_Metadata
  pointClass = Point.new(@xml)
  lineClass = LineString.new(@xml)
  multiGeoClass = MultiGeometry.new(@xml)
  polygonClass = Polygon.new(@xml)

  hGeometry = hGeoElement[:elementGeometry]
  polyType = hGeometry[:geoType]

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

    # bounding polygon - extent type - required
    extentType = hGeoElement[:elementIncludeData]
    if extentType.nil?
      @xml.tag!('gmd:extentTypeCode',{'gco:nilReason'=>'missing'})
    elsif extentType == true || extentType == false
      @xml.tag!('gmd:extentTypeCode') do
        @xml.tag!('gco:Boolean',extentType)
      end
    else
      @xml.tag!('gmd:extentTypeCode',{'gco:nilReason'=>extentType})
    end

    # bounding polygon - polygon - required
    if hGeometry[:geometry].empty?
      @xml.tag!('gmd:polygon', {'gco:nilReason' => 'missing'})
    else
      @xml.tag!('gmd:polygon') do
        case polyType
          when 'Point'
            pointClass.writeXML(hGeoElement)
          when 'LineString'
            lineClass.writeXML(hGeoElement)
          when 'Polygon'
            polygonClass.writeXML(hGeoElement)
          when 'MultiPoint', 'MultiLineString', 'MultiPolygon', 'MultiGeometry'
            multiGeoClass.writeXML(hGeoElement)
          when 'MultiGeometry'
            multiGeoClass.writeXML(hGeoElement)
          else
            # log - the bounding polygon type is not supported
        end
      end
    end

  end

end