]> git.openstreetmap.org Git - nominatim.git/commitdiff
slightly relax viewbox parameter check
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 13 Oct 2016 06:03:28 +0000 (08:03 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 13 Oct 2016 06:03:28 +0000 (08:03 +0200)
Allow out of bounds parameters as long as the resulting box
covers some legal coodinates.

lib/Geocode.php

index 273fc0f006ff12361fdd106ad30c69d89f1ebdbe..7fa349cacefdfddf5d1fb2fed9932e317a1b9327 100644 (file)
@@ -180,14 +180,15 @@ class Geocode
     {
         $this->aViewBox = array_map('floatval', $aViewbox);
 
     {
         $this->aViewBox = array_map('floatval', $aViewbox);
 
-        if ($this->aViewBox[0] < -180
-            || $this->aViewBox[2] > 180
-            || $this->aViewBox[0] >= $this->aViewBox[2]
-            || $this->aViewBox[1] < -90
-            || $this->aViewBox[3] > 90
-            || $this->aViewBox[1] >= $this->aViewBox[3]
+        $this->aViewBox[0] = max(-180.0, min(180, $this->aViewBox[0]));
+        $this->aViewBox[1] = max(-90.0, min(90, $this->aViewBox[1]));
+        $this->aViewBox[2] = max(-180.0, min(180, $this->aViewBox[2]));
+        $this->aViewBox[3] = max(-90.0, min(90, $this->aViewBox[3]));
+
+        if (abs($this->aViewBox[0] - $this->aViewBox[2]) < 0.000000001
+            || abs($this->aViewBox[1] - $this->aViewBox[3]) < 0.000000001
         ) {
         ) {
-            userError("Bad parameter 'viewbox'. Out of range.");
+            userError("Bad parameter 'viewbox'. Not a box.");
         }
 
         $fHeight = $this->aViewBox[0] - $this->aViewBox[2];
         }
 
         $fHeight = $this->aViewBox[0] - $this->aViewBox[2];