Class: Geospatial::KML::Placemark
- Inherits:
-
Object
- Object
- Geospatial::KML::Placemark
- Defined in:
- lib/geospatial/kml/placemark.rb
Instance Method Summary collapse
- #bounding_circle ⇒ Object
- #description ⇒ Object
-
#initialize(node) ⇒ Placemark
constructor
A new instance of Placemark.
- #name ⇒ Object
- #polygons ⇒ Object
Constructor Details
#initialize(node) ⇒ Placemark
Returns a new instance of Placemark.
30 31 32 |
# File 'lib/geospatial/kml/placemark.rb', line 30 def initialize(node) @node = node end |
Instance Method Details
#bounding_circle ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/geospatial/kml/placemark.rb', line 46 def bounding_circle if look_at = @node.css("LookAt").first longitude = look_at.css("longitude").first.text.to_f latitude = look_at.css("latitude").first.text.to_f range = look_at.css("range").first.text.to_f center = Location.new(longitude, latitude) return Circle.new(center, range) end end |
#description ⇒ Object
40 41 42 43 44 |
# File 'lib/geospatial/kml/placemark.rb', line 40 def description if node = @node.css("description").first node.text.strip end end |
#name ⇒ Object
34 35 36 37 38 |
# File 'lib/geospatial/kml/placemark.rb', line 34 def name if node = @node.css("name").first node.text.strip end end |
#polygons ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/geospatial/kml/placemark.rb', line 58 def polygons return to_enum(:polygons) unless block_given? @node.css("Polygon").collect do |polygon_node| coordinates_node = polygon_node.css("coordinates").first text = coordinates_node.text.strip coordinates = text.split(/\s+/).collect do |coordinate| Vector.elements(coordinate.split(',').collect(&:to_f).first(2)) end yield Polygon.new(coordinates) end end |