]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/details-html.php
change tiger housenumber format to save as lines instead of points and thus new inter...
[nominatim.git] / lib / template / details-html.php
1 <?php
2         header("content-type: text/html; charset=UTF-8");
3 ?>
4 <?php include(CONST_BasePath.'/lib/template/includes/html-header.php'); ?>
5         <link href="css/common.css" rel="stylesheet" type="text/css" />
6         <link href="css/details.css" rel="stylesheet" type="text/css" />
7 </head>
8
9
10
11 <?php
12
13         function headline($sTitle)
14         {
15                 echo "<tr class='all-columns'><td colspan='6'><h2>".$sTitle."</h2></td></tr>\n";
16         }
17
18         function headline3($sTitle)
19         {
20                 echo "<tr class='all-columns'><td colspan='6'><h3>".$sTitle."</h3></td></tr>\n";
21         }
22
23         function osm_link($aFeature)
24         {
25                 $sOSMType = ($aFeature['osm_type'] == 'N'?'node':($aFeature['osm_type'] == 'W'?'way':($aFeature['osm_type'] == 'R'?'relation':'')));
26                 if ($sOSMType)
27                 {
28                         return '<a href="http://www.openstreetmap.org/browse/'.$sOSMType.'/'.$aFeature['osm_id'].'">'.$sOSMType.' '.$aFeature['osm_id'].'</a>';
29                 }
30                 return '';
31         }
32
33         function wikipedia_link($aFeature)
34         {
35                 if ($aFeature['wikipedia'])
36                 {
37                         list($sWikipediaLanguage,$sWikipediaArticle) = explode(':',$aFeature['wikipedia']);
38                         return '<a href="https://'.$sWikipediaLanguage.'.wikipedia.org/wiki/'.urlencode($sWikipediaArticle).'" target="_blank">'.$aFeature['wikipedia'].'</a>';
39                 }
40                 return '';
41         }
42
43         function nominatim_link($aFeature, $sTitle)
44         {
45                 return '<a href="details.php?place_id='.$aFeature['place_id'].'">'.$sTitle.'</a>';
46         }
47
48         function format_distance($fDistance)
49         {
50                 // $fDistance is in meters
51                 if ($fDistance < 1)
52                 {
53                         return '0';
54                 }
55                 elseif ($fDistance < 1000)
56                 {
57                         return'<abbr class="distance" title="'.$fDistance.'">~'.(round($fDistance,0)).' m</abbr>';
58                 }
59                 else
60                 {
61                         return'<abbr class="distance" title="'.$fDistance.'">~'.(round($fDistance/1000,1)).' km</abbr>';
62                 }
63         }
64
65         function kv($sKey,$sValue)
66         {
67                 echo ' <tr><td>' . $sKey . '</td><td>'.$sValue.'</td></tr>'. "\n";
68         }
69
70
71         function hash_to_subtable($aAssociatedList)
72         {
73                 $sHTML = '';
74                 foreach($aAssociatedList as $sKey => $sValue)
75                 {
76                         $sHTML = $sHTML.' <div class="line"><span class="name">'.$sValue.'</span> ('.$sKey.')</div>'."\n";
77                 }
78                 return $sHTML;
79         }
80
81         // function hash_to_subtable($aAssociatedList)
82         // {
83         //      $sHTML = '<table class="table">';
84         //      foreach($aAssociatedList as $sKey => $sValue)
85         //      {
86         //              $sHTML = $sHTML . '<tr><td>'.$sKey.'</td><td class="name">'.$sValue.'</td></tr>'."\n";
87         //      }
88         //      $sHTML = $sHTML . '</table>';
89         //      return $sHTML;
90         // }
91
92
93         function map_icon($sIcon)
94         {
95                 if ($sIcon){
96                         echo '<img id="mapicon" src="'.CONST_Website_BaseURL.'images/mapicons/'.$sIcon.'.n.32.png'.'" alt="'.$sIcon.'" />';
97                 }
98         }
99
100
101         function _one_row($aAddressLine){
102                 $bNotUsed = (isset($aAddressLine['isaddress']) && $aAddressLine['isaddress'] == 'f');
103
104                 echo '<tr class="' . ($bNotUsed?'notused':'') . '">'."\n";
105                 echo '  <td class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>')."</td>\n";
106                 echo '  <td>' . $aAddressLine['class'].':'.$aAddressLine['type'] . "</td>\n";
107                 echo '  <td>' . osm_link($aAddressLine) . "</td>\n";
108                 echo '  <td>' . (isset($aAddressLine['admin_level']) ? $aAddressLine['admin_level'] : '') . "</td>\n";
109                 // echo '<td>' . (isset($aAddressLine['rank_search_label']) ? $aAddressLine['rank_search_label'] : '') ."</td>\n";
110                 // echo ', <span class="area">'.($aAddressLine['fromarea']=='t'?'Polygon':'Point').'</span>';
111                 echo '  <td>' . format_distance($aAddressLine['distance'])."</td>\n";
112                 echo '  <td>' . nominatim_link($aAddressLine,'details &gt;') . "</td>\n";
113                 echo "</tr>\n";
114         }
115
116         function _one_keyword_row($keyword_token,$word_id){
117                 echo "<tr>\n";
118                 echo '<td>';
119                 // mark partial tokens (those starting with a space) with a star for readability
120                 echo ($keyword_token[0]==' '?'*':'');
121                 echo $keyword_token;
122                 if (isset($word_id))
123                 {
124                         echo '</td><td>word id: '.$word_id;
125                 }
126                 echo "</td></tr>\n";
127         }
128
129 ?>
130
131
132
133 <body id="details-page">
134         <?php include(CONST_BasePath.'/lib/template/includes/html-top-navigation.php'); ?>
135         <div class="container">
136                 <div class="row">
137                         <div class="col-sm-10">
138                                 <h1><?php echo $aPointDetails['localname'] ?></h1>
139                         </div>
140                         <div class="col-sm-2 text-right">
141                                 <?php map_icon($aPointDetails['icon']) ?>
142                         </div>
143                 </div>
144                 <div class="row">
145                         <div class="col-md-6">
146                                 <table id="locationdetails" class="table table-striped">
147
148                                 <?php
149
150                                         kv('Name'            , hash_to_subtable($aPointDetails['aNames']) );
151                                         kv('Type'            , $aPointDetails['class'].':'.$aPointDetails['type'] );
152                                         kv('Last Updated'    , $aPointDetails['indexed_date'] );
153                                         kv('Admin Level'     , $aPointDetails['admin_level'] );
154                                         kv('Rank'            , $aPointDetails['rank_search_label'] );
155                                         if ($aPointDetails['calculated_importance']) {
156                                                 kv('Importance'    , $aPointDetails['calculated_importance'].($aPointDetails['importance']?'':' (estimated)') );
157                                         }
158                                         kv('Coverage'        , ($aPointDetails['isarea']=='t'?'Polygon':'Point') );
159                                         kv('Centre Point'    , $aPointDetails['lat'].','.$aPointDetails['lon'] );
160                                         kv('OSM'             , osm_link($aPointDetails) );
161                                         if ($aPointDetails['wikipedia'])
162                                         {
163                                                 kv('Wikipedia Calculated' , wikipedia_link($aPointDetails) );
164                                         }
165
166                                         kv('Extra Tags'      , hash_to_subtable($aPointDetails['aExtraTags']) );
167
168                                 ?>
169
170                                 </table>
171                         </div>
172
173                         <div class="col-md-6">
174                                 <div id="map"></div>
175                         </div>
176
177                 </div>
178                 <div class="row">
179                         <div class="col-md-12">
180
181                         <h2>Address</h2>
182
183                         <table id="address" class="table table-striped table-responsive">
184                                 <thead>
185                                         <tr>
186                                           <td>Local name</td>
187                                           <td>Type</td>
188                                           <td>OSM</td>
189                                           <td>Admin level</td>
190                                           <!-- <td>Search rank</td> -->
191                                           <td>Distance</td>
192                                           <td></td>
193                                         </tr>
194                                 </thead>
195                                 <tbody>
196
197                                 <?php
198
199                                         foreach($aAddressLines as $aAddressLine)
200                                         {       
201                                                 _one_row($aAddressLine);
202                                         }
203                                 ?>
204         
205
206
207 <?php
208
209         if ($aLinkedLines)
210         {
211                 headline('Linked Places');
212                 foreach($aLinkedLines as $aAddressLine)
213                 {       
214                         _one_row($aAddressLine);
215                 }
216         }
217
218
219
220         if ($aPlaceSearchNameKeywords)
221         {
222                 headline('Name Keywords');
223                 foreach($aPlaceSearchNameKeywords as $aRow)
224                 {
225                         _one_keyword_row($aRow['word_token'], $aRow['word_id']);
226                 }
227         }
228
229         if ($aPlaceSearchAddressKeywords)
230         {
231                 headline('Address Keywords');
232                 foreach($aPlaceSearchAddressKeywords as $aRow)
233                 {
234                         _one_keyword_row($aRow['word_token'], $aRow['word_id']);
235                 }
236         }
237         
238         if (sizeof($aParentOfLines))
239         {
240                 headline('Parent Of');
241
242                 $aGroupedAddressLines = array();
243                 foreach($aParentOfLines as $aAddressLine)
244                 {
245                         if ($aAddressLine['type'] == 'yes') $sType = $aAddressLine['class'];
246                         else $sType = $aAddressLine['type'];
247
248                         if (!isset($aGroupedAddressLines[$sType]))
249                                 $aGroupedAddressLines[$sType] = array();
250                         $aGroupedAddressLines[$sType][] = $aAddressLine;
251                 }
252                 foreach($aGroupedAddressLines as $sGroupHeading => $aParentOfLines)
253                 {
254                         $sGroupHeading = ucwords($sGroupHeading);
255                         headline3($sGroupHeading);
256
257                         foreach($aParentOfLines as $aAddressLine)
258                         {
259                                 _one_row($aAddressLine);
260                         }
261                 }
262                 if (sizeof($aParentOfLines) >= 500) {
263                         echo '<p>There are more child objects which are not shown.</p>';
264                 }
265         }
266
267         // headline('Other Parts');
268         // headline('Linked To');
269
270         echo "</table>\n";
271 ?>
272
273                         </div>
274                 </div>
275         </div>
276
277         <script type="text/javascript">
278         <?php
279
280                 $aNominatimMapInit = [
281                   'tile_url' => $sTileURL,
282                   'tile_attribution' => $sTileAttribution
283                 ];
284                 echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
285
286                 $aPlace = [
287                                 'outlinestring' => $aPointDetails['outlinestring'],
288                                 'lon' => $aPointDetails['lon'],
289                                 'lat' => $aPointDetails['lat'],
290                 ];
291                 echo 'var nominatim_result = ' . json_encode($aPlace, JSON_PRETTY_PRINT) . ';'; 
292
293
294         ?>
295         </script>
296
297
298
299         <?php include(CONST_BasePath.'/lib/template/includes/html-footer.php'); ?>
300 </body>
301 </html>