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