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

Instance Method Summary collapse

Methods inherited from Object

#change

Constructor Details

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

Returns a new instance of AbstractView.



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/kamelopard/classes.rb', line 355

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

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

    super options

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

Instance Attribute Details

#altitudeModeObject

Returns the value of attribute altitudeMode.



352
353
354
# File 'lib/kamelopard/classes.rb', line 352

def altitudeMode
  @altitudeMode
end

#classNameObject (readonly)

Returns the value of attribute className.



353
354
355
# File 'lib/kamelopard/classes.rb', line 353

def className
  @className
end

#headingObject

Returns the value of attribute heading.



352
353
354
# File 'lib/kamelopard/classes.rb', line 352

def heading
  @heading
end

#pointObject

Returns the value of attribute point.



353
354
355
# File 'lib/kamelopard/classes.rb', line 353

def point
  @point
end

#rangeObject

Returns the value of attribute range.



352
353
354
# File 'lib/kamelopard/classes.rb', line 352

def range
  @range
end

#rollObject

Returns the value of attribute roll.



352
353
354
# File 'lib/kamelopard/classes.rb', line 352

def roll
  @roll
end

#tiltObject

Returns the value of attribute tilt.



352
353
354
# File 'lib/kamelopard/classes.rb', line 352

def tilt
  @tilt
end

#timespanObject

Returns the value of attribute timespan.



352
353
354
# File 'lib/kamelopard/classes.rb', line 352

def timespan
  @timespan
end

#timestampObject

Returns the value of attribute timestamp.



352
353
354
# File 'lib/kamelopard/classes.rb', line 352

def timestamp
  @timestamp
end

#viewerOptionsObject

Returns the value of attribute viewerOptions.



352
353
354
# File 'lib/kamelopard/classes.rb', line 352

def viewerOptions
  @viewerOptions
end

Instance Method Details

#[](a) ⇒ Object



452
453
454
# File 'lib/kamelopard/classes.rb', line 452

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

#[]=(a, b) ⇒ Object



456
457
458
459
460
461
462
463
464
# File 'lib/kamelopard/classes.rb', line 456

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



392
393
394
# File 'lib/kamelopard/classes.rb', line 392

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

#altitude=(a) ⇒ Object



412
413
414
415
416
417
418
# File 'lib/kamelopard/classes.rb', line 412

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

#latitudeObject



388
389
390
# File 'lib/kamelopard/classes.rb', line 388

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

#latitude=(a) ⇒ Object



404
405
406
407
408
409
410
# File 'lib/kamelopard/classes.rb', line 404

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

#longitudeObject



384
385
386
# File 'lib/kamelopard/classes.rb', line 384

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

#longitude=(a) ⇒ Object



396
397
398
399
400
401
402
# File 'lib/kamelopard/classes.rb', line 396

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

#to_kml(elem = nil) ⇒ Object



420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
# File 'lib/kamelopard/classes.rb', line 420

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