2 header("content-type: text/xml; charset=UTF-8");
\r
3 header("Access-Control-Allow-Origin: *");
\r
6 echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
\r
9 echo "<reversegeocode";
\r
10 echo " timestamp='".date(DATE_RFC822)."'";
\r
11 echo " attribution='Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.'";
\r
12 echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'";
\r
15 if (!sizeof($aPlace))
\r
18 echo "<error>$sError</error>";
\r
20 echo "<error>Unable to geocode</error>";
\r
25 if ($aPlace['place_id']) echo ' place_id="'.$aPlace['place_id'].'"';
\r
26 if ($aPlace['osm_type'] && $aPlace['osm_id']) echo ' osm_type="'.($aPlace['osm_type']=='N'?'node':($aPlace['osm_type']=='W'?'way':'relation')).'"'.' osm_id="'.$aPlace['osm_id'].'"';
\r
27 if ($aPlace['ref']) echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';
\r
28 if (isset($aPlace['lat'])) echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';
\r
29 if (isset($aPlace['lon'])) echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';
\r
30 echo ">".htmlspecialchars($aPlace['langaddress'])."</result>";
\r
32 echo "<addressparts>";
\r
33 foreach($aAddress as $sKey => $sValue)
\r
35 $sKey = str_replace(' ','_',$sKey);
\r
37 echo htmlspecialchars($sValue);
\r
40 echo "</addressparts>";
\r
43 echo "</reversegeocode>";
\r