]> git.openstreetmap.org Git - rails.git/commitdiff
Convert lat and lon values to integers
authorTom Hughes <tom@compton.nu>
Fri, 21 May 2010 18:51:30 +0000 (19:51 +0100)
committerTom Hughes <tom@compton.nu>
Fri, 21 May 2010 18:51:30 +0000 (19:51 +0100)
Make sure the lat and lon values in changeset bounding box queries
are integers or Postgres will refuse to use the index.

app/controllers/changeset_controller.rb

index d0a357c85c8258436acbc826f8995580f3e43762..e17d652ad262c58ac7eab65257c44d69412664e7 100644 (file)
@@ -345,7 +345,10 @@ private
       raise OSM::APIBadUserInput.new("Minimum longitude should be less than maximum.") unless bbox[0] <= bbox[2]
       raise OSM::APIBadUserInput.new("Minimum latitude should be less than maximum.") unless bbox[1] <= bbox[3]
       return ['min_lon < ? and max_lon > ? and min_lat < ? and max_lat > ?',
       raise OSM::APIBadUserInput.new("Minimum longitude should be less than maximum.") unless bbox[0] <= bbox[2]
       raise OSM::APIBadUserInput.new("Minimum latitude should be less than maximum.") unless bbox[1] <= bbox[3]
       return ['min_lon < ? and max_lon > ? and min_lat < ? and max_lat > ?',
-              bbox[2] * GeoRecord::SCALE, bbox[0] * GeoRecord::SCALE, bbox[3]* GeoRecord::SCALE, bbox[1] * GeoRecord::SCALE]
+              (bbox[2] * GeoRecord::SCALE).to_i,
+              (bbox[0] * GeoRecord::SCALE).to_i,
+              (bbox[3] * GeoRecord::SCALE).to_i,
+              (bbox[1] * GeoRecord::SCALE).to_i]
     else
       return nil
     end
     else
       return nil
     end