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';
19 javascript_renderData($aFilteredPlaces);
21 $aFilteredPlaces = array(
23 'properties' => array()
26 if (isset($aPlace['place_id'])) {
27 $aFilteredPlaces['properties']['place_id'] = $aPlace['place_id'];
29 $sOSMType = formatOSMType($aPlace['osm_type']);
31 $aFilteredPlaces['properties']['osm_type'] = $sOSMType;
32 $aFilteredPlaces['properties']['osm_id'] = $aPlace['osm_id'];
35 $aFilteredPlaces['properties']['place_rank'] = $aPlace['rank_search'];
37 $aFilteredPlaces['properties']['category'] = $aPlace['class'];
38 $aFilteredPlaces['properties']['type'] = $aPlace['type'];
40 $aFilteredPlaces['properties']['importance'] = $aPlace['importance'];
42 $aFilteredPlaces['properties']['addresstype'] = strtolower($aPlace['addresstype']);
44 $aFilteredPlaces['properties']['name'] = $aPlace['placename'];
46 $aFilteredPlaces['properties']['display_name'] = $aPlace['langaddress'];
48 if (isset($aPlace['address'])) {
49 $aFilteredPlaces['properties']['address'] = $aPlace['address']->getAddressNames();
51 if (isset($aPlace['sExtraTags'])) {
52 $aFilteredPlaces['properties']['extratags'] = $aPlace['sExtraTags'];
54 if (isset($aPlace['sNameDetails'])) {
55 $aFilteredPlaces['properties']['namedetails'] = $aPlace['sNameDetails'];
58 if (isset($aPlace['aBoundingBox'])) {
59 $aFilteredPlaces['bbox'] = array(
60 (float) $aPlace['aBoundingBox'][2], // minlon
61 (float) $aPlace['aBoundingBox'][0], // minlat
62 (float) $aPlace['aBoundingBox'][3], // maxlon
63 (float) $aPlace['aBoundingBox'][1] // maxlat
67 if (isset($aPlace['asgeojson'])) {
68 $aFilteredPlaces['geometry'] = json_decode($aPlace['asgeojson']);
70 $aFilteredPlaces['geometry'] = array(
72 'coordinates' => array(
73 (float) $aPlace['lon'],
74 (float) $aPlace['lat']
80 javascript_renderData(array(
81 'type' => 'FeatureCollection',
82 'licence' => 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
83 'features' => array($aFilteredPlaces)