##
# 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
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
# 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