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 $aPlaceDetails = array();
13 $aPlaceDetails['place_id'] = (int) $aPointDetails['place_id'];
14 $aPlaceDetails['parent_place_id'] = (int) $aPointDetails['parent_place_id'];
16 $aPlaceDetails['osm_type'] = $aPointDetails['osm_type'];
17 $aPlaceDetails['osm_id'] = (int) $aPointDetails['osm_id'];
19 $aPlaceDetails['category'] = $aPointDetails['class'];
20 $aPlaceDetails['type'] = $aPointDetails['type'];
21 $aPlaceDetails['admin_level'] = $aPointDetails['admin_level'];
23 $aPlaceDetails['localname'] = $aPointDetails['localname'];
24 $aPlaceDetails['names'] = $aPointDetails['aNames'];
26 $aPlaceDetails['addresstags'] = $aPointDetails['aAddressTags'];
27 $aPlaceDetails['housenumber'] = $aPointDetails['housenumber'];
28 $aPlaceDetails['calculated_postcode'] = $aPointDetails['postcode'];
29 $aPlaceDetails['country_code'] = $aPointDetails['country_code'];
31 $aPlaceDetails['indexed_date'] = (new DateTime('@'.$aPointDetails['indexed_epoch']))->format(DateTime::RFC3339);
32 $aPlaceDetails['importance'] = (float) $aPointDetails['importance'];
33 $aPlaceDetails['calculated_importance'] = (float) $aPointDetails['calculated_importance'];
35 $aPlaceDetails['extratags'] = $aPointDetails['aExtraTags'];
36 $aPlaceDetails['calculated_wikipedia'] = $aPointDetails['wikipedia'];
37 $sIcon = Nominatim\ClassTypes\getIconFile($aPointDetails);
39 $aPlaceDetails['icon'] = $sIcon;
42 $aPlaceDetails['rank_address'] = (int) $aPointDetails['rank_address'];
43 $aPlaceDetails['rank_search'] = (int) $aPointDetails['rank_search'];
45 $aPlaceDetails['isarea'] = $aPointDetails['isarea'];
46 $aPlaceDetails['centroid'] = array(
48 'coordinates' => array( (float) $aPointDetails['lon'], (float) $aPointDetails['lat'] )
51 $aPlaceDetails['geometry'] = json_decode($aPointDetails['asgeojson'], true);
53 $funcMapAddressLine = function ($aFull) {
55 'localname' => $aFull['localname'],
56 'place_id' => isset($aFull['place_id']) ? (int) $aFull['place_id'] : null,
57 'osm_id' => isset($aFull['osm_id']) ? (int) $aFull['osm_id'] : null,
58 'osm_type' => isset($aFull['osm_type']) ? $aFull['osm_type'] : null,
59 'place_type' => isset($aFull['place_type']) ? $aFull['place_type'] : null,
60 'class' => $aFull['class'],
61 'type' => $aFull['type'],
62 'admin_level' => isset($aFull['admin_level']) ? (int) $aFull['admin_level'] : null,
63 'rank_address' => $aFull['rank_address'] ? (int) $aFull['rank_address'] : null,
64 'distance' => (float) $aFull['distance'],
65 'isaddress' => isset($aFull['isaddress']) ? (bool) $aFull['isaddress'] : null
69 $funcMapKeyword = function ($aFull) {
71 'id' => (int) $aFull['word_id'],
72 'token' => $aFull['word_token']
77 $aPlaceDetails['address'] = array_map($funcMapAddressLine, $aAddressLines);
81 $aPlaceDetails['linked_places'] = array_map($funcMapAddressLine, $aLinkedLines);
84 if ($bIncludeKeywords) {
85 $aPlaceDetails['keywords'] = array();
87 if ($aPlaceSearchNameKeywords) {
88 $aPlaceDetails['keywords']['name'] = array_map($funcMapKeyword, $aPlaceSearchNameKeywords);
90 $aPlaceDetails['keywords']['name'] = array();
93 if ($aPlaceSearchAddressKeywords) {
94 $aPlaceDetails['keywords']['address'] = array_map($funcMapKeyword, $aPlaceSearchAddressKeywords);
96 $aPlaceDetails['keywords']['address'] = array();
100 if ($bIncludeHierarchy) {
101 if ($bGroupHierarchy) {
102 $aPlaceDetails['hierarchy'] = array();
103 foreach ($aHierarchyLines as $aAddressLine) {
104 if ($aAddressLine['type'] == 'yes') {
105 $sType = $aAddressLine['class'];
107 $sType = $aAddressLine['type'];
110 if (!isset($aPlaceDetails['hierarchy'][$sType])) {
111 $aPlaceDetails['hierarchy'][$sType] = array();
113 $aPlaceDetails['hierarchy'][$sType][] = $funcMapAddressLine($aAddressLine);
116 $aPlaceDetails['hierarchy'] = array_map($funcMapAddressLine, $aHierarchyLines);
120 javascript_renderData($aPlaceDetails);