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