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