Class: MultiGeometry
- Inherits:
-
Object
- Object
- MultiGeometry
- Defined in:
- lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiGeometry.rb
Instance Method Summary collapse
-
#initialize(xml) ⇒ MultiGeometry
constructor
A new instance of MultiGeometry.
- #writeXML(hGeoElement) ⇒ Object
Constructor Details
#initialize(xml) ⇒ MultiGeometry
Returns a new instance of MultiGeometry.
17 18 19 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiGeometry.rb', line 17 def initialize(xml) @xml = xml end |
Instance Method Details
#writeXML(hGeoElement) ⇒ Object
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 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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiGeometry.rb', line 21 def writeXML(hGeoElement) # classes used intMetadataClass = InternalMetadata.new pointClass = Point.new(@xml) lineClass = LineString.new(@xml) polygonClass = Polygon.new(@xml) # gml:MultiGeometry attributes attributes = {} # gml:MultiGeometry attributes - gml:id - required mGeoID = hGeoElement[:elementId] if mGeoID.nil? $idCount = $idCount.succ mGeoID = 'multiGeo' + $idCount end attributes['gml:id'] = mGeoID # gml:MultiGeometry attributes - srsDimension s = hGeoElement[:elementGeometry][:dimension] if !s.nil? attributes[:srsDimension] = s end # gml:MultiGeometry attributes - srsName s = hGeoElement[:elementSrs][:srsName] if !s.nil? attributes[:srsName] = s end @xml.tag!('gml:MultiGeometry',attributes) do # multi geometry - description s = hGeoElement[:elementDescription] if !s.nil? @xml.tag!('gml:description',s) elsif $showAllTags @xml.tag!('gml:description') end # multi geometry - name s = hGeoElement[:elementName] if !s.nil? @xml.tag!('gml:name',s) elsif $showAllTags @xml.tag!('gml:name') end # GeoJSON multi-objects need to be broken into independent # ... geometry members for ISO representation geoType = hGeoElement[:elementGeometry][:geoType] case geoType when 'MultiPoint' aPoints = hGeoElement[:elementGeometry][:geometry] if !aPoints.empty? @xml.tag!('gml:geometryMembers') do aPoints.each do |aCoords| intPoint = intMetadataClass.newGeoElement intPoint[:elementSrs] = hGeoElement[:elementSrs] intPoint[:elementGeometry] = Adiwg_Point.unpack(aCoords,'Point') pointClass.writeXML(intPoint) end end end when 'MultiLineString' aLines = hGeoElement[:elementGeometry][:geometry] if !aLines.empty? @xml.tag!('gml:geometryMembers') do aLines.each do |aCoords| intLine = intMetadataClass.newGeoElement intLine[:elementSrs] = hGeoElement[:elementSrs] intLine[:elementGeometry] = Adiwg_LineString.unpack(aCoords,'LineString') lineClass.writeXML(intLine) end end end when 'MultiPolygon' aPolygons = hGeoElement[:elementGeometry][:geometry] if !aPolygons.empty? @xml.tag!('gml:geometryMembers') do aPolygons.each do |aCoords| intPolygon = intMetadataClass.newGeoElement intPolygon[:elementSrs] = hGeoElement[:elementSrs] intPolygon[:elementGeometry] = Adiwg_LineString.unpack(aCoords,'Polygon') polygonClass.writeXML(intPolygon) end end end end # multi geometry - geometry members # GeoJSON GeometryCollection # GeoJSON FeatureCollection case geoType when 'MultiGeometry' aGeometry = hGeoElement[:elementGeometry][:geometry] if !aGeometry.empty? @xml.tag!('gml:geometryMembers') do aGeometry.each do |hGeometry| hGeoType = hGeometry[:elementGeometry][:geoType] case hGeoType when 'Point' pointClass.writeXML(hGeometry) when 'LineString' lineClass.writeXML(hGeometry) when 'Polygon' polygonClass.writeXML(hGeometry) end end end end end end end |