]> git.openstreetmap.org Git - nominatim.git/commitdiff
immediately drop searches where requested country code does not match
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 5 Jul 2017 19:34:00 +0000 (21:34 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Sat, 19 Aug 2017 17:37:05 +0000 (19:37 +0200)
lib/Geocode.php

index eae3baf89aa1079c821c5bf407e40fc5dae3f7d5..7f1c4edc88f7b2f35b8a941490a9d016a937d34c 100644 (file)
@@ -1272,13 +1272,16 @@ class Geocode
                     if (CONST_Debug) echo "<hr><b>Search Loop, group $iGroupLoop, loop $iQueryLoop</b>";
                     if (CONST_Debug) _debugDumpGroupedSearches(array($iGroupedRank => array($aSearch)), $aValidTokens);
 
+                    if ($sCountryCodesSQL && $aSearch['sCountryCode'] && !in_array($aSearch['sCountryCode'], $this->aCountryCodes)) {
+                        continue;
+                    }
+
                     // No location term?
                     if (!sizeof($aSearch['aName']) && !sizeof($aSearch['aAddress']) && !$aSearch['oNear']) {
                         if ($aSearch['sCountryCode'] && !$aSearch['sClass'] && !$aSearch['sHouseNumber']) {
                             // Just looking for a country by code - look it up
                             if (4 >= $this->iMinAddressRank && 4 <= $this->iMaxAddressRank) {
                                 $sSQL = "SELECT place_id FROM placex WHERE country_code='".$aSearch['sCountryCode']."' AND rank_search = 4";
-                                if ($sCountryCodesSQL) $sSQL .= " AND country_code in ($sCountryCodesSQL)";
                                 if ($bBoundingBoxSearch)
                                     $sSQL .= " AND _st_intersects($this->sViewboxSmallSQL, geometry)";
                                 $sSQL .= " ORDER BY st_area(geometry) DESC LIMIT 1";
@@ -1349,8 +1352,7 @@ class Geocode
                         $sSQL .= "p.postcode = '".pg_escape_string(reset($aSearch['aName']))."'";
                         if ($aSearch['sCountryCode']) {
                             $sSQL .= " AND p.country_code = '".$aSearch['sCountryCode']."'";
-                        }
-                        if ($sCountryCodesSQL) {
+                        } elseif ($sCountryCodesSQL) {
                             $sSQL .= " AND p.country_code in ($sCountryCodesSQL)";
                         }
                         $sSQL .= " LIMIT $this->iLimit";