]> git.openstreetmap.org Git - nominatim.git/blob - lib/template/details-html.php
Merge pull request #1348 from mtmail/checkmodulepresence-to-raise-exception
[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 <?php
11
12     function headline($sTitle)
13     {
14         echo "<tr class='all-columns'><td colspan='6'><h2>".$sTitle."</h2></td></tr>\n";
15     }
16
17     function headline3($sTitle)
18     {
19         echo "<tr class='all-columns'><td colspan='6'><h3>".$sTitle."</h3></td></tr>\n";
20     }
21
22
23     function format_distance($fDistance)
24     {
25         // $fDistance is in meters
26         if ($fDistance < 1)
27         {
28             return '0';
29         }
30         elseif ($fDistance < 1000)
31         {
32             return'<abbr class="distance" title="'.$fDistance.'">~'.(round($fDistance,0)).' m</abbr>';
33         }
34         else
35         {
36             return'<abbr class="distance" title="'.$fDistance.'">~'.(round($fDistance/1000,1)).' km</abbr>';
37         }
38     }
39
40     function kv($sKey,$sValue)
41     {
42         echo ' <tr><td>' . $sKey . '</td><td>'.$sValue.'</td></tr>'. "\n";
43     }
44
45
46     function hash_to_subtable($aAssociatedList)
47     {
48         $sHTML = '';
49         foreach ($aAssociatedList as $sKey => $sValue) {
50             $sHTML = $sHTML.' <div class="line"><span class="name">'.$sValue.'</span> ('.$sKey.')</div>'."\n";
51         }
52         return $sHTML;
53     }
54
55     function map_icon($sIcon)
56     {
57         if ($sIcon){
58             echo '<img id="mapicon" src="'.CONST_Website_BaseURL.'images/mapicons/'.$sIcon.'.n.32.png'.'" alt="'.$sIcon.'" />';
59         }
60     }
61
62
63     function _one_row($aAddressLine){
64         $bNotUsed = !$aAddressLine['isaddress'];
65
66         echo '<tr class="' . ($bNotUsed?'notused':'') . '">'."\n";
67         echo '  <td class="name">'.(trim($aAddressLine['localname'])?$aAddressLine['localname']:'<span class="noname">No Name</span>')."</td>\n";
68         echo '  <td>' . $aAddressLine['class'].':'.$aAddressLine['type'] . "</td>\n";
69         echo '  <td>' . osmLink($aAddressLine) . "</td>\n";
70         echo '  <td>' . (isset($aAddressLine['rank_address']) ? $aAddressLine['rank_address'] : '') . "</td>\n";
71         echo '  <td>' . ($aAddressLine['admin_level'] < 15 ? $aAddressLine['admin_level'] : '') . "</td>\n";
72         echo '  <td>' . format_distance($aAddressLine['distance'])."</td>\n";
73         echo '  <td>' . detailsLink($aAddressLine,'details &gt;') . "</td>\n";
74         echo "</tr>\n";
75     }
76
77     function _one_keyword_row($keyword_token,$word_id){
78         echo "<tr>\n";
79         echo '<td>';
80         // mark partial tokens (those starting with a space) with a star for readability
81         echo ($keyword_token[0]==' '?'*':'');
82         echo $keyword_token;
83         if (isset($word_id))
84         {
85             echo '</td><td>word id: '.$word_id;
86         }
87         echo "</td></tr>\n";
88     }
89
90 ?>
91
92
93
94 <body id="details-page">
95     <?php include(CONST_BasePath.'/lib/template/includes/html-top-navigation.php'); ?>
96     <div class="container">
97         <div class="row">
98             <div class="col-sm-10">
99                 <h1>
100                     <?php echo $aPointDetails['localname'] ?>
101                     <small><?php echo detailsPermaLink($aPointDetails, 'link to this page') ?></small>
102                 </h1>
103             </div>
104             <div class="col-sm-2 text-right">
105                 <?php map_icon($aPointDetails['icon']) ?>
106             </div>
107         </div>
108         <div class="row">
109             <div class="col-md-6">
110                 <table id="locationdetails" class="table table-striped">
111
112                 <?php
113
114                     kv('Name'            , hash_to_subtable($aPointDetails['aNames']) );
115                     kv('Type'            , $aPointDetails['class'].':'.$aPointDetails['type'] );
116                     kv('Last Updated'    , (new DateTime('@'.$aPointDetails['indexed_epoch']))->format(DateTime::RFC822) );
117                     kv('Admin Level'     , $aPointDetails['admin_level'] );
118                     kv('Rank'            , $aPointDetails['rank_search_label'] );
119                     if ($aPointDetails['calculated_importance']) {
120                         kv('Importance'    , $aPointDetails['calculated_importance'].($aPointDetails['importance']?'':' (estimated)') );
121                     }
122                     kv('Coverage'        , ($aPointDetails['isarea']?'Polygon':'Point') );
123                     kv('Centre Point'    , $aPointDetails['lat'].','.$aPointDetails['lon'] );
124                     kv('OSM'             , osmLink($aPointDetails) );
125                     if ($aPointDetails['wikipedia'])
126                     {
127                         kv('Wikipedia Calculated' , wikipediaLink($aPointDetails) );
128                     }
129
130                     kv('Computed Postcode', $aPointDetails['postcode']);
131                     kv('Address Tags'    , hash_to_subtable($aPointDetails['aAddressTags']) );
132                     kv('Extra Tags'      , hash_to_subtable($aPointDetails['aExtraTags']) );
133
134                 ?>
135
136                 </table>
137             </div>
138
139             <div class="col-md-6">
140                 <div id="map"></div>
141             </div>
142
143         </div>
144         <div class="row">
145             <div class="col-md-12">
146
147             <h2>Address</h2>
148
149             <table id="address" class="table table-striped table-responsive">
150                 <thead>
151                     <tr>
152                       <td>Local name</td>
153                       <td>Type</td>
154                       <td>OSM</td>
155                       <td>Address rank</td>
156                       <td>Admin level</td>
157                       <td>Distance</td>
158                       <td></td>
159                     </tr>
160                 </thead>
161                 <tbody>
162
163                 <?php
164                     foreach ($aAddressLines as $aAddressLine) {
165                         _one_row($aAddressLine);
166                     }
167                 ?>
168
169
170 <?php
171
172     if ($aLinkedLines)
173     {
174         headline('Linked Places');
175         foreach ($aLinkedLines as $aAddressLine) {
176             _one_row($aAddressLine);
177         }
178     }
179
180     if ($bIncludeKeywords)
181     {
182         headline('Name Keywords');
183         if ($aPlaceSearchNameKeywords) {
184             foreach ($aPlaceSearchNameKeywords as $aRow) {
185                 _one_keyword_row($aRow['word_token'], $aRow['word_id']);
186             }
187         }
188
189         headline('Address Keywords');
190         if ($aPlaceSearchAddressKeywords) {
191             foreach ($aPlaceSearchAddressKeywords as $aRow) {
192                 _one_keyword_row($aRow['word_token'], $aRow['word_id']);
193             }
194         }
195     }
196
197     if (!empty($aHierarchyLines))
198     {
199         headline('Parent Of');
200
201         $aGroupedAddressLines = array();
202         foreach ($aHierarchyLines as $aAddressLine) {
203             if ($aAddressLine['type'] == 'yes') $sType = $aAddressLine['class'];
204             else $sType = $aAddressLine['type'];
205
206             if (!isset($aGroupedAddressLines[$sType]))
207                 $aGroupedAddressLines[$sType] = array();
208             $aGroupedAddressLines[$sType][] = $aAddressLine;
209         }
210         foreach ($aGroupedAddressLines as $sGroupHeading => $aHierarchyLines) {
211             $sGroupHeading = ucwords($sGroupHeading);
212             headline3($sGroupHeading);
213
214             foreach ($aHierarchyLines as $aAddressLine) {
215                 _one_row($aAddressLine);
216             }
217         }
218         if (count($aHierarchyLines) >= 500) {
219             echo '<p>There are more child objects which are not shown.</p>';
220         }
221     }
222
223     echo "</table>\n";
224 ?>
225
226             </div>
227         </div>
228     </div>
229
230     <script type="text/javascript">
231     <?php
232
233         $aNominatimMapInit = array(
234           'tile_url' => $sTileURL,
235           'tile_attribution' => $sTileAttribution
236         );
237         echo 'var nominatim_map_init = ' . json_encode($aNominatimMapInit, JSON_PRETTY_PRINT) . ';';
238
239         $aPlace = array(
240                 'asgeojson' => $aPointDetails['asgeojson'],
241                 'lon' => $aPointDetails['lon'],
242                 'lat' => $aPointDetails['lat'],
243         );
244         echo 'var nominatim_result = ' . json_encode($aPlace, JSON_PRETTY_PRINT) . ';';
245
246
247     ?>
248     </script>
249
250
251
252     <?php include(CONST_BasePath.'/lib/template/includes/html-footer.php'); ?>
253 </body>
254 </html>