]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/details-html.php
Use GB postcode table as definitive source. resort by pressence of search word in...
[nominatim.git] / lib / template / details-html.php
1 <?php
2         header("content-type: text/html; charset=UTF-8");
3 ?>
4 <html>
5   <head>
6     <title>OpenStreetMap Nominatim: <?php echo $aPointDetails['localname'];?></title>
7     <style>
8 body {
9         margin:0px;
10         padding:16px;
11   background:#ffffff;
12   height: 100%;
13   font: normal 12px/15px arial,sans-serif;
14 }
15 .line{
16   margin-left:20px;
17 }
18 .name{
19   font-weight: bold;
20 }
21 .notused{
22   color:#ddd;
23 }
24 .noname{
25   color:#800;
26 }
27 #map {
28   width:500px;
29   height:500px;
30   border: 2px solid #666;
31   float: right;
32 }
33     </style>
34         <script src="js/OpenLayers.js"></script>
35         <script src="js/tiles.js"></script>
36         <script type="text/javascript">
37         
38                 var map;
39
40     function init() {
41                         map = new OpenLayers.Map ("map", {
42                 controls:[
43                                                                                 new OpenLayers.Control.Permalink(),
44                                                                                 new OpenLayers.Control.Navigation(),
45                                                                                 new OpenLayers.Control.PanZoomBar(),
46                                                                                 new OpenLayers.Control.MouseDefaults(),
47                                                                                 new OpenLayers.Control.MousePosition(),
48                                                                                 new OpenLayers.Control.Attribution()],
49                 maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
50                 maxResolution: 156543.0399,
51                 numZoomLevels: 19,
52                 units: 'm',
53                 projection: new OpenLayers.Projection("EPSG:900913"),
54                 displayProjection: new OpenLayers.Projection("EPSG:4326")
55                 } );
56                         map.addLayer(new OpenLayers.Layer.OSM.<?php echo CONST_Tile_Default;?>("Default"));
57
58                         var layer_style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
59                         layer_style.fillOpacity = 0.2;
60                         layer_style.graphicOpacity = 0.2;
61
62                         vectorLayer = new OpenLayers.Layer.Vector("Points", {style: layer_style});
63                         map.addLayer(vectorLayer);
64
65                         var pointList = [];
66                         var style = {
67                                 strokeColor: "#75ADFF",
68                                 fillColor: "#F0F7FF",
69                                 strokeWidth: 2,
70                                 strokeOpacity: 0.75,
71                                 fillOpacity: 0.75
72                         };
73                         var proj_EPSG4326 = new OpenLayers.Projection("EPSG:4326");
74                         var proj_map = map.getProjectionObject();
75                         var latlon;
76 <?php
77 if (isset($aPolyPoints))
78 {
79         foreach($aPolyPoints as $aPolyPoint)
80         {
81                 echo "                        pointList.push(new OpenLayers.Geometry.Point(".$aPolyPoint[1].",".$aPolyPoint[2]."));\n";
82         }
83 }
84 ?>
85                         var linearRing = new OpenLayers.Geometry.LinearRing(pointList).transform(proj_EPSG4326, proj_map);;
86                         var polygonFeature = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Polygon([linearRing]),null,style);
87                         vectorLayer.addFeatures([polygonFeature]);
88
89                         map.zoomToExtent(new OpenLayers.Bounds(<?php echo $aPointPolygon['minlon']?>, <?php echo $aPointPolygon['minlat']?>, <?php echo $aPointPolygon['maxlon']?>, <?php echo $aPointPolygon['maxlat']?>).transform(proj_EPSG4326, proj_map));
90                 }
91                 
92         </script>
93   </head>
94   <body onload="init();">
95     <div id="map"></div>
96 <?php
97         echo '<h1>';
98         if ($aPointDetails['icon'])
99         {
100                 echo '<img style="float:right;margin-right:40px;" src="'.CONST_Website_BaseURL.'images/mapicons/'.$aPointDetails['icon'].'.n.32.png'.'">';
101         }
102         echo $aPointDetails['localname'].'</h1>';
103         echo '<div class="locationdetails">';
104         echo ' <div>Name: ';
105         foreach($aPointDetails['aNames'] as $sKey => $sValue)
106         {
107                 echo ' <div class="line"><span class="name">'.$sValue.'</span> ('.$sKey.')</div>';
108         }
109         echo ' </div>';
110         echo ' <div>Type: <span class="type">'.$aPointDetails['class'].':'.$aPointDetails['type'].'</span></div>';
111         echo ' <div>Admin Level: <span class="adminlevel">'.$aPointDetails['admin_level'].'</span></div>';
112         echo ' <div>Rank: <span class="rankaddress">'.$aPointDetails['rank_search_label'].'</span></div>';
113         if ($aPointDetails['importance']) echo ' <div>Importance: <span class="rankaddress">'.$aPointDetails['importance'].'</span></div>';
114         echo ' <div>Coverage: <span class="area">'.($aPointDetails['isarea']=='t'?'Polygon':'Point').'</span></div>';
115         $sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':'')));
116         if ($sOSMType) echo ' <div>OSM: <span class="osm"><span class="label"></span>'.$sOSMType.' <a href="http://www.openstreetmap.org/browse/'.$sOSMType.'/'.$aPointDetails['osm_id'].'">'.$aPointDetails['osm_id'].'</a></span></div>';
117         echo ' <div>Extra Tags: ';
118         foreach($aPointDetails['aExtraTags'] as $sKey => $sValue)
119         {
120                 echo ' <div class="line"><span class="name">'.$sValue.'</span> ('.$sKey.')</div>';
121         }
122         echo ' </div>';
123         echo '</div>';
124
125         echo '<h2>Address</h2>';
126         echo '<div class=\"address\">';
127         $iPrevRank = 1000000;
128         $sPrevLocalName = '';
129         foreach($aAddressLines as $aAddressLine)
130         {       
131                 $sOSMType = ($aAddressLine['osm_type'] == 'N'?'node':($aAddressLine['osm_type'] == 'W'?'way':($aAddressLine['osm_type'] == 'R'?'relation':'')));
132
133                 echo '<div class="line'.($aAddressLine['isaddress']=='f'?' notused':'').'">';
134                 if (!($iPrevRank<=$aAddressLine['rank_address'] || $sPrevLocalName == $aAddressLine['localname']))
135                 {
136                         $iPrevRank = $aAddressLine['rank_address'];
137                         $sPrevLocalName = $aAddressLine['localname'];
138                 }
139                 echo '<span class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>').'</span>';
140                 echo ' (';
141                 echo '<span class="type"><span class="label">Type: </span>'.$aAddressLine['class'].':'.$aAddressLine['type'].'</span>';
142                 if ($sOSMType) echo ', <span class="osm"><span class="label"></span>'.$sOSMType.' <a href="http://www.openstreetmap.org/browse/'.$sOSMType.'/'.$aAddressLine['osm_id'].'">'.$aAddressLine['osm_id'].'</a></span>';
143                 echo ', <span class="adminlevel">'.$aAddressLine['admin_level'].'</span>';
144                 echo ', <span class="rankaddress">'.$aAddressLine['rank_search_label'].'</span>';
145                 echo ', <span class="area">'.($aAddressLine['fromarea']=='t'?'Polygon':'Point').'</span>';
146                 echo ', <span class="distance">'.$aAddressLine['distance'].'</span>';
147                 echo ' <a href="details.php?place_id='.$aAddressLine['place_id'].'">GOTO</a>';
148                 echo ')';
149                 echo '</div>';
150         }
151         echo '</div>';
152
153         if ($aPlaceSearchNameKeywords)
154         {
155                 echo '<h2>Name Keywords</h2>';
156                 foreach($aPlaceSearchNameKeywords as $aRow)
157                 {
158                         echo '<div>'.$aRow['word_token'].'</div>';
159                 }
160         }
161
162         if ($aPlaceSearchAddressKeywords)
163         {
164                 echo '<h2>Address Keywords</h2>';
165                 foreach($aPlaceSearchAddressKeywords as $aRow)
166                 {
167                         echo '<div>'.($aRow['word_token'][0]==' '?'*':'').$aRow['word_token'].'('.$aRow['word_id'].')'.'</div>';
168                 }
169         }
170
171         if (sizeof($aParentOfLines))
172         {
173                 echo '<h2>Parent Of (named features only):</h2>';
174
175                 $aGroupedAddressLines = array();
176                 foreach($aParentOfLines as $aAddressLine)
177                 {
178                         if (!isset($aGroupedAddressLines[$aAddressLine['type']])) $aGroupedAddressLines[$aAddressLine['type']] = array();
179                         $aGroupedAddressLines[$aAddressLine['type']][] = $aAddressLine;
180                 }
181                 foreach($aGroupedAddressLines as $sGroupHeading => $aParentOfLines)
182                 {
183                         $sGroupHeading = ucwords($sGroupHeading);
184                         echo "<h3>$sGroupHeading</h3>";
185                 foreach($aParentOfLines as $aAddressLine)
186                 {
187                         $aAddressLine['localname'] = $aAddressLine['localname']?$aAddressLine['localname']:$aAddressLine['housenumber'];
188                         $sOSMType = ($aAddressLine['osm_type'] == 'N'?'node':($aAddressLine['osm_type'] == 'W'?'way':($aAddressLine['osm_type'] == 'R'?'relation':'')));
189         
190                         echo '<div class="line">';
191                         echo '<span class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>').'</span>';
192                         echo ' (';
193 //                      echo '<span class="type"><span class="label">Type: </span>'.$aAddressLine['class'].':'.$aAddressLine['type'].'</span>';
194 //                      echo ', <span class="adminlevel">'.$aAddressLine['admin_level'].'</span>';
195 //                      echo ', <span class="rankaddress">'.$aAddressLine['rank_address'].'</span>';
196                         echo '<span class="area">'.($aAddressLine['isarea']=='t'?'Polygon':'Point').'</span>';
197                         echo ', <span class="distance">~'.(round($aAddressLine['distance']*69,1)).'&nbsp;miles</span>';
198                         if ($sOSMType) echo ', <span class="osm"><span class="label"></span>'.$sOSMType.' <a href="http://www.openstreetmap.org/browse/'.$sOSMType.'/'.$aAddressLine['osm_id'].'">'.$aAddressLine['osm_id'].'</a></span>';
199                         echo ', <a href="details.php?place_id='.$aAddressLine['place_id'].'">GOTO</a>';
200                         echo ')';
201                         echo '</div>';
202                 }
203                 }
204                 echo '</div>';
205         }
206
207 //      echo '<h2>Other Parts:</h2>';
208 //      echo '<h2>Linked To:</h2>';
209 ?>
210
211   </body>
212 </html>