From c563c2bfec51a12c139c7690934e243dfc8af54a Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sat, 7 Oct 2017 12:23:46 +0200 Subject: [PATCH] drop searches with excluded country codes earlier --- lib/Geocode.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/Geocode.php b/lib/Geocode.php index 652434cc..a403fa10 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -922,7 +922,7 @@ class Geocode //if (CONST_Debug) _debugDumpGroupedSearches($aGroupedSearches, $aValidTokens); } - // Revisit searches, giving penalty to unlikely combinations + // Revisit searches, drop bad searches and give penalty to unlikely combinations. $aGroupedSearches = array(); foreach ($aSearches as $aSearch) { if (!$aSearch['aName']) { @@ -930,6 +930,11 @@ class Geocode continue; } } + if ($this->aCountryCodes && $aSearch['sCountryCode'] + && !in_array($aSearch['sCountryCode'], $this->aCountryCodes)) { + continue; + } + $aSearch['iSearchRank'] += $iGlobalRank; $aGroupedSearches[$aSearch['iSearchRank']][] = $aSearch; } @@ -1256,10 +1261,6 @@ 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'])) { if ($aSearch['sCountryCode'] && !$aSearch['sClass'] && !$aSearch['sHouseNumber'] && !$aSearch['oNear']) { -- 2.45.2