]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-xml.php
convert CRLF to make git happy
[nominatim.git] / lib / template / search-xml.php
1 <?php
2         header("content-type: text/xml; charset=UTF-8");
3         header("Access-Control-Allow-Origin: *");
4
5         echo "<";
6         echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
7         echo ">\n";
8
9         echo "<searchresults";
10         echo " timestamp='".date(DATE_RFC822)."'";
11         echo " attribution='Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.'";
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))
16         {
17                 echo " exclude_place_ids='".htmlspecialchars(join(',',$aExcludePlaceIDs))."'";
18         }
19         if ($sMoreURL)
20         {
21                 echo " more_url='".htmlspecialchars($sMoreURL)."'";
22         }
23         echo ">\n";
24
25         foreach($aSearchResults as $iResNum => $aResult)
26         {
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                 if ($sOSMType)
30                 {
31                         echo " osm_type='$sOSMType'";
32                         echo " osm_id='".$aResult['osm_id']."'";
33                 }
34                 echo " place_rank='".$aResult['rank_search']."'";
35
36                 if (isset($aResult['aBoundingBox']))
37                 {
38                         echo ' boundingbox="';
39                         echo $aResult['aBoundingBox'][0];
40                         echo ','.$aResult['aBoundingBox'][1];
41                         echo ','.$aResult['aBoundingBox'][2];
42                         echo ','.$aResult['aBoundingBox'][3];
43                         echo '"';
44
45                         if ($bShowPolygons && isset($aResult['aPolyPoints']))
46                         {
47                                 echo ' polygonpoints=\'';
48                                 echo javascript_renderData($aResult['aPolyPoints']);
49                                 echo '\'';
50                         }
51                 }
52
53                 if (isset($aResult['zoom']))
54                 {
55                         echo " zoom='".$aResult['zoom']."'";
56                 }
57
58                 echo " lat='".$aResult['lat']."'";
59                 echo " lon='".$aResult['lon']."'";
60                 echo " display_name='".htmlspecialchars($aResult['name'], ENT_QUOTES)."'";
61
62                 echo " class='".htmlspecialchars($aResult['class'])."'";
63                 echo " type='".htmlspecialchars($aResult['type'])."'";
64                 if ($aResult['icon'])
65                 {
66                         echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
67                 }
68
69                 if (isset($aResult['address']))
70                 {
71                         echo ">";
72                         foreach($aResult['address'] as $sKey => $sValue)
73                         {
74                                 $sKey = str_replace(' ','_',$sKey);
75                                 echo "<$sKey>";
76                                 echo htmlspecialchars($sValue);
77                                 echo "</$sKey>";
78                         }
79
80                         echo "</place>";
81                 }
82                 else
83                 {
84                         echo "/>";
85                 }
86         }
87         
88         echo "</searchresults>";