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