X-Git-Url: https://git.openstreetmap.org/nominatim.git/blobdiff_plain/34adfd504104fa941f6edbfa155b990ef7b3d77b..3eb21a769482b271af6a2fb04da9ba4f6ae784f3:/lib/Geocode.php diff --git a/lib/Geocode.php b/lib/Geocode.php index 92e1a0b3..1604d43f 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -890,6 +890,9 @@ if ($aSearch['sHouseNumber'] === '') { $aSearch['sHouseNumber'] = $sToken; + // sanity check: if the housenumber is not mainly made + // up of numbers, add a penalty + if (preg_match_all("/[^0-9]/", $sToken, $aMatches) > 2) $aSearch['iSearchRank']++; if ($aSearch['iSearchRank'] < $this->iMaxRank) $aNewWordsetSearches[] = $aSearch; /* // Fall back to not searching for this item (better than nothing) @@ -908,7 +911,7 @@ $aSearch['sType'] = $aSearchTerm['type']; if (sizeof($aSearch['aName'])) $aSearch['sOperator'] = 'name'; else $aSearch['sOperator'] = 'near'; // near = in for the moment - if (strlen($aSearchTerm['operator']) == 0) $aSearch['iSearchRank'] += 1; + if (strlen($aSearchTerm['operator']) == 0) $aSearch['iSearchRank'] += 1; // Do we have a shortcut id? if ($aSearch['sOperator'] == 'name') @@ -1202,7 +1205,8 @@ // If excluded place IDs are given, it is fair to assume that // there have been results in the small box, so no further // expansion in that case. - if (!sizeof($aPlaceIDs) && !sizeof($this->aExcludePlaceIDs)) + // Also don't expand if bounded results were requested. + if (!sizeof($aPlaceIDs) && !sizeof($this->aExcludePlaceIDs) && !$this->bBoundedSearch) { $sSQL = "select place_id from place_classtype_".$aSearch['sClass']."_".$aSearch['sType']." ct"; if ($sCountryCodesSQL) $sSQL .= " join placex using (place_id)";