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