]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/address-xml.php
final result ordering, remove GB postcode hacks
[nominatim.git] / lib / template / address-xml.php
1 <?php\r
2         header("content-type: text/xml; charset=UTF-8");\r
3         header("Access-Control-Allow-Origin: *");\r
4 \r
5         echo "<";\r
6         echo "?xml version=\"1.0\" encoding=\"UTF-8\" ?";\r
7         echo ">\n";\r
8 \r
9         echo "<reversegeocode";\r
10         echo " timestamp='".date(DATE_RFC822)."'";\r
11         echo " attribution='Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.'";\r
12         echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'";\r
13         echo ">\n";\r
14 \r
15         if (!sizeof($aPlace))\r
16         {\r
17                 if ($sError)\r
18                         echo "<error>$sError</error>";\r
19                 else\r
20                         echo "<error>Unable to geocode</error>";\r
21         }\r
22         else\r
23         {\r
24                 echo "<result";\r
25                 if ($aPlace['place_id']) echo ' place_id="'.$aPlace['place_id'].'"';\r
26                 if ($aPlace['osm_type'] && $aPlace['osm_id']) echo ' osm_type="'.($aPlace['osm_type']=='N'?'node':($aPlace['osm_type']=='W'?'way':'relation')).'"'.' osm_id="'.$aPlace['osm_id'].'"';\r
27                 if ($aPlace['ref']) echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';\r
28                 echo ">".htmlspecialchars($aPlace['langaddress'])."</result>";\r
29 \r
30                 echo "<addressparts>";\r
31                 foreach($aAddress as $sKey => $sValue)\r
32                 {\r
33                         $sKey = str_replace(' ','_',$sKey);\r
34                         echo "<$sKey>";\r
35                         echo htmlspecialchars($sValue);\r
36                         echo "</$sKey>";\r
37                 }\r
38                 echo "</addressparts>";\r
39         }\r
40         \r
41         echo "</reversegeocode>";\r