/**
- * Collects search constraints that are independent of the
+ * Collection of search constraints that are independent of the
* actual interpretation of the search query.
*
* The search context is shared between all SearchDescriptions. This
*/
class SearchContext
{
+ /// Search radius around a given Near reference point.
private $fNearRadius = false;
+ /// True if search must be restricted to viewbox only.
public $bViewboxBounded = false;
+ /// Reference point for search (as SQL).
public $sqlNear = '';
+ /// Viewbox selected for search (as SQL).
public $sqlViewboxSmall = '';
+ /// Viewbox with a larger buffer around (as SQL).
public $sqlViewboxLarge = '';
+ /// Reference along a route (as SQL).
public $sqlViewboxCentre = '';
+ /// List of countries to restrict search to (as SQL).
public $sqlCountryList = '';
+ /// List of place IDs to exclude (as SQL).
private $sqlExcludeList = '';
+
public function hasNearPoint()
{
return $this->fNearRadius !== false;
public function isBoundedSearch()
{
return $this->hasNearPoint() || ($this->sqlViewboxSmall && $this->bViewboxBounded);
-
}
public function setViewboxFromBox(&$aViewBox, $bBounded)
&& preg_match('/[0-9]+/', $this->sHouseNumber);
}
- private function poiTable()
- {
- return 'place_classtype_'.$this->sClass.'_'.$this->sType;
- }
-
- public function countryCodeSQL($sVar)
- {
- if ($this->sCountryCode) {
- return $sVar.' = \''.$this->sCountryCode."'";
- }
- if ($this->oContext->sqlCountryList) {
- return $sVar.' in '.$this->oContext->sqlCountryList;
- }
-
- return '';
- }
-
public function hasOperator()
{
return $this->iOperator != Operator::NONE;
/////////// Query functions
+
public function query(&$oDB, &$aWordFrequencyScores, &$aExactMatchCache, $iMinRank, $iMaxRank, $iLimit)
{
$aPlaceIDs = array();
}
if ($this->oContext->hasNearPoint()) {
$sSQL .= ' WHERE '.$this->oContext->withinSQL('ct.centroid');
- } else if ($this->oContext->bViewboxBounded) {
+ } elseif ($this->oContext->bViewboxBounded) {
$sSQL .= ' WHERE ST_Contains('.$this->oContext->sqlViewboxSmall.', ct.centroid)';
}
if ($this->oContext->sqlCountryList) {
return $aClassPlaceIDs;
}
+ private function poiTable()
+ {
+ return 'place_classtype_'.$this->sClass.'_'.$this->sType;
+ }
+
+ private function countryCodeSQL($sVar)
+ {
+ if ($this->sCountryCode) {
+ return $sVar.' = \''.$this->sCountryCode."'";
+ }
+ if ($this->oContext->sqlCountryList) {
+ return $sVar.' in '.$this->oContext->sqlCountryList;
+ }
+
+ return '';
+ }
/////////// Sort functions