]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/SearchDescription.php
do not use artificial housenumbers as names
[nominatim.git] / lib / SearchDescription.php
index bb478b29b88af4fbcef3a174d8e5405cedd616ea..d8c541dbc8f8514d04a5f297d5681c4fb6e8ab54 100644 (file)
@@ -199,15 +199,10 @@ class SearchDescription
         } elseif (($sPhraseType == '' || $sPhraseType == 'postalcode')
                   && is_a($oSearchTerm, '\Nominatim\Token\Postcode')
         ) {
-            // We need to try the case where the postal code is the primary element
-            // (i.e. no way to tell if it is (postalcode, city) OR (city, postalcode)
-            // so try both.
             if (!$this->sPostcode) {
                 // If we have structured search or this is the first term,
                 // make the postcode the primary search element.
-                if ($this->iOperator == Operator::NONE
-                    && ($sPhraseType == 'postalcode' || $bFirstToken)
-                ) {
+                if ($this->iOperator == Operator::NONE && $bFirstToken) {
                     $oSearch = clone $this;
                     $oSearch->iSearchRank++;
                     $oSearch->iOperator = Operator::POSTCODE;
@@ -252,6 +247,18 @@ class SearchDescription
                     $oSearch->iSearchRank++;
                 }
                 $aNewSearches[] = $oSearch;
+                // Housenumbers may appear in the name when the place has its own
+                // address terms.
+                if ($oSearchTerm->iId !== null
+                    && ($this->iNamePhrase >= 0 || empty($this->aName))
+                    && empty($this->aAddress)
+                   ) {
+                    $oSearch = clone $this;
+                    $oSearch->iSearchRank++;
+                    $oSearch->aAddress = $this->aName;
+                    $oSearch->aName = array($oSearchTerm->iId => $oSearchTerm->iId);
+                    $aNewSearches[] = $oSearch;
+                }
             }
         } elseif ($sPhraseType == ''
                   && is_a($oSearchTerm, '\Nominatim\Token\SpecialTerm')
@@ -657,7 +664,7 @@ class SearchDescription
         }
 
         if ($this->sHouseNumber) {
-            $aTerms[] = 'address_rank between 16 and 27';
+            $aTerms[] = 'address_rank between 16 and 30';
         } elseif (!$this->sClass || $this->iOperator == Operator::NAME) {
             if ($iMinAddressRank > 0) {
                 $aTerms[] = "((address_rank between $iMinAddressRank and $iMaxAddressRank) or (search_rank between $iMinAddressRank and $iMaxAddressRank))";