]> git.openstreetmap.org Git - nominatim.git/blob - website/lookup.php
2e2a1c2f514f99a6a2152f91badeb03b298f35d4
[nominatim.git] / website / lookup.php
1 <?php
2         @define('CONST_ConnectionBucket_PageType', 'Reverse');
3
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/output.php');
9
10         $oDB =& getDB();
11         ini_set('memory_limit', '200M');
12
13         // Format for output
14         $sOutputFormat = getParamSet('format', array('xml', 'json'), 'xml');
15
16         // Preferred language
17         $aLangPrefOrder = getPreferredLanguages();
18
19         $hLog = logStart($oDB, 'place', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
20
21         $aSearchResults = array();
22         $aCleanedQueryParts = array();
23
24         $oPlaceLookup = new PlaceLookup($oDB);
25         $oPlaceLookup->setLanguagePreference($aLangPrefOrder);
26         $oPlaceLookup->setIncludeAddressDetails(getParamBool('addressdetails', true));
27         $oPlaceLookup->setIncludeExtraTags(getParamBool('extratags', false));
28         $oPlaceLookup->setIncludeNameDetails(getParamBool('namedetails', false));
29
30         $aOsmIds = explode(',', getParamString('osm_ids', ''));
31
32         if (count($aOsmIds) > CONST_Places_Max_ID_count)
33         {
34                 userError('Bulk User: Only ' . CONST_Places_Max_ID_count . " ids are allowed in one request.");
35         }
36
37         foreach ($aOsmIds AS $sItem)
38         {
39                 // Skip empty sItem
40                 if (empty($sItem)) continue;
41                 
42                 $sType = $sItem[0];
43                 $iId = (int) substr($sItem, 1);
44                 if ( $iId > 0 && ($sType == 'N' || $sType == 'W' || $sType == 'R') )
45                 {
46                         $aCleanedQueryParts[] = $sType . $iId;
47                         $oPlaceLookup->setOSMID($sType, $iId);
48                         $oPlace = $oPlaceLookup->lookup();
49                         if ($oPlace){
50                                 // we want to use the search-* output templates, so we need to fill
51                                 // $aSearchResults and slightly change the (reverse search) oPlace
52                                 // key names
53                                 $oResult = $oPlace;
54                                 unset($oResult['aAddress']);
55                                 if (isset($oPlace['aAddress'])) $oResult['address'] = $oPlace['aAddress'];
56                                 unset($oResult['langaddress']);
57                                 $oResult['name'] = $oPlace['langaddress'];
58                                 $aSearchResults[] = $oResult;
59                         }
60                 }
61         }
62
63
64         if (CONST_Debug) exit;
65
66         $sXmlRootTag = 'lookupresults';
67         $sQuery = join(',',$aCleanedQueryParts);
68         // we initialize these to avoid warnings in our logfile
69         $sViewBox = '';
70         $bShowPolygons = '';
71         $aExcludePlaceIDs = [];
72         $sMoreURL = '';
73
74         include(CONST_BasePath.'/lib/template/search-'.$sOutputFormat.'.php');