&& is_a($oSearchTerm, '\Nominatim\Token\HouseNumber')
) {
if (!$this->sHouseNumber && $this->iOperator != Operator::POSTCODE) {
- $oSearch = clone $this;
- $oSearch->iSearchRank++;
- $oSearch->iNamePhrase = -1;
- $oSearch->sHouseNumber = $oSearchTerm->sToken;
- if ($this->iOperator != Operator::NONE) {
- $oSearch->iSearchRank++;
- }
// sanity check: if the housenumber is not mainly made
// up of numbers, add a penalty
- if (preg_match('/\\d/', $oSearch->sHouseNumber) === 0
- || preg_match_all('/[^0-9]/', $oSearch->sHouseNumber, $aMatches) > 2) {
- $oSearch->iSearchRank++;
+ $iSearchCost = 1;
+ if (preg_match('/\\d/', $oSearchTerm->sToken) === 0
+ || preg_match_all('/[^0-9]/', $oSearchTerm->sToken, $aMatches) > 2) {
+ $iSearchCost++;
+ }
+ if ($this->iOperator != Operator::NONE) {
+ $iSearchCost++;
}
if (empty($oSearchTerm->iId)) {
- $oSearch->iSearchRank++;
+ $iSearchCost++;
}
// also must not appear in the middle of the address
if (!empty($this->aAddress)
|| (!empty($this->aAddressNonSearch))
|| $this->sPostcode
) {
- $oSearch->iSearchRank++;
+ $iSearchCost++;
}
+
+ $oSearch = clone $this;
+ $oSearch->iSearchRank += $iSearchCost;
+ $oSearch->iNamePhrase = -1;
+ $oSearch->sHouseNumber = $oSearchTerm->sToken;
$aNewSearches[] = $oSearch;
// Housenumbers may appear in the name when the place has its own
// address terms.
&& empty($this->aAddress)
) {
$oSearch = clone $this;
- $oSearch->iSearchRank++;
+ $oSearch->iSearchRank += $iSearchCost;
$oSearch->aAddress = $this->aName;
$oSearch->bRareName = false;
$oSearch->aName = array($oSearchTerm->iId => $oSearchTerm->iId);