]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-jsonv2.php
more tests for libphp - incorporate lonvias feedback
[nominatim.git] / lib / template / search-jsonv2.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                 $aPlace['place_rank'] = $aPointDetails['rank_search'];
40
41                 $aPlace['category'] = $aPointDetails['class'];
42                 $aPlace['type'] = $aPointDetails['type'];
43
44                 $aPlace['importance'] = $aPointDetails['importance'];
45
46                 if (isset($aPointDetails['icon']))
47                 {
48                         $aPlace['icon'] = $aPointDetails['icon'];
49                 }
50
51                 if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0)
52                 {
53                         $aPlace['address'] = $aPointDetails['address'];
54                 }
55
56                 if (isset($aPointDetails['asgeojson']))
57                 {
58                         $aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
59                 }
60
61                 if (isset($aPointDetails['assvg']))
62                 {
63                         $aPlace['svg'] = $aPointDetails['assvg'];
64                 }
65
66                 if (isset($aPointDetails['astext']))
67                 {
68                         $aPlace['geotext'] = $aPointDetails['astext'];
69                 }
70
71                 if (isset($aPointDetails['askml']))
72                 {
73                         $aPlace['geokml'] = $aPointDetails['askml'];
74                 }
75
76                 if (isset($aPointDetails['sExtraTags'])) $aPlace['extratags'] = $aPointDetails['sExtraTags'];
77                 if (isset($aPointDetails['sNameDetails'])) $aPlace['namedetails'] = $aPointDetails['sNameDetails'];
78
79                 $aFilteredPlaces[] = $aPlace;
80         }
81
82         javascript_renderData($aFilteredPlaces);