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');
11 ini_set('memory_limit', '200M');
14 $sOutputFormat = getParamSet('format', array('xml', 'json'), 'xml');
17 $aLangPrefOrder = getPreferredLanguages();
19 $hLog = logStart($oDB, 'place', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
21 $aSearchResults = array();
22 $aCleanedQueryParts = array();
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));
30 $aOsmIds = explode(',', getParamString('osm_ids', ''));
32 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)
40 if (empty($sItem)) continue;
43 $iId = (int) substr($sItem, 1);
44 if ( $iId > 0 && ($sType == 'N' || $sType == 'W' || $sType == 'R') )
46 $aCleanedQueryParts[] = $sType . $iId;
47 $oPlaceLookup->setOSMID($sType, $iId);
48 $oPlace = $oPlaceLookup->lookup();
50 // we want to use the search-* output templates, so we need to fill
51 // $aSearchResults and slightly change the (reverse search) 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;
64 if (CONST_Debug) exit;
66 $sXmlRootTag = 'lookupresults';
67 $sQuery = join(',',$aCleanedQueryParts);
68 // we initialize these to avoid warnings in our logfile
71 $aExcludePlaceIDs = [];
74 include(CONST_BasePath.'/lib/template/search-'.$sOutputFormat.'.php');