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 // https://github.com/geocoders/geocodejson-spec/
13 $aFilteredPlaces = array();
17 $aFilteredPlaces['error'] = $sError;
19 $aFilteredPlaces['error'] = 'Unable to geocode';
21 javascript_renderData($aFilteredPlaces);
23 $aFilteredPlaces = array(
25 'properties' => array(
26 'geocoding' => array()
30 if (isset($aPlace['place_id'])) {
31 $aFilteredPlaces['properties']['geocoding']['place_id'] = $aPlace['place_id'];
33 $sOSMType = formatOSMType($aPlace['osm_type']);
35 $aFilteredPlaces['properties']['geocoding']['osm_type'] = $sOSMType;
36 $aFilteredPlaces['properties']['geocoding']['osm_id'] = $aPlace['osm_id'];
39 $aFilteredPlaces['properties']['geocoding']['type'] = addressRankToGeocodeJsonType($aPlace['rank_address']);
41 $aFilteredPlaces['properties']['geocoding']['accuracy'] = (int) $fDistance;
43 $aFilteredPlaces['properties']['geocoding']['label'] = $aPlace['langaddress'];
45 if ($aPlace['placename'] !== null) {
46 $aFilteredPlaces['properties']['geocoding']['name'] = $aPlace['placename'];
49 if (isset($aPlace['address'])) {
50 $aPlace['address']->addGeocodeJsonAddressParts(
51 $aFilteredPlaces['properties']['geocoding']
54 $aFilteredPlaces['properties']['geocoding']['admin']
55 = $aPlace['address']->getAdminLevels();
58 if (isset($aPlace['asgeojson'])) {
59 $aFilteredPlaces['geometry'] = json_decode($aPlace['asgeojson']);
61 $aFilteredPlaces['geometry'] = array(
63 'coordinates' => array(
64 (float) $aPlace['lon'],
65 (float) $aPlace['lat']
70 javascript_renderData(array(
71 'type' => 'FeatureCollection',
74 'attribution' => 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
78 'features' => array($aFilteredPlaces)