Class: Polygon
- Inherits:
-
Object
- Object
- Polygon
- Defined in:
- lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_polygon.rb
Instance Method Summary collapse
-
#initialize(xml) ⇒ Polygon
constructor
A new instance of Polygon.
- #writeXML(hGeoElement) ⇒ Object
Constructor Details
#initialize(xml) ⇒ Polygon
Returns a new instance of Polygon.
13 14 15 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_polygon.rb', line 13 def initialize(xml) @xml = xml end |
Instance Method Details
#writeXML(hGeoElement) ⇒ Object
17 18 19 20 21 22 23 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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_polygon.rb', line 17 def writeXML(hGeoElement) # gml:Polygon attributes attributes = {} # gml:Polygon attributes - gml:id - required lineID = hGeoElement[:elementId] if lineID.nil? $idCount = $idCount.succ lineID = 'polygon' + $idCount end attributes['gml:id'] = lineID # gml:Polygon attributes - srsDimension s = hGeoElement[:elementGeometry][:dimension] if !s.nil? attributes[:srsDimension] = s end # gml:Polygon attributes - srsName s = hGeoElement[:elementSrs][:srsName] if !s.nil? attributes[:srsName] = s end @xml.tag!('gml:Polygon',attributes) do # polygon - description s = hGeoElement[:elementDescription] if !s.nil? @xml.tag!('gml:description',s) elsif $showAllTags @xml.tag!('gml:description') end # polygon - name s = hGeoElement[:elementName] if !s.nil? @xml.tag!('gml:name',s) elsif $showAllTags @xml.tag!('gml:name') end # polygon - exterior ring # convert coordinate string from geoJSON to gml aCoords = hGeoElement[:elementGeometry][:geometry][:exteriorRing] if !aCoords.empty? s = Adiwg_Coordinates.unpack(aCoords) @xml.tag!('gml:exterior') do @xml.tag!('gml:LinearRing') do @xml.tag!('gml:coordinates',s) end end else @xml.tag!('gml:exterior') end # polygon - interior ring # convert coordinate string from geoJSON to gml # XSDs do not all gml:interior to be displayed empty aRings = hGeoElement[:elementGeometry][:geometry][:exclusionRings] unless aRings.empty? aRings.each do |aRing| s = Adiwg_Coordinates.unpack(aRing) @xml.tag!('gml:interior') do @xml.tag!('gml:LinearRing') do @xml.tag!('gml:coordinates', s) end end end end end end |