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