From: Tom Hughes Date: Sun, 4 Feb 2018 17:42:40 +0000 (+0000) Subject: Make OSM::GreatCircle clamp results to the globe X-Git-Tag: live~3139 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/162ffd9acccc844ab37b4f60b1ff9d5465f43686?ds=sidebyside Make OSM::GreatCircle clamp results to the globe --- diff --git a/lib/osm.rb b/lib/osm.rb index e4835a76b..40027991a 100644 --- a/lib/osm.rb +++ b/lib/osm.rb @@ -475,10 +475,10 @@ module OSM lonradius = PI end - minlat = (@lat - latradius) * 180 / PI - maxlat = (@lat + latradius) * 180 / PI - minlon = (@lon - lonradius) * 180 / PI - maxlon = (@lon + lonradius) * 180 / PI + minlat = [(@lat - latradius) * 180 / PI, -90].max + maxlat = [(@lat + latradius) * 180 / PI, 90].min + minlon = [(@lon - lonradius) * 180 / PI, -180].max + maxlon = [(@lon + lonradius) * 180 / PI, 180].min { :minlat => minlat, :maxlat => maxlat, :minlon => minlon, :maxlon => maxlon } end