Class: Kamelopard::LatLonBox

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

Overview

Corresponds to KML’s LatLonBox and LatLonAltBox

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(north, south, east, west, rotation = 0, minAltitude = nil, maxAltitude = nil, altitudeMode = :clampToGround) ⇒ LatLonBox

Returns a new instance of LatLonBox.



1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
# File 'lib/kamelopard/classes.rb', line 1540

def initialize(north, south, east, west, rotation = 0, minAltitude = nil, maxAltitude = nil, altitudeMode = :clampToGround)
    @north = Kamelopard.convert_coord north
    @south = Kamelopard.convert_coord south
    @east = Kamelopard.convert_coord east
    @west = Kamelopard.convert_coord west
    @minAltitude = minAltitude
    @maxAltitude = maxAltitude
    @altitudeMode = altitudeMode
    @rotation = rotation
end

Instance Attribute Details

#altitudeModeObject

Returns the value of attribute altitudeMode.



1538
1539
1540
# File 'lib/kamelopard/classes.rb', line 1538

def altitudeMode
  @altitudeMode
end

#eastObject

Returns the value of attribute east.



1537
1538
1539
# File 'lib/kamelopard/classes.rb', line 1537

def east
  @east
end

#maxAltitudeObject

Returns the value of attribute maxAltitude.



1538
1539
1540
# File 'lib/kamelopard/classes.rb', line 1538

def maxAltitude
  @maxAltitude
end

#minAltitudeObject

Returns the value of attribute minAltitude.



1538
1539
1540
# File 'lib/kamelopard/classes.rb', line 1538

def minAltitude
  @minAltitude
end

#northObject

Returns the value of attribute north.



1537
1538
1539
# File 'lib/kamelopard/classes.rb', line 1537

def north
  @north
end

#rotationObject

Returns the value of attribute rotation.



1538
1539
1540
# File 'lib/kamelopard/classes.rb', line 1538

def rotation
  @rotation
end

#southObject

Returns the value of attribute south.



1537
1538
1539
# File 'lib/kamelopard/classes.rb', line 1537

def south
  @south
end

#westObject

Returns the value of attribute west.



1537
1538
1539
# File 'lib/kamelopard/classes.rb', line 1537

def west
  @west
end

Instance Method Details

#to_kml(elem = nil, alt = false) ⇒ Object



1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
# File 'lib/kamelopard/classes.rb', line 1567

def to_kml(elem = nil, alt = false)
    name = alt ? 'LatLonAltBox' : 'LatLonBox'
    k = REXML::Element.new name
    [
        ['north', @north], 
        ['south', @south], 
        ['east', @east], 
        ['west', @west],
        ['minAltitude', @minAltitude],
        ['maxAltitude', @maxAltitude]
    ].each do |a|
        if not a[1].nil? then
            m = REXML::Element.new a[0]
            m.text = a[1]
            k.elements << m
        end
    end
    if (not @minAltitude.nil? or not @maxAltitude.nil?) then
        Kamelopard.add_altitudeMode(@altitudeMode, k)
    end
    m = REXML::Element.new 'rotation'
    m.text = @rotation
    k.elements << m
    elem.elements << k unless elem.nil?
    k
end