X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/89e976c6e57c9aa8afae00437aaf4399ea5fc58f..d95c17e4f7ddcbb54db4f57472f1ab735e61fb16:/lib/osm.rb diff --git a/lib/osm.rb b/lib/osm.rb index 9e2ab04ad..33a6f2c57 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -68,14 +68,12 @@ module OSM attr_reader :tracksegs def initialize(filename) - @filename = filename @possible_points = 0 @actual_points = 0 @tracksegs = 0 - end + @points = [] - def points - file = File.new(@filename) + file = File.new(filename) parser = REXML::Parsers::SAX2Parser.new( file ) lat = -1 @@ -114,7 +112,7 @@ module OSM ele = '0' unless gotele if lat < 90 && lat > -90 && lon > -180 && lon < 180 @actual_points += 1 - yield Hash['latitude' => lat,'longitude' => lon,'timestamp' => date,'altitude' => ele,'segment' => @tracksegs] + @points.push(Hash['latitude' => lat,'longitude' => lon,'timestamp' => date,'altitude' => ele,'segment' => @tracksegs]) end end gotlatlon = false @@ -124,6 +122,10 @@ module OSM parser.parse end + def points + @points.each { |p| yield p } + end + def get_picture(min_lat, min_lon, max_lat, max_lon, num_points) #puts "getting picfor bbox #{min_lat},#{min_lon} - #{max_lat},#{max_lon}" frames = 10 @@ -300,7 +302,7 @@ module OSM lat_el << latitude.to_s item << lat_el - lon_el = XML::Node.new 'geo:lon' + lon_el = XML::Node.new 'geo:long' lon_el << longitude.to_s item << lon_el