Class: 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.



1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
# File 'lib/kamelopard/classes.rb', line 1420

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

Instance Attribute Details

#altitudeModeObject

Returns the value of attribute altitudeMode.



1418
1419
1420
# File 'lib/kamelopard/classes.rb', line 1418

def altitudeMode
  @altitudeMode
end

#eastObject

Returns the value of attribute east.



1417
1418
1419
# File 'lib/kamelopard/classes.rb', line 1417

def east
  @east
end

#maxAltitudeObject

Returns the value of attribute maxAltitude.



1418
1419
1420
# File 'lib/kamelopard/classes.rb', line 1418

def maxAltitude
  @maxAltitude
end

#minAltitudeObject

Returns the value of attribute minAltitude.



1418
1419
1420
# File 'lib/kamelopard/classes.rb', line 1418

def minAltitude
  @minAltitude
end

#northObject

Returns the value of attribute north.



1417
1418
1419
# File 'lib/kamelopard/classes.rb', line 1417

def north
  @north
end

#rotationObject

Returns the value of attribute rotation.



1418
1419
1420
# File 'lib/kamelopard/classes.rb', line 1418

def rotation
  @rotation
end

#southObject

Returns the value of attribute south.



1417
1418
1419
# File 'lib/kamelopard/classes.rb', line 1417

def south
  @south
end

#westObject

Returns the value of attribute west.



1417
1418
1419
# File 'lib/kamelopard/classes.rb', line 1417

def west
  @west
end

Instance Method Details

#to_kml(indent = 0, alt = false) ⇒ Object



1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
# File 'lib/kamelopard/classes.rb', line 1447

def to_kml(indent = 0, alt = false)
    name = alt ? 'LatLonAltBox' : 'LatLonBox'
    k = <<-latlonbox
#{ ' ' * indent }<#{ name }>
#{ ' ' * indent }    <north>#{ @north }</north>
#{ ' ' * indent }    <south>#{ @south }</south>
#{ ' ' * indent }    <east>#{ @east }</east>
#{ ' ' * indent }    <west>#{ @west }</west>
    latlonbox
    k << "#{ ' ' * indent }    <minAltitude>#{ @minAltitude }</minAltitude>\n" unless @minAltitude.nil?
    k << "#{ ' ' * indent }    <maxAltitude>#{ @maxAltitude }</maxAltitude>\n" unless @maxAltitude.nil?
    if (not @minAltitude.nil? or not @maxAltitude.nil?) then
        if @altitudeMode == :clampToGround or @altitudeMode == :relativeToGround or @altitudeMode == :absolute then
            altitudeModeString = "#{ ' ' * indent }    <altitudeMode>#{ @altitudeMode }</altitudeMode>\n"
        else
            altitudeModeString = "#{ ' ' * indent }    <gx:altitudeMode>#{ @altitudeMode }</gx:altitudeMode>\n"
        end
    end
    k << <<-latlonbox2
#{ ' ' * indent }    <rotation>#{ @rotation }</rotation>
#{ ' ' * indent }</#{ name }>
    latlonbox2
end