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