Cope with the degenerate case of a GPX file with only a single point.
authorTom Hughes <tom@compton.nu>
Tue, 19 Jun 2007 13:58:44 +0000 (13:58 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 19 Jun 2007 13:58:44 +0000 (13:58 +0000)
lib/osm.rb

index 1941d6dafc41b9532ffd23e6455428bc2d316494..40ec9da3d9f14c88e8bc71507a39bc80a6bb5bba 100644 (file)
@@ -22,10 +22,11 @@ module OSM
       @clat = lat
       @clon = lon
       @degrees_per_pixel = degrees_per_pixel
+      @degrees_per_pixel = 0.0000000001 if @degrees_per_pixel < 0.0000000001
       @width = width
       @height = height
-      @dlon = width / 2 * degrees_per_pixel
-      @dlat = height / 2 * degrees_per_pixel  * cos(@clat * PI / 180)
+      @dlon = width / 2 * @degrees_per_pixel
+      @dlat = height / 2 * @degrees_per_pixel  * cos(@clat * PI / 180)
 
       @tx = xsheet(@clon - @dlon)
       @ty = ysheet(@clat - @dlat)
@@ -197,7 +198,7 @@ module OSM
     end
 
     def get_icon(min_lat, min_lon, max_lat, max_lon)
-      puts "getting icon for bbox #{min_lat},#{min_lon} - #{max_lat},#{max_lon}"
+      #puts "getting icon for bbox #{min_lat},#{min_lon} - #{max_lat},#{max_lon}"
       width = 50
       height = 50
       rat= Math.cos( ((max_lat + min_lat)/2.0) /  180.0 * 3.141592)