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