]> git.openstreetmap.org Git - nominatim.git/blob - lib/output.php
clean up docs for lookup call
[nominatim.git] / lib / output.php
1 <?php
2
3
4 function formatOSMType($sType, $bIncludeExternal = true)
5 {
6     if ($sType == 'N') return 'node';
7     if ($sType == 'W') return 'way';
8     if ($sType == 'R') return 'relation';
9
10     if (!$bIncludeExternal) return '';
11
12     if ($sType == 'T') return 'way';
13     if ($sType == 'I') return 'way';
14
15     return '';
16 }
17
18 function osmLink($aFeature, $sRefText = false)
19 {
20     $sOSMType = formatOSMType($aFeature['osm_type'], false);
21     if ($sOSMType) {
22         return '<a href="//www.openstreetmap.org/'.$sOSMType.'/'.$aFeature['osm_id'].'">'.$sOSMType.' '.($sRefText?$sRefText:$aFeature['osm_id']).'</a>';
23     }
24     return '';
25 }
26
27 function wikipediaLink($aFeature)
28 {
29     if ($aFeature['wikipedia']) {
30         list($sLanguage, $sArticle) = explode(':', $aFeature['wikipedia']);
31         return '<a href="https://'.$sLanguage.'.wikipedia.org/wiki/'.urlencode($sArticle).'" target="_blank">'.$aFeature['wikipedia'].'</a>';
32     }
33     return '';
34 }
35
36 function detailsLink($aFeature, $sTitle = false)
37 {
38     if (!$aFeature['place_id']) return '';
39
40     return '<a href="details.php?place_id='.$aFeature['place_id'].'">'.($sTitle?$sTitle:$aFeature['place_id']).'</a>';
41 }
42
43 function detailsPermaLink($aFeature, $sRefText = false)
44 {
45     $sOSMType = formatOSMType($aFeature['osm_type'], false);
46
47     if ($sOSMType) {
48         $sLabel = $sRefText ? $sRefText : $sOSMType.' '.$aFeature['osm_id'];
49         return '<a href="details.php?osmtype='.$aFeature['osm_type'].'&osmid='.$aFeature['osm_id'].'&class='.$aFeature['class'].'">'.$sLabel.'</a>';
50     }
51     return '';
52 }