]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-batch-json.php
fix structured and batch mode. Add constant to disable batch mode by default
[nominatim.git] / lib / template / search-batch-json.php
1 <?php
2
3         $aOutput = array();
4         $aOutput['licence'] = "Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright";
5         $aOutput['batch'] = array();
6
7         foreach($aBatchResults as $aSearchResults)
8         {
9                 if (!$aSearchResults) $aSearchResults = array();
10                 $aFilteredPlaces = array();
11                 foreach($aSearchResults as $iResNum => $aPointDetails)
12                 {
13                         $aPlace = array(
14                                         'place_id'=>$aPointDetails['place_id'],
15                                   );
16
17                         $sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':'')));
18                         if ($sOSMType)
19                         {
20                                 $aPlace['osm_type'] = $sOSMType;
21                                 $aPlace['osm_id'] = $aPointDetails['osm_id'];
22                         }
23
24                         if (isset($aPointDetails['aBoundingBox']))
25                         {
26                                 $aPlace['boundingbox'] = array(
27                                         $aPointDetails['aBoundingBox'][0],
28                                         $aPointDetails['aBoundingBox'][1],
29                                         $aPointDetails['aBoundingBox'][2],
30                                         $aPointDetails['aBoundingBox'][3]);
31
32                                 if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons)
33                                 {
34                                         $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
35                                 }
36                         }
37
38                         if (isset($aPointDetails['zoom']))
39                         {
40                                 $aPlace['zoom'] = $aPointDetails['zoom'];
41                         }
42
43                         $aPlace['lat'] = $aPointDetails['lat'];
44                         $aPlace['lon'] = $aPointDetails['lon'];
45                         $aPlace['display_name'] = $aPointDetails['name'];
46                         $aPlace['place_rank'] = $aPointDetails['rank_search'];
47
48                         $aPlace['category'] = $aPointDetails['class'];
49                         $aPlace['type'] = $aPointDetails['type'];
50
51                         $aPlace['importance'] = $aPointDetails['importance'];
52
53                         if (isset($aPointDetails['icon']))
54                         {
55                                 $aPlace['icon'] = $aPointDetails['icon'];
56                         }
57
58                         if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0)
59                         {
60                                 $aPlace['address'] = $aPointDetails['address'];
61                         }
62
63                         if (isset($aPointDetails['asgeojson']))
64                         {
65                                 $aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
66                         }
67
68                         if (isset($aPointDetails['assvg']))
69                         {
70                                 $aPlace['svg'] = $aPointDetails['assvg'];
71                         }
72
73                         if (isset($aPointDetails['astext']))
74                         {
75                                 $aPlace['geotext'] = $aPointDetails['astext'];
76                         }
77
78                         if (isset($aPointDetails['askml']))
79                         {
80                                 $aPlace['geokml'] = $aPointDetails['askml'];
81                         }
82
83                         $aFilteredPlaces[] = $aPlace;
84                 }
85                 $aOutput['batch'][] = $aFilteredPlaces;
86         }
87
88         javascript_renderData($aOutput, array('geojson'));