Class: KMLPoint

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

Overview

Represents a Point in KML.

Instance Attribute Summary collapse

Attributes inherited from KMLObject

#comment, #id

Instance Method Summary collapse

Constructor Details

#initialize(long, lat, alt = 0, altmode = :clampToGround, extrude = false) ⇒ KMLPoint

Returns a new instance of KMLPoint.



109
110
111
112
113
114
115
116
# File 'lib/kamelopard/classes.rb', line 109

def initialize(long, lat, alt=0, altmode=:clampToGround, extrude=false)
    super()
    @longitude = convert_coord(long)
    @latitude = convert_coord(lat)
    @altitude = alt
    @altitudeMode = altmode
    @extrude = extrude
end

Instance Attribute Details

#altitudeObject

Returns the value of attribute altitude.



108
109
110
# File 'lib/kamelopard/classes.rb', line 108

def altitude
  @altitude
end

#altitudeModeObject

Returns the value of attribute altitudeMode.



108
109
110
# File 'lib/kamelopard/classes.rb', line 108

def altitudeMode
  @altitudeMode
end

#extrudeObject

Returns the value of attribute extrude.



108
109
110
# File 'lib/kamelopard/classes.rb', line 108

def extrude
  @extrude
end

#latitudeObject

Returns the value of attribute latitude.



108
109
110
# File 'lib/kamelopard/classes.rb', line 108

def latitude
  @latitude
end

#longitudeObject

Returns the value of attribute longitude.



108
109
110
# File 'lib/kamelopard/classes.rb', line 108

def longitude
  @longitude
end

Instance Method Details

#to_kml(indent = 0, short = false) ⇒ Object



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/kamelopard/classes.rb', line 122

def to_kml(indent = 0, short = false)
    # The short form includes only the coordinates tag
    k = super(indent + 4) + "#{ ' ' * indent }<Point id=\"#{ @id }\">\n"
    k << "#{ ' ' * indent }    <extrude>#{ @extrude ? 1 : 0 }</extrude>\n" unless short
    if not short 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 << "#{ ' ' * indent }    <coordinates>#{ @longitude }, #{ @latitude }, #{ @altitude }</coordinates>\n"
    k << "#{ ' ' * indent }</Point>\n"
    k
end

#to_sObject



118
119
120
# File 'lib/kamelopard/classes.rb', line 118

def to_s
    "KMLPoint (#{@longitude}, #{@latitude}, #{@altitude}, mode = #{@altitudeMode}, #{ @extrude ? 'extruded' : 'not extruded' })"
end