]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/address-xml.php
don't print address details if they are not requested
[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                 if (isset($aPlace['lat'])) echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';\r
29                 if (isset($aPlace['lon'])) echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';\r
30                 echo ">".htmlspecialchars($aPlace['langaddress'])."</result>";\r
31 \r
32         if ($bShowAddressDetails) {\r
33                         echo "<addressparts>";\r
34                         foreach($aAddress as $sKey => $sValue)\r
35                         {\r
36                                 $sKey = str_replace(' ','_',$sKey);\r
37                                 echo "<$sKey>";\r
38                                 echo htmlspecialchars($sValue);\r
39                                 echo "</$sKey>";\r
40                         }\r
41                         echo "</addressparts>";\r
42         }\r
43         }\r
44         \r
45         echo "</reversegeocode>";\r