Class: Kamelopard::AbstractView
- Defined in:
- lib/kamelopard/classes.rb
Overview
Abstract class corresponding to KML’s AbstractView object
Instance Attribute Summary collapse
-
#altitudeMode ⇒ Object
Returns the value of attribute altitudeMode.
-
#className ⇒ Object
readonly
Returns the value of attribute className.
-
#heading ⇒ Object
Returns the value of attribute heading.
-
#point ⇒ Object
Returns the value of attribute point.
-
#range ⇒ Object
Returns the value of attribute range.
-
#roll ⇒ Object
Returns the value of attribute roll.
-
#tilt ⇒ Object
Returns the value of attribute tilt.
-
#timespan ⇒ Object
Returns the value of attribute timespan.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#viewerOptions ⇒ Object
Returns the value of attribute viewerOptions.
Attributes inherited from Object
#comment, #kml_id, #master_only
Instance Method Summary collapse
- #[](a) ⇒ Object
- #[]=(a, b) ⇒ Object
- #altitude ⇒ Object
- #altitude=(a) ⇒ Object
-
#initialize(className, point, options = {}) ⇒ AbstractView
constructor
A new instance of AbstractView.
- #latitude ⇒ Object
- #latitude=(a) ⇒ Object
- #longitude ⇒ Object
- #longitude=(a) ⇒ Object
- #to_kml(elem = nil) ⇒ Object
- #to_queries_txt(name = '', planet = 'earth') ⇒ Object
Methods inherited from Object
#_alternate_to_kml, #change, #master_only?
Constructor Details
#initialize(className, point, options = {}) ⇒ AbstractView
Returns a new instance of AbstractView.
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File 'lib/kamelopard/classes.rb', line 500 def initialize(className, point, = {}) raise "className argument must not be nil" if className.nil? @heading = 0 @tilt = 0 @roll = nil @range = nil @altitudeMode = :clampToGround @viewerOptions = {} super @className = className self.point= point unless point.nil? end |
Instance Attribute Details
#altitudeMode ⇒ Object
Returns the value of attribute altitudeMode.
497 498 499 |
# File 'lib/kamelopard/classes.rb', line 497 def altitudeMode @altitudeMode end |
#className ⇒ Object (readonly)
Returns the value of attribute className.
498 499 500 |
# File 'lib/kamelopard/classes.rb', line 498 def className @className end |
#heading ⇒ Object
Returns the value of attribute heading.
497 498 499 |
# File 'lib/kamelopard/classes.rb', line 497 def heading @heading end |
#point ⇒ Object
Returns the value of attribute point.
498 499 500 |
# File 'lib/kamelopard/classes.rb', line 498 def point @point end |
#range ⇒ Object
Returns the value of attribute range.
497 498 499 |
# File 'lib/kamelopard/classes.rb', line 497 def range @range end |
#roll ⇒ Object
Returns the value of attribute roll.
497 498 499 |
# File 'lib/kamelopard/classes.rb', line 497 def roll @roll end |
#tilt ⇒ Object
Returns the value of attribute tilt.
497 498 499 |
# File 'lib/kamelopard/classes.rb', line 497 def tilt @tilt end |
#timespan ⇒ Object
Returns the value of attribute timespan.
497 498 499 |
# File 'lib/kamelopard/classes.rb', line 497 def timespan @timespan end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
497 498 499 |
# File 'lib/kamelopard/classes.rb', line 497 def @timestamp end |
#viewerOptions ⇒ Object
Returns the value of attribute viewerOptions.
497 498 499 |
# File 'lib/kamelopard/classes.rb', line 497 def viewerOptions @viewerOptions end |
Instance Method Details
#[](a) ⇒ Object
601 602 603 |
# File 'lib/kamelopard/classes.rb', line 601 def [](a) return @viewerOptions[a] end |
#[]=(a, b) ⇒ Object
605 606 607 608 609 610 611 612 613 |
# File 'lib/kamelopard/classes.rb', line 605 def []=(a, b) if not b.kind_of? FalseClass and not b.kind_of? TrueClass then raise 'Option value must be boolean' end if a != :streetview and a != :historicalimagery and a != :sunlight then raise 'Option index must be :streetview, :historicalimagery, or :sunlight' end @viewerOptions[a] = b end |
#altitude ⇒ Object
537 538 539 |
# File 'lib/kamelopard/classes.rb', line 537 def altitude @point.nil? ? nil : @point.altitude end |
#altitude=(a) ⇒ Object
557 558 559 560 561 562 563 |
# File 'lib/kamelopard/classes.rb', line 557 def altitude=(a) if @point.nil? then @point = Point.new(0, 0, a) else @point.altitude = a end end |
#latitude ⇒ Object
533 534 535 |
# File 'lib/kamelopard/classes.rb', line 533 def latitude @point.nil? ? nil : @point.latitude end |
#latitude=(a) ⇒ Object
549 550 551 552 553 554 555 |
# File 'lib/kamelopard/classes.rb', line 549 def latitude=(a) if @point.nil? then @point = Point.new(0, a) else @point.latitude = a end end |
#longitude ⇒ Object
529 530 531 |
# File 'lib/kamelopard/classes.rb', line 529 def longitude @point.nil? ? nil : @point.longitude end |
#longitude=(a) ⇒ Object
541 542 543 544 545 546 547 |
# File 'lib/kamelopard/classes.rb', line 541 def longitude=(a) if @point.nil? then @point = Point.new(a, 0) else @point.longitude = a end end |
#to_kml(elem = nil) ⇒ Object
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 |
# File 'lib/kamelopard/classes.rb', line 565 def to_kml(elem = nil) t = XML::Node.new @className super(t) Kamelopard.kml_array(t, [ [ @point.nil? ? nil : @point.longitude, 'longitude' ], [ @point.nil? ? nil : @point.latitude, 'latitude' ], [ @point.nil? ? nil : @point.altitude, 'altitude' ], [ @heading, 'heading' ], [ @tilt, 'tilt' ], [ @range, 'range' ], [ @roll, 'roll' ] ]) Kamelopard.add_altitudeMode(@altitudeMode, t) if @viewerOptions.keys.length > 0 then vo = XML::Node.new 'gx:ViewerOptions' @viewerOptions.each do |k, v| o = XML::Node.new 'gx:option' o.attributes['name'] = k.to_s o.attributes['enabled'] = v ? 'true' : 'false' vo << o end t << vo end if not @timestamp.nil? then @timestamp.to_kml(t, 'gx') elsif not @timespan.nil? then @timespan.to_kml(t, 'gx') end elem << t unless elem.nil? t end |
#to_queries_txt(name = '', planet = 'earth') ⇒ Object
597 598 599 |
# File 'lib/kamelopard/classes.rb', line 597 def to_queries_txt(name = '', planet = 'earth') return "#{planet}@#{name}@flytoview=" + self.to_kml.to_s.gsub(/^\s+/, '').gsub("\n", '') end |