Advise what can parse GPX file in Ruby?
I tried:
http://github.com/dougfales/gpx - it does not work with Ruby Enterprise Edition (http://github.com/dougfales/gpx/issues # issue / 1)
I would not like to write a parser
Advise what can parse GPX file in Ruby?
I tried:
http://github.com/dougfales/gpx - it does not work with Ruby Enterprise Edition (http://github.com/dougfales/gpx/issues # issue / 1)
I would not like to write a parser
I was looking for the same thing but in the end a GPX file is just another XML file so you can parse it with XML parsing libraries like Nokogiri. Here is how I extract all the latitudes and longitudes form a GPX log:
#!/usr/bin/env ruby
require 'rubygems'
require 'nokogiri'
doc = Nokogiri::XML(open(my-log.gpx))
trackpoints = doc.xpath('//xmlns:trkpt/')
points = Array.new
trackpoints.each do |trkpt|
points << [trkpt.xpath('@lat').to_s.to_f, trkpt.xpath('@lon').to_s.to_f]
end
There are probably better ways to do this but this works for me.