]> git.openstreetmap.org Git - rails.git/commitdiff
Stop the API changeset query accepting min_lon etc
authorTom Hughes <tom@compton.nu>
Thu, 27 Oct 2011 20:36:16 +0000 (21:36 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 14 Nov 2011 09:42:57 +0000 (09:42 +0000)
app/controllers/changeset_controller.rb

index f6d35b440f386f67c77674060db1d7465312a852..07a123bf8d53d82681854eb20d5f84347849e100 100644 (file)
@@ -196,14 +196,19 @@ class ChangesetController < ApplicationController
   ##
   # query changesets by bounding box, time, user or open/closed status.
   def query
+    # find any bounding box
+    if params['bbox']
+      bbox = BoundingBox.from_bbox_params(params)
+    end
+
     # create the conditions that the user asked for. some or all of
     # these may be nil.
     changesets = Changeset.scoped
-    changesets, bbox = conditions_bbox(changesets, params)
-    changesets       = conditions_user(changesets, params['user'], params['display_name'])
-    changesets       = conditions_time(changesets, params['time'])
-    changesets       = conditions_open(changesets, params['open'])
-    changesets       = conditions_closed(changesets, params['closed'])
+    changesets = conditions_bbox(changesets, bbox)
+    changesets = conditions_user(changesets, params['user'], params['display_name'])
+    changesets = conditions_time(changesets, params['time'])
+    changesets = conditions_open(changesets, params['open'])
+    changesets = conditions_closed(changesets, params['closed'])
 
     # create the results document
     results = OSM::API.new.get_xml_doc
@@ -266,10 +271,15 @@ class ChangesetController < ApplicationController
           render :template => 'user/no_such_user', :status => :not_found
         end
       end
-      
-      changesets, bbox = conditions_bbox(changesets, params)
+
+      if params[:bbox]
+        bbox = BoundingBox.from_bbox_params(params)
+      elsif params[:minlon] and params[:minlat] and params[:maxlon] and params[:maxlat]
+        bbox = BoundingBox.from_lon_lat_params(params)
+      end
 
       if bbox
+        changesets = conditions_bbox(changesets, bbox)
         bbox_link = render_to_string :partial => "bbox", :object => bbox
       end
       
@@ -313,21 +323,15 @@ private
   # if a bounding box was specified do some sanity checks.
   # restrict changesets to those enclosed by a bounding box
   # we need to return both the changesets and the bounding box
-  def conditions_bbox(changesets, params)
-    if params[:bbox]
-      bbox = BoundingBox.from_bbox_params(params)
-    elsif params[:minlon] and params[:minlat] and params[:maxlon] and params[:maxlat]
-      bbox = BoundingBox.from_lon_lat_params(params)
-    end
+  def conditions_bbox(changesets, bbox)
     if  bbox
       bbox.check_boundaries
       bbox = bbox.to_scaled
       return changesets.where("min_lon < ? and max_lon > ? and min_lat < ? and max_lat > ?",
                               bbox.max_lon.to_i, bbox.min_lon.to_i,
-                              bbox.max_lat.to_i, bbox.min_lat.to_i),
-                              bbox
+                              bbox.max_lat.to_i, bbox.min_lat.to_i)
     else
-      return changesets, bbox
+      return changesets
     end
   end