Class: ADIWG::Mdtranslator::Writers::Iso19115_2::MultiLineString

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

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ MultiLineString

Returns a new instance of MultiLineString.



18
19
20
21
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiLine.rb', line 18

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

Instance Method Details

#writeXML(hGeoObject, hProperties, objId) ⇒ Object



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

def writeXML(hGeoObject, hProperties, objId)

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

   # classes used
   lineClass = LineString.new(@xml, @hResponseObj)

   # multiLineString attributes
   attributes = {}

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

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

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

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

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

      # multiLineString - lineString members (required)
      @xml.tag!('gml:geometryMembers') do
         unless hGeoObject[:coordinates].empty?
            aLines = hGeoObject[:coordinates]
            aLines.each do |aLine|
               newLine = {}
               newLine[:type] = 'LineString'
               newLine[:coordinates] = aLine
               lineClass.writeXML(newLine, {}, nil)
            end
         end
      end

   end # gml:MultiGeometry tag
end