]> git.openstreetmap.org Git - nominatim.git/blob - lib-php/template/search-json.php
Merge pull request #2314 from lonvia/fix-status-no-import-date
[nominatim.git] / lib-php / template / search-json.php
1 <?php
2
3 $aFilteredPlaces = array();
4 foreach ($aSearchResults as $iResNum => $aPointDetails) {
5     $aPlace = array(
6                'place_id'=>$aPointDetails['place_id'],
7                'licence'=>'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
8               );
9     
10     $sOSMType = formatOSMType($aPointDetails['osm_type']);
11     if ($sOSMType) {
12         $aPlace['osm_type'] = $sOSMType;
13         $aPlace['osm_id'] = $aPointDetails['osm_id'];
14     }
15
16     if (isset($aPointDetails['aBoundingBox'])) {
17         $aPlace['boundingbox'] = $aPointDetails['aBoundingBox'];
18     }
19
20     if (isset($aPointDetails['zoom'])) {
21         $aPlace['zoom'] = $aPointDetails['zoom'];
22     }
23
24     $aPlace['lat'] = $aPointDetails['lat'];
25     $aPlace['lon'] = $aPointDetails['lon'];
26
27     $aPlace['display_name'] = $aPointDetails['name'];
28
29     if ($sOutputFormat == 'jsonv2' || $sOutputFormat == 'geojson') {
30         $aPlace['place_rank'] = $aPointDetails['rank_search'];
31         $aPlace['category'] = $aPointDetails['class'];
32     } else {
33         $aPlace['class'] = $aPointDetails['class'];
34     }
35     $aPlace['type'] = $aPointDetails['type'];
36
37     $aPlace['importance'] = $aPointDetails['importance'];
38
39     if (isset($aPointDetails['icon']) && $aPointDetails['icon']) {
40         $aPlace['icon'] = $aPointDetails['icon'];
41     }
42
43     if (isset($aPointDetails['address'])) {
44         $aPlace['address'] = $aPointDetails['address']->getAddressNames();
45     }
46
47     if (isset($aPointDetails['asgeojson'])) {
48         $aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
49     }
50
51     if (isset($aPointDetails['assvg'])) {
52         $aPlace['svg'] = $aPointDetails['assvg'];
53     }
54
55     if (isset($aPointDetails['astext'])) {
56         $aPlace['geotext'] = $aPointDetails['astext'];
57     }
58
59     if (isset($aPointDetails['askml'])) {
60         $aPlace['geokml'] = $aPointDetails['askml'];
61     }
62
63     if (isset($aPointDetails['sExtraTags'])) $aPlace['extratags'] = $aPointDetails['sExtraTags'];
64     if (isset($aPointDetails['sNameDetails'])) $aPlace['namedetails'] = $aPointDetails['sNameDetails'];
65
66     $aFilteredPlaces[] = $aPlace;
67 }
68
69 javascript_renderData($aFilteredPlaces);