forked from hans/Nominatim
coding style and some documentation
This commit is contained in:
@@ -846,7 +846,7 @@ class Geocode
|
|||||||
$this->aRouteWidth,
|
$this->aRouteWidth,
|
||||||
$this->bBoundedSearch
|
$this->bBoundedSearch
|
||||||
);
|
);
|
||||||
} else if ($this->aViewBox) {
|
} elseif ($this->aViewBox) {
|
||||||
$oCtx->setViewboxFromBox($this->aViewBox, $this->bBoundedSearch);
|
$oCtx->setViewboxFromBox($this->aViewBox, $this->bBoundedSearch);
|
||||||
}
|
}
|
||||||
if ($this->aExcludePlaceIDs) {
|
if ($this->aExcludePlaceIDs) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ require_once(CONST_BasePath.'/lib/lib.php');
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects search constraints that are independent of the
|
* Collection of search constraints that are independent of the
|
||||||
* actual interpretation of the search query.
|
* actual interpretation of the search query.
|
||||||
*
|
*
|
||||||
* The search context is shared between all SearchDescriptions. This
|
* The search context is shared between all SearchDescriptions. This
|
||||||
@@ -15,16 +15,25 @@ require_once(CONST_BasePath.'/lib/lib.php');
|
|||||||
*/
|
*/
|
||||||
class SearchContext
|
class SearchContext
|
||||||
{
|
{
|
||||||
|
/// Search radius around a given Near reference point.
|
||||||
private $fNearRadius = false;
|
private $fNearRadius = false;
|
||||||
|
/// True if search must be restricted to viewbox only.
|
||||||
public $bViewboxBounded = false;
|
public $bViewboxBounded = false;
|
||||||
|
|
||||||
|
/// Reference point for search (as SQL).
|
||||||
public $sqlNear = '';
|
public $sqlNear = '';
|
||||||
|
/// Viewbox selected for search (as SQL).
|
||||||
public $sqlViewboxSmall = '';
|
public $sqlViewboxSmall = '';
|
||||||
|
/// Viewbox with a larger buffer around (as SQL).
|
||||||
public $sqlViewboxLarge = '';
|
public $sqlViewboxLarge = '';
|
||||||
|
/// Reference along a route (as SQL).
|
||||||
public $sqlViewboxCentre = '';
|
public $sqlViewboxCentre = '';
|
||||||
|
/// List of countries to restrict search to (as SQL).
|
||||||
public $sqlCountryList = '';
|
public $sqlCountryList = '';
|
||||||
|
/// List of place IDs to exclude (as SQL).
|
||||||
private $sqlExcludeList = '';
|
private $sqlExcludeList = '';
|
||||||
|
|
||||||
|
|
||||||
public function hasNearPoint()
|
public function hasNearPoint()
|
||||||
{
|
{
|
||||||
return $this->fNearRadius !== false;
|
return $this->fNearRadius !== false;
|
||||||
@@ -44,7 +53,6 @@ class SearchContext
|
|||||||
public function isBoundedSearch()
|
public function isBoundedSearch()
|
||||||
{
|
{
|
||||||
return $this->hasNearPoint() || ($this->sqlViewboxSmall && $this->bViewboxBounded);
|
return $this->hasNearPoint() || ($this->sqlViewboxSmall && $this->bViewboxBounded);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setViewboxFromBox(&$aViewBox, $bBounded)
|
public function setViewboxFromBox(&$aViewBox, $bBounded)
|
||||||
|
|||||||
@@ -73,23 +73,6 @@ class SearchDescription
|
|||||||
&& preg_match('/[0-9]+/', $this->sHouseNumber);
|
&& 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()
|
public function hasOperator()
|
||||||
{
|
{
|
||||||
return $this->iOperator != Operator::NONE;
|
return $this->iOperator != Operator::NONE;
|
||||||
@@ -335,6 +318,7 @@ class SearchDescription
|
|||||||
|
|
||||||
/////////// Query functions
|
/////////// Query functions
|
||||||
|
|
||||||
|
|
||||||
public function query(&$oDB, &$aWordFrequencyScores, &$aExactMatchCache, $iMinRank, $iMaxRank, $iLimit)
|
public function query(&$oDB, &$aWordFrequencyScores, &$aExactMatchCache, $iMinRank, $iMaxRank, $iLimit)
|
||||||
{
|
{
|
||||||
$aPlaceIDs = array();
|
$aPlaceIDs = array();
|
||||||
@@ -450,7 +434,7 @@ class SearchDescription
|
|||||||
}
|
}
|
||||||
if ($this->oContext->hasNearPoint()) {
|
if ($this->oContext->hasNearPoint()) {
|
||||||
$sSQL .= ' WHERE '.$this->oContext->withinSQL('ct.centroid');
|
$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)';
|
$sSQL .= ' WHERE ST_Contains('.$this->oContext->sqlViewboxSmall.', ct.centroid)';
|
||||||
}
|
}
|
||||||
if ($this->oContext->sqlCountryList) {
|
if ($this->oContext->sqlCountryList) {
|
||||||
@@ -869,6 +853,22 @@ class SearchDescription
|
|||||||
return $aClassPlaceIDs;
|
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
|
/////////// Sort functions
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user