]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master'
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 13 Oct 2016 06:08:04 +0000 (08:08 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 13 Oct 2016 06:08:04 +0000 (08:08 +0200)
lib/Geocode.php
tests/features/api/regression.feature

index fd381c7a10f983adc66e699772399a805ae65697..b5f0c74f9612a1e01e943a277c6414f5f77dbb64 100644 (file)
@@ -180,14 +180,15 @@ class Geocode
     {
         $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];
index 5b7f10ada79026e269e9541497e203b0d510013e..08156d62a46c148e53b4f7f9bb25fc878bee9951 100644 (file)
@@ -178,7 +178,7 @@ Feature: API regression tests
      Scenario: trac #5238
         Given the request parameters
          | bounded | viewbox
-         | 1       | 0,0,1,-1
+         | 1       | -1,0,0,-1
         When sending json search query "sy"
         Then exactly 0 results are returned