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. Note: whereas most objects implicitly add themselves to the end of the current Document, Placemarks do not. They must be explicitly added to the Document or other Container they live in, typically with the Container’s << operator.

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?, parse

Constructor Details

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

Returns a new instance of Placemark.



1752
1753
1754
1755
# File 'lib/kamelopard/classes.rb', line 1752

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

Instance Attribute Details

#balloonVisibilityObject

Returns the value of attribute balloonVisibility.



1750
1751
1752
# File 'lib/kamelopard/classes.rb', line 1750

def balloonVisibility
  @balloonVisibility
end

#geometryObject

Returns the value of attribute geometry.



1750
1751
1752
# File 'lib/kamelopard/classes.rb', line 1750

def geometry
  @geometry
end

#nameObject

Returns the value of attribute name.



1750
1751
1752
# File 'lib/kamelopard/classes.rb', line 1750

def name
  @name
end

Instance Method Details

#altitudeObject



1782
1783
1784
# File 'lib/kamelopard/classes.rb', line 1782

def altitude
    @geometry.altitude
end

#altitudeModeObject



1786
1787
1788
# File 'lib/kamelopard/classes.rb', line 1786

def altitudeMode
    @geometry.altitudeMode
end

#latitudeObject



1778
1779
1780
# File 'lib/kamelopard/classes.rb', line 1778

def latitude
    @geometry.latitude
end

#longitudeObject



1774
1775
1776
# File 'lib/kamelopard/classes.rb', line 1774

def longitude
    @geometry.longitude
end

#pointObject



1790
1791
1792
1793
1794
1795
1796
1797
1798
# File 'lib/kamelopard/classes.rb', line 1790

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



1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
# File 'lib/kamelopard/classes.rb', line 1757

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



1770
1771
1772
# File 'lib/kamelopard/classes.rb', line 1770

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