]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/SearchContext.php
PDOException call in catch was causing exception itself
[nominatim.git] / lib / SearchContext.php
index c0ae903295073b237bb44e19bc30b440ba48f46c..3cb11e8271dc55a4ec982664350ae5ca8bd76fe4 100644 (file)
@@ -108,8 +108,8 @@ class SearchContext
             $aViewBox[3]
         );
 
-        $fHeight = $aViewBox[0] - $aViewBox[2];
-        $fWidth = $aViewBox[1] - $aViewBox[3];
+        $fHeight = abs($aViewBox[0] - $aViewBox[2]);
+        $fWidth = abs($aViewBox[1] - $aViewBox[3]);
 
         $this->sqlViewboxLarge = sprintf(
             'ST_SetSRID(ST_MakeBox2D(ST_Point(%F,%F),ST_Point(%F,%F)),4326)',
@@ -126,7 +126,7 @@ class SearchContext
      * The viewbox may be bounded which means that no search results
      * must be outside the viewbox.
      *
-     * @param object   $oDB          DB connection to use for computing the box.
+     * @param object   $oDB          Nominatim::DB instance to use for computing the box.
      * @param string[] $aRoutePoints List of x,y coordinates along a route.
      * @param float    $fRouteWidth  Buffer around the route to use.
      * @param bool     $bBounded     True if the viewbox bounded.
@@ -146,11 +146,11 @@ class SearchContext
         $this->sqlViewboxCentre .= ")'::geometry,4326)";
 
         $sSQL = 'ST_BUFFER('.$this->sqlViewboxCentre.','.($fRouteWidth/69).')';
-        $sGeom = chksql($oDB->getOne('select '.$sSQL), 'Could not get small viewbox');
+        $sGeom = $oDB->getOne('select '.$sSQL, null, 'Could not get small viewbox');
         $this->sqlViewboxSmall = "'".$sGeom."'::geometry";
 
         $sSQL = 'ST_BUFFER('.$this->sqlViewboxCentre.','.($fRouteWidth/30).')';
-        $sGeom = chksql($oDB->getOne('select '.$sSQL), 'Could not get large viewbox');
+        $sGeom = $oDB->getOne('select '.$sSQL, null, 'Could not get large viewbox');
         $this->sqlViewboxLarge = "'".$sGeom."'::geometry";
     }