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