3 require_once(CONST_BasePath.'/lib/init-website.php');
4 require_once(CONST_BasePath.'/lib/log.php');
5 require_once(CONST_BasePath.'/lib/PlaceLookup.php');
6 require_once(CONST_BasePath.'/lib/output.php');
7 ini_set('memory_limit', '200M');
9 $oParams = new Nominatim\ParameterParser();
12 $sOutputFormat = $oParams->getSet('format', array('xml', 'json', 'jsonv2', 'geojson', 'geocodejson'), 'xml');
13 set_exception_handler_by_format($sOutputFormat);
16 $aLangPrefOrder = $oParams->getPreferredLanguages();
18 $oDB = new Nominatim\DB();
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);
28 $oPlaceLookup->setIncludeAddressDetails($oParams->getBool('addressdetails', true));
30 $aOsmIds = explode(',', $oParams->getString('osm_ids', ''));
32 if (count($aOsmIds) > CONST_Places_Max_ID_count) {
33 userError('Bulk User: Only ' . CONST_Places_Max_ID_count . ' ids are allowed in one request.');
36 foreach ($aOsmIds as $sItem) {
38 if (empty($sItem)) continue;
41 $iId = (int) substr($sItem, 1);
42 if ($iId > 0 && ($sType == 'N' || $sType == 'W' || $sType == 'R')) {
43 $aCleanedQueryParts[] = $sType . $iId;
44 $oPlace = $oPlaceLookup->lookupOSMID($sType, $iId);
46 // we want to use the search-* output templates, so we need to fill
47 // $aSearchResults and slightly change the (reverse search) oPlace
50 unset($oResult['aAddress']);
51 if (isset($oPlace['aAddress'])) $oResult['address'] = $oPlace['aAddress'];
52 if ($sOutputFormat != 'geocodejson') {
53 unset($oResult['langaddress']);
54 $oResult['name'] = $oPlace['langaddress'];
57 $aOutlineResult = $oPlaceLookup->getOutlines(
61 Nominatim\ClassTypes\getDefRadius($oPlace)
64 if ($aOutlineResult) {
65 $oResult = array_merge($oResult, $aOutlineResult);
68 $aSearchResults[] = $oResult;
74 if (CONST_Debug) exit;
76 $sXmlRootTag = 'lookupresults';
77 $sQuery = join(',', $aCleanedQueryParts);
78 // we initialize these to avoid warnings in our logfile
81 $aExcludePlaceIDs = array();
84 logEnd($oDB, $hLog, 1);
86 $sOutputTemplate = ($sOutputFormat == 'jsonv2') ? 'json' : $sOutputFormat;
87 include(CONST_BasePath.'/lib/template/search-'.$sOutputTemplate.'.php');