2015-06-16 22:11:21 +03:00
|
|
|
<?php
|
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
require_once(CONST_BasePath.'/lib/init-website.php');
|
|
|
|
require_once(CONST_BasePath.'/lib/log.php');
|
|
|
|
require_once(CONST_BasePath.'/lib/PlaceLookup.php');
|
|
|
|
require_once(CONST_BasePath.'/lib/output.php');
|
|
|
|
ini_set('memory_limit', '200M');
|
2015-06-16 22:11:21 +03:00
|
|
|
|
2016-09-16 03:27:36 +03:00
|
|
|
$oParams = new Nominatim\ParameterParser();
|
2016-07-31 22:04:33 +03:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
// Format for output
|
2018-03-18 03:49:26 +03:00
|
|
|
$sOutputFormat = $oParams->getSet('format', array('xml', 'json', 'geojson'), 'xml');
|
2018-09-16 18:16:42 +03:00
|
|
|
set_exception_handler_by_format($sOutputFormat);
|
2015-06-16 22:11:21 +03:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
// Preferred language
|
|
|
|
$aLangPrefOrder = $oParams->getPreferredLanguages();
|
2016-07-31 22:04:33 +03:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
$oDB =& getDB();
|
2015-06-16 22:11:21 +03:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
$hLog = logStart($oDB, 'place', $_SERVER['QUERY_STRING'], $aLangPrefOrder);
|
2015-06-16 22:11:21 +03:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
$aSearchResults = array();
|
|
|
|
$aCleanedQueryParts = array();
|
2016-06-12 00:07:06 +03:00
|
|
|
|
2016-09-16 03:27:36 +03:00
|
|
|
$oPlaceLookup = new Nominatim\PlaceLookup($oDB);
|
2017-10-24 00:28:00 +03:00
|
|
|
$oPlaceLookup->loadParamArray($oParams);
|
2018-07-11 00:38:27 +03:00
|
|
|
$oPlaceLookup->setIncludeAddressDetails($oParams->getBool('addressdetails', true));
|
2016-06-12 00:07:06 +03:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
$aOsmIds = explode(',', $oParams->getString('osm_ids', ''));
|
2016-06-12 00:07:06 +03:00
|
|
|
|
2016-09-08 04:16:22 +03:00
|
|
|
if (count($aOsmIds) > CONST_Places_Max_ID_count) {
|
2017-10-26 22:21:21 +03:00
|
|
|
userError('Bulk User: Only ' . CONST_Places_Max_ID_count . ' ids are allowed in one request.');
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
2016-06-12 00:07:06 +03:00
|
|
|
|
2016-09-14 04:16:46 +03:00
|
|
|
foreach ($aOsmIds as $sItem) {
|
2016-09-04 04:19:48 +03:00
|
|
|
// Skip empty sItem
|
|
|
|
if (empty($sItem)) continue;
|
|
|
|
|
|
|
|
$sType = $sItem[0];
|
|
|
|
$iId = (int) substr($sItem, 1);
|
2016-09-08 04:16:22 +03:00
|
|
|
if ($iId > 0 && ($sType == 'N' || $sType == 'W' || $sType == 'R')) {
|
2016-09-04 04:19:48 +03:00
|
|
|
$aCleanedQueryParts[] = $sType . $iId;
|
|
|
|
$oPlace = $oPlaceLookup->lookupOSMID($sType, $iId);
|
2016-09-08 04:16:22 +03:00
|
|
|
if ($oPlace) {
|
2016-09-04 04:19:48 +03:00
|
|
|
// we want to use the search-* output templates, so we need to fill
|
|
|
|
// $aSearchResults and slightly change the (reverse search) oPlace
|
|
|
|
// key names
|
|
|
|
$oResult = $oPlace;
|
|
|
|
unset($oResult['aAddress']);
|
|
|
|
if (isset($oPlace['aAddress'])) $oResult['address'] = $oPlace['aAddress'];
|
|
|
|
unset($oResult['langaddress']);
|
|
|
|
$oResult['name'] = $oPlace['langaddress'];
|
|
|
|
$aSearchResults[] = $oResult;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-16 22:11:21 +03:00
|
|
|
|
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
if (CONST_Debug) exit;
|
2015-06-16 22:11:21 +03:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
$sXmlRootTag = 'lookupresults';
|
2016-09-11 06:22:51 +03:00
|
|
|
$sQuery = join(',', $aCleanedQueryParts);
|
2016-09-04 04:19:48 +03:00
|
|
|
// we initialize these to avoid warnings in our logfile
|
|
|
|
$sViewBox = '';
|
|
|
|
$bShowPolygons = '';
|
2018-04-13 14:18:29 +03:00
|
|
|
$aExcludePlaceIDs = array();
|
2016-09-04 04:19:48 +03:00
|
|
|
$sMoreURL = '';
|
2015-06-16 22:11:21 +03:00
|
|
|
|
2018-03-18 03:49:26 +03:00
|
|
|
$sOutputTemplate = ($sOutputFormat == 'jsonv2') ? 'json' : $sOutputFormat;
|
|
|
|
include(CONST_BasePath.'/lib/template/search-'.$sOutputTemplate.'.php');
|