From: Sarah Hoffmann Date: Wed, 5 Jul 2017 19:34:00 +0000 (+0200) Subject: immediately drop searches where requested country code does not match X-Git-Tag: v3.1.0~88^2~22 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/0ecb920866cea50294d1124b85f971626355d520 immediately drop searches where requested country code does not match --- diff --git a/lib/Geocode.php b/lib/Geocode.php index eae3baf8..7f1c4edc 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -1272,13 +1272,16 @@ class Geocode if (CONST_Debug) echo "
Search Loop, group $iGroupLoop, loop $iQueryLoop"; 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";