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" ?';
 
  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)."'";
 
  24         echo "<error>$sError</error>";
 
  26         echo '<error>Unable to geocode</error>';
 
  30     if ($aPlace['place_id']) {
 
  31         echo ' place_id="'.$aPlace['place_id'].'"';
 
  33     $sOSMType = formatOSMType($aPlace['osm_type']);
 
  35         echo ' osm_type="'.$sOSMType.'"'.' osm_id="'.$aPlace['osm_id'].'"';
 
  38         echo ' ref="'.htmlspecialchars($aPlace['ref']).'"';
 
  40     if (isset($aPlace['lat'])) {
 
  41         echo ' lat="'.htmlspecialchars($aPlace['lat']).'"';
 
  43     if (isset($aPlace['lon'])) {
 
  44         echo ' lon="'.htmlspecialchars($aPlace['lon']).'"';
 
  46     if (isset($aPlace['aBoundingBox'])) {
 
  47         echo ' boundingbox="';
 
  48         echo join(',', $aPlace['aBoundingBox']);
 
  51     echo " place_rank='".$aPlace['rank_search']."'";
 
  52     echo " address_rank='".$aPlace['rank_address']."'";
 
  55     if (isset($aPlace['asgeojson'])) {
 
  57         echo $aPlace['asgeojson'];
 
  61     if (isset($aPlace['assvg'])) {
 
  63         echo $aPlace['assvg'];
 
  67     if (isset($aPlace['astext'])) {
 
  69         echo $aPlace['astext'];
 
  72     echo '>'.htmlspecialchars($aPlace['langaddress']).'</result>';
 
  74     if (isset($aPlace['address'])) {
 
  75         echo '<addressparts>';
 
  76         foreach ($aPlace['address']->getAddressNames() as $sKey => $sValue) {
 
  77             $sKey = str_replace(' ', '_', $sKey);
 
  79             echo htmlspecialchars($sValue);
 
  82         echo '</addressparts>';
 
  85     if (isset($aPlace['sExtraTags'])) {
 
  87         foreach ($aPlace['sExtraTags'] as $sKey => $sValue) {
 
  88             echo '<tag key="'.htmlspecialchars($sKey).'" value="'.htmlspecialchars($sValue).'"/>';
 
  93     if (isset($aPlace['sNameDetails'])) {
 
  95         foreach ($aPlace['sNameDetails'] as $sKey => $sValue) {
 
  96             echo '<name desc="'.htmlspecialchars($sKey).'">';
 
  97             echo htmlspecialchars($sValue);
 
 100         echo '</namedetails>';
 
 103     if (isset($aPlace['askml'])) {
 
 105         echo $aPlace['askml'];
 
 110 echo '</reversegeocode>';