Nominatim/lib/template/address-xml.php

88 lines
2.6 KiB
PHP
Raw Normal View History

2012-03-04 19:41:43 +04:00
<?php
header('content-type: text/xml; charset=UTF-8');
2012-03-04 19:41:43 +04: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
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
if (empty($aPlace)) {
2016-09-04 04:19:48 +03:00
if (isset($sError))
echo "<error>$sError</error>";
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']).'"';
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
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
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
if (isset($aPlace['astext'])) {
2016-09-04 04:19:48 +03:00
echo ' geotext=\'';
echo $aPlace['astext'];
echo '\'';
}
echo '>'.htmlspecialchars($aPlace['langaddress']).'</result>';
2012-03-04 19:41:43 +04:00
if (isset($aPlace['address'])) {
echo '<addressparts>';
foreach ($aPlace['address']->getAddressNames() as $sKey => $sValue) {
$sKey = str_replace(' ', '_', $sKey);
2016-09-04 04:19:48 +03:00
echo "<$sKey>";
echo htmlspecialchars($sValue);
echo "</$sKey>";
}
echo '</addressparts>';
2016-09-04 04:19:48 +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).'"/>';
}
echo '</extratags>';
2016-09-04 04:19:48 +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);
echo '</name>';
2016-09-04 04:19:48 +03:00
}
echo '</namedetails>';
2016-09-04 04:19:48 +03:00
}
2016-03-04 22:29:09 +03:00
if (isset($aPlace['askml'])) {
2016-09-04 04:19:48 +03:00
echo "\n<geokml>";
echo $aPlace['askml'];
echo '</geokml>';
2016-09-04 04:19:48 +03:00
}
}
echo '</reversegeocode>';