Class: Kamelopard::LinearRing

Inherits:
Geometry show all
Defined in:
lib/kamelopard/classes.rb

Overview

Corresponds to KML’s LinearRing object

Instance Attribute Summary collapse

Attributes inherited from Object

#comment, #id

Instance Method Summary collapse

Constructor Details

#initialize(coordinates = nil, tessellate = 0, extrude = 0, altitudeMode = :clampToGround, altitudeOffset = nil) ⇒ LinearRing

Returns a new instance of LinearRing.



298
299
300
301
302
303
304
305
306
307
308
309
310
311
# File 'lib/kamelopard/classes.rb', line 298

def initialize(coordinates = nil, tessellate = 0, extrude = 0, altitudeMode = :clampToGround, altitudeOffset = nil)
    super()
    if coordinates.nil? then
        @coordinates = nil
    elsif coordinates.kind_of? CoordinateList then
        @coordinates = coordinates
    else
        @coordinates = CoordinateList.new(coordinates)
    end
    @tessellate = tessellate
    @extrude = extrude
    @altitudeMode = altitudeMode
    @altitudeOffset = altitudeOffset
end

Instance Attribute Details

#altitudeModeObject

Returns the value of attribute altitudeMode.



296
297
298
# File 'lib/kamelopard/classes.rb', line 296

def altitudeMode
  @altitudeMode
end

#altitudeOffsetObject

Returns the value of attribute altitudeOffset.



296
297
298
# File 'lib/kamelopard/classes.rb', line 296

def altitudeOffset
  @altitudeOffset
end

#coordinatesObject

Returns the value of attribute coordinates.



296
297
298
# File 'lib/kamelopard/classes.rb', line 296

def coordinates
  @coordinates
end

#extrudeObject

Returns the value of attribute extrude.



296
297
298
# File 'lib/kamelopard/classes.rb', line 296

def extrude
  @extrude
end

#tessellateObject

Returns the value of attribute tessellate.



296
297
298
# File 'lib/kamelopard/classes.rb', line 296

def tessellate
  @tessellate
end

Instance Method Details

#<<(a) ⇒ Object

Appends an element to this LinearRing’s CoordinateList. See CoordinateList#add_element



323
324
325
# File 'lib/kamelopard/classes.rb', line 323

def <<(a)
    @coordinates << a
end

#set_coords(a) ⇒ Object

Sets @coordinates element



314
315
316
317
318
319
320
# File 'lib/kamelopard/classes.rb', line 314

def set_coords(a)
    if a.kind_of? CoordinateList then
        @coordinates = a
    else
        @coordinates = CoordinateList.new(a)
    end
end

#to_kml(elem = nil) ⇒ Object



327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/kamelopard/classes.rb', line 327

def to_kml(elem = nil)
    k = REXML::Element.new 'LinearRing'
    super(k)
    Kamelopard.kml_array(k, [
        [ @altitudeOffset, 'gx:altitudeOffset' ],
        [ @tessellate, 'tessellate' ],
        [ @extrude, 'extrude' ]
    ])
    Kamelopard.add_altitudeMode(@altitudeMode, k)
    @coordinates.to_kml(k)
    elem.elements << k unless elem.nil?
    k
end