]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-json.php
Change access control to implement more of CORS. Change so OPTIONS requests don...
[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':'')));
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'] = array(
22                                 $aPointDetails['aBoundingBox'][0],
23                                 $aPointDetails['aBoundingBox'][1],
24                                 $aPointDetails['aBoundingBox'][2],
25                                 $aPointDetails['aBoundingBox'][3]);
26
27                         if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons)
28                         {
29                                 $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
30                         }
31                 }
32
33                 if (isset($aPointDetails['zoom']))
34                 {
35                         $aPlace['zoom'] = $aPointDetails['zoom'];
36                 }
37
38                 $aPlace['lat'] = $aPointDetails['lat'];
39                 $aPlace['lon'] = $aPointDetails['lon'];
40                 $aPlace['display_name'] = $aPointDetails['name'];
41
42                 $aPlace['class'] = $aPointDetails['class'];
43                 $aPlace['type'] = $aPointDetails['type'];
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($aResult['asgeojson']))
55                 {
56                         $aPlace['geojson'] = json_decode($aResult['asgeojson']);
57                 }
58
59                 if (isset($aResult['assvg']))
60                 {
61                         $aPlace['svg'] = $aResult['assvg'];
62                 }
63
64                 if (isset($aResult['astext']))
65                 {
66                         $aPlace['geotext'] = $aResult['astext'];
67                 }
68
69                 if (isset($aResult['askml']))
70                 {
71                         $aPlace['geokml'] = $aResult['askml'];
72                 }
73
74                 $aFilteredPlaces[] = $aPlace;
75         }
76
77         javascript_renderData($aFilteredPlaces);