Class: ADIWG::Mdtranslator::Writers::Iso19115_2::LineString

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ LineString

Returns a new instance of LineString.



25
26
27
28
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_lineString.rb', line 25

def initialize(xml, hResponseObj)
   @xml = xml
   @hResponseObj = hResponseObj
end

Instance Method Details

#writeXML(hGeoObject, hProperties, lineId) ⇒ Object



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

def writeXML(hGeoObject, hProperties, lineId)

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

   # LineString attributes
   attributes = {}

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

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

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

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

      # lineString - 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

      # lineString - pos (required)
      unless hGeoObject[:coordinates].empty?
         aCoords = hGeoObject[:coordinates]
         aCoords.each do |aCoord|
            s = aCoord[0].to_s + ' ' + aCoord[1].to_s
            @xml.tag!('gml:pos', s)
         end
      end

   end # gml:LineString
end