protected $iLimit = 20;
protected $iFinalLimit = 10;
protected $iOffset = 0;
+ protected $bFallback = false;
protected $aCountryCodes = false;
protected $aNearPoint = false;
$this->iOffset = $iOffset;
}
+ function setFallback($bFallback = true)
+ {
+ $this->bFallback = (bool)$bFallback;
+ }
+
function setExcludedPlaceIDs($a)
{
// TODO: force to int
{
$this->sQuery = false;
+ // Reset
+ $this->iMinAddressRank = 0;
+ $this->iMaxAddressRank = 30;
+ $this->aAddressRankList = array();
+
$this->aStructuredQuery = array();
$this->sAllowedTypesSQLList = '';
$sAllowedTypesSQLList = '(\'place\',\'boundary\')';
}
}
+ }
+ function fallbackStructuredQuery()
+ {
+ if (!$this->aStructuredQuery) return false;
+
+ $aParams = $this->aStructuredQuery;
+
+ if (sizeof($aParams) == 1) return false;
+
+ $aOrderToFallback = array('postalcode', 'street', 'city', 'county', 'state');
+
+ foreach($aOrderToFallback as $sType)
+ {
+ if (isset($aParams[$sType]))
+ {
+ unset($aParams[$sType]);
+ $this->setStructuredQuery(@$aParams['amenity'], @$aParams['street'], @$aParams['city'], @$aParams['county'], @$aParams['state'], @$aParams['country'], @$aParams['postalcode']);
+ return true;
+ }
+ }
+
+ return false;
}
function getDetails($aPlaceIDs)
if ($this->aRoutePoints)
{
$sViewboxCentreSQL = "ST_SetSRID('LINESTRING(";
- $bFirst = false;
- foreach($this->aRouteaPoints as $aPoint)
+ $bFirst = true;
+ foreach($this->aRoutePoints as $aPoint)
{
if (!$bFirst) $sViewboxCentreSQL .= ",";
$sViewboxCentreSQL .= $aPoint[1].' '.$aPoint[0];
+ $bFirst = false;
}
$sViewboxCentreSQL .= ")'::geometry,4326)";
// No results? Done
if (!sizeof($aSearchResults))
{
+ if ($this->bFallback)
+ {
+ if ($this->fallbackStructuredQuery())
+ {
+ return $this->lookup();
+ }
+ }
+
return array();
}
$aResult['aPolyPoints'][] = array($aPoint[1], $aPoint[2]);
}
}
- $aResult['aBoundingBox'] = array($aPointPolygon['minlat'],$aPointPolygon['maxlat'],$aPointPolygon['minlon'],$aPointPolygon['maxlon']);
+ $aResult['aBoundingBox'] = array((string)$aPointPolygon['minlat'],(string)$aPointPolygon['maxlat'],(string)$aPointPolygon['minlon'],(string)$aPointPolygon['maxlon']);
}
// Is there an icon set for this type of result?