]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-json.php
Merge pull request #1090 from mtmail/add-more-nominatim.so-faq-entries
[nominatim.git] / lib / template / search-json.php
1 <?php
2
3 $aFilteredPlaces = array();
4 foreach ($aSearchResults as $iResNum => $aPointDetails) {
5     $aPlace = array(
6                'place_id'=>$aPointDetails['place_id'],
7                'licence'=>'Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright',
8               );
9     
10     $sOSMType = formatOSMType($aPointDetails['osm_type']);
11     if ($sOSMType) {
12         $aPlace['osm_type'] = $sOSMType;
13         $aPlace['osm_id'] = $aPointDetails['osm_id'];
14     }
15
16     if (isset($aPointDetails['aBoundingBox'])) {
17         $aPlace['boundingbox'] = $aPointDetails['aBoundingBox'];
18
19         if (isset($aPointDetails['aPolyPoints'])) {
20             $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
21         }
22     }
23
24     if (isset($aPointDetails['zoom'])) {
25         $aPlace['zoom'] = $aPointDetails['zoom'];
26     }
27
28     $aPlace['lat'] = $aPointDetails['lat'];
29     $aPlace['lon'] = $aPointDetails['lon'];
30
31     $aPlace['display_name'] = $aPointDetails['name'];
32
33     if ($sOutputFormat == 'jsonv2' || $sOutputFormat == 'geojson') {
34         $aPlace['place_rank'] = $aPointDetails['rank_search'];
35         $aPlace['category'] = $aPointDetails['class'];
36     } else {
37         $aPlace['class'] = $aPointDetails['class'];
38     }
39     $aPlace['type'] = $aPointDetails['type'];
40
41     $aPlace['importance'] = $aPointDetails['importance'];
42
43     if (isset($aPointDetails['icon']) && $aPointDetails['icon']) {
44         $aPlace['icon'] = $aPointDetails['icon'];
45     }
46
47     if (isset($aPointDetails['address'])) {
48         $aPlace['address'] = $aPointDetails['address']->getAddressNames();
49     }
50
51     if (isset($aPointDetails['asgeojson'])) {
52         $aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
53     }
54
55     if (isset($aPointDetails['assvg'])) {
56         $aPlace['svg'] = $aPointDetails['assvg'];
57     }
58
59     if (isset($aPointDetails['astext'])) {
60         $aPlace['geotext'] = $aPointDetails['astext'];
61     }
62
63     if (isset($aPointDetails['askml'])) {
64         $aPlace['geokml'] = $aPointDetails['askml'];
65     }
66
67     if (isset($aPointDetails['sExtraTags'])) $aPlace['extratags'] = $aPointDetails['sExtraTags'];
68     if (isset($aPointDetails['sNameDetails'])) $aPlace['namedetails'] = $aPointDetails['sNameDetails'];
69
70     $aFilteredPlaces[] = $aPlace;
71 }
72
73 javascript_renderData($aFilteredPlaces);