]> git.openstreetmap.org Git - rails.git/blob - lib/map_boundary.rb
Optimise the Potlatch whichways and getway calls a bit.
[rails.git] / lib / map_boundary.rb
1 module MapBoundary
2    def check_boundaries(min_lon, min_lat, max_lon, max_lat)
3       # check the bbox is sane
4       unless min_lon <= max_lon
5         raise("The minimum longitude must be less than the maximum longitude, but it wasn't")
6       end
7       unless min_lat <= max_lat
8         raise("The minimum latitude must be less than the maximum latitude, but it wasn't")
9       end
10       unless min_lon >= -180 && min_lat >= -90 && max_lon <= 180 && max_lat <= 90
11         raise("The latitudes must be between -90 and 90, and longitudes between -180 and 180")
12       end
13
14       # check the bbox isn't too large
15       requested_area = (max_lat-min_lat)*(max_lon-min_lon)
16       if requested_area > APP_CONFIG['max_request_area']
17         raise("The maximum bbox size is " + APP_CONFIG['max_request_area'].to_s + 
18           ", and your request was too large. Either request a smaller area, or use planet.osm")
19       end
20     end
21 end