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':($aResult['osm_type'] == 'T'?'tiger':''))));
31 echo " osm_type='$sOSMType'";
32 echo " osm_id='".$aResult['osm_id']."'";
34 echo " place_rank='".$aResult['rank_search']."'";
36 if (isset($aResult['aBoundingBox']))
38 echo ' boundingbox="';
39 echo $aResult['aBoundingBox'][0];
40 echo ','.$aResult['aBoundingBox'][1];
41 echo ','.$aResult['aBoundingBox'][2];
42 echo ','.$aResult['aBoundingBox'][3];
45 if ($bShowPolygons && isset($aResult['aPolyPoints']))
47 echo ' polygonpoints=\'';
48 echo json_encode($aResult['aPolyPoints']);
53 if (isset($aResult['asgeojson']))
56 echo $aResult['asgeojson'];
60 if (isset($aResult['assvg']))
63 echo $aResult['assvg'];
67 if (isset($aResult['astext']))
70 echo $aResult['astext'];
74 if (isset($aResult['zoom']))
76 echo " zoom='".$aResult['zoom']."'";
79 echo " lat='".$aResult['lat']."'";
80 echo " lon='".$aResult['lon']."'";
81 echo " display_name='".htmlspecialchars($aResult['name'], ENT_QUOTES)."'";
83 echo " class='".htmlspecialchars($aResult['class'])."'";
84 echo " type='".htmlspecialchars($aResult['type'], ENT_QUOTES)."'";
85 echo " importance='".htmlspecialchars($aResult['importance'])."'";
86 if (isset($aResult['icon']) && $aResult['icon'])
88 echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
93 if (isset($aResult['askml']))
101 echo $aResult['askml'];
105 if (isset($aResult['sExtraTags']))
112 echo "\n<extratags>";
113 foreach ($aResult['sExtraTags'] as $sKey => $sValue)
115 echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
120 if (isset($aResult['sNameDetails']))
127 echo "\n<namedetails>";
128 foreach ($aResult['sNameDetails'] as $sKey => $sValue)
130 echo '<name desc="'.htmlspecialchars($sKey).'">';
131 echo htmlspecialchars($sValue);
134 echo "</namedetails>";
137 if (isset($aResult['address']))
145 foreach($aResult['address'] as $sKey => $sValue)
147 $sKey = str_replace(' ','_',$sKey);
149 echo htmlspecialchars($sValue);
164 echo "</" . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . ">";