]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/address-jsonv2.php
remove unused protolib
[nominatim.git] / lib / template / address-jsonv2.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 \r
7         if (!sizeof($aPlace))\r
8         {\r
9                 if ($sError)\r
10                         $aFilteredPlaces['error'] = $sError;\r
11                 else\r
12                         $aFilteredPlaces['error'] = 'Unable to geocode';\r
13         }\r
14         else\r
15         {\r
16                 if ($aPlace['place_id']) $aFilteredPlaces['place_id'] = $aPlace['place_id'];\r
17                 $aFilteredPlaces['licence'] = "Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.";\r
18                 $sOSMType = ($aPlace['osm_type'] == 'N'?'node':($aPlace['osm_type'] == 'W'?'way':($aPlace['osm_type'] == 'R'?'relation':'')));\r
19                 if ($sOSMType)\r
20                 {\r
21                         $aFilteredPlaces['osm_type'] = $sOSMType;\r
22                         $aFilteredPlaces['osm_id'] = $aPlace['osm_id'];\r
23                 }\r
24                 if (isset($aPlace['lat'])) $aFilteredPlaces['lat'] = $aPlace['lat'];\r
25                 if (isset($aPlace['lon'])) $aFilteredPlaces['lon'] = $aPlace['lon'];\r
26                 $aFilteredPlaces['category'] = $aPlace['class'];\r
27                 $aFilteredPlaces['type'] = $aPlace['type'];\r
28                 $aFilteredPlaces['addresstype'] = strtolower($aPlace['addresstype']);\r
29 \r
30                 $aFilteredPlaces['display_name'] = $aPlace['langaddress'];\r
31                 $aFilteredPlaces['name'] = $aPlace['placename'];\r
32                 $aFilteredPlaces['address'] = $aAddress;\r
33         }\r
34 \r
35         if (isset($_GET['json_callback']) && preg_match('/^[-A-Za-z0-9:_]+$/',$_GET['json_callback']))\r
36         {\r
37                 echo $_GET['json_callback'].'('.javascript_renderData($aFilteredPlaces).')';\r
38         }\r
39         else\r
40         {\r
41                 echo javascript_renderData($aFilteredPlaces);\r
42         }\r
43 \r
44 \r