]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-xml.php
wrong variable name in json output
[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 (isset($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'])."'";
84                 if (isset($aResult['icon']) && $aResult['icon'])
85                 {
86                         echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
87                 }
88
89                 if (isset($aResult['address']) || isset($aResult['askml']))
90                 {
91                         echo ">";
92                 }
93
94                 if (isset($aResult['askml']))
95                 {
96                         echo "\n<geokml>";
97                         echo $aResult['askml'];
98                         echo "</geokml>";
99                 }
100
101                 if (isset($aResult['address']))
102                 {
103                         echo "\n";
104                         foreach($aResult['address'] as $sKey => $sValue)
105                         {
106                                 $sKey = str_replace(' ','_',$sKey);
107                                 echo "<$sKey>";
108                                 echo htmlspecialchars($sValue);
109                                 echo "</$sKey>";
110                         }
111                 }
112
113                 if (isset($aResult['address']) || isset($aResult['askml']))
114                 {
115                         echo "</place>";
116                 }
117                 else
118                 {
119                         echo "/>";
120                 }
121         }
122         
123         echo "</searchresults>";