]> git.openstreetmap.org Git - nominatim.git/commitdiff
be more strict with searches involving house numbers
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 2 Oct 2017 19:57:44 +0000 (21:57 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 2 Oct 2017 20:22:50 +0000 (22:22 +0200)
Housenumber searches without a name cannot exist per
definition. Searches with only a name but no address
should not fall back on a search without house number.
This should improve postcode only search.

lib/Geocode.php

index 0c2a9963e639ce44f785a060190ebb32e4d9b0a2..6961b6303dee407e84a57036f0a8fc551a24c595 100644 (file)
@@ -910,6 +910,19 @@ class Geocode
 
             //if (CONST_Debug) _debugDumpGroupedSearches($aGroupedSearches, $aValidTokens);
         }
+
+        // Revisit searches, giving penalty to unlikely combinations
+        $aGroupedSearches = array();
+        foreach ($aSearches as $aSearch) {
+            if (!$aSearch['aName']) {
+                if ($aSearch['sHouseNumber']) {
+                    continue;
+                }
+            }
+            $aGroupedSearches[$aSearch['iSearchRank']][] = $aSearch;
+        }
+        ksort($aGroupedSearches);
+
         return $aGroupedSearches;
     }
 
@@ -1563,7 +1576,8 @@ class Geocode
                             }
 
                             // Fallback to the road (if no housenumber was found)
-                            if (!sizeof($aPlaceIDs) && preg_match('/[0-9]+/', $aSearch['sHouseNumber'])) {
+                            if (!sizeof($aPlaceIDs) && preg_match('/[0-9]+/', $aSearch['sHouseNumber'])
+                                && ($aSearch['aAddress'] || $aSearch['sCountryCode'])) {
                                 $aPlaceIDs = $aRoadPlaceIDs;
                                 //set to -1, if no housenumbers were found
                                 $searchedHousenumber = -1;