]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/details-html.php
Merge pull request #354 from mtmail/configurable-tile-url
[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 "<h2>".$sTitle."</h2>\n";
16         }
17
18         function osm_link($aFeature)
19         {
20                 $sOSMType = ($aFeature['osm_type'] == 'N'?'node':($aFeature['osm_type'] == 'W'?'way':($aFeature['osm_type'] == 'R'?'relation':'')));
21                 if ($sOSMType)
22                 {
23                         return '<a href="http://www.openstreetmap.org/browse/'.$sOSMType.'/'.$aFeature['osm_id'].'">'.$sOSMType.' '.$aFeature['osm_id'].'</a>';
24                 }
25                 return '';
26         }
27
28         function wikipedia_link($aFeature)
29         {
30                 if ($aFeature['wikipedia'])
31                 {
32                         list($sWikipediaLanguage,$sWikipediaArticle) = explode(':',$aFeature['wikipedia']);
33                         return '<a href="https://'.$sWikipediaLanguage.'.wikipedia.org/wiki/'.urlencode($sWikipediaArticle).'" target="_blank">'.$aFeature['wikipedia'].'</a>';
34                 }
35                 return '';
36         }
37
38         function nominatim_link($aFeature, $sTitle)
39         {
40                 return '<a href="details.php?place_id='.$aFeature['place_id'].'">'.$sTitle.'</a>';
41         }
42
43         function format_distance($fDistance)
44         {
45                 // $fDistance is in meters
46                 if ($fDistance < 1)
47                 {
48                         return '0';
49                 }
50                 elseif ($fDistance < 1000)
51                 {
52                         return'<abbr class="distance" title="'.$fDistance.'">~'.(round($fDistance,0)).' m</abbr>';
53                 }
54                 else
55                 {
56                         return'<abbr class="distance" title="'.$fDistance.'">~'.(round($fDistance/1000,1)).' km</abbr>';
57                 }
58         }
59
60         function kv($sKey,$sValue)
61         {
62                 echo ' <tr><td>' . $sKey . '</td><td>'.$sValue.'</td></tr>'. "\n";
63         }
64
65
66         function hash_to_subtable($aAssociatedList)
67         {
68                 $sHTML = '';
69                 foreach($aAssociatedList as $sKey => $sValue)
70                 {
71                         $sHTML = $sHTML.' <div class="line"><span class="name">'.$sValue.'</span> ('.$sKey.')</div>'."\n";
72                 }
73                 return $sHTML;
74         }
75
76         // function hash_to_subtable($aAssociatedList)
77         // {
78         //      $sHTML = '<table class="table">';
79         //      foreach($aAssociatedList as $sKey => $sValue)
80         //      {
81         //              $sHTML = $sHTML . '<tr><td>'.$sKey.'</td><td class="name">'.$sValue.'</td></tr>'."\n";
82         //      }
83         //      $sHTML = $sHTML . '</table>';
84         //      return $sHTML;
85         // }
86
87
88         function map_icon($sIcon)
89         {
90                 if ($sIcon){
91                         echo '<img id="mapicon" src="'.CONST_Website_BaseURL.'images/mapicons/'.$sIcon.'.n.32.png'.'" alt="'.$sIcon.'" />';
92                 }
93         }
94
95
96         function _one_row($aAddressLine){
97                 $bNotUsed = (isset($aAddressLine['isaddress']) && $aAddressLine['isaddress'] == 'f');
98
99                 echo '<tr class="' . ($bNotUsed?'notused':'') . '">';
100                 echo '  <td class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>').'</td>';
101                 echo '  <td>' . $aAddressLine['class'].':'.$aAddressLine['type'] . '</td>';
102                 echo '  <td>' . osm_link($aAddressLine) . '</td>';
103                 echo '  <td>' . (isset($aAddressLine['admin_level']) ? $aAddressLine['admin_level'] : '') . '</td>';
104                 // echo '<td>' . (isset($aAddressLine['rank_search_label']) ? $aAddressLine['rank_search_label'] : '') .'</td>';
105                 // echo ', <span class="area">'.($aAddressLine['fromarea']=='t'?'Polygon':'Point').'</span>';
106                 echo '  <td>' . format_distance($aAddressLine['distance']).'</td>';;
107                 echo '  <td>' . nominatim_link($aAddressLine,'details &gt;') . '</td>';;
108                 echo "</tr>\n";
109         }
110
111 ?>
112
113
114
115 <body id="details-page">
116         <?php include(CONST_BasePath.'/lib/template/includes/html-top-navigation.php'); ?>
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         <?php
265
266     $aNominatimMapInit = [
267       'tile_url' => $sTileURL,
268       'tile_attribution' => $sTileAttribution
269     ];
270     echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
271
272     $aPlace = [
273                         'outlinestring' => $aPointDetails['outlinestring'],
274                         'lon' => $aPointDetails['lon'],
275                         'lat' => $aPointDetails['lat'],
276     ];
277           echo 'var nominatim_result = ' . json_encode($aPlace, JSON_PRETTY_PRINT) . ';'; 
278
279
280   ?>
281         </script>
282
283
284
285         <?php include(CONST_BasePath.'/lib/template/includes/html-footer.php'); ?>
286 </body>
287 </html>