Class: Kamelopard::Placemark

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

Overview

Corresponds to KML’s Placemark objects. The geometry attribute requires a descendant of Geometry

Instance Attribute Summary collapse

Attributes inherited from Feature

#abstractView, #addressDetails, #atom_author, #atom_link, #description, #extendedData, #metadata, #open, #phoneNumber, #region, #snippet, #styleSelector, #styleUrl, #styles, #timeprimitive, #visibility

Attributes included from Snippet

#maxLines, #snippet_text

Attributes inherited from Object

#comment, #kml_id

Instance Method Summary collapse

Methods inherited from Feature

add_author, #hide, #show, #styles_to_kml, #timespan, #timespan=, #timestamp, #timestamp=

Methods included from Snippet

#snippet_to_kml

Methods inherited from Object

#change

Constructor Details

#initialize(name = nil, options = {}) ⇒ Placemark

Returns a new instance of Placemark.



1228
1229
1230
1231
# File 'lib/kamelopard/classes.rb', line 1228

def initialize(name = nil, options = {})
    super
    @name = name unless name.nil?
end

Instance Attribute Details

#geometryObject

Returns the value of attribute geometry.



1226
1227
1228
# File 'lib/kamelopard/classes.rb', line 1226

def geometry
  @geometry
end

#nameObject

Returns the value of attribute name.



1226
1227
1228
# File 'lib/kamelopard/classes.rb', line 1226

def name
  @name
end

Instance Method Details

#altitudeObject



1253
1254
1255
# File 'lib/kamelopard/classes.rb', line 1253

def altitude
    @geometry.altitude
end

#altitudeModeObject



1257
1258
1259
# File 'lib/kamelopard/classes.rb', line 1257

def altitudeMode
    @geometry.altitudeMode
end

#latitudeObject



1249
1250
1251
# File 'lib/kamelopard/classes.rb', line 1249

def latitude
    @geometry.latitude
end

#longitudeObject



1245
1246
1247
# File 'lib/kamelopard/classes.rb', line 1245

def longitude
    @geometry.longitude
end

#pointObject



1261
1262
1263
1264
1265
1266
1267
# File 'lib/kamelopard/classes.rb', line 1261

def point
    if @geometry.kind_of? Point then
        @geometry
    else
        raise "This placemark uses a non-point geometry, but the operation you're trying requires a point object"
    end
end

#to_kml(elem = nil) ⇒ Object



1233
1234
1235
1236
1237
1238
1239
# File 'lib/kamelopard/classes.rb', line 1233

def to_kml(elem = nil)
    k = XML::Node.new 'Placemark'
    super k
    @geometry.to_kml(k) unless @geometry.nil?
    elem << k unless elem.nil?
    k
end

#to_sObject



1241
1242
1243
# File 'lib/kamelopard/classes.rb', line 1241

def to_s
    "Placemark id #{ @kml_id } named #{ @name }"
end