]> git.openstreetmap.org Git - nominatim.git/commitdiff
Fix for regressions: broken bounded search, error on country codes
authorBrian Quinion <brian.quinion@mapquest.com>
Fri, 30 Aug 2013 11:18:57 +0000 (12:18 +0100)
committerBrian Quinion <brian.quinion@mapquest.com>
Fri, 6 Sep 2013 08:47:46 +0000 (09:47 +0100)
lib/Geocode.php
lib/lib.php
website/search.php

index 35c8541a0e80fbc6c38b9804b955a70073c100cf..51ed32055c578d8557b0da55b89fd6c0bdf99336 100644 (file)
                        $sCountryCodesSQL = false;
                        if ($this->aCountryCodes && sizeof($this->aCountryCodes))
                        {
-                               $sCountryCodesSQL = join(',', $this->aCountryCodes);
+                               $sCountryCodesSQL = join(',', array_map('addQuotes', $this->aCountryCodes));
                        }
 
                        // Hack to make it handle "new york, ny" (and variants) correctly
 
                                $sViewboxSmallSQL = "ST_SetSRID(ST_MakeBox2D(ST_Point(".(float)$this->aViewBox[0].",".(float)$this->aViewBox[1]."),ST_Point(".(float)$this->aViewBox[2].",".(float)$this->aViewBox[3].")),4326)";
                                $sViewboxLargeSQL = "ST_SetSRID(ST_MakeBox2D(ST_Point(".(float)$aBigViewBox[0].",".(float)$aBigViewBox[1]."),ST_Point(".(float)$aBigViewBox[2].",".(float)$aBigViewBox[3].")),4326)";
-                               $bBoundingBoxSearch = true;
+                               $bBoundingBoxSearch = $this->bBoundedSearch;
                        }
 
                        // Route SQL
                                        failInternalError("Could not get large viewbox.", $sSQL, $sViewboxLargeSQL);
                                }
                                $sViewboxLargeSQL = "'".$sViewboxLargeSQL."'::geometry";
-                               $bBoundingBoxSearch = true;
+                               $bBoundingBoxSearch = $this->bBoundedSearch;
                        }
 
                        // Do we have anything that looks like a lat/lon pair?
                                                if (CONST_Debug) { echo "<hr><b>Search Loop, group $iGroupLoop, loop $iQueryLoop</b>"; }
                                                if (CONST_Debug) _debugDumpGroupedSearches(array($iGroupedRank => array($aSearch)), $aValidTokens);
 
-                                               // Must have a location term
+                                               // No location term?
                                                if (!sizeof($aSearch['aName']) && !sizeof($aSearch['aAddress']) && !$aSearch['fLon'])
                                                {
                                                        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 calculated_country_code='".$aSearch['sCountryCode']."' and rank_search = 4";
index 3b16b399a6e9eb9001ac2755073ba491836657dd..3417c95b0e253968136ddeb996a3ca4236636a4f 100644 (file)
                if ($aItemListValues) $aAddressRankList = array_merge($aAddressRankList, $aItemListValues);
                return true;
        }
+
+       function addQuotes($s)
+       {
+               return "'".$s."'";
+       }
index 26f7b2a648bcebf530b57206eb61b9232ec3bdfe..e9f13632ad495caea70b5b873d613b69d5fae07c 100755 (executable)
@@ -55,7 +55,7 @@
                                        $aCountryCodes[] = strtolower($sCountryCode);
                                }
                        }
-                       $oGeocode->setCountryCodeList($aCountryCodes);
+                       $oGeocode->setCountryCodesList($aCountryCodes);
                }
 
                if (isset($aParams['viewboxlbrt']) && $aParams['viewboxlbrt'])