class GpxUtils::WaypointsImporter
Attributes
pois[R]
Public Class Methods
new()
click to toggle source
# File lib/gpx_utils/waypoints_importer.rb, line 8 def initialize @pois = Array.new end
Public Instance Methods
add_file(y)
click to toggle source
# File lib/gpx_utils/waypoints_importer.rb, line 14 def add_file(y) @pois += parse_gpx_file(y) end
parse_gpx_file(path)
click to toggle source
# File lib/gpx_utils/waypoints_importer.rb, line 18 def parse_gpx_file(path) f = File.new(path) doc = Nokogiri::XML(f) doc.remove_namespaces! a = Array.new trackpoints = doc.xpath('//gpx/wpt') trackpoints.each do |wpt| w = { :lat => wpt.xpath('@lat').to_s.to_f, :lon => wpt.xpath('@lon').to_s.to_f, :time => GpxUtils::TrackImporter.proc_time(wpt.xpath('time').children.first.to_s), :alt => wpt.xpath('ele').children.first.to_s.to_f, :name => wpt.xpath('name').children.first.to_s, :sym => wpt.xpath('sym').children.first.to_s } a << w end f.close return a end