- xmin -= 0.01; ymin -= 0.01
- xmax += 0.01; ymax += 0.01
-
- # check boundary is sane and area within defined
- # see /config/application.yml
- check_boundaries(xmin, ymin, xmax, ymax)
-
- if POTLATCH_USE_SQL then
- ways = sql_find_ways_in_area(xmin, ymin, xmax, ymax)
- points = sql_find_pois_in_area(xmin, ymin, xmax, ymax)
- relations = sql_find_relations_in_area_and_ways(xmin, ymin, xmax, ymax, ways.collect {|x| x[0]})
- else
- # find the way ids in an area
- nodes_in_area = Node.find_by_area(ymin, xmin, ymax, xmax, :conditions => ["current_nodes.visible = ?", true], :include => :ways)
- ways = nodes_in_area.inject([]) { |sum, node|
- visible_ways = node.ways.select { |w| w.visible? }
- sum + visible_ways.collect { |w| [w.id,w.version] }
- }.uniq
- ways.delete([])
-
- # find the node ids in an area that aren't part of ways
- nodes_not_used_in_area = nodes_in_area.select { |node| node.ways.empty? }
- points = nodes_not_used_in_area.collect { |n| [n.id, n.lon, n.lat, n.tags, n.version] }
-
- # find the relations used by those nodes and ways
- relations = Relation.find_for_nodes(nodes_in_area.collect { |n| n.id }, :conditions => {:visible => true}) +
- Relation.find_for_ways(ways.collect { |w| w[0] }, :conditions => {:visible => true})
- relations = relations.collect { |relation| [relation.id,relation.version] }.uniq
- end
+ amf_handle_error_with_timeout("'whichways'",nil,nil) do
+ enlarge = [(xmax-xmin)/8,0.01].min
+ xmin -= enlarge; ymin -= enlarge
+ xmax += enlarge; ymax += enlarge
+
+ # check boundary is sane and area within defined
+ # see /config/application.yml
+ check_boundaries(xmin, ymin, xmax, ymax)