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