2 @define('CONST_ConnectionBucket_PageType', 'Reverse');
4 require_once(dirname(dirname(__FILE__)).'/settings/settings.php');
5 require_once(CONST_BasePath.'/lib/init-website.php');
6 require_once(CONST_BasePath.'/lib/log.php');
7 require_once(CONST_BasePath.'/lib/PlaceLookup.php');
8 require_once(CONST_BasePath.'/lib/ReverseGeocode.php');
9 require_once(CONST_BasePath.'/lib/output.php');
10 ini_set('memory_limit', '200M');
12 $oParams = new Nominatim\ParameterParser();
15 $sOutputFormat = $oParams->getSet('format', array('html', 'xml', 'json', 'jsonv2'), 'xml');
18 $aLangPrefOrder = $oParams->getPreferredLanguages();
22 $hLog = logStart($oDB, 'reverse', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
24 $oPlaceLookup = new Nominatim\PlaceLookup($oDB);
25 $oPlaceLookup->loadParamArray($oParams);
27 $sOsmType = $oParams->getSet('osm_type', array('N', 'W', 'R'));
28 $iOsmId = $oParams->getInt('osm_id', -1);
29 $fLat = $oParams->getFloat('lat');
30 $fLon = $oParams->getFloat('lon');
31 $iZoom = $oParams->getInt('zoom', 18);
33 if ($sOsmType && $iOsmId > 0) {
34 $aPlace = $oPlaceLookup->lookupOSMID($sOsmType, $iOsmId);
35 } elseif ($fLat !== false && $fLon !== false) {
36 $oReverseGeocode = new Nominatim\ReverseGeocode($oDB);
37 $oReverseGeocode->setZoom($iZoom);
39 $oLookup = $oReverseGeocode->lookup($fLat, $fLon);
40 if (CONST_Debug) var_dump($oLookup);
43 $aPlaces = $oPlaceLookup->lookup(array($oLookup->iId => $oLookup));
44 if (sizeof($aPlaces)) {
45 $aPlace = reset($aPlaces);
48 } elseif ($sOutputFormat != 'html') {
49 userError("Need coordinates or OSM object to lookup.");
53 $fRadius = $fDiameter = getResultDiameter($aPlace);
54 $aOutlineResult = $oPlaceLookup->getOutlines(
61 if ($aOutlineResult) {
62 $aPlace = array_merge($aPlace, $aOutlineResult);
74 if ($sOutputFormat == 'html') {
75 $sDataDate = chksql($oDB->getOne("select TO_CHAR(lastimportdate - '2 minutes'::interval,'YYYY/MM/DD HH24:MI')||' GMT' from import_status limit 1"));
76 $sTileURL = CONST_Map_Tile_URL;
77 $sTileAttribution = CONST_Map_Tile_Attribution;
79 include(CONST_BasePath.'/lib/template/address-'.$sOutputFormat.'.php');