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']);
31 echo " place_rank='".$aPlace['rank_search']."'";
32 echo " address_rank='".$aPlace['rank_address']."'";
35 if (isset($aPlace['asgeojson'])) {
37 echo $aPlace['asgeojson'];
41 if (isset($aPlace['assvg'])) {
43 echo $aPlace['assvg'];
47 if (isset($aPlace['astext'])) {
49 echo $aPlace['astext'];
52 echo '>'.htmlspecialchars($aPlace['langaddress']).'</result>';
54 if (isset($aPlace['address'])) {
55 echo '<addressparts>';
56 foreach ($aPlace['address']->getAddressNames() as $sKey => $sValue) {
57 $sKey = str_replace(' ', '_', $sKey);
59 echo htmlspecialchars($sValue);
62 echo '</addressparts>';
65 if (isset($aPlace['sExtraTags'])) {
67 foreach ($aPlace['sExtraTags'] as $sKey => $sValue) {
68 echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
73 if (isset($aPlace['sNameDetails'])) {
75 foreach ($aPlace['sNameDetails'] as $sKey => $sValue) {
76 echo '<name desc="'.htmlspecialchars($sKey).'">';
77 echo htmlspecialchars($sValue);
80 echo '</namedetails>';
83 if (isset($aPlace['askml'])) {
85 echo $aPlace['askml'];
90 echo '</reversegeocode>';