]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/SearchContext.php
Merge pull request #2102 from mtmail/typo-in-reverse-md
[nominatim.git] / lib / SearchContext.php
index c0ae903295073b237bb44e19bc30b440ba48f46c..c2898d274b44266aa567fb74cddfd9790a67df13 100644 (file)
@@ -32,7 +32,18 @@ class SearchContext
     public $sqlCountryList = '';
     /// List of place IDs to exclude (as SQL).
     private $sqlExcludeList = '';
+    /// Subset of word ids of full words in the query.
+    private $aFullNameWords = array();
 
+    public function setFullNameWords($aWordList)
+    {
+        $this->aFullNameWords = $aWordList;
+    }
+
+    public function getFullNameTerms()
+    {
+        return $this->aFullNameWords;
+    }
 
     /**
      * Check if a reference point is defined.
@@ -108,8 +119,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 +137,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 +157,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";
     }
 
@@ -203,7 +214,7 @@ class SearchContext
     }
 
     /**
-     * Get an SQL snipped for computing the distance from the reference point.
+     * Get an SQL snippet for computing the distance from the reference point.
      *
      * @param string $sObj SQL variable name to compute the distance from.
      *
@@ -215,7 +226,7 @@ class SearchContext
     }
 
     /**
-     * Get an SQL snipped for checking if something is within range of the
+     * Get an SQL snippet for checking if something is within range of the
      * reference point.
      *
      * @param string $sObj SQL variable name to compute if it is within range.
@@ -228,14 +239,14 @@ class SearchContext
     }
 
     /**
-     * Get an SQL snipped of the importance factor of the viewbox.
+     * Get an SQL snippet of the importance factor of the viewbox.
      *
      * The importance factor is computed by checking if an object is within
      * the viewbox and/or the extended version of the viewbox.
      *
      * @param string $sObj SQL variable name of object to weight the importance
      *
-     * @return string SQL snipped of the factor with a leading multiply sign.
+     * @return string SQL snippet of the factor with a leading multiply sign.
      */
     public function viewboxImportanceSQL($sObj)
     {
@@ -252,7 +263,7 @@ class SearchContext
     }
 
     /**
-     * SQL snipped checking if a place ID should be excluded.
+     * SQL snippet checking if a place ID should be excluded.
      *
      * @param string $sVariable SQL variable name of place ID to check,
      *                          potentially prefixed with more SQL.