Class: Geospatial::KML::Reader
- Inherits:
-
Object
- Object
- Geospatial::KML::Reader
- Defined in:
- lib/geospatial/kml/reader.rb
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(doc) ⇒ Reader
constructor
A new instance of Reader.
- #polygons ⇒ Object
Constructor Details
#initialize(doc) ⇒ Reader
Returns a new instance of Reader.
32 33 34 |
# File 'lib/geospatial/kml/reader.rb', line 32 def initialize(doc) @doc = doc end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
36 37 38 |
# File 'lib/geospatial/kml/reader.rb', line 36 def doc @doc end |
Class Method Details
.load_file(path) ⇒ Object
26 27 28 29 30 |
# File 'lib/geospatial/kml/reader.rb', line 26 def self.load_file(path) doc = File.open(path) {|file| Nokogiri::XML(file)} return self.new(doc) end |
Instance Method Details
#polygons ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/geospatial/kml/reader.rb', line 38 def polygons @doc.css("Polygon").collect do |polygon_node| coordinates_node = polygon_node.css("coordinates").first text = coordinates_node.text.strip text.split(/\s+/).collect{|coordinate| coordinate.split(',').collect(&:to_f)} end end |