]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/address-json.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / lib / template / address-json.php
1 <?php
2
3 $aFilteredPlaces = array();
4
5 if (empty($aPlace)) {
6     if (isset($sError))
7         $aFilteredPlaces['error'] = $sError;
8     else $aFilteredPlaces['error'] = 'Unable to geocode';
9 } else {
10     if (isset($aPlace['place_id'])) $aFilteredPlaces['place_id'] = $aPlace['place_id'];
11     $aFilteredPlaces['licence'] = 'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright';
12     $sOSMType = formatOSMType($aPlace['osm_type']);
13     if ($sOSMType) {
14         $aFilteredPlaces['osm_type'] = $sOSMType;
15         $aFilteredPlaces['osm_id'] = $aPlace['osm_id'];
16     }
17     if (isset($aPlace['lat'])) $aFilteredPlaces['lat'] = $aPlace['lat'];
18     if (isset($aPlace['lon'])) $aFilteredPlaces['lon'] = $aPlace['lon'];
19
20     if ($sOutputFormat == 'jsonv2' || $sOutputFormat == 'geojson') {
21         $aFilteredPlaces['place_rank'] = $aPlace['rank_search'];
22
23         $aFilteredPlaces['category'] = $aPlace['class'];
24         $aFilteredPlaces['type'] = $aPlace['type'];
25
26         $aFilteredPlaces['importance'] = $aPlace['importance'];
27
28         $aFilteredPlaces['addresstype'] = strtolower($aPlace['addresstype']);
29
30         $aFilteredPlaces['name'] = $aPlace['placename'];
31     }
32
33     $aFilteredPlaces['display_name'] = $aPlace['langaddress'];
34
35     if (isset($aPlace['aAddress'])) $aFilteredPlaces['address'] = $aPlace['aAddress'];
36     if (isset($aPlace['sExtraTags'])) $aFilteredPlaces['extratags'] = $aPlace['sExtraTags'];
37     if (isset($aPlace['sNameDetails'])) $aFilteredPlaces['namedetails'] = $aPlace['sNameDetails'];
38
39     if (isset($aPlace['aBoundingBox'])) {
40         $aFilteredPlaces['boundingbox'] = $aPlace['aBoundingBox'];
41     }
42
43     if (isset($aPlace['asgeojson'])) {
44         $aFilteredPlaces['geojson'] = json_decode($aPlace['asgeojson']);
45     }
46
47     if (isset($aPlace['assvg'])) {
48         $aFilteredPlaces['svg'] = $aPlace['assvg'];
49     }
50
51     if (isset($aPlace['astext'])) {
52         $aFilteredPlaces['geotext'] = $aPlace['astext'];
53     }
54
55     if (isset($aPlace['askml'])) {
56         $aFilteredPlaces['geokml'] = $aPlace['askml'];
57     }
58 }
59
60 javascript_renderData($aFilteredPlaces);