class ADIWG::Mdtranslator::Writers::Iso19115_2::Point

Public Class Methods

new(xml, hResponseObj) click to toggle source
# File lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_point.rb, line 25
def initialize(xml, hResponseObj)
   @xml = xml
   @hResponseObj = hResponseObj
end

Public Instance Methods

writeXML(hGeoObject, hProperties, objId) click to toggle source
# File lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_point.rb, line 30
def writeXML(hGeoObject, hProperties, objId)

   # classes used
   geoPropClass = FeatureProperties.new(@xml, @hResponseObj)

   # Point attributes
   attributes = {}

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

   # Point attributes - srsDimension
   s = AdiwgCoordinates.getDimension(hGeoObject[:coordinates])
   if !s.nil?
      attributes[:srsDimension] = s
   end

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

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

      # point - properties for Feature
      unless hProperties.empty?
         geoPropClass.writeXML(hProperties)
      end
      if hProperties.empty? && @hResponseObj[:writerShowTags]
         @xml.tag!('gml:description')
         @xml.tag!('gml:identifier', {'codeSpace' => ''})
         @xml.tag!('gml:name')
      end

      # point - pos (required)
      s = ''
      unless hGeoObject[:coordinates].empty?
         hGeoObject[:coordinates].each do |coord|
            s += coord.to_s + ' '
         end
         s = s.strip
      end
      @xml.tag!('gml:pos', s)

   end # gml:Point tag
end