]> git.openstreetmap.org Git - rails.git/blobdiff - lib/osm.rb
remove timeout
[rails.git] / lib / osm.rb
index 9e2ab04ada1cc752c39f739d5763a40a5d7b271a..33a6f2c5726266caa5f3c93aed3fe359d0891553 100644 (file)
@@ -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