]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/search-json.php
order search results by existance of housenumbers
[nominatim.git] / lib / template / search-json.php
1 <?php
2         header("content-type: application/json; charset=UTF-8");
3
4         $aFilteredPlaces = array();
5         foreach($aSearchResults as $iResNum => $aPointDetails)
6         {
7                 $aPlace = array(
8                                 'place_id'=>$aPointDetails['place_id'],
9                                 'licence'=>"Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright",
10                         );
11
12                 $sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':'')));
13                 if ($sOSMType)
14                 {
15                         $aPlace['osm_type'] = $sOSMType;
16                         $aPlace['osm_id'] = $aPointDetails['osm_id'];
17                 }
18
19                 if (isset($aPointDetails['aBoundingBox']))
20                 {
21                         $aPlace['boundingbox'] = array(
22                                 $aPointDetails['aBoundingBox'][0],
23                                 $aPointDetails['aBoundingBox'][1],
24                                 $aPointDetails['aBoundingBox'][2],
25                                 $aPointDetails['aBoundingBox'][3]);
26
27                         if (isset($aPointDetails['aPolyPoints']) && $bShowPolygons)
28                         {
29                                 $aPlace['polygonpoints'] = $aPointDetails['aPolyPoints'];
30                         }
31                 }
32
33                 if (isset($aPointDetails['zoom']))
34                 {
35                         $aPlace['zoom'] = $aPointDetails['zoom'];
36                 }
37
38                 $aPlace['lat'] = $aPointDetails['lat'];
39                 $aPlace['lon'] = $aPointDetails['lon'];
40                 $aPlace['display_name'] = $aPointDetails['name'];
41
42                 $aPlace['class'] = $aPointDetails['class'];
43                 $aPlace['type'] = $aPointDetails['type'];
44
45                 $aPlace['importance'] = $aPointDetails['importance'];
46
47                 if (isset($aPointDetails['icon']) && $aPointDetails['icon'])
48                 {
49                         $aPlace['icon'] = $aPointDetails['icon'];
50                 }
51
52                 if (isset($aPointDetails['address']))
53                 {
54                         $aPlace['address'] = $aPointDetails['address'];
55                 }
56
57                 if (isset($aPointDetails['asgeojson']))
58                 {
59                         $aPlace['geojson'] = json_decode($aPointDetails['asgeojson']);
60                 }
61
62                 if (isset($aPointDetails['assvg']))
63                 {
64                         $aPlace['svg'] = $aPointDetails['assvg'];
65                 }
66
67                 if (isset($aPointDetails['astext']))
68                 {
69                         $aPlace['geotext'] = $aPointDetails['astext'];
70                 }
71
72                 if (isset($aPointDetails['askml']))
73                 {
74                         $aPlace['geokml'] = $aPointDetails['askml'];
75                 }
76
77                 $aFilteredPlaces[] = $aPlace;
78         }
79
80         javascript_renderData($aFilteredPlaces);