2 header('content-type: text/xml; charset=UTF-8');
5 echo '?xml version="1.0" encoding="UTF-8" ?';
9 echo (isset($sXmlRootTag)?$sXmlRootTag:'searchresults');
10 echo " timestamp='".date(DATE_RFC822)."'";
11 echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
12 echo " querystring='".htmlspecialchars($sQuery, ENT_QUOTES)."'";
13 if (isset($aMoreParams['viewbox'])) {
14 echo " viewbox='".htmlspecialchars($aMoreParams['viewbox'], ENT_QUOTES)."'";
16 if (isset($aMoreParams['exclude_place_ids'])) {
17 echo " exclude_place_ids='".htmlspecialchars($aMoreParams['exclude_place_ids'])."'";
19 echo " more_url='".htmlspecialchars($sMoreURL)."'";
22 foreach ($aSearchResults as $iResNum => $aResult) {
23 echo "<place place_id='".$aResult['place_id']."'";
24 $sOSMType = formatOSMType($aResult['osm_type']);
26 echo " osm_type='$sOSMType'";
27 echo " osm_id='".$aResult['osm_id']."'";
29 echo " place_rank='".$aResult['rank_search']."'";
30 echo " address_rank='".$aResult['rank_address']."'";
32 if (isset($aResult['aBoundingBox'])) {
33 echo ' boundingbox="';
34 echo join(',', $aResult['aBoundingBox']);
38 if (isset($aResult['asgeojson'])) {
40 echo $aResult['asgeojson'];
44 if (isset($aResult['assvg'])) {
46 echo $aResult['assvg'];
50 if (isset($aResult['astext'])) {
52 echo $aResult['astext'];
56 if (isset($aResult['zoom'])) {
57 echo " zoom='".$aResult['zoom']."'";
60 echo " lat='".$aResult['lat']."'";
61 echo " lon='".$aResult['lon']."'";
62 echo " display_name='".htmlspecialchars($aResult['name'], ENT_QUOTES)."'";
64 echo " class='".htmlspecialchars($aResult['class'])."'";
65 echo " type='".htmlspecialchars($aResult['type'], ENT_QUOTES)."'";
66 echo " importance='".htmlspecialchars($aResult['importance'])."'";
67 if (isset($aResult['icon']) && $aResult['icon']) {
68 echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
73 if (isset($aResult['askml'])) {
79 echo $aResult['askml'];
83 if (isset($aResult['sExtraTags'])) {
89 foreach ($aResult['sExtraTags'] as $sKey => $sValue) {
90 echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
95 if (isset($aResult['sNameDetails'])) {
100 echo "\n<namedetails>";
101 foreach ($aResult['sNameDetails'] as $sKey => $sValue) {
102 echo '<name desc="'.htmlspecialchars($sKey).'">';
103 echo htmlspecialchars($sValue);
106 echo '</namedetails>';
109 if (isset($aResult['address'])) {
115 foreach ($aResult['address']->getAddressNames() as $sKey => $sValue) {
116 $sKey = str_replace(' ', '_', $sKey);
118 echo htmlspecialchars($sValue);
130 echo '</' . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . '>';