]> git.openstreetmap.org Git - nominatim.git/blob - website/reverse.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / website / reverse.php
1 <?php
2         @define('CONST_ConnectionBucket_PageType', 'Reverse');
3
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');
8
9         $oDB =& getDB();
10         ini_set('memory_limit', '200M');
11
12         // Format for output
13         $sOutputFormat = 'xml';
14         if (isset($_GET['format']) && ($_GET['format'] == 'xml' || $_GET['format'] == 'json' || $_GET['format'] == 'jsonv2'))
15         {
16                 $sOutputFormat = $_GET['format'];
17         }
18
19         // Show address breakdown
20         $bShowAddressDetails = true;
21         if (isset($_GET['addressdetails'])) $bShowAddressDetails = (bool)$_GET['addressdetails'];
22
23         // Preferred language
24         $aLangPrefOrder = getPreferredLanguages();
25
26         $hLog = logStart($oDB, 'reverse', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
27
28         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'))
29         {
30                 $oPlaceLookup = new PlaceLookup($oDB);
31                 $oPlaceLookup->setLanguagePreference($aLangPrefOrder);
32                 $oPlaceLookup->setIncludeAddressDetails($bShowAddressDetails);
33                 $oPlaceLookup->setOSMID($_GET['osm_type'], $_GET['osm_id']);
34
35                 $aPlace = $oPlaceLookup->lookup();
36
37                 //if (!$iPlaceID) $sError = 'OSM ID Not Found';
38         }
39         else
40         {
41                 $oReverseGeocode = new ReverseGeocode($oDB);
42                 $oReverseGeocode->setLanguagePreference($aLangPrefOrder);
43                 $oReverseGeocode->setIncludeAddressDetails($bShowAddressDetails);
44
45                 $oReverseGeocode->setLatLon($_GET['lat'], $_GET['lon']);
46                 $oReverseGeocode->setZoom(@$_GET['zoom']);
47
48                 $aPlace = $oReverseGeocode->lookup();
49         }
50
51         if (CONST_Debug) exit;
52
53         include(CONST_BasePath.'/lib/template/address-'.$sOutputFormat.'.php');