2 @define('CONST_ConnectionBucket_PageType', 'Reverse');
4 require_once(dirname(dirname(__FILE__)).'/lib/init-website.php');
5 require_once(CONST_BasePath.'/lib/log.php');
6 require_once(CONST_BasePath.'/lib/PlaceLookup.php');
7 require_once(CONST_BasePath.'/lib/ReverseGeocode.php');
9 if (strpos(CONST_BulkUserIPs, ','.$_SERVER["REMOTE_ADDR"].',') !== false)
11 $fLoadAvg = getLoadAverage();
12 if ($fLoadAvg > 2) sleep(60);
13 if ($fLoadAvg > 4) sleep(120);
16 echo "Bulk User: Temporary block due to high server load\n";
22 ini_set('memory_limit', '200M');
25 $sOutputFormat = 'xml';
26 if (isset($_GET['format']) && ($_GET['format'] == 'xml' || $_GET['format'] == 'json' || $_GET['format'] == 'jsonv2'))
28 $sOutputFormat = $_GET['format'];
31 // Show address breakdown
32 $bShowAddressDetails = true;
33 if (isset($_GET['addressdetails'])) $bShowAddressDetails = (bool)$_GET['addressdetails'];
36 $aLangPrefOrder = getPreferredLanguages();
38 $hLog = logStart($oDB, 'reverse', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
40 if (isset($_GET['osm_type']) && isset($_GET['osm_id']) && (int)$_GET['osm_id'] && ($_GET['osm_type'] == 'N' || $_GET['osm_type'] == 'W' || $_GET['osm_type'] == 'R'))
42 $oPlaceLookup = new PlaceLookup($oDB);
43 $oPlaceLookup->setLanguagePreference($aLangPrefOrder);
44 $oPlaceLookup->setIncludeAddressDetails($bShowAddressDetails);
45 $oPlaceLookup->setOSMID($_GET['osm_type'], $_GET['osm_id']);
47 $aPlace = $oPlaceLookup->lookup();
49 //if (!$iPlaceID) $sError = 'OSM ID Not Found';
53 $oReverseGeocode = new ReverseGeocode($oDB);
54 $oReverseGeocode->setLanguagePreference($aLangPrefOrder);
55 $oReverseGeocode->setIncludeAddressDetails($bShowAddressDetails);
57 $oReverseGeocode->setLatLon($_GET['lat'], $_GET['lon']);
58 $oReverseGeocode->setZoom(@$_GET['zoom']);
60 $aPlace = $oReverseGeocode->lookup();
63 if (CONST_Debug) exit;
65 include(CONST_BasePath.'/lib/template/address-'.$sOutputFormat.'.php');