]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/SearchContext.php
README: tiny markdown syntax error
[nominatim.git] / lib / SearchContext.php
index 134b138f6966f77aa3995d029687f6ff4f926edd..84159b83ca21c660112df8d4c8ed27837ff6ce19 100644 (file)
@@ -47,7 +47,7 @@ class SearchContext
     /**
      * Get radius around reference point.
      *
-     * @return float Search radius around refernce point.
+     * @return float Search radius around reference point.
      */
     public function nearRadius()
     {
@@ -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)',
@@ -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 = chksql($oDB->getOne('select '.$sSQL), '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 = chksql($oDB->getOne('select '.$sSQL), 'Could not get large viewbox');
         $this->sqlViewboxLarge = "'".$sGeom."'::geometry";
     }
 
@@ -267,4 +267,18 @@ class SearchContext
 
         return '';
     }
+
+    public function debugInfo()
+    {
+        return array(
+                'Near radius' => $this->fNearRadius,
+                'Near point (SQL)' => $this->sqlNear,
+                'Bounded viewbox' => $this->bViewboxBounded,
+                'Viewbox (SQL, small)' => $this->sqlViewboxSmall,
+                'Viewbox (SQL, large)' => $this->sqlViewboxLarge,
+                'Viewbox (SQL, centre)' => $this->sqlViewboxCentre,
+                'Countries (SQL)' => $this->sqlCountryList,
+                'Excluded IDs (SQL)' => $this->sqlExcludeList
+               );
+    }
 }