- // Country code list
- if (isset($_GET['countrycodes']))
- {
- $aCountryCodes = array();
- foreach(explode(',',$_GET['countrycodes']) as $sCountryCode)
- {
- if (preg_match('/^[a-zA-Z][a-zA-Z]$/', $sCountryCode))
- {
- $aCountryCodes[] = strtolower($sCountryCode);
- }
- }
- $oGeocode->setCountryCodeList($aCountryCodes);
- }
-
- if (isset($_GET['viewboxlbrt']) && $_GET['viewboxlbrt'])
- {
- $aCoOrdinatesLBRT = explode(',',$_GET['viewboxlbrt']);
- $oGeocode->setViewBox($aCoOrdinatesLBRT[0], $aCoOrdinatesLBRT[1], $aCoOrdinatesLBRT[2], $aCoOrdinatesLBRT[3]);
- }
-
- if (isset($_GET['viewbox']) && $_GET['viewbox'])
- {
- $aCoOrdinatesLTRB = explode(',',$_GET['viewbox']);
- $oGeocode->setViewBox($aCoOrdinatesLTRB[0], $aCoOrdinatesLTRB[3], $aCoOrdinatesLTRB[2], $aCoOrdinatesLTRB[1]);
- }
-
- if (isset($_GET['route']) && $_GET['route'] && isset($_GET['routewidth']) && $_GET['routewidth'])
- {
- $aPoints = explode(',',$_GET['route']);
- if (sizeof($aPoints) % 2 != 0)
- {
- userError("Uneven number of points");
- exit;
- }
- $fPrevCoord = false;
- $aRoute = array();
- foreach($aPoints as $i => $fPoint)
- {
- if ($i%2)
- {
- $aRoute[] = array((float)$fPoint, $fPrevCoord);
- }
- else
- {
- $fPrevCoord = (float)$fPoint;
- }
- }
- $oGeocode->setRoute($aRoute);
- }
-
- // Search query
- $sQuery = (isset($_GET['q'])?trim($_GET['q']):'');
- if (!$sQuery && isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'][0] == '/')
- {
- $sQuery = substr($_SERVER['PATH_INFO'], 1);
-
- // reverse order of '/' separated string
- $aPhrases = explode('/', $sQuery);
- $aPhrases = array_reverse($aPhrases);
- $sQuery = join(', ',$aPhrases);
- }
- if (!$sQuery)
- {
- $oGeocode->setStructuredQuery(@$_GET['amenity'], @$_GET['street'], @$_GET['city'], @$_GET['county'], @$_GET['state'], @$_GET['country'], @$_GET['postalcode']);
- }
- else
- {
- $oGeocode->setQuery($sQuery);
- }
-
- $hLog = logStart($oDB, 'search', $sQuery, $aLangPrefOrder);
-
- if (isset($_GET['batch']))