class ADIWG::Mdtranslator::Writers::Iso19115_1::GeometryCollection

Public Class Methods

new(xml, hResponseObj) click to toggle source
# File lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_geometryCollection.rb, line 23
def initialize(xml, hResponseObj)
   @xml = xml
   @hResponseObj = hResponseObj
   @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_1
end

Public Instance Methods

writeXML(hGeoObject, hProperties, objId) click to toggle source
# File lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_geometryCollection.rb, line 29
def writeXML(hGeoObject, hProperties, objId)

   # classes used
   pointClass = Point.new(@xml, @hResponseObj)
   lineClass = LineString.new(@xml, @hResponseObj)
   polyClass = Polygon.new(@xml, @hResponseObj)
   multiPointClass = MultiPoint.new(@xml, @hResponseObj)
   multiLineClass = MultiLineString.new(@xml, @hResponseObj)
   multiPolyClass = MultiPolygon.new(@xml, @hResponseObj)
   geoPropClass = FeatureProperties.new(@xml, @hResponseObj)

   # geometry collection attributes
   attributes = {}

   # geometry collection attributes - gml:id (required)
   if objId.nil?
      @hResponseObj[:writerMissingIdCount] = @hResponseObj[:writerMissingIdCount].succ
      objId = 'geometryCollection' + @hResponseObj[:writerMissingIdCount]
   else
      objId.gsub!(/[^0-9a-zA-Z]/, '')
   end
   attributes['gml:id'] = objId

   # geometry collection attributes - srsName (GeoJSON is WGS84)
   attributes[:srsName] = 'WGS84'

   @xml.tag!('gml:MultiGeometry', attributes) do

      # geometry collection - properties for Feature
      unless hProperties.empty?
         geoPropClass.writeXML(hProperties)
      end

      # geometry collection - geometry objects (required)
      unless hGeoObject[:geometryObjects].empty?
         @xml.tag!('gml:geometryMembers') do
            aObjects = hGeoObject[:geometryObjects]
            aObjects.each do |hGeoObj|
               case hGeoObj[:type]
                  when 'Point'
                     pointClass.writeXML(hGeoObj, {}, nil)
                  when 'LineString'
                     lineClass.writeXML(hGeoObj, {}, nil)
                  when 'Polygon'
                     polyClass.writeXML(hGeoObj, {}, nil)
                  when 'MultiPoint'
                     multiPointClass.writeXML(hGeoObj, {}, nil)
                  when 'MultiLineString'
                     multiLineClass.writeXML(hGeoObj, {}, nil)
                  when 'MultiPolygon'
                     multiPolyClass.writeXML(hGeoObj, {}, nil)
                  else
                     @NameSpace.issueNotice(160, "#{hGeoObj[:type]}")
               end
            end
         end
      end
      if hGeoObject[:geometryObjects].empty?
         @NameSpace.issueWarning(161, nil, 'geometry collection')
      end

   end # gml:MultiGeometry tag
end