2 header('content-type: text/xml; charset=UTF-8');
5 echo '?xml version="1.0" encoding="UTF-8" ?';
8 echo '<reversegeocode';
9 echo " timestamp='".date(DATE_RFC822)."'";
10 echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
11 echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'";
16 echo "<error>$sError</error>";
17 else echo '<error>Unable to geocode</error>';
20 if ($aPlace['place_id']) echo ' place_id="'.$aPlace['place_id'].'"';
21 $sOSMType = formatOSMType($aPlace['osm_type']);
22 if ($sOSMType) echo ' osm_type="'.$sOSMType.'"'.' osm_id="'.$aPlace['osm_id'].'"';
23 if ($aPlace['ref']) echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';
24 if (isset($aPlace['lat'])) echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';
25 if (isset($aPlace['lon'])) echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';
26 if (isset($aPlace['aBoundingBox'])) {
27 echo ' boundingbox="';
28 echo join(',', $aPlace['aBoundingBox']);
32 if (isset($aPlace['asgeojson'])) {
34 echo $aPlace['asgeojson'];
38 if (isset($aPlace['assvg'])) {
40 echo $aPlace['assvg'];
44 if (isset($aPlace['astext'])) {
46 echo $aPlace['astext'];
49 echo '>'.htmlspecialchars($aPlace['langaddress']).'</result>';
51 if (isset($aPlace['address'])) {
52 echo '<addressparts>';
53 foreach ($aPlace['address']->getAddressNames() as $sKey => $sValue) {
54 $sKey = str_replace(' ', '_', $sKey);
56 echo htmlspecialchars($sValue);
59 echo '</addressparts>';
62 if (isset($aPlace['sExtraTags'])) {
64 foreach ($aPlace['sExtraTags'] as $sKey => $sValue) {
65 echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
70 if (isset($aPlace['sNameDetails'])) {
72 foreach ($aPlace['sNameDetails'] as $sKey => $sValue) {
73 echo '<name desc="'.htmlspecialchars($sKey).'">';
74 echo htmlspecialchars($sValue);
77 echo '</namedetails>';
80 if (isset($aPlace['askml'])) {
82 echo $aPlace['askml'];
87 echo '</reversegeocode>';