2012-03-04 19:41:43 +04:00
|
|
|
<?php
|
2018-02-23 03:16:01 +03:00
|
|
|
header('content-type: text/xml; charset=UTF-8');
|
2016-09-04 04:19:48 +03:00
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '<';
|
|
|
|
echo '?xml version="1.0" encoding="UTF-8" ?';
|
2016-09-04 04:19:48 +03:00
|
|
|
echo ">\n";
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '<';
|
2016-09-04 04:19:48 +03:00
|
|
|
echo (isset($sXmlRootTag)?$sXmlRootTag:'searchresults');
|
|
|
|
echo " timestamp='".date(DATE_RFC822)."'";
|
|
|
|
echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
|
|
|
|
echo " querystring='".htmlspecialchars($sQuery, ENT_QUOTES)."'";
|
2017-03-23 02:16:58 +03:00
|
|
|
if (isset($aMoreParams['viewbox'])) echo " viewbox='".htmlspecialchars($aMoreParams['viewbox'], ENT_QUOTES)."'";
|
|
|
|
echo " polygon='".(isset($aMoreParams['polygon'])?'true':'false')."'";
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aMoreParams['exclude_place_ids'])) {
|
2017-03-23 02:16:58 +03:00
|
|
|
echo " exclude_place_ids='".htmlspecialchars($aMoreParams['exclude_place_ids'])."'";
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
2017-03-23 02:16:58 +03:00
|
|
|
echo " more_url='".htmlspecialchars($sMoreURL)."'";
|
2016-09-04 04:19:48 +03:00
|
|
|
echo ">\n";
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
foreach ($aSearchResults as $iResNum => $aResult) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo "<place place_id='".$aResult['place_id']."'";
|
|
|
|
$sOSMType = formatOSMType($aResult['osm_type']);
|
2018-02-23 03:16:01 +03:00
|
|
|
if ($sOSMType) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo " osm_type='$sOSMType'";
|
|
|
|
echo " osm_id='".$aResult['osm_id']."'";
|
|
|
|
}
|
|
|
|
echo " place_rank='".$aResult['rank_search']."'";
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aResult['aBoundingBox'])) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo ' boundingbox="';
|
2018-02-23 03:16:01 +03:00
|
|
|
echo join(',', $aResult['aBoundingBox']);
|
2016-09-04 04:19:48 +03:00
|
|
|
echo '"';
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aResult['aPolyPoints'])) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo ' polygonpoints=\'';
|
|
|
|
echo json_encode($aResult['aPolyPoints']);
|
|
|
|
echo '\'';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aResult['asgeojson'])) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo ' geojson=\'';
|
|
|
|
echo $aResult['asgeojson'];
|
|
|
|
echo '\'';
|
|
|
|
}
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aResult['assvg'])) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo ' geosvg=\'';
|
|
|
|
echo $aResult['assvg'];
|
|
|
|
echo '\'';
|
|
|
|
}
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aResult['astext'])) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo ' geotext=\'';
|
|
|
|
echo $aResult['astext'];
|
|
|
|
echo '\'';
|
|
|
|
}
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aResult['zoom'])) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo " zoom='".$aResult['zoom']."'";
|
|
|
|
}
|
|
|
|
|
|
|
|
echo " lat='".$aResult['lat']."'";
|
|
|
|
echo " lon='".$aResult['lon']."'";
|
|
|
|
echo " display_name='".htmlspecialchars($aResult['name'], ENT_QUOTES)."'";
|
|
|
|
|
|
|
|
echo " class='".htmlspecialchars($aResult['class'])."'";
|
|
|
|
echo " type='".htmlspecialchars($aResult['type'], ENT_QUOTES)."'";
|
|
|
|
echo " importance='".htmlspecialchars($aResult['importance'])."'";
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aResult['icon']) && $aResult['icon']) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
|
|
|
|
}
|
|
|
|
|
|
|
|
$bHasDelim = false;
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aResult['askml'])) {
|
|
|
|
if (!$bHasDelim) {
|
2016-09-04 04:19:48 +03:00
|
|
|
$bHasDelim = true;
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '>';
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
|
|
|
echo "\n<geokml>";
|
|
|
|
echo $aResult['askml'];
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '</geokml>';
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aResult['sExtraTags'])) {
|
|
|
|
if (!$bHasDelim) {
|
2016-09-04 04:19:48 +03:00
|
|
|
$bHasDelim = true;
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '>';
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
|
|
|
echo "\n<extratags>";
|
2018-02-23 03:16:01 +03:00
|
|
|
foreach ($aResult['sExtraTags'] as $sKey => $sValue) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
|
|
|
|
}
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '</extratags>';
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aResult['sNameDetails'])) {
|
|
|
|
if (!$bHasDelim) {
|
2016-09-04 04:19:48 +03:00
|
|
|
$bHasDelim = true;
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '>';
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
|
|
|
echo "\n<namedetails>";
|
2018-02-23 03:16:01 +03:00
|
|
|
foreach ($aResult['sNameDetails'] as $sKey => $sValue) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo '<name desc="'.htmlspecialchars($sKey).'">';
|
|
|
|
echo htmlspecialchars($sValue);
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '</name>';
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '</namedetails>';
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aResult['address'])) {
|
|
|
|
if (!$bHasDelim) {
|
2016-09-04 04:19:48 +03:00
|
|
|
$bHasDelim = true;
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '>';
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
|
|
|
echo "\n";
|
2018-07-11 00:38:27 +03:00
|
|
|
foreach ($aResult['address']->getAddressNames() as $sKey => $sValue) {
|
2018-02-23 03:16:01 +03:00
|
|
|
$sKey = str_replace(' ', '_', $sKey);
|
2016-09-04 04:19:48 +03:00
|
|
|
echo "<$sKey>";
|
|
|
|
echo htmlspecialchars($sValue);
|
|
|
|
echo "</$sKey>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if ($bHasDelim) {
|
|
|
|
echo '</place>';
|
|
|
|
} else {
|
|
|
|
echo '/>';
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '</' . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . '>';
|