Class: Kamelopard::Point
- Defined in:
- lib/kamelopard/classes.rb
Overview
Represents a Point in KML.
Instance Attribute Summary collapse
-
#altitude ⇒ Object
Returns the value of attribute altitude.
-
#altitudeMode ⇒ Object
Returns the value of attribute altitudeMode.
-
#extrude ⇒ Object
Returns the value of attribute extrude.
-
#latitude ⇒ Object
Returns the value of attribute latitude.
-
#longitude ⇒ Object
Returns the value of attribute longitude.
Attributes inherited from Object
#comment, #kml_id, #master_only
Class Method Summary collapse
-
.parse(p) ⇒ Object
Converts an XML::Node to a Kamelopard::Point.
Instance Method Summary collapse
-
#initialize(longitude = nil, latitude = nil, altitude = nil, options = {}) ⇒ Point
constructor
A new instance of Point.
- #to_kml(elem = nil, short = false) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Object
#_alternate_to_kml, #change, #master_only?
Constructor Details
#initialize(longitude = nil, latitude = nil, altitude = nil, options = {}) ⇒ Point
Returns a new instance of Point.
377 378 379 380 381 382 |
# File 'lib/kamelopard/classes.rb', line 377 def initialize(longitude = nil, latitude = nil, altitude = nil, = {}) super @longitude = Kamelopard.convert_coord(longitude) unless longitude.nil? @latitude = Kamelopard.convert_coord(latitude) unless latitude.nil? @altitude = altitude unless altitude.nil? end |
Instance Attribute Details
#altitude ⇒ Object
Returns the value of attribute altitude.
375 376 377 |
# File 'lib/kamelopard/classes.rb', line 375 def altitude @altitude end |
#altitudeMode ⇒ Object
Returns the value of attribute altitudeMode.
375 376 377 |
# File 'lib/kamelopard/classes.rb', line 375 def altitudeMode @altitudeMode end |
#extrude ⇒ Object
Returns the value of attribute extrude.
375 376 377 |
# File 'lib/kamelopard/classes.rb', line 375 def extrude @extrude end |
#latitude ⇒ Object
Returns the value of attribute latitude.
374 375 376 |
# File 'lib/kamelopard/classes.rb', line 374 def latitude @latitude end |
#longitude ⇒ Object
Returns the value of attribute longitude.
374 375 376 |
# File 'lib/kamelopard/classes.rb', line 374 def longitude @longitude end |
Class Method Details
.parse(p) ⇒ Object
Converts an XML::Node to a Kamelopard::Point
385 386 387 388 389 |
# File 'lib/kamelopard/classes.rb', line 385 def self.parse(p) a = Kamelopard.xml_to_hash(p, %w[altitudeMode extrude coordinates]) (lon, lat, alt) = a[:coordinates].to_s.split(/,\s+/).collect { |a| a.to_f } return Point.new(lon, lat, alt, :altitudeMode => a[:altitudeMode].to_s.to_sym, :extrude => a[:extrude].to_s.to_i) end |
Instance Method Details
#to_kml(elem = nil, short = false) ⇒ Object
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
# File 'lib/kamelopard/classes.rb', line 407 def to_kml(elem = nil, short = false) e = XML::Node.new 'Point' super(e) e.attributes['id'] = @kml_id c = XML::Node.new 'coordinates' c << "#{ @longitude }, #{ @latitude }, #{ @altitude }" e << c if not short then c = XML::Node.new 'extrude' c << @extrude.to_s e << c Kamelopard.add_altitudeMode(@altitudeMode, e) end elem << e unless elem.nil? e end |
#to_s ⇒ Object
399 400 401 |
# File 'lib/kamelopard/classes.rb', line 399 def to_s "Point (#{@longitude}, #{@latitude}, #{@altitude}, mode = #{@altitudeMode}, #{ @extrude == 1 ? 'extruded' : 'not extruded' })" end |