Class: Kamelopard::Orientation

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

Overview

Sub-object in the KML Model class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(heading, tilt, roll) ⇒ Orientation

Returns a new instance of Orientation.



2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
# File 'lib/kamelopard/classes.rb', line 2314

def initialize(heading, tilt, roll)
    @heading = heading
    # Although the KML reference by Google is clear on these ranges, Google Earth
    # supports values outside the ranges, and sometimes it's useful to use
    # them. So I'm turning off this error checking
    #raise "Heading should be between 0 and 360 inclusive; you gave #{ heading }" unless @heading <= 360 and @heading >= 0
    @tilt = tilt
    #raise "Tilt should be between 0 and 180 inclusive; you gave #{ tilt }" unless @tilt <= 180 and @tilt >= 0
    @roll = roll
    #raise "Roll should be between 0 and 180 inclusive; you gave #{ roll }" unless @roll <= 180 and @roll >= 0
end

Instance Attribute Details

#headingObject

Returns the value of attribute heading.



2313
2314
2315
# File 'lib/kamelopard/classes.rb', line 2313

def heading
  @heading
end

#rollObject

Returns the value of attribute roll.



2313
2314
2315
# File 'lib/kamelopard/classes.rb', line 2313

def roll
  @roll
end

#tiltObject

Returns the value of attribute tilt.



2313
2314
2315
# File 'lib/kamelopard/classes.rb', line 2313

def tilt
  @tilt
end

Instance Method Details

#to_kml(elem = nil) ⇒ Object



2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
# File 'lib/kamelopard/classes.rb', line 2326

def to_kml(elem = nil)
    x = XML::Node.new 'Orientation'
    {
        :heading => @heading,
        :tilt => @tilt,
        :roll => @roll
    }.each do |k, v|
        d = XML::Node.new k.to_s
        d << v.to_s
        x << d
    end
    elem << x unless elem.nil?
    x
end