]> git.openstreetmap.org Git - nominatim.git/commitdiff
fix structured and batch mode. Add constant to disable batch mode by default
authorBrian Quinion <brian.quinion@mapquest.com>
Thu, 12 Sep 2013 15:16:00 +0000 (16:16 +0100)
committerBrian Quinion <brian.quinion@mapquest.com>
Thu, 12 Sep 2013 15:16:08 +0000 (16:16 +0100)
lib/Geocode.php
lib/lib.php
lib/template/search-batch-json.php
settings/settings.php
website/search.php

index 0e1d7c1f2787dbf0b33eb32b720495b6cd8daab6..4b5b4e3d8be3007a72cd497b7a0deb92e4aa1dd0 100644 (file)
                        return $this->sQuery;
                }
 
+               function loadStructuredAddressElement(&$aStructuredQuery, &$iMinAddressRank, &$iMaxAddressRank, &$aAddressRankList, $sValue, $sKey, $iNewMinAddressRank, $iNewMaxAddressRank, $aItemListValues)
+               {
+                       $sValue = trim($sValue);
+                       if (!$sValue) return false;
+                       $aStructuredQuery[$sKey] = $sValue;
+                       if ($iMinAddressRank == 0 && $iMaxAddressRank == 30)
+                       {
+                               $iMinAddressRank = $iNewMinAddressRank;
+                               $iMaxAddressRank = $iNewMaxAddressRank;
+                       }
+                       if ($aItemListValues) $aAddressRankList = array_merge($aAddressRankList, $aItemListValues);
+                       return true;
+               }
+
                function setStructuredQuery($sAmentiy = false, $sStreet = false, $sCity = false, $sCounty = false, $sState = false, $sCountry = false, $sPostalCode = false)
                {
                        $this->sQuery = false;
                        $this->aStructuredQuery = array();
                        $this->sAllowedTypesSQLList = '';
 
-                       loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sAmentiy, 'amenity', 26, 30, false);
-                       loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sStreet, 'street', 26, 30, false);
-                       loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sCity, 'city', 14, 24, false);
-                       loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sCounty, 'county', 9, 13, false);
-                       loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sState, 'state', 8, 8, false);
-                       loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sCountry, 'country', 4, 4, false);
-                       loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sPostalCode, 'postalcode' , 5, 11, array(5, 11));
+                       $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sAmentiy, 'amenity', 26, 30, false);
+                       $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sStreet, 'street', 26, 30, false);
+                       $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sCity, 'city', 14, 24, false);
+                       $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sCounty, 'county', 9, 13, false);
+                       $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sState, 'state', 8, 8, false);
+                       $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sCountry, 'country', 4, 4, false);
+                       $this->loadStructuredAddressElement($this->aStructuredQuery, $this->iMinAddressRank, $this->iMaxAddressRank, $this->aAddressRankList, $sPostalCode, 'postalcode' , 5, 11, array(5, 11));
 
                        if (sizeof($this->aStructuredQuery) > 0) 
                        {
index 3417c95b0e253968136ddeb996a3ca4236636a4f..a75c3af7f23f5bbd4e62ac81dcf97f4da9d16bf2 100644 (file)
                return $iPlaceID;
        }
 
-       function loadStructuredAddressElement(&$aStructuredQuery, &$iMinAddressRank, &$iMaxAddressRank, &$aAddressRankList, $aParams, $sKey, $iNewMinAddressRank, $iNewMaxAddressRank, $aItemListValues)
-       {
-               if (!isset($_GET[$sKey])) return false;
-               $sValue = trim($_GET[$sKey]);
-               if (!$sValue) return false;
-               $aStructuredQuery[$sKey] = $sValue;
-               if ($iMinAddressRank == 0 && $iMaxAddressRank == 30)
-               {
-                       $iMinAddressRank = $iNewMinAddressRank;
-                       $iMaxAddressRank = $iNewMaxAddressRank;
-               }
-               if ($aItemListValues) $aAddressRankList = array_merge($aAddressRankList, $aItemListValues);
-               return true;
-       }
-
        function addQuotes($s)
        {
                return "'".$s."'";
index 13c619525aa1f9c2618704c0ff2a2a62a074b322..ef2c143abf16ae9b440127f1f6397758062fad52 100644 (file)
@@ -6,6 +6,7 @@
 
        foreach($aBatchResults as $aSearchResults)
        {
+               if (!$aSearchResults) $aSearchResults = array();
                $aFilteredPlaces = array();
                foreach($aSearchResults as $iResNum => $aPointDetails)
                {
index fc6ee8dedfca2f4fa7f46ad7246121e5e8c4518e..0ce34ad2e5601b7d972e9b68a0980ab63203f9b2 100644 (file)
@@ -67,6 +67,8 @@
        @define('CONST_Search_AreaPolygons_Enabled', true);
        @define('CONST_Search_AreaPolygons', true);
 
+       @define('CONST_Search_BatchMode', false);
+
        @define('CONST_Search_TryDroppedAddressTerms', false);
        @define('CONST_Search_NameOnlySearchFrequencyThreshold', false);
 
index 8e0bb6f64557c56d97d0a71c988a6304d53bb200..b87f60e071aa8674cd46252b59e65576da35c377 100755 (executable)
 
        loadParamsToGeocode($oGeocode, $_GET, false);
 
-       if (isset($_GET['batch']))
+       if (CONST_Search_BatchMode && isset($_GET['batch']))
        {
                $aBatch = json_decode($_GET['batch'], true);
                $aBatchResults = array();