From 0ecb920866cea50294d1124b85f971626355d520 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Wed, 5 Jul 2017 21:34:00 +0200 Subject: [PATCH] immediately drop searches where requested country code does not match --- lib/Geocode.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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"; -- 2.45.2