Class: AbstractView
Overview
Abstract class corresponding to KML’s AbstractView object
Instance Attribute Summary collapse
-
#altitudeMode ⇒ Object
Returns the value of attribute altitudeMode.
-
#heading ⇒ Object
Returns the value of attribute heading.
-
#options ⇒ Object
Returns the value of attribute options.
-
#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.
Attributes inherited from KMLObject
Instance Method Summary collapse
- #[](a) ⇒ Object
- #[]=(a, b) ⇒ Object
- #altitude ⇒ Object
- #altitude=(a) ⇒ Object
-
#initialize(className, point = nil, heading = 0, tilt = 0, roll = 0, range = 0, altitudeMode = :clampToGround) ⇒ AbstractView
constructor
A new instance of AbstractView.
- #latitude ⇒ Object
- #latitude=(a) ⇒ Object
- #longitude ⇒ Object
- #longitude=(a) ⇒ Object
- #to_kml(indent = 0) ⇒ Object
Constructor Details
#initialize(className, point = nil, heading = 0, tilt = 0, roll = 0, range = 0, altitudeMode = :clampToGround) ⇒ AbstractView
Returns a new instance of AbstractView.
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 |
# File 'lib/kamelopard/classes.rb', line 328 def initialize(className, point = nil, heading = 0, tilt = 0, roll = 0, range = 0, altitudeMode = :clampToGround) raise "className argument must not be nil" if className.nil? super() @point = point @options = {} @className = className if point.nil? then @point = nil elsif point.kind_of? Placemark then @point = point.point else @point = point end @heading = heading @tilt = tilt @roll = roll @range = range @altitudeMode = altitudeMode end |
Instance Attribute Details
#altitudeMode ⇒ Object
Returns the value of attribute altitudeMode.
327 328 329 |
# File 'lib/kamelopard/classes.rb', line 327 def altitudeMode @altitudeMode end |
#heading ⇒ Object
Returns the value of attribute heading.
327 328 329 |
# File 'lib/kamelopard/classes.rb', line 327 def heading @heading end |
#options ⇒ Object
Returns the value of attribute options.
327 328 329 |
# File 'lib/kamelopard/classes.rb', line 327 def @options end |
#point ⇒ Object
Returns the value of attribute point.
327 328 329 |
# File 'lib/kamelopard/classes.rb', line 327 def point @point end |
#range ⇒ Object
Returns the value of attribute range.
327 328 329 |
# File 'lib/kamelopard/classes.rb', line 327 def range @range end |
#roll ⇒ Object
Returns the value of attribute roll.
327 328 329 |
# File 'lib/kamelopard/classes.rb', line 327 def roll @roll end |
#tilt ⇒ Object
Returns the value of attribute tilt.
327 328 329 |
# File 'lib/kamelopard/classes.rb', line 327 def tilt @tilt end |
#timespan ⇒ Object
Returns the value of attribute timespan.
327 328 329 |
# File 'lib/kamelopard/classes.rb', line 327 def timespan @timespan end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
327 328 329 |
# File 'lib/kamelopard/classes.rb', line 327 def @timestamp end |
Instance Method Details
#[](a) ⇒ Object
423 424 425 |
# File 'lib/kamelopard/classes.rb', line 423 def [](a) return @options[a] end |
#[]=(a, b) ⇒ Object
427 428 429 430 431 432 433 434 435 |
# File 'lib/kamelopard/classes.rb', line 427 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 @options[a] = b end |
#altitude ⇒ Object
362 363 364 |
# File 'lib/kamelopard/classes.rb', line 362 def altitude @point.nil? ? nil : @point.altitude end |
#altitude=(a) ⇒ Object
382 383 384 385 386 387 388 |
# File 'lib/kamelopard/classes.rb', line 382 def altitude=(a) if @point.nil? then @point = KMLPoint.new(0, 0, a) else @point.altitude = a end end |
#latitude ⇒ Object
358 359 360 |
# File 'lib/kamelopard/classes.rb', line 358 def latitude @point.nil? ? nil : @point.latitude end |
#latitude=(a) ⇒ Object
374 375 376 377 378 379 380 |
# File 'lib/kamelopard/classes.rb', line 374 def latitude=(a) if @point.nil? then @point = KMLPoint.new(0, a) else @point.latitude = a end end |
#longitude ⇒ Object
354 355 356 |
# File 'lib/kamelopard/classes.rb', line 354 def longitude @point.nil? ? nil : @point.longitude end |
#longitude=(a) ⇒ Object
366 367 368 369 370 371 372 |
# File 'lib/kamelopard/classes.rb', line 366 def longitude=(a) if @point.nil? then @point = KMLPoint.new(a, 0) else @point.longitude = a end end |
#to_kml(indent = 0) ⇒ Object
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
# File 'lib/kamelopard/classes.rb', line 390 def to_kml(indent = 0) t = "#{ ' ' * indent }<#{ @className } id=\"#{ @id }\">\n" t << super(indent) t << kml_array([ [ @point.nil? ? nil : @point.longitude, 'longitude', true ], [ @point.nil? ? nil : @point.latitude, 'latitude', true ], [ @point.nil? ? nil : @point.altitude, 'altitude', true ], [ @heading, 'heading', true ], [ @tilt, 'tilt', true ], [ @range, 'range', true ], [ @roll, 'roll', true ] ], indent + 4) if @altitudeMode == :clampToGround or @altitudeMode == :relativeToGround or @altitudeMode == :absolute then t << "#{ ' ' * indent } <altitudeMode>#{ @altitudeMode }</altitudeMode>\n" else t << "#{ ' ' * indent } <gx:altitudeMode>#{ @altitudeMode }</gx:altitudeMode>\n" end if @options.keys.length > 0 then t << "#{ ' ' * indent } <gx:ViewerOptions>\n" @options.each do |k, v| t << "#{ ' ' * ( indent + 8 ) }<gx:option name=\"#{ k }\" enabled=\"#{ v ? 'true' : 'false' }\" />\n" end t << "#{ ' ' * indent } </gx:ViewerOptions>\n" end if not @timestamp.nil? then t << @timestamp.to_kml(indent+4, 'gx') elsif not @timespan.nil? then t << @timespan.to_kml(indent+4, 'gx') end t << "#{ ' ' * indent }</#{ @className }>\n" t end |