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