]> git.openstreetmap.org Git - nominatim.git/blob - lib-php/template/address-xml.php
don't even try heavily penalized searches
[nominatim.git] / lib-php / template / address-xml.php
1 <?php
2 /**
3  * SPDX-License-Identifier: GPL-2.0-only
4  *
5  * This file is part of Nominatim. (https://nominatim.org)
6  *
7  * Copyright (C) 2022 by the Nominatim developer community.
8  * For a full list of authors see the git log.
9  */
10 header('content-type: text/xml; charset=UTF-8');
11
12 echo '<';
13 echo '?xml version="1.0" encoding="UTF-8" ?';
14 echo ">\n";
15
16 echo '<reversegeocode';
17 echo " timestamp='".date(DATE_RFC822)."'";
18 echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
19 echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'";
20 echo ">\n";
21
22 if (empty($aPlace)) {
23     if (isset($sError)) {
24         echo "<error>$sError</error>";
25     } else {
26         echo '<error>Unable to geocode</error>';
27     }
28 } else {
29     echo '<result';
30     if ($aPlace['place_id']) {
31         echo ' place_id="'.$aPlace['place_id'].'"';
32     }
33     $sOSMType = formatOSMType($aPlace['osm_type']);
34     if ($sOSMType) {
35         echo ' osm_type="'.$sOSMType.'"'.' osm_id="'.$aPlace['osm_id'].'"';
36     }
37     if ($aPlace['ref']) {
38         echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';
39     }
40     if (isset($aPlace['lat'])) {
41         echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';
42     }
43     if (isset($aPlace['lon'])) {
44         echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';
45     }
46     if (isset($aPlace['aBoundingBox'])) {
47         echo ' boundingbox="';
48         echo join(',', $aPlace['aBoundingBox']);
49         echo '"';
50     }
51     echo " place_rank='".$aPlace['rank_search']."'";
52     echo " address_rank='".$aPlace['rank_address']."'";
53
54
55     if (isset($aPlace['asgeojson'])) {
56         echo ' geojson=\'';
57         echo $aPlace['asgeojson'];
58         echo '\'';
59     }
60
61     if (isset($aPlace['assvg'])) {
62         echo ' geosvg=\'';
63         echo $aPlace['assvg'];
64         echo '\'';
65     }
66
67     if (isset($aPlace['astext'])) {
68         echo ' geotext=\'';
69         echo $aPlace['astext'];
70         echo '\'';
71     }
72     echo '>'.htmlspecialchars($aPlace['langaddress']).'</result>';
73
74     if (isset($aPlace['address'])) {
75         echo '<addressparts>';
76         foreach ($aPlace['address']->getAddressNames() as $sKey => $sValue) {
77             $sKey = str_replace(' ', '_', $sKey);
78             echo "<$sKey>";
79             echo htmlspecialchars($sValue);
80             echo "</$sKey>";
81         }
82         echo '</addressparts>';
83     }
84
85     if (isset($aPlace['sExtraTags'])) {
86         echo '<extratags>';
87         foreach ($aPlace['sExtraTags'] as $sKey => $sValue) {
88             echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
89         }
90         echo '</extratags>';
91     }
92
93     if (isset($aPlace['sNameDetails'])) {
94         echo '<namedetails>';
95         foreach ($aPlace['sNameDetails'] as $sKey => $sValue) {
96             echo '<name desc="'.htmlspecialchars($sKey).'">';
97             echo htmlspecialchars($sValue);
98             echo '</name>';
99         }
100         echo '</namedetails>';
101     }
102
103     if (isset($aPlace['askml'])) {
104         echo "\n<geokml>";
105         echo $aPlace['askml'];
106         echo '</geokml>';
107     }
108 }
109
110 echo '</reversegeocode>';