]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-json.php
remove unused protolib
[nominatim.git] / lib / template / search-json.php
1 <?php\r
2         header("Content-Type: application/json; charset=UTF-8");\r
3         header("Access-Control-Allow-Origin: *");\r
4 \r
5         $aFilteredPlaces = array();\r
6         foreach($aSearchResults as $iResNum => $aPointDetails)\r
7         {\r
8                 $aPlace = array(\r
9                                 'place_id'=>$aPointDetails['place_id'],\r
10                                 'licence'=>"Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.",\r
11                         );\r
12 \r
13                 $sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':'')));\r
14                 if ($sOSMType)\r
15                 {\r
16                         $aPlace['osm_type'] = $sOSMType;\r
17                         $aPlace['osm_id'] = $aPointDetails['osm_id'];\r
18                 }\r
19 \r
20                 if (isset($aPointDetails['aBoundingBox']))\r
21                 {\r
22                         $aPlace['boundingbox'] = array(\r
23                                 $aPointDetails['aBoundingBox'][0],\r
24                                 $aPointDetails['aBoundingBox'][1],\r
25                                 $aPointDetails['aBoundingBox'][2],\r
26                                 $aPointDetails['aBoundingBox'][3]);\r
27 \r
28                         if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons)\r
29                         {\r
30                                 $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];\r
31                         }\r
32                 }\r
33 \r
34                 if (isset($aPointDetails['zoom']))\r
35                 {\r
36                         $aPlace['zoom'] = $aPointDetails['zoom'];\r
37                 }\r
38 \r
39                 $aPlace['lat'] = $aPointDetails['lat'];\r
40                 $aPlace['lon'] = $aPointDetails['lon'];\r
41                 $aPlace['display_name'] = $aPointDetails['name'];\r
42 \r
43                 $aPlace['class'] = $aPointDetails['class'];\r
44                 $aPlace['type'] = $aPointDetails['type'];\r
45                 if ($aPointDetails['icon'])\r
46                 {\r
47                         $aPlace['icon'] = $aPointDetails['icon'];\r
48                 }\r
49 \r
50                 if (isset($aPointDetails['address']))\r
51                 {\r
52                         $aPlace['address'] = $aPointDetails['address'];\r
53                 }\r
54 \r
55                 $aFilteredPlaces[] = $aPlace;\r
56         }\r
57 \r
58         if (isset($_GET['json_callback']) && preg_match('/^[-A-Za-z0-9:_.]+$/',$_GET['json_callback']))\r
59         {\r
60                 echo $_GET['json_callback'].'('.javascript_renderData($aFilteredPlaces).')';\r
61         }\r
62         else\r
63         {\r
64                 echo javascript_renderData($aFilteredPlaces);\r
65         }\r