Class: 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 KMLObject

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



278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/kamelopard/classes.rb', line 278

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.



276
277
278
# File 'lib/kamelopard/classes.rb', line 276

def altitudeMode
  @altitudeMode
end

#altitudeOffsetObject

Returns the value of attribute altitudeOffset.



276
277
278
# File 'lib/kamelopard/classes.rb', line 276

def altitudeOffset
  @altitudeOffset
end

#coordinatesObject

Returns the value of attribute coordinates.



276
277
278
# File 'lib/kamelopard/classes.rb', line 276

def coordinates
  @coordinates
end

#extrudeObject

Returns the value of attribute extrude.



276
277
278
# File 'lib/kamelopard/classes.rb', line 276

def extrude
  @extrude
end

#tessellateObject

Returns the value of attribute tessellate.



276
277
278
# File 'lib/kamelopard/classes.rb', line 276

def tessellate
  @tessellate
end

Instance Method Details

#<<(a) ⇒ Object

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



303
304
305
# File 'lib/kamelopard/classes.rb', line 303

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

#set_coords(a) ⇒ Object

Sets @coordinates element



294
295
296
297
298
299
300
# File 'lib/kamelopard/classes.rb', line 294

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

#to_kml(indent = 0) ⇒ Object



307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/kamelopard/classes.rb', line 307

def to_kml(indent = 0)
    k = super(indent + 4) + "#{ ' ' * indent }<LinearRing id=\"#{ @id }\">\n"
    k << "#{ ' ' * indent }    <gx:altitudeOffset>#{ @altitudeOffset }</gx:altitudeOffset>\n" unless @altitudeOffset.nil?
    k << "#{ ' ' * indent }    <tessellate>#{ @tessellate }</tessellate>\n" unless @tessellate.nil?
    k << "#{ ' ' * indent }    <extrude>#{ @extrude }</extrude>\n" unless @extrude.nil?
    if not @altitudeMode.nil? then
        if @altitudeMode == :clampToGround or @altitudeMode == :relativeToGround or @altitudeMode == :absolute then
            k << "#{ ' ' * indent }    <altitudeMode>#{ @altitudeMode }</altitudeMode>\n"
        else
            k << "#{ ' ' * indent }    <gx:altitudeMode>#{ @altitudeMode }</gx:altitudeMode>\n"
        end
    end
    k << @coordinates.to_kml(indent + 4)
    k << "#{ ' ' * indent }</LinearRing>\n"
    k
end