]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-xml.php
replace final reference to way-node index with spatial lookup
[nominatim.git] / lib / template / search-xml.php
1 <?php
2         header("content-type: text/xml; charset=UTF-8");
3
4         echo "<";
5         echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";
6         echo ">\n";
7
8         echo "<searchresults";
9         echo " timestamp='".date(DATE_RFC822)."'";
10         echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
11         echo " querystring='".htmlspecialchars($sQuery, ENT_QUOTES)."'";
12         if ($sViewBox) echo " viewbox='".htmlspecialchars($sViewBox, ENT_QUOTES)."'";
13         echo " polygon='".($bShowPolygons?'true':'false')."'";
14         if (sizeof($aExcludePlaceIDs))
15         {
16                 echo " exclude_place_ids='".htmlspecialchars(join(',',$aExcludePlaceIDs))."'";
17         }
18         if ($sMoreURL)
19         {
20                 echo " more_url='".htmlspecialchars($sMoreURL)."'";
21         }
22         echo ">\n";
23
24         foreach($aSearchResults as $iResNum => $aResult)
25         {
26                 echo "<place place_id='".$aResult['place_id']."'";
27                 $sOSMType = ($aResult['osm_type'] == 'N'?'node':($aResult['osm_type'] == 'W'?'way':($aResult['osm_type'] == 'R'?'relation':'')));
28                 if ($sOSMType)
29                 {
30                         echo " osm_type='$sOSMType'";
31                         echo " osm_id='".$aResult['osm_id']."'";
32                 }
33                 echo " place_rank='".$aResult['rank_search']."'";
34
35                 if (isset($aResult['aBoundingBox']))
36                 {
37                         echo ' boundingbox="';
38                         echo $aResult['aBoundingBox'][0];
39                         echo ','.$aResult['aBoundingBox'][1];
40                         echo ','.$aResult['aBoundingBox'][2];
41                         echo ','.$aResult['aBoundingBox'][3];
42                         echo '"';
43
44                         if ($bShowPolygons && isset($aResult['aPolyPoints']))
45                         {
46                                 echo ' polygonpoints=\'';
47                                 echo json_encode($aResult['aPolyPoints']);
48                                 echo '\'';
49                         }
50                 }
51
52                 if (isset($aResult['asgeojson']))
53                 {
54                         echo ' geojson=\'';
55                         echo $aResult['asgeojson'];
56                         echo '\'';
57                 }
58
59                 if (isset($aResult['assvg']))
60                 {
61                         echo ' geosvg=\'';
62                         echo $aResult['assvg'];
63                         echo '\'';
64                 }
65
66                 if (isset($aResult['astext']))
67                 {
68                         echo ' geotext=\'';
69                         echo $aResult['astext'];
70                         echo '\'';
71                 }
72
73                 if (isset($aResult['zoom']))
74                 {
75                         echo " zoom='".$aResult['zoom']."'";
76                 }
77
78                 echo " lat='".$aResult['lat']."'";
79                 echo " lon='".$aResult['lon']."'";
80                 echo " display_name='".htmlspecialchars($aResult['name'], ENT_QUOTES)."'";
81
82                 echo " class='".htmlspecialchars($aResult['class'])."'";
83                 echo " type='".htmlspecialchars($aResult['type'], ENT_QUOTES)."'";
84                 echo " importance='".htmlspecialchars($aResult['importance'])."'";
85                 if (isset($aResult['icon']) && $aResult['icon'])
86                 {
87                         echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
88                 }
89
90                 if (isset($aResult['address']) || isset($aResult['askml']))
91                 {
92                         echo ">";
93                 }
94
95                 if (isset($aResult['askml']))
96                 {
97                         echo "\n<geokml>";
98                         echo $aResult['askml'];
99                         echo "</geokml>";
100                 }
101
102                 if (isset($aResult['address']))
103                 {
104                         echo "\n";
105                         foreach($aResult['address'] as $sKey => $sValue)
106                         {
107                                 $sKey = str_replace(' ','_',$sKey);
108                                 echo "<$sKey>";
109                                 echo htmlspecialchars($sValue);
110                                 echo "</$sKey>";
111                         }
112                 }
113
114                 if (isset($aResult['address']) || isset($aResult['askml']))
115                 {
116                         echo "</place>";
117                 }
118                 else
119                 {
120                         echo "/>";
121                 }
122         }
123         
124         echo "</searchresults>";