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