]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-batch-json.php
README: tiny markdown syntax error
[nominatim.git] / lib / 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             if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons) {
30                 $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
31             }
32         }
33
34         if (isset($aPointDetails['zoom'])) {
35             $aPlace['zoom'] = $aPointDetails['zoom'];
36         }
37
38         $aPlace['lat'] = $aPointDetails['lat'];
39         $aPlace['lon'] = $aPointDetails['lon'];
40         $aPlace['display_name'] = $aPointDetails['name'];
41         $aPlace['place_rank'] = $aPointDetails['rank_search'];
42
43         $aPlace['category'] = $aPointDetails['class'];
44         $aPlace['type'] = $aPointDetails['type'];
45
46         $aPlace['importance'] = $aPointDetails['importance'];
47
48         if (isset($aPointDetails['icon'])) {
49             $aPlace['icon'] = $aPointDetails['icon'];
50         }
51
52         if (isset($aPointDetails['address'])) {
53             $aPlace['address'] = $aPointDetails['address']->getAddressNames();
54         }
55
56         if (isset($aPointDetails['asgeojson'])) {
57             $aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
58         }
59
60         if (isset($aPointDetails['assvg'])) {
61             $aPlace['svg'] = $aPointDetails['assvg'];
62         }
63
64         if (isset($aPointDetails['astext'])) {
65             $aPlace['geotext'] = $aPointDetails['astext'];
66         }
67
68         if (isset($aPointDetails['askml'])) {
69             $aPlace['geokml'] = $aPointDetails['askml'];
70         }
71
72         $aFilteredPlaces[] = $aPlace;
73     }
74     $aOutput['batch'][] = $aFilteredPlaces;
75 }
76
77 javascript_renderData($aOutput, array('geojson'));