]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/details-html.php
simplify geometry handling in details page
[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                         { attribution : '© <a target="_parent" href="http://www.openstreetmap.org">OpenStreetMap</a> and contributors, under an <a target="_parent" href="http://www.openstreetmap.org/copyright">open license</a>'}));
58
59                         var layer_style = OpenLayers.Util.extend({}, OpenLayers.Feature.Vector.style['default']);
60                         layer_style.fillOpacity = 0.2;
61                         layer_style.graphicOpacity = 0.2;
62
63                         vectorLayer = new OpenLayers.Layer.Vector("Points", {style: layer_style});
64                         map.addLayer(vectorLayer);
65
66                         var pointList = [];
67                         var style = {
68                                 strokeColor: "#75ADFF",
69                                 fillColor: "#F0F7FF",
70                                 strokeWidth: 2,
71                                 strokeOpacity: 0.75,
72                                 fillOpacity: 0.75
73                         };
74                         var proj_EPSG4326 = new OpenLayers.Projection("EPSG:4326");
75                         var proj_map = map.getProjectionObject();
76
77                         freader = new OpenLayers.Format.WKT({
78                                 'internalProjection': proj_map,
79                                 'externalProjection': proj_EPSG4326
80                         });
81
82                         var feature = freader.read('<?php echo $aPointDetails['outlinestring'];?>');
83                         if (feature) {
84                                 map.zoomToExtent(feature.geometry.getBounds());
85
86                                 feature.style = {
87                                         strokeColor: "#75ADFF",
88                                         fillColor: "#F0F7FF",
89                                         strokeWidth: <?php echo ($aPointDetails['isarea']=='t'?'2':'5');?>,
90                                         strokeOpacity: 0.75,
91                                         fillOpacity: 0.75,
92                                         pointRadius: 100
93                                 };
94                                 vectorLayer.addFeatures([feature]);
95                         }
96                 }
97         </script>
98   </head>
99   <body onload="init();">
100     <div id="map"></div>
101 <?php
102         echo '<h1>';
103         if ($aPointDetails['icon'])
104         {
105                 echo '<img style="float:right;margin-right:40px;" src="'.CONST_Website_BaseURL.'images/mapicons/'.$aPointDetails['icon'].'.n.32.png'.'">';
106         }
107         echo $aPointDetails['localname'].'</h1>';
108         echo '<div class="locationdetails">';
109         echo ' <div>Name: ';
110         foreach($aPointDetails['aNames'] as $sKey => $sValue)
111         {
112                 echo ' <div class="line"><span class="name">'.$sValue.'</span> ('.$sKey.')</div>';
113         }
114         echo ' </div>';
115         echo ' <div>Type: <span class="type">'.$aPointDetails['class'].':'.$aPointDetails['type'].'</span></div>';
116         echo ' <div>Admin Level: <span class="adminlevel">'.$aPointDetails['admin_level'].'</span></div>';
117         echo ' <div>Rank: <span class="rankaddress">'.$aPointDetails['rank_search_label'].'</span></div>';
118         if ($aPointDetails['importance']) echo ' <div>Importance: <span class="rankaddress">'.$aPointDetails['importance'].'</span></div>';
119         echo ' <div>Coverage: <span class="area">'.($aPointDetails['isarea']=='t'?'Polygon':'Point').'</span></div>';
120         $sOSMType = ($aPointDetails['osm_type'] == 'N'?'node':($aPointDetails['osm_type'] == 'W'?'way':($aPointDetails['osm_type'] == 'R'?'relation':'')));
121         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>';
122         if ($aPointDetails['wikipedia'])
123         {
124                 list($sWikipediaLanguage,$sWikipediaArticle) = explode(':',$aPointDetails['wikipedia']);
125                 echo ' <div>Wikipedia Calculated: <span class="wikipedia"><a href="http://'.$sWikipediaLanguage.'.wikipedia.org/wiki/'.urlencode($sWikipediaArticle).'">'.$aPointDetails['wikipedia'].'</a></span></div>';
126         }
127         echo ' <div>Extra Tags: ';
128         foreach($aPointDetails['aExtraTags'] as $sKey => $sValue)
129         {
130                 echo ' <div class="line"><span class="name">'.$sValue.'</span> ('.$sKey.')</div>';
131         }
132         echo ' </div>';
133         echo '</div>';
134
135         echo '<h2>Address</h2>';
136         echo '<div class=\"address\">';
137         $iPrevRank = 1000000;
138         $sPrevLocalName = '';
139         foreach($aAddressLines as $aAddressLine)
140         {       
141                 $sOSMType = ($aAddressLine['osm_type'] == 'N'?'node':($aAddressLine['osm_type'] == 'W'?'way':($aAddressLine['osm_type'] == 'R'?'relation':'')));
142
143                 echo '<div class="line'.($aAddressLine['isaddress']=='f'?' notused':'').'">';
144                 if (!($iPrevRank<=$aAddressLine['rank_address'] || $sPrevLocalName == $aAddressLine['localname']))
145                 {
146                         $iPrevRank = $aAddressLine['rank_address'];
147                         $sPrevLocalName = $aAddressLine['localname'];
148                 }
149                 echo '<span class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>').'</span>';
150                 echo ' (';
151                 echo '<span class="type"><span class="label">Type: </span>'.$aAddressLine['class'].':'.$aAddressLine['type'].'</span>';
152                 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>';
153                 echo ', <span class="adminlevel">'.$aAddressLine['admin_level'].'</span>';
154                 if (isset($aAddressLine['rank_search_label']) echo ', <span class="rankaddress">'.$aAddressLine['rank_search_label'].'</span>';
155 //              echo ', <span class="area">'.($aAddressLine['fromarea']=='t'?'Polygon':'Point').'</span>';
156                 echo ', <span class="distance">'.$aAddressLine['distance'].'</span>';
157                 echo ' <a href="details.php?place_id='.$aAddressLine['place_id'].'">GOTO</a>';
158                 echo ')';
159                 echo '</div>';
160         }
161         echo '</div>';
162
163         if ($aLinkedLines)
164         {
165                 echo '<h2>Linked Places</h2>';
166                 echo '<div class=\"linked\">';
167                 foreach($aLinkedLines as $aAddressLine)
168                 {       
169                         $sOSMType = ($aAddressLine['osm_type'] == 'N'?'node':($aAddressLine['osm_type'] == 'W'?'way':($aAddressLine['osm_type'] == 'R'?'relation':'')));
170
171                         echo '<div class="line">';
172                         echo '<span class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>').'</span>';
173                         echo ' (';
174                         echo '<span class="type"><span class="label">Type: </span>'.$aAddressLine['class'].':'.$aAddressLine['type'].'</span>';
175                         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>';
176                         echo ', <span class="adminlevel">'.$aAddressLine['admin_level'].'</span>';
177                         echo ', <span class="rankaddress">'.$aAddressLine['rank_search_label'].'</span>';
178 //                      echo ', <span class="area">'.($aAddressLine['fromarea']=='t'?'Polygon':'Point').'</span>';
179                         echo ', <span class="distance">'.$aAddressLine['distance'].'</span>';
180                         echo ' <a href="details.php?place_id='.$aAddressLine['place_id'].'">GOTO</a>';
181                         echo ')';
182                         echo '</div>';
183                 }
184                 echo '</div>';
185         }
186
187         if ($aPlaceSearchNameKeywords)
188         {
189                 echo '<h2>Name Keywords</h2>';
190                 foreach($aPlaceSearchNameKeywords as $aRow)
191                 {
192                         echo '<div>'.$aRow['word_token'].'</div>';
193                 }
194         }
195
196         if ($aPlaceSearchAddressKeywords)
197         {
198                 echo '<h2>Address Keywords</h2>';
199                 foreach($aPlaceSearchAddressKeywords as $aRow)
200                 {
201                         echo '<div>'.($aRow['word_token'][0]==' '?'*':'').$aRow['word_token'].'('.$aRow['word_id'].')'.'</div>';
202                 }
203         }
204
205         if (sizeof($aParentOfLines))
206         {
207                 echo '<h2>Parent Of:</h2>';
208
209                 $aGroupedAddressLines = array();
210                 foreach($aParentOfLines as $aAddressLine)
211                 {
212                         if (!isset($aGroupedAddressLines[$aAddressLine['type']])) $aGroupedAddressLines[$aAddressLine['type']] = array();
213                         $aGroupedAddressLines[$aAddressLine['type']][] = $aAddressLine;
214                 }
215                 foreach($aGroupedAddressLines as $sGroupHeading => $aParentOfLines)
216                 {
217                         $sGroupHeading = ucwords($sGroupHeading);
218                         echo "<h3>$sGroupHeading</h3>";
219                 foreach($aParentOfLines as $aAddressLine)
220                 {
221                         $aAddressLine['localname'] = $aAddressLine['localname']?$aAddressLine['localname']:$aAddressLine['housenumber'];
222                         $sOSMType = ($aAddressLine['osm_type'] == 'N'?'node':($aAddressLine['osm_type'] == 'W'?'way':($aAddressLine['osm_type'] == 'R'?'relation':'')));
223         
224                         echo '<div class="line">';
225                         echo '<span class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>').'</span>';
226                         echo ' (';
227 //                      echo '<span class="type"><span class="label">Type: </span>'.$aAddressLine['class'].':'.$aAddressLine['type'].'</span>';
228 //                      echo ', <span class="adminlevel">'.$aAddressLine['admin_level'].'</span>';
229 //                      echo ', <span class="rankaddress">'.$aAddressLine['rank_address'].'</span>';
230                         echo '<span class="area">'.($aAddressLine['isarea']=='t'?'Polygon':'Point').'</span>';
231                         echo ', <span class="distance">~'.(round($aAddressLine['distance']*69,1)).'&nbsp;miles</span>';
232                         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>';
233                         echo ', <a href="details.php?place_id='.$aAddressLine['place_id'].'">GOTO</a>';
234                         echo ')';
235                         echo '</div>';
236                 }
237                 }
238                 if (sizeof($aParentOfLines) >= 500) {
239                         echo '<p>There are more child objects which are not shown.</p>';
240                 }
241                 echo '</div>';
242         }
243
244 //      echo '<h2>Other Parts:</h2>';
245 //      echo '<h2>Linked To:</h2>';
246 ?>
247
248   </body>
249 </html>