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

#comment, #id

Instance Method Summary collapse

Methods inherited from Feature

#styles_to_kml, #timespan, #timespan=, #timestamp, #timestamp=

Constructor Details

#initialize(name = nil, geo = nil) ⇒ Placemark

Returns a new instance of Placemark.



1084
1085
1086
1087
1088
1089
1090
1091
1092
# File 'lib/kamelopard/classes.rb', line 1084

def initialize(name = nil, geo = nil)
    super(name)
    Document.instance.folder << self
    if geo.respond_to? '[]' then
        @geometry = geo
    else
        @geometry = [ geo ]
    end
end

Instance Attribute Details

#geometryObject

Returns the value of attribute geometry.



1083
1084
1085
# File 'lib/kamelopard/classes.rb', line 1083

def geometry
  @geometry
end

#nameObject

Returns the value of attribute name.



1083
1084
1085
# File 'lib/kamelopard/classes.rb', line 1083

def name
  @name
end

Instance Method Details

#altitudeObject



1116
1117
1118
# File 'lib/kamelopard/classes.rb', line 1116

def altitude
    @geometry.altitude
end

#altitudeModeObject



1120
1121
1122
# File 'lib/kamelopard/classes.rb', line 1120

def altitudeMode
    @geometry.altitudeMode
end

#latitudeObject



1112
1113
1114
# File 'lib/kamelopard/classes.rb', line 1112

def latitude
    @geometry.latitude
end

#longitudeObject



1108
1109
1110
# File 'lib/kamelopard/classes.rb', line 1108

def longitude
    @geometry.longitude
end

#pointObject



1124
1125
1126
1127
1128
1129
1130
# File 'lib/kamelopard/classes.rb', line 1124

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

#to_kml(indent = 0) ⇒ Object



1094
1095
1096
1097
1098
1099
1100
1101
1102
# File 'lib/kamelopard/classes.rb', line 1094

def to_kml(indent = 0)
    a = "#{ ' ' * indent }<Placemark id=\"#{ @id }\">\n"
    a << super(indent + 4) {
        k = ''
        @geometry.each do |i| k << i.to_kml(indent + 4) unless i.nil? end
        k
    }
    a << "#{ ' ' * indent }</Placemark>\n"
end

#to_sObject



1104
1105
1106
# File 'lib/kamelopard/classes.rb', line 1104

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