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', 'geojson'), 'xml');
15 set_exception_handler_by_format($sOutputFormat);
18 $aLangPrefOrder = $oParams->getPreferredLanguages();
22 $hLog = logStart($oDB, 'place', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
24 $aSearchResults = array();
25 $aCleanedQueryParts = array();
27 $oPlaceLookup = new Nominatim\PlaceLookup($oDB);
28 $oPlaceLookup->loadParamArray($oParams);
29 $oPlaceLookup->setIncludeAddressDetails($oParams->getBool('addressdetails', true));
31 $aOsmIds = explode(',', $oParams->getString('osm_ids', ''));
33 if (count($aOsmIds) > CONST_Places_Max_ID_count) {
34 userError('Bulk User: Only ' . CONST_Places_Max_ID_count . ' ids are allowed in one request.');
37 foreach ($aOsmIds as $sItem) {
39 if (empty($sItem)) continue;
42 $iId = (int) substr($sItem, 1);
43 if ($iId > 0 && ($sType == 'N' || $sType == 'W' || $sType == 'R')) {
44 $aCleanedQueryParts[] = $sType . $iId;
45 $oPlace = $oPlaceLookup->lookupOSMID($sType, $iId);
47 // we want to use the search-* output templates, so we need to fill
48 // $aSearchResults and slightly change the (reverse search) oPlace
51 unset($oResult['aAddress']);
52 if (isset($oPlace['aAddress'])) $oResult['address'] = $oPlace['aAddress'];
53 unset($oResult['langaddress']);
54 $oResult['name'] = $oPlace['langaddress'];
55 $aSearchResults[] = $oResult;
61 if (CONST_Debug) exit;
63 $sXmlRootTag = 'lookupresults';
64 $sQuery = join(',', $aCleanedQueryParts);
65 // we initialize these to avoid warnings in our logfile
68 $aExcludePlaceIDs = array();
71 $sOutputTemplate = ($sOutputFormat == 'jsonv2') ? 'json' : $sOutputFormat;
72 include(CONST_BasePath.'/lib/template/search-'.$sOutputTemplate.'.php');