X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/124cd67ac83cac270f35a078c31e0c03fb328c5d..4769eec5aab27cdb0ae6ac1b7bb713da720feb93:/lib/osm.rb diff --git a/lib/osm.rb b/lib/osm.rb index 9e2ab04ad..6c3cf07c4 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