]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-json.php
Merge branch 'tigerlines' of /home/markus/Nominatim into tiger
[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'?'relation':($aPointDetails['osm_type'] == 'T'?'tiger':''))));
13                 if ($sOSMType)
14                 {
15                         $aPlace['osm_type'] = $sOSMType;
16                         $aPlace['osm_id'] = $aPointDetails['osm_id'];
17                 }
18
19                 if (isset($aPointDetails['aBoundingBox']))
20                 {
21                         $aPlace['boundingbox'] = $aPointDetails['aBoundingBox'];
22
23                         if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons)
24                         {
25                                 $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
26                         }
27                 }
28
29                 if (isset($aPointDetails['zoom']))
30                 {
31                         $aPlace['zoom'] = $aPointDetails['zoom'];
32                 }
33
34                 $aPlace['lat'] = $aPointDetails['lat'];
35                 $aPlace['lon'] = $aPointDetails['lon'];
36                 $aPlace['display_name'] = $aPointDetails['name'];
37
38                 $aPlace['class'] = $aPointDetails['class'];
39                 $aPlace['type'] = $aPointDetails['type'];
40
41                 $aPlace['importance'] = $aPointDetails['importance'];
42
43                 if (isset($aPointDetails['icon']) && $aPointDetails['icon'])
44                 {
45                         $aPlace['icon'] = $aPointDetails['icon'];
46                 }
47
48                 if (isset($aPointDetails['address']))
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);