fix structured and batch mode. Add constant to disable batch mode by default

This commit is contained in:
Brian Quinion 2013-09-12 16:16:00 +01:00
parent 27e6a24718
commit a974d25092
5 changed files with 25 additions and 23 deletions

View File

@ -190,6 +190,20 @@
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;
@ -197,13 +211,13 @@
$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)
{

View File

@ -884,21 +884,6 @@
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."'";

View File

@ -6,6 +6,7 @@
foreach($aBatchResults as $aSearchResults)
{
if (!$aSearchResults) $aSearchResults = array();
$aFilteredPlaces = array();
foreach($aSearchResults as $iResNum => $aPointDetails)
{

View 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);

View File

@ -160,7 +160,7 @@
loadParamsToGeocode($oGeocode, $_GET, false);
if (isset($_GET['batch']))
if (CONST_Search_BatchMode && isset($_GET['batch']))
{
$aBatch = json_decode($_GET['batch'], true);
$aBatchResults = array();