]> git.openstreetmap.org Git - nominatim.git/blob - lib-php/template/address-xml.php
always use brackets on if statements
[nominatim.git] / lib-php / 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 (empty($aPlace)) {
15     if (isset($sError)) {
16         echo "<error>$sError</error>";
17     } else {
18         echo '<error>Unable to geocode</error>';
19     }
20 } else {
21     echo '<result';
22     if ($aPlace['place_id']) {
23         echo ' place_id="'.$aPlace['place_id'].'"';
24     }
25     $sOSMType = formatOSMType($aPlace['osm_type']);
26     if ($sOSMType) {
27         echo ' osm_type="'.$sOSMType.'"'.' osm_id="'.$aPlace['osm_id'].'"';
28     }
29     if ($aPlace['ref']) {
30         echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';
31     }
32     if (isset($aPlace['lat'])) {
33         echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';
34     }
35     if (isset($aPlace['lon'])) {
36         echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';
37     }
38     if (isset($aPlace['aBoundingBox'])) {
39         echo ' boundingbox="';
40         echo join(',', $aPlace['aBoundingBox']);
41         echo '"';
42     }
43     echo " place_rank='".$aPlace['rank_search']."'";
44     echo " address_rank='".$aPlace['rank_address']."'";
45
46
47     if (isset($aPlace['asgeojson'])) {
48         echo ' geojson=\'';
49         echo $aPlace['asgeojson'];
50         echo '\'';
51     }
52
53     if (isset($aPlace['assvg'])) {
54         echo ' geosvg=\'';
55         echo $aPlace['assvg'];
56         echo '\'';
57     }
58
59     if (isset($aPlace['astext'])) {
60         echo ' geotext=\'';
61         echo $aPlace['astext'];
62         echo '\'';
63     }
64     echo '>'.htmlspecialchars($aPlace['langaddress']).'</result>';
65
66     if (isset($aPlace['address'])) {
67         echo '<addressparts>';
68         foreach ($aPlace['address']->getAddressNames() as $sKey => $sValue) {
69             $sKey = str_replace(' ', '_', $sKey);
70             echo "<$sKey>";
71             echo htmlspecialchars($sValue);
72             echo "</$sKey>";
73         }
74         echo '</addressparts>';
75     }
76
77     if (isset($aPlace['sExtraTags'])) {
78         echo '<extratags>';
79         foreach ($aPlace['sExtraTags'] as $sKey => $sValue) {
80             echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
81         }
82         echo '</extratags>';
83     }
84
85     if (isset($aPlace['sNameDetails'])) {
86         echo '<namedetails>';
87         foreach ($aPlace['sNameDetails'] as $sKey => $sValue) {
88             echo '<name desc="'.htmlspecialchars($sKey).'">';
89             echo htmlspecialchars($sValue);
90             echo '</name>';
91         }
92         echo '</namedetails>';
93     }
94
95     if (isset($aPlace['askml'])) {
96         echo "\n<geokml>";
97         echo $aPlace['askml'];
98         echo '</geokml>';
99     }
100 }
101
102 echo '</reversegeocode>';