Class: Model

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

Overview

Corresponds to the KML Model class

Instance Attribute Summary collapse

Attributes inherited from KMLObject

#comment, #id

Instance Method Summary collapse

Constructor Details

#initialize(link, location, orientation, scale, resourceMap) ⇒ Model

location should be a KMLPoint, or some object that can behave like one, including a Placemark. Model will get its Location and altitudeMode data from this attribute



1678
1679
1680
1681
1682
1683
1684
1685
# File 'lib/kamelopard/classes.rb', line 1678

def initialize(link, location, orientation, scale, resourceMap)
    super()
    @link = link
    @location = location
    @orientation = orientation
    @scale = scale
    @resourceMap = resourceMap
end

Instance Attribute Details

Returns the value of attribute link.



1673
1674
1675
# File 'lib/kamelopard/classes.rb', line 1673

def link
  @link
end

#locationObject

Returns the value of attribute location.



1673
1674
1675
# File 'lib/kamelopard/classes.rb', line 1673

def location
  @location
end

#orientationObject

Returns the value of attribute orientation.



1673
1674
1675
# File 'lib/kamelopard/classes.rb', line 1673

def orientation
  @orientation
end

#resourceMapObject

Returns the value of attribute resourceMap.



1673
1674
1675
# File 'lib/kamelopard/classes.rb', line 1673

def resourceMap
  @resourceMap
end

#scaleObject

Returns the value of attribute scale.



1673
1674
1675
# File 'lib/kamelopard/classes.rb', line 1673

def scale
  @scale
end

Instance Method Details

#to_kml(indent = 0) ⇒ Object



1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
# File 'lib/kamelopard/classes.rb', line 1687

def to_kml(indent = 0)
    k = "#{ ' ' * indent }<Model id=\"#{ @id }\">\n"
    k << @link.to_kml(indent + 4)
    if @location.altitudeMode == :clampToGround or @location.altitudeMode == :relativeToGround or @location.altitudeMode == :absolute then
        k << "#{ ' ' * indent }    <altitudeMode>#{ @location.altitudeMode }</altitudeMode>\n"
    else
        k << "#{ ' ' * indent }    <gx:altitudeMode>#{ @location.altitudeMode }</gx:altitudeMode>\n"
    end
    k << "#{ ' ' * indent }    <Location>\n"
    k << "#{ ' ' * indent }        <longitude>#{ @location.longitude }</longitude>\n"
    k << "#{ ' ' * indent }        <latitude>#{ @location.latitude }</latitude>\n"
    k << "#{ ' ' * indent }        <altitude>#{ @location.altitude }</altitude>\n"
    k << "#{ ' ' * indent }    </Location>\n"
    k << @orientation.to_kml(indent + 4)
    k << @scale.to_kml(indent + 4)
    k << @resourceMap.to_kml(indent + 4)
    k << "#{ ' ' * indent }</Model>\n"
    k
end