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');
|
2012-03-04 19:41:43 +04: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";
|
2012-03-04 19:41:43 +04:00
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '<reversegeocode';
|
2016-09-04 04:19:48 +03:00
|
|
|
echo " timestamp='".date(DATE_RFC822)."'";
|
|
|
|
echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
|
|
|
|
echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'";
|
|
|
|
echo ">\n";
|
2012-03-04 19:41:43 +04:00
|
|
|
|
2018-03-22 14:36:24 +03:00
|
|
|
if (empty($aPlace)) {
|
2016-09-04 04:19:48 +03:00
|
|
|
if (isset($sError))
|
|
|
|
echo "<error>$sError</error>";
|
2018-02-23 03:16:01 +03:00
|
|
|
else echo '<error>Unable to geocode</error>';
|
|
|
|
} else {
|
|
|
|
echo '<result';
|
2016-09-04 04:19:48 +03:00
|
|
|
if ($aPlace['place_id']) echo ' place_id="'.$aPlace['place_id'].'"';
|
|
|
|
$sOSMType = formatOSMType($aPlace['osm_type']);
|
|
|
|
if ($sOSMType) echo ' osm_type="'.$sOSMType.'"'.' osm_id="'.$aPlace['osm_id'].'"';
|
|
|
|
if ($aPlace['ref']) echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';
|
|
|
|
if (isset($aPlace['lat'])) echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';
|
|
|
|
if (isset($aPlace['lon'])) echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aPlace['aBoundingBox'])) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo ' boundingbox="';
|
|
|
|
echo join(',', $aPlace['aBoundingBox']);
|
|
|
|
echo '"';
|
|
|
|
}
|
2016-03-04 22:29:09 +03:00
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aPlace['asgeojson'])) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo ' geojson=\'';
|
|
|
|
echo $aPlace['asgeojson'];
|
|
|
|
echo '\'';
|
|
|
|
}
|
2016-03-04 22:29:09 +03:00
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aPlace['assvg'])) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo ' geosvg=\'';
|
|
|
|
echo $aPlace['assvg'];
|
|
|
|
echo '\'';
|
|
|
|
}
|
2016-03-04 22:29:09 +03:00
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aPlace['astext'])) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo ' geotext=\'';
|
|
|
|
echo $aPlace['astext'];
|
|
|
|
echo '\'';
|
|
|
|
}
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '>'.htmlspecialchars($aPlace['langaddress']).'</result>';
|
2012-03-04 19:41:43 +04:00
|
|
|
|
2018-07-11 00:38:27 +03:00
|
|
|
if (isset($aPlace['address'])) {
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '<addressparts>';
|
2018-07-11 00:38:27 +03:00
|
|
|
foreach ($aPlace['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
|
|
|
echo '</addressparts>';
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
2015-08-09 16:14:59 +03:00
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aPlace['sExtraTags'])) {
|
|
|
|
echo '<extratags>';
|
|
|
|
foreach ($aPlace['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
|
|
|
}
|
2015-08-09 16:14:59 +03:00
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aPlace['sNameDetails'])) {
|
|
|
|
echo '<namedetails>';
|
|
|
|
foreach ($aPlace['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
|
|
|
}
|
2016-03-04 22:29:09 +03:00
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
if (isset($aPlace['askml'])) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo "\n<geokml>";
|
|
|
|
echo $aPlace['askml'];
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '</geokml>';
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
|
|
|
}
|
2012-12-17 04:24:58 +04:00
|
|
|
|
2018-02-23 03:16:01 +03:00
|
|
|
echo '</reversegeocode>';
|