]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/address-xml.php
status after hackweekend London
[nominatim.git] / lib / template / address-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 "<reversegeocode";
9         echo " timestamp='".date(DATE_RFC822)."'";
10         echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
11         echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'";
12         echo ">\n";
13
14         if (!sizeof($aPlace))
15         {
16                 if (isset($sError))
17                         echo "<error>$sError</error>";
18                 else
19                         echo "<error>Unable to geocode</error>";
20         }
21         else
22         {
23                 echo "<result";
24                 if ($aPlace['place_id']) echo ' place_id="'.$aPlace['place_id'].'"';
25                 $sOSMType = ($aPlace['osm_type'] == 'N'?'node':($aPlace['osm_type'] == 'W'?'way':($aPlace['osm_type'] == 'R'?'relation':'')));
26                 if ($sOSMType) echo ' osm_type="'.$sOSMType.'"'.' osm_id="'.$aPlace['osm_id'].'"';
27                 if ($aPlace['ref']) echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';
28                 if (isset($aPlace['lat'])) echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';
29                 if (isset($aPlace['lon'])) echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';
30                 echo ">".htmlspecialchars($aPlace['langaddress'])."</result>";
31
32                 if (isset($aPlace['aAddress']))
33                 {
34                         echo "<addressparts>";
35                         foreach($aPlace['aAddress'] as $sKey => $sValue)
36                         {
37                                 $sKey = str_replace(' ','_',$sKey);
38                                 echo "<$sKey>";
39                                 echo htmlspecialchars($sValue);
40                                 echo "</$sKey>";
41                         }
42                         echo "</addressparts>";
43                 }
44
45                 if (isset($aPlace['sExtraTags']))
46                 {
47                         echo "<extratags>";
48                         foreach ($aPlace['sExtraTags'] as $sKey => $sValue)
49                         {
50                                 echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
51                         }
52                         echo "</extratags>";
53                 }
54
55                 if (isset($aPlace['sNameDetails']))
56                 {
57                         echo "<namedetails>";
58                         foreach ($aPlace['sNameDetails'] as $sKey => $sValue)
59                         {
60                                 echo '<name desc="'.htmlspecialchars($sKey).'">';
61                                 echo htmlspecialchars($sValue);
62                                 echo "</name>";
63                         }
64                         echo "</namedetails>";
65                 }
66         }
67
68         echo "</reversegeocode>";