]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-batch-json.php
Merge branch 'osmosis_error_return' of https://github.com/woodpeck/Nominatim
[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                 $aFilteredPlaces = array();
10                 foreach($aSearchResults as $iResNum => $aPointDetails)
11                 {
12                         $aPlace = array(
13                                         'place_id'=>$aPointDetails['place_id'],
14                                   );
15
16                         $sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':'')));
17                         if ($sOSMType)
18                         {
19                                 $aPlace['osm_type'] = $sOSMType;
20                                 $aPlace['osm_id'] = $aPointDetails['osm_id'];
21                         }
22
23                         if (isset($aPointDetails['aBoundingBox']))
24                         {
25                                 $aPlace['boundingbox'] = array(
26                                         $aPointDetails['aBoundingBox'][0],
27                                         $aPointDetails['aBoundingBox'][1],
28                                         $aPointDetails['aBoundingBox'][2],
29                                         $aPointDetails['aBoundingBox'][3]);
30
31                                 if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons)
32                                 {
33                                         $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
34                                 }
35                         }
36
37                         if (isset($aPointDetails['zoom']))
38                         {
39                                 $aPlace['zoom'] = $aPointDetails['zoom'];
40                         }
41
42                         $aPlace['lat'] = $aPointDetails['lat'];
43                         $aPlace['lon'] = $aPointDetails['lon'];
44                         $aPlace['display_name'] = $aPointDetails['name'];
45                         $aPlace['place_rank'] = $aPointDetails['rank_search'];
46
47                         $aPlace['category'] = $aPointDetails['class'];
48                         $aPlace['type'] = $aPointDetails['type'];
49
50                         $aPlace['importance'] = $aPointDetails['importance'];
51
52                         if (isset($aPointDetails['icon']))
53                         {
54                                 $aPlace['icon'] = $aPointDetails['icon'];
55                         }
56
57                         if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0)
58                         {
59                                 $aPlace['address'] = $aPointDetails['address'];
60                         }
61
62                         if (isset($aPointDetails['asgeojson']))
63                         {
64                                 $aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
65                         }
66
67                         if (isset($aPointDetails['assvg']))
68                         {
69                                 $aPlace['svg'] = $aPointDetails['assvg'];
70                         }
71
72                         if (isset($aPointDetails['astext']))
73                         {
74                                 $aPlace['geotext'] = $aPointDetails['astext'];
75                         }
76
77                         if (isset($aPointDetails['askml']))
78                         {
79                                 $aPlace['geokml'] = $aPointDetails['askml'];
80                         }
81
82                         $aFilteredPlaces[] = $aPlace;
83                 }
84                 $aOutput['batch'][] = $aFilteredPlaces;
85         }
86
87         javascript_renderData($aOutput, array('geojson'));