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