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();
12 foreach ($aSearchResults as $iResNum => $aPointDetails) {
15 'properties' => array(
16 'geocoding' => array()
20 if (isset($aPointDetails['place_id'])) {
21 $aPlace['properties']['geocoding']['place_id'] = $aPointDetails['place_id'];
23 $sOSMType = formatOSMType($aPointDetails['osm_type']);
25 $aPlace['properties']['geocoding']['osm_type'] = $sOSMType;
26 $aPlace['properties']['geocoding']['osm_id'] = $aPointDetails['osm_id'];
28 $aPlace['properties']['geocoding']['osm_key'] = $aPointDetails['class'];
29 $aPlace['properties']['geocoding']['osm_value'] = $aPointDetails['type'];
31 $aPlace['properties']['geocoding']['type'] = addressRankToGeocodeJsonType($aPointDetails['rank_address']);
33 $aPlace['properties']['geocoding']['label'] = $aPointDetails['langaddress'];
35 if ($aPointDetails['placename'] !== null) {
36 $aPlace['properties']['geocoding']['name'] = $aPointDetails['placename'];
39 if (isset($aPointDetails['address'])) {
40 $aPointDetails['address']->addGeocodeJsonAddressParts(
41 $aPlace['properties']['geocoding']
44 $aPlace['properties']['geocoding']['admin']
45 = $aPointDetails['address']->getAdminLevels();
48 if (isset($aPointDetails['asgeojson'])) {
49 $aPlace['geometry'] = json_decode($aPointDetails['asgeojson'], true);
51 $aPlace['geometry'] = array(
53 'coordinates' => array(
54 (float) $aPointDetails['lon'],
55 (float) $aPointDetails['lat']
59 $aFilteredPlaces[] = $aPlace;
63 javascript_renderData(array(
64 'type' => 'FeatureCollection',
67 'attribution' => 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
71 'features' => $aFilteredPlaces