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 ($sViewBox) echo " viewbox='".htmlspecialchars($sViewBox, ENT_QUOTES)."'";
14 echo " polygon='".($bShowPolygons?'true':'false')."'";
15 if (sizeof($aExcludePlaceIDs))
17 echo " exclude_place_ids='".htmlspecialchars(join(',',$aExcludePlaceIDs))."'";
21 echo " more_url='".htmlspecialchars($sMoreURL)."'";
25 foreach($aSearchResults as $iResNum => $aResult)
27 echo "<place place_id='".$aResult['place_id']."'";
28 $sOSMType = ($aResult['osm_type'] == 'N'?'node':($aResult['osm_type'] == 'W'?'way':($aResult['osm_type'] == 'R'?'relation':
29 ($aResult['osm_type'] == 'T'?'tiger':($aResult['osm_type'] == 'I'?'interpolation':'')))));
32 echo " osm_type='$sOSMType'";
33 echo " osm_id='".$aResult['osm_id']."'";
35 echo " place_rank='".$aResult['rank_search']."'";
37 if (isset($aResult['aBoundingBox']))
39 echo ' boundingbox="';
40 echo join(',',$aResult['aBoundingBox']);
43 if ($bShowPolygons && isset($aResult['aPolyPoints']))
45 echo ' polygonpoints=\'';
46 echo json_encode($aResult['aPolyPoints']);
51 if (isset($aResult['asgeojson']))
54 echo $aResult['asgeojson'];
58 if (isset($aResult['assvg']))
61 echo $aResult['assvg'];
65 if (isset($aResult['astext']))
68 echo $aResult['astext'];
72 if (isset($aResult['zoom']))
74 echo " zoom='".$aResult['zoom']."'";
77 echo " lat='".$aResult['lat']."'";
78 echo " lon='".$aResult['lon']."'";
79 echo " display_name='".htmlspecialchars($aResult['name'], ENT_QUOTES)."'";
81 echo " class='".htmlspecialchars($aResult['class'])."'";
82 echo " type='".htmlspecialchars($aResult['type'], ENT_QUOTES)."'";
83 echo " importance='".htmlspecialchars($aResult['importance'])."'";
84 if (isset($aResult['icon']) && $aResult['icon'])
86 echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
91 if (isset($aResult['askml']))
99 echo $aResult['askml'];
103 if (isset($aResult['sExtraTags']))
110 echo "\n<extratags>";
111 foreach ($aResult['sExtraTags'] as $sKey => $sValue)
113 echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
118 if (isset($aResult['sNameDetails']))
125 echo "\n<namedetails>";
126 foreach ($aResult['sNameDetails'] as $sKey => $sValue)
128 echo '<name desc="'.htmlspecialchars($sKey).'">';
129 echo htmlspecialchars($sValue);
132 echo "</namedetails>";
135 if (isset($aResult['address']))
143 foreach($aResult['address'] as $sKey => $sValue)
145 $sKey = str_replace(' ','_',$sKey);
147 echo htmlspecialchars($sValue);
162 echo "</" . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . ">";