Class: KML::Geometry
- Defined in:
- lib/kml/geometry.rb
Direct Known Subclasses
LineString, LinearRing, Model, MultiGeometry, Point, Polygon
Instance Attribute Summary
Attributes inherited from Container
Attributes inherited from Feature
#address, #address_details, #description, #look_at, #metadata, #name, #phone_number, #region, #snippet, #style_selector, #style_url, #time_primitive
Attributes inherited from Object
Class Method Summary collapse
Instance Method Summary collapse
-
#altitude_mode ⇒ Object
Specifies how altitude components in the <coordinates> element are interpreted.
-
#altitude_mode=(mode) ⇒ Object
Set the altitude mode.
- #altitude_mode_set? ⇒ Boolean
-
#extrude ⇒ Object
Return nil if extrude has not been defined, otherwise return ‘1’ for true or ‘0’ for false.
-
#extrude=(v) ⇒ Object
Set to true to extrude.
-
#extrude? ⇒ Boolean
Specifies whether to connect the point to the ground.
- #parse(node) ⇒ Object
- #render(xm = Builder::XmlMarkup.new(:indent => 2)) ⇒ Object
-
#tessellate ⇒ Object
Return nil if tessellate has not been defined, otherwise return ‘1’ for true or ‘0’ for false.
-
#tessellate=(v) ⇒ Object
Set to true to tessellate.
-
#tessellate? ⇒ Boolean
Specifies whether to allow lines and paths to follow the terrain.
Methods inherited from Feature
#open, #open=, #open?, #visibility, #visibility=, #visibility?
Methods inherited from Object
Constructor Details
This class inherits a constructor from KML::Object
Class Method Details
.parse(node) ⇒ Object
78 79 80 |
# File 'lib/kml/geometry.rb', line 78 def self.parse(node) self.new.parse(node) end |
Instance Method Details
#altitude_mode ⇒ Object
Specifies how altitude components in the <coordinates> element are interpreted. Possible values are:
-
clampToGround - (default) Indicates to ignore an altitude specification (for example, in the
coordinates
). -
relativeToGround - Sets the altitude of the element relative to the actual ground elevation of a particular location. For example, if the ground elevation of a location is exactly at sea level and the altitude for a point is set to 9 meters, then the elevation for the icon of a point placemark elevation is 9 meters with this mode. However, if the same coordinate is set over a location where the ground elevation is 10 meters above sea level, then the elevation of the coordinate is 19 meters. A typical use of this mode is for placing telephone poles or a ski lift.
-
absolute - Sets the altitude of the coordinate relative to sea level, regardless of the actual elevation of the terrain beneath the element. For example, if you set the altitude of a coordinate to 10 meters with an absolute altitude mode, the icon of a point placemark will appear to be at ground level if the terrain beneath is also 10 meters above sea level. If the terrain is 3 meters above sea level, the placemark will appear elevated above the terrain by 7 meters. A typical use of this mode is for aircraft placement.
54 55 56 |
# File 'lib/kml/geometry.rb', line 54 def altitude_mode @altitude_mode || 'clampToGround' end |
#altitude_mode=(mode) ⇒ Object
Set the altitude mode
63 64 65 66 67 68 69 70 |
# File 'lib/kml/geometry.rb', line 63 def altitude_mode=(mode) allowed_modes = %w(clampToGround relativeToGround absolute) if allowed_modes.include?(mode) @altitude_mode = mode else raise ArgumentError, "Must be one of the allowed altitude modes: #{allowed_modes.join(',')}" end end |
#altitude_mode_set? ⇒ Boolean
58 59 60 |
# File 'lib/kml/geometry.rb', line 58 def altitude_mode_set? !(@altitude_mode.nil?) end |
#extrude ⇒ Object
Return nil if extrude has not been defined, otherwise return ‘1’ for true or ‘0’ for false.
16 17 18 19 |
# File 'lib/kml/geometry.rb', line 16 def extrude return nil unless @extrude @extrude ? '1' : '0' end |
#extrude=(v) ⇒ Object
Set to true to extrude.
11 12 13 |
# File 'lib/kml/geometry.rb', line 11 def extrude=(v) @extrude = v end |
#extrude? ⇒ Boolean
Specifies whether to connect the point to the ground. Extrusion requires that the point’s altitude_mode
be either “relativeToGround” or “absolute” and that within the coordinates
, the altitude component be greater than 0 (that is, in the air). Default is false.
6 7 8 |
# File 'lib/kml/geometry.rb', line 6 def extrude? @extrude end |
#parse(node) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/kml/geometry.rb', line 82 def parse(node) super(node) do |cld| case cld.name when 'tessellate' self.tessellate = cld.content else yield cld end end self end |
#render(xm = Builder::XmlMarkup.new(:indent => 2)) ⇒ Object
72 73 74 75 76 |
# File 'lib/kml/geometry.rb', line 72 def render(xm=Builder::XmlMarkup.new(:indent => 2)) xm.extrude(extrude) unless extrude.nil? xm.tessellate(tessellate) unless tessellate.nil? xm.altitudeMode(altitude_mode) if altitude_mode_set? end |
#tessellate ⇒ Object
Return nil if tessellate has not been defined, otherwise return ‘1’ for true or ‘0’ for false.
35 36 37 38 |
# File 'lib/kml/geometry.rb', line 35 def tessellate return nil unless @tessellate @tessellate ? '1' : '0' end |
#tessellate=(v) ⇒ Object
Set to true to tessellate.
30 31 32 |
# File 'lib/kml/geometry.rb', line 30 def tessellate=(v) @tessellate = v end |
#tessellate? ⇒ Boolean
Specifies whether to allow lines and paths to follow the terrain. This specification applies only to LineStrings (paths) and LinearRings (polygons) that have an altitude_mode
of “clampToGround”. Very long lines should enable tessellation so that they follow the curvature of the earth (otherwise, they may go underground and be hidden). Default is false.
25 26 27 |
# File 'lib/kml/geometry.rb', line 25 def tessellate? @tessellate end |