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