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.
11 $aFilteredPlaces = array();
15 $aFilteredPlaces['error'] = $sError;
17 $aFilteredPlaces['error'] = 'Unable to geocode';
20 if (isset($aPlace['place_id'])) {
21 $aFilteredPlaces['place_id'] = $aPlace['place_id'];
23 $aFilteredPlaces['licence'] = 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright';
24 $sOSMType = formatOSMType($aPlace['osm_type']);
26 $aFilteredPlaces['osm_type'] = $sOSMType;
27 $aFilteredPlaces['osm_id'] = $aPlace['osm_id'];
29 if (isset($aPlace['lat'])) {
30 $aFilteredPlaces['lat'] = $aPlace['lat'];
32 if (isset($aPlace['lon'])) {
33 $aFilteredPlaces['lon'] = $aPlace['lon'];
36 if ($sOutputFormat == 'jsonv2' || $sOutputFormat == 'geojson') {
37 $aFilteredPlaces['place_rank'] = $aPlace['rank_search'];
39 $aFilteredPlaces['category'] = $aPlace['class'];
40 $aFilteredPlaces['type'] = $aPlace['type'];
42 $aFilteredPlaces['importance'] = $aPlace['importance'];
44 $aFilteredPlaces['addresstype'] = strtolower($aPlace['addresstype']);
46 $aFilteredPlaces['name'] = $aPlace['placename'];
49 $aFilteredPlaces['display_name'] = $aPlace['langaddress'];
51 if (isset($aPlace['address'])) {
52 $aFilteredPlaces['address'] = $aPlace['address']->getAddressNames();
54 if (isset($aPlace['sExtraTags'])) {
55 $aFilteredPlaces['extratags'] = $aPlace['sExtraTags'];
57 if (isset($aPlace['sNameDetails'])) {
58 $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails'];
61 if (isset($aPlace['aBoundingBox'])) {
62 $aFilteredPlaces['boundingbox'] = $aPlace['aBoundingBox'];
65 if (isset($aPlace['asgeojson'])) {
66 $aFilteredPlaces['geojson'] = json_decode($aPlace['asgeojson'], true);
69 if (isset($aPlace['assvg'])) {
70 $aFilteredPlaces['svg'] = $aPlace['assvg'];
73 if (isset($aPlace['astext'])) {
74 $aFilteredPlaces['geotext'] = $aPlace['astext'];
77 if (isset($aPlace['askml'])) {
78 $aFilteredPlaces['geokml'] = $aPlace['askml'];
82 javascript_renderData($aFilteredPlaces);