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/output.php');
9 ini_set('memory_limit', '200M');
11 $oParams = new Nominatim\ParameterParser();
14 $sOutputFormat = $oParams->getSet('format', array('xml', 'json'), 'xml');
17 $aLangPrefOrder = $oParams->getPreferredLanguages();
21 $hLog = logStart($oDB, 'place', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
23 $aSearchResults = array();
24 $aCleanedQueryParts = array();
26 $oPlaceLookup = new Nominatim\PlaceLookup($oDB);
27 $oPlaceLookup->loadParamArray($oParams);
29 $aOsmIds = explode(',', $oParams->getString('osm_ids', ''));
31 if (count($aOsmIds) > CONST_Places_Max_ID_count) {
32 userError('Bulk User: Only ' . CONST_Places_Max_ID_count . ' ids are allowed in one request.');
35 foreach ($aOsmIds as $sItem) {
37 if (empty($sItem)) continue;
40 $iId = (int) substr($sItem, 1);
41 if ($iId > 0 && ($sType == 'N' || $sType == 'W' || $sType == 'R')) {
42 $aCleanedQueryParts[] = $sType . $iId;
43 $oPlace = $oPlaceLookup->lookupOSMID($sType, $iId);
45 // we want to use the search-* output templates, so we need to fill
46 // $aSearchResults and slightly change the (reverse search) oPlace
49 unset($oResult['aAddress']);
50 if (isset($oPlace['aAddress'])) $oResult['address'] = $oPlace['aAddress'];
51 unset($oResult['langaddress']);
52 $oResult['name'] = $oPlace['langaddress'];
53 $aSearchResults[] = $oResult;
59 if (CONST_Debug) exit;
61 $sXmlRootTag = 'lookupresults';
62 $sQuery = join(',', $aCleanedQueryParts);
63 // we initialize these to avoid warnings in our logfile
66 $aExcludePlaceIDs = [];
69 include(CONST_BasePath.'/lib/template/search-'.$sOutputFormat.'.php');