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