]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-json.php
replace PHP sizeof() with either count() or empty()
[nominatim.git] / lib / 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         if (isset($aPointDetails['aPolyPoints'])) {
20             $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
21         }
22     }
23
24     if (isset($aPointDetails['zoom'])) {
25         $aPlace['zoom'] = $aPointDetails['zoom'];
26     }
27
28     $aPlace['lat'] = $aPointDetails['lat'];
29     $aPlace['lon'] = $aPointDetails['lon'];
30     $aPlace['display_name'] = $aPointDetails['name'];
31
32     if ($sOutputFormat == 'jsonv2') {
33         $aPlace['place_rank'] = $aPointDetails['rank_search'];
34         $aPlace['category'] = $aPointDetails['class'];
35     } else {
36         $aPlace['class'] = $aPointDetails['class'];
37     }
38     $aPlace['type'] = $aPointDetails['type'];
39
40     $aPlace['importance'] = $aPointDetails['importance'];
41
42     if (isset($aPointDetails['icon']) && $aPointDetails['icon']) {
43         $aPlace['icon'] = $aPointDetails['icon'];
44     }
45
46     if (isset($aPointDetails['address']) && !empty($aPointDetails['address'])) {
47         $aPlace['address'] = $aPointDetails['address'];
48     }
49
50     if (isset($aPointDetails['asgeojson'])) {
51         $aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
52     }
53
54     if (isset($aPointDetails['assvg'])) {
55         $aPlace['svg'] = $aPointDetails['assvg'];
56     }
57
58     if (isset($aPointDetails['astext'])) {
59         $aPlace['geotext'] = $aPointDetails['astext'];
60     }
61
62     if (isset($aPointDetails['askml'])) {
63         $aPlace['geokml'] = $aPointDetails['askml'];
64     }
65
66     if (isset($aPointDetails['sExtraTags'])) $aPlace['extratags'] = $aPointDetails['sExtraTags'];
67     if (isset($aPointDetails['sNameDetails'])) $aPlace['namedetails'] = $aPointDetails['sNameDetails'];
68
69     $aFilteredPlaces[] = $aPlace;
70 }
71
72 javascript_renderData($aFilteredPlaces);