Class: Map::KmlService
- Inherits:
-
Object
- Object
- Map::KmlService
- Includes:
- FileImportBasic
- Defined in:
- lib/map/kml_service.rb
Instance Method Summary collapse
- #coordinates ⇒ Object
-
#initialize(kml) ⇒ KmlService
constructor
A new instance of KmlService.
Methods included from FileImportBasic
#all_latitudes, #all_longitudes, #point_more_north_east, #point_more_south_west, #polygons_rgeo
Constructor Details
#initialize(kml) ⇒ KmlService
Returns a new instance of KmlService.
6 7 8 |
# File 'lib/map/kml_service.rb', line 6 def initialize(kml) @kml = kml end |
Instance Method Details
#coordinates ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/map/kml_service.rb', line 10 def coordinates unless @coordinates xml_doc = if @kml.is_a? Nokogiri::XML::Element @kml else Nokogiri::XML(@kml) end coordinates = xml_doc.xpath(".//*[local-name()='coordinates']") @coordinates = coordinates.to_a.collect do |coordinate| coordinate.text.split(' ').collect do |polygon| string_to_coordinate(polygon) end end end @coordinates end |