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'])) echo " viewbox='".htmlspecialchars($aMoreParams['viewbox'], ENT_QUOTES)."'";
14 if (isset($aMoreParams['exclude_place_ids'])) {
15 echo " exclude_place_ids='".htmlspecialchars($aMoreParams['exclude_place_ids'])."'";
17 echo " more_url='".htmlspecialchars($sMoreURL)."'";
20 foreach ($aSearchResults as $iResNum => $aResult) {
21 echo "<place place_id='".$aResult['place_id']."'";
22 $sOSMType = formatOSMType($aResult['osm_type']);
24 echo " osm_type='$sOSMType'";
25 echo " osm_id='".$aResult['osm_id']."'";
27 echo " place_rank='".$aResult['rank_search']."'";
28 echo " address_rank='".$aResult['rank_address']."'";
30 if (isset($aResult['aBoundingBox'])) {
31 echo ' boundingbox="';
32 echo join(',', $aResult['aBoundingBox']);
36 if (isset($aResult['asgeojson'])) {
38 echo $aResult['asgeojson'];
42 if (isset($aResult['assvg'])) {
44 echo $aResult['assvg'];
48 if (isset($aResult['astext'])) {
50 echo $aResult['astext'];
54 if (isset($aResult['zoom'])) {
55 echo " zoom='".$aResult['zoom']."'";
58 echo " lat='".$aResult['lat']."'";
59 echo " lon='".$aResult['lon']."'";
60 echo " display_name='".htmlspecialchars($aResult['name'], ENT_QUOTES)."'";
62 echo " class='".htmlspecialchars($aResult['class'])."'";
63 echo " type='".htmlspecialchars($aResult['type'], ENT_QUOTES)."'";
64 echo " importance='".htmlspecialchars($aResult['importance'])."'";
65 if (isset($aResult['icon']) && $aResult['icon']) {
66 echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
71 if (isset($aResult['askml'])) {
77 echo $aResult['askml'];
81 if (isset($aResult['sExtraTags'])) {
87 foreach ($aResult['sExtraTags'] as $sKey => $sValue) {
88 echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
93 if (isset($aResult['sNameDetails'])) {
98 echo "\n<namedetails>";
99 foreach ($aResult['sNameDetails'] as $sKey => $sValue) {
100 echo '<name desc="'.htmlspecialchars($sKey).'">';
101 echo htmlspecialchars($sValue);
104 echo '</namedetails>';
107 if (isset($aResult['address'])) {
113 foreach ($aResult['address']->getAddressNames() as $sKey => $sValue) {
114 $sKey = str_replace(' ', '_', $sKey);
116 echo htmlspecialchars($sValue);
128 echo '</' . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . '>';