Class: Kamelopard::AbstractView

Inherits:
Object
  • Object
show all
Defined in:
lib/kamelopard/classes.rb

Overview

Abstract class corresponding to KML’s AbstractView object

Direct Known Subclasses

Camera, LookAt

Instance Attribute Summary collapse

Attributes inherited from Object

#comment, #kml_id, #master_only

Instance Method Summary collapse

Methods inherited from Object

#_alternate_to_kml, #change, #master_only?, parse

Constructor Details

#initialize(className, point, options = {}) ⇒ AbstractView

Returns a new instance of AbstractView.



578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
# File 'lib/kamelopard/classes.rb', line 578

def initialize(className, point, options = {})
    raise "className argument must not be nil" if className.nil?

    @heading = 0
    @tilt = 0
    @roll = nil
    @range = nil
    @altitudeMode = :clampToGround
    @viewerOptions = {}

    super options

    @className = className
    self.point= point unless point.nil?
end

Instance Attribute Details

#altitudeModeObject

Returns the value of attribute altitudeMode.



574
575
576
# File 'lib/kamelopard/classes.rb', line 574

def altitudeMode
  @altitudeMode
end

#classNameObject (readonly)

Returns the value of attribute className.



576
577
578
# File 'lib/kamelopard/classes.rb', line 576

def className
  @className
end

#headingObject

Returns the value of attribute heading.



574
575
576
# File 'lib/kamelopard/classes.rb', line 574

def heading
  @heading
end

#pointObject

Returns the value of attribute point.



576
577
578
# File 'lib/kamelopard/classes.rb', line 576

def point
  @point
end

#rangeObject

Returns the value of attribute range.



574
575
576
# File 'lib/kamelopard/classes.rb', line 574

def range
  @range
end

#rollObject

Returns the value of attribute roll.



574
575
576
# File 'lib/kamelopard/classes.rb', line 574

def roll
  @roll
end

#tiltObject

Returns the value of attribute tilt.



574
575
576
# File 'lib/kamelopard/classes.rb', line 574

def tilt
  @tilt
end

#timespanObject

Returns the value of attribute timespan.



574
575
576
# File 'lib/kamelopard/classes.rb', line 574

def timespan
  @timespan
end

#timestampObject

Returns the value of attribute timestamp.



574
575
576
# File 'lib/kamelopard/classes.rb', line 574

def timestamp
  @timestamp
end

#viewerOptionsObject

Returns the value of attribute viewerOptions.



574
575
576
# File 'lib/kamelopard/classes.rb', line 574

def viewerOptions
  @viewerOptions
end

Instance Method Details

#[](a) ⇒ Object



679
680
681
# File 'lib/kamelopard/classes.rb', line 679

def [](a)
    return @viewerOptions[a]
end

#[]=(a, b) ⇒ Object



683
684
685
686
687
688
689
690
691
# File 'lib/kamelopard/classes.rb', line 683

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

#altitudeObject



615
616
617
# File 'lib/kamelopard/classes.rb', line 615

def altitude
    @point.nil? ? nil : @point.altitude
end

#altitude=(a) ⇒ Object



635
636
637
638
639
640
641
# File 'lib/kamelopard/classes.rb', line 635

def altitude=(a)
    if @point.nil? then
        @point = Point.new(0, 0, a)
    else
        @point.altitude = a
    end
end

#latitudeObject



611
612
613
# File 'lib/kamelopard/classes.rb', line 611

def latitude
    @point.nil? ? nil : @point.latitude
end

#latitude=(a) ⇒ Object



627
628
629
630
631
632
633
# File 'lib/kamelopard/classes.rb', line 627

def latitude=(a)
    if @point.nil? then
        @point = Point.new(0, a)
    else
        @point.latitude = a
    end
end

#longitudeObject



607
608
609
# File 'lib/kamelopard/classes.rb', line 607

def longitude
    @point.nil? ? nil : @point.longitude
end

#longitude=(a) ⇒ Object



619
620
621
622
623
624
625
# File 'lib/kamelopard/classes.rb', line 619

def longitude=(a)
    if @point.nil? then
        @point = Point.new(a, 0)
    else
        @point.longitude = a
    end
end

#to_kml(elem = nil) ⇒ Object



643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
# File 'lib/kamelopard/classes.rb', line 643

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



675
676
677
# File 'lib/kamelopard/classes.rb', line 675

def to_queries_txt(name = '', planet = 'earth')
    return "#{planet}@#{name}@flytoview=" + self.to_kml.to_s.gsub(/^\s+/, '').gsub("\n", '')
end