- traces = Trace.find(:all, :conditions => ['inserted = ?', false])
-
- if traces and traces.length > 0
- traces.each do |trace|
- begin
-
- logger.info("GPX Import importing #{trace.name} (#{trace.id}) from #{trace.user.email}")
-
- # TODO *nix specific, could do to work on windows... would be functionally inferior though - check for '.gz'
- filetype = `file -b /home/osm/gpx/#{trace.id}.gpx`.chomp
- gzipped = filetype =~ /^gzip/
- zipped = filetype =~ /^Zip/
-
- if gzipped
- logger.info("gzipped")
- filename = "/tmp/#{rand}"
- system("gunzip -c /home/osm/gpx/#{trace.id}.gpx > #{filename}")
- elsif zipped
- logger.info("zipped")
- filename = "/tmp/#{rand}"
- system("unzip -p /home/osm/gpx/#{trace.id}.gpx > #{filename}")
- else
- logger.info("not gzipped")
- filename = "/home/osm/gpx/#{trace.id}.gpx"
- end
-
- gpx = OSM::GPXImporter.new(filename)
-
- f_lat = 0
- f_lon = 0
- first = true