X-Git-Url: https://git.openstreetmap.org/nominatim.git/blobdiff_plain/795153b213121c6ec8cc725451d4f20c307b4174..8e0ffde3e0a403d289b91ad720444fd94f3ae210:/lib/SearchDescription.php diff --git a/lib/SearchDescription.php b/lib/SearchDescription.php index b7b4498d..d84c8bf8 100644 --- a/lib/SearchDescription.php +++ b/lib/SearchDescription.php @@ -1,46 +1,8 @@ getConstants(); - - Operator::$aConstantNames = array(); - foreach ($aConstants as $sName => $iValue) { - Operator::$aConstantNames[$iValue] = $sName; - } - } +require_once(CONST_BasePath.'/lib/SpecialSearchOperator.php'); - return Operator::$aConstantNames[$iOperator]; - } -} +namespace Nominatim; /** * Description of a single interpretation of a search query. @@ -79,6 +41,7 @@ class SearchDescription /// Index of phrase currently processed private $iNamePhrase = -1; + public function getRank() { return $this->iSearchRank; @@ -95,9 +58,6 @@ class SearchDescription return $this->sPostcode; } - /** - * Set the geographic search radius. - */ public function setNear(&$oNearPoint) { $this->oNearPoint = $oNearPoint; @@ -110,26 +70,17 @@ class SearchDescription $this->sType = $sType; } - /** - * Check if name or address for the search are specified. - */ public function isNamedSearch() { return sizeof($this->aName) > 0 || sizeof($this->aAddress) > 0; } - /** - * Check if only a country is requested. - */ public function isCountrySearch() { return $this->sCountryCode && sizeof($this->aName) == 0 && !$this->iOperator && !$this->oNearPoint; } - /** - * Check if a search near a geographic location is requested. - */ public function isNearSearch() { return (bool) $this->oNearPoint; @@ -179,13 +130,6 @@ class SearchDescription return $this->iOperator != Operator::NONE; } - /** - * Extract special terms from the query, amend the search - * and return the shortended query. - * - * Only the first special term found will be used but all will - * be removed from the query. - */ public function extractKeyValuePairs($sQuery) { // Search for terms of kind [=]. @@ -225,6 +169,7 @@ class SearchDescription /////////// Search building functions + public function extendWithFullTerm($aSearchTerm, $bWordInQuery, $bHasPartial, $sPhraseType, $bFirstToken, $bFirstPhrase, $bLastToken, &$iGlobalRank) { $aNewSearches = array(); @@ -335,8 +280,7 @@ class SearchDescription $oSearch->iSearchRank++; $oSearch->aAddress[$iWordID] = $iWordID; $aNewSearches[] = $oSearch; - } - else { + } else { $this->aFullNameAddress[$iWordID] = $iWordID; } } else { @@ -393,7 +337,7 @@ class SearchDescription $aNewSearches[] = $oSearch; } } - } + } } if ((!$this->sPostcode && !$this->aAddress && !$this->aAddressNonSearch) @@ -421,6 +365,7 @@ class SearchDescription /////////// Query functions + public function queryCountry(&$oDB, $sViewboxSQL) { $sSQL = 'SELECT place_id FROM placex '; @@ -490,7 +435,7 @@ class SearchDescription public function queryPostcode(&$oDB, $sCountryList, $iLimit) { - $sSQL = 'SELECT p.place_id FROM location_postcode p '; + $sSQL = 'SELECT p.place_id FROM location_postcode p '; if (sizeof($this->aAddress)) { $sSQL .= ', search_name s '; @@ -592,7 +537,7 @@ class SearchDescription } if ($sViewboxSmall) { - $aTerms[] = 'centroid && '.$sViewboxSmall; + $aTerms[] = 'centroid && '.$sViewboxSmall; } if ($this->oNearPoint) { @@ -895,7 +840,8 @@ class SearchDescription /////////// Sort functions - static function bySearchRank($a, $b) + + public static function bySearchRank($a, $b) { if ($a->iSearchRank == $b->iSearchRank) { return $a->iOperator + strlen($a->sHouseNumber) @@ -907,9 +853,12 @@ class SearchDescription //////////// Debugging functions - function dumpAsHtmlTableRow(&$aWordIDs) + + public function dumpAsHtmlTableRow(&$aWordIDs) { - $kf = function($k) use (&$aWordIDs) { return $aWordIDs[$k]; }; + $kf = function ($k) use (&$aWordIDs) { + return $aWordIDs[$k]; + }; echo ""; echo "$this->iSearchRank"; @@ -934,4 +883,4 @@ class SearchDescription echo ""; } -}; +}