]> git.openstreetmap.org Git - nominatim.git/blobdiff - lib/Geocode.php
move country list to SearchContext
[nominatim.git] / lib / Geocode.php
index 1138824cd029868086b6e37e7988c41da9d8a3a9..b27f69e8647e27eb0aaf308cd91df9bde9d059dd 100644 (file)
@@ -849,15 +849,17 @@ class Geocode
         } else if ($this->aViewBox) {
             $oCtx->setViewboxFromBox($this->aViewBox, $this->bBoundedSearch);
         }
+        if ($this->aExcludePlaceIDs) {
+            $oCtx->setExcludeList($this->aExcludePlaceIDs);
+        }
+        if ($this->aCountryCodes) {
+            $oCtx->setCountryList($this->aCountryCodes);
+        }
 
         $sNormQuery = $this->normTerm($this->sQuery);
         $sLanguagePrefArraySQL = getArraySQL(
             array_map("getDBQuoted", $this->aLangPrefOrder)
         );
-        $sCountryCodesSQL = false;
-        if ($this->aCountryCodes) {
-            $sCountryCodesSQL = join(',', array_map('addQuotes', $this->aCountryCodes));
-        }
 
         $sQuery = $this->sQuery;
         if (!preg_match('//u', $sQuery)) {
@@ -1104,29 +1106,18 @@ class Geocode
                         if (!$oCtx->isBoundedSearch()) {
                             continue;
                         }
-
-                        $aPlaceIDs = $oSearch->queryNearbyPoi(
-                            $this->oDB,
-                            $sCountryCodesSQL,
-                            $this->aExcludePlaceIDs ? join(',', $this->aExcludePlaceIDs) : '',
-                            $this->iLimit
-                        );
+                        $aPlaceIDs = $oSearch->queryNearbyPoi($this->oDB, $this->iLimit);
                     } elseif ($oSearch->isOperator(Operator::POSTCODE)) {
-                        $aPlaceIDs = $oSearch->queryPostcode(
-                            $this->oDB,
-                            $sCountryCodesSQL,
-                            $this->iLimit
-                        );
+                        // looking for postcode
+                        $aPlaceIDs = $oSearch->queryPostcode($this->oDB, $this->iLimit);
                     } else {
                         // Ordinary search:
                         // First search for places according to name and address.
                         $aNamedPlaceIDs = $oSearch->queryNamedPlace(
                             $this->oDB,
                             $aWordFrequencyScores,
-                            $sCountryCodesSQL,
                             $this->iMinAddressRank,
                             $this->iMaxAddressRank,
-                            $this->aExcludePlaceIDs ? join(',', $this->aExcludePlaceIDs) : '',
                             $this->iLimit
                         );
 
@@ -1142,7 +1133,6 @@ class Geocode
                             $aResult = $oSearch->queryHouseNumber(
                                 $this->oDB,
                                 $aPlaceIDs,
-                                $this->aExcludePlaceIDs ? join(',', $this->aExcludePlaceIDs) : '',
                                 $this->iLimit
                             );
 
@@ -1159,7 +1149,6 @@ class Geocode
                             $aPlaceIDs = $oSearch->queryPoiByOperator(
                                 $this->oDB,
                                 $aPlaceIDs,
-                                $this->aExcludePlaceIDs ? join(',', $this->aExcludePlaceIDs) : '',
                                 $this->iLimit
                             );
                         }