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, #master_only

Instance Method Summary collapse

Methods inherited from Feature

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

Methods included from Snippet

#snippet_to_kml

Methods inherited from Object

#_alternate_to_kml, #change, #master_only?

Constructor Details

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

Returns a new instance of Placemark.



1546
1547
1548
1549
# File 'lib/kamelopard/classes.rb', line 1546

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

Instance Attribute Details

#balloonVisibilityObject

Returns the value of attribute balloonVisibility.



1544
1545
1546
# File 'lib/kamelopard/classes.rb', line 1544

def balloonVisibility
  @balloonVisibility
end

#geometryObject

Returns the value of attribute geometry.



1544
1545
1546
# File 'lib/kamelopard/classes.rb', line 1544

def geometry
  @geometry
end

#nameObject

Returns the value of attribute name.



1544
1545
1546
# File 'lib/kamelopard/classes.rb', line 1544

def name
  @name
end

Instance Method Details

#altitudeObject



1576
1577
1578
# File 'lib/kamelopard/classes.rb', line 1576

def altitude
    @geometry.altitude
end

#altitudeModeObject



1580
1581
1582
# File 'lib/kamelopard/classes.rb', line 1580

def altitudeMode
    @geometry.altitudeMode
end

#latitudeObject



1572
1573
1574
# File 'lib/kamelopard/classes.rb', line 1572

def latitude
    @geometry.latitude
end

#longitudeObject



1568
1569
1570
# File 'lib/kamelopard/classes.rb', line 1568

def longitude
    @geometry.longitude
end

#pointObject



1584
1585
1586
1587
1588
1589
1590
1591
1592
# File 'lib/kamelopard/classes.rb', line 1584

def point
    if @geometry.kind_of? Point then
        @geometry
    elsif @geometry.respond_to? :point then
        @geometry.point
    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



1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
# File 'lib/kamelopard/classes.rb', line 1551

def to_kml(elem = nil)
    k = XML::Node.new 'Placemark'
    super k
    @geometry.to_kml(k) unless @geometry.nil?
    if ! @balloonVisibility.nil? then
         x = XML::Node.new 'gx:balloonVisibility'
         x << ( @balloonVisibility ? 1 : 0 )
         k << x
    end
    elem << k unless elem.nil?
    k
end

#to_sObject



1564
1565
1566
# File 'lib/kamelopard/classes.rb', line 1564

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