]> git.openstreetmap.org Git - nominatim.git/blob - lib-php/template/search-json.php
allow search for partials consisting of 3 or more words
[nominatim.git] / lib-php / template / search-json.php
1 <?php
2 /**
3  * SPDX-License-Identifier: GPL-2.0-only
4  *
5  * This file is part of Nominatim. (https://nominatim.org)
6  *
7  * Copyright (C) 2022 by the Nominatim developer community.
8  * For a full list of authors see the git log.
9  */
10
11 $aFilteredPlaces = array();
12 foreach ($aSearchResults as $iResNum => $aPointDetails) {
13     $aPlace = array(
14                'place_id'=>$aPointDetails['place_id'],
15                'licence'=>'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
16               );
17
18     $sOSMType = formatOSMType($aPointDetails['osm_type']);
19     if ($sOSMType) {
20         $aPlace['osm_type'] = $sOSMType;
21         $aPlace['osm_id'] = $aPointDetails['osm_id'];
22     }
23
24     if (isset($aPointDetails['aBoundingBox'])) {
25         $aPlace['boundingbox'] = $aPointDetails['aBoundingBox'];
26     }
27
28     if (isset($aPointDetails['zoom'])) {
29         $aPlace['zoom'] = $aPointDetails['zoom'];
30     }
31
32     $aPlace['lat'] = $aPointDetails['lat'];
33     $aPlace['lon'] = $aPointDetails['lon'];
34
35     $aPlace['display_name'] = $aPointDetails['name'];
36
37     if ($sOutputFormat == 'jsonv2' || $sOutputFormat == 'geojson') {
38         $aPlace['place_rank'] = $aPointDetails['rank_search'];
39         $aPlace['category'] = $aPointDetails['class'];
40     } else {
41         $aPlace['class'] = $aPointDetails['class'];
42     }
43     $aPlace['type'] = $aPointDetails['type'];
44
45     $aPlace['importance'] = $aPointDetails['importance'];
46
47     if (isset($aPointDetails['icon']) && $aPointDetails['icon']) {
48         $aPlace['icon'] = $aPointDetails['icon'];
49     }
50
51     if (isset($aPointDetails['address'])) {
52         $aPlace['address'] = $aPointDetails['address']->getAddressNames();
53     }
54
55     if (isset($aPointDetails['asgeojson'])) {
56         $aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
57     }
58
59     if (isset($aPointDetails['assvg'])) {
60         $aPlace['svg'] = $aPointDetails['assvg'];
61     }
62
63     if (isset($aPointDetails['astext'])) {
64         $aPlace['geotext'] = $aPointDetails['astext'];
65     }
66
67     if (isset($aPointDetails['askml'])) {
68         $aPlace['geokml'] = $aPointDetails['askml'];
69     }
70
71     if (isset($aPointDetails['sExtraTags'])) {
72         $aPlace['extratags'] = $aPointDetails['sExtraTags'];
73     }
74     if (isset($aPointDetails['sNameDetails'])) {
75         $aPlace['namedetails'] = $aPointDetails['sNameDetails'];
76     }
77
78     $aFilteredPlaces[] = $aPlace;
79 }
80
81 javascript_renderData($aFilteredPlaces);