]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/address-xml.php
tabs-to-spaces
[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 = formatOSMType($aPlace['osm_type']);
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     if (isset($aPlace['aBoundingBox']))
31     {
32         echo ' boundingbox="';
33         echo join(',', $aPlace['aBoundingBox']);
34         echo '"';
35     }
36
37     if (isset($aPlace['asgeojson']))
38     {
39         echo ' geojson=\'';
40         echo $aPlace['asgeojson'];
41         echo '\'';
42     }
43
44     if (isset($aPlace['assvg']))
45     {
46         echo ' geosvg=\'';
47         echo $aPlace['assvg'];
48         echo '\'';
49     }
50
51     if (isset($aPlace['astext']))
52     {
53         echo ' geotext=\'';
54         echo $aPlace['astext'];
55         echo '\'';
56     }
57     echo ">".htmlspecialchars($aPlace['langaddress'])."</result>";
58
59     if (isset($aPlace['aAddress']))
60     {
61         echo "<addressparts>";
62         foreach($aPlace['aAddress'] as $sKey => $sValue)
63         {
64             $sKey = str_replace(' ','_',$sKey);
65             echo "<$sKey>";
66             echo htmlspecialchars($sValue);
67             echo "</$sKey>";
68         }
69         echo "</addressparts>";
70     }
71
72     if (isset($aPlace['sExtraTags']))
73     {
74         echo "<extratags>";
75         foreach ($aPlace['sExtraTags'] as $sKey => $sValue)
76         {
77             echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
78         }
79         echo "</extratags>";
80     }
81
82     if (isset($aPlace['sNameDetails']))
83     {
84         echo "<namedetails>";
85         foreach ($aPlace['sNameDetails'] as $sKey => $sValue)
86         {
87             echo '<name desc="'.htmlspecialchars($sKey).'">';
88             echo htmlspecialchars($sValue);
89             echo "</name>";
90         }
91         echo "</namedetails>";
92     }
93
94     if (isset($aPlace['askml']))
95     {
96         echo "\n<geokml>";
97         echo $aPlace['askml'];
98         echo "</geokml>";
99     }
100
101 }
102
103 echo "</reversegeocode>";