Nominatim/lib/output.php

42 lines
1.1 KiB
PHP
Raw Normal View History

<?php
function formatOSMType($sType, $bIncludeExternal = true)
2016-09-04 04:19:48 +03:00
{
if ($sType == 'N') return 'node';
if ($sType == 'W') return 'way';
if ($sType == 'R') return 'relation';
if (!$bIncludeExternal) return '';
if ($sType == 'T') return 'tiger';
if ($sType == 'I') return 'way';
return '';
}
function osmLink($aFeature, $sRefText = false)
2016-09-04 04:19:48 +03:00
{
$sOSMType = formatOSMType($aFeature['osm_type'], false);
if ($sOSMType) {
2016-09-04 04:19:48 +03:00
return '<a href="//www.openstreetmap.org/'.$sOSMType.'/'.$aFeature['osm_id'].'">'.$sOSMType.' '.($sRefText?$sRefText:$aFeature['osm_id']).'</a>';
}
return '';
}
function wikipediaLink($aFeature)
{
if ($aFeature['wikipedia']) {
list($sLanguage, $sArticle) = explode(':', $aFeature['wikipedia']);
2016-09-04 04:19:48 +03:00
return '<a href="https://'.$sLanguage.'.wikipedia.org/wiki/'.urlencode($sArticle).'" target="_blank">'.$aFeature['wikipedia'].'</a>';
}
return '';
}
function detailsLink($aFeature, $sTitle = false)
2016-09-04 04:19:48 +03:00
{
if (!$aFeature['place_id']) return '';
return '<a href="details.php?place_id='.$aFeature['place_id'].'">'.($sTitle?$sTitle:$aFeature['place_id']).'</a>';
}