3 * SPDX-License-Identifier: GPL-2.0-only
5 * This file is part of Nominatim. (https://nominatim.org)
7 * Copyright (C) 2022 by the Nominatim developer community.
8 * For a full list of authors see the git log.
10 header('content-type: text/xml; charset=UTF-8');
13 echo '?xml version="1.0" encoding="UTF-8" ?';
17 echo (isset($sXmlRootTag)?$sXmlRootTag:'searchresults');
18 echo " timestamp='".date(DATE_RFC822)."'";
19 echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright'";
20 echo " querystring='".htmlspecialchars($sQuery, ENT_QUOTES)."'";
21 if (isset($aMoreParams['viewbox'])) {
22 echo " viewbox='".htmlspecialchars($aMoreParams['viewbox'], ENT_QUOTES)."'";
24 if (isset($aMoreParams['exclude_place_ids'])) {
25 echo " exclude_place_ids='".htmlspecialchars($aMoreParams['exclude_place_ids'])."'";
27 echo " more_url='".htmlspecialchars($sMoreURL)."'";
30 foreach ($aSearchResults as $iResNum => $aResult) {
31 echo "<place place_id='".$aResult['place_id']."'";
32 $sOSMType = formatOSMType($aResult['osm_type']);
34 echo " osm_type='$sOSMType'";
35 echo " osm_id='".$aResult['osm_id']."'";
37 echo " place_rank='".$aResult['rank_search']."'";
38 echo " address_rank='".$aResult['rank_address']."'";
40 if (isset($aResult['aBoundingBox'])) {
41 echo ' boundingbox="';
42 echo join(',', $aResult['aBoundingBox']);
46 if (isset($aResult['asgeojson'])) {
48 echo $aResult['asgeojson'];
52 if (isset($aResult['assvg'])) {
54 echo $aResult['assvg'];
58 if (isset($aResult['astext'])) {
60 echo $aResult['astext'];
64 if (isset($aResult['zoom'])) {
65 echo " zoom='".$aResult['zoom']."'";
68 echo " lat='".$aResult['lat']."'";
69 echo " lon='".$aResult['lon']."'";
70 echo " display_name='".htmlspecialchars($aResult['name'], ENT_QUOTES)."'";
72 echo " class='".htmlspecialchars($aResult['class'])."'";
73 echo " type='".htmlspecialchars($aResult['type'], ENT_QUOTES)."'";
74 echo " importance='".htmlspecialchars($aResult['importance'])."'";
75 if (isset($aResult['icon']) && $aResult['icon']) {
76 echo " icon='".htmlspecialchars($aResult['icon'], ENT_QUOTES)."'";
81 if (isset($aResult['askml'])) {
87 echo $aResult['askml'];
91 if (isset($aResult['sExtraTags'])) {
97 foreach ($aResult['sExtraTags'] as $sKey => $sValue) {
98 echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
103 if (isset($aResult['sNameDetails'])) {
108 echo "\n<namedetails>";
109 foreach ($aResult['sNameDetails'] as $sKey => $sValue) {
110 echo '<name desc="'.htmlspecialchars($sKey).'">';
111 echo htmlspecialchars($sValue);
114 echo '</namedetails>';
117 if (isset($aResult['address'])) {
123 foreach ($aResult['address']->getAddressNames() as $sKey => $sValue) {
124 $sKey = str_replace(' ', '_', $sKey);
126 echo htmlspecialchars($sValue);
138 echo '</' . (isset($sXmlRootTag)?$sXmlRootTag:'searchresults') . '>';