2016-06-12 13:39:09 +03:00
|
|
|
<?php
|
|
|
|
|
2016-09-14 04:16:46 +03:00
|
|
|
|
2016-09-11 06:22:51 +03:00
|
|
|
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 '';
|
|
|
|
|
2016-10-30 19:07:43 +03:00
|
|
|
if ($sType == 'T') return 'way';
|
2016-09-04 04:19:48 +03:00
|
|
|
if ($sType == 'I') return 'way';
|
|
|
|
|
2020-02-09 18:50:04 +03:00
|
|
|
// not handled: P, L
|
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
2016-09-11 06:22:51 +03:00
|
|
|
function osmLink($aFeature, $sRefText = false)
|
2016-09-04 04:19:48 +03:00
|
|
|
{
|
|
|
|
$sOSMType = formatOSMType($aFeature['osm_type'], false);
|
2016-09-08 04:16:22 +03:00
|
|
|
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)
|
|
|
|
{
|
2016-09-08 04:16:22 +03:00
|
|
|
if ($aFeature['wikipedia']) {
|
2016-09-11 06:22:51 +03:00
|
|
|
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 '';
|
|
|
|
}
|
|
|
|
|
2020-02-09 18:05:22 +03:00
|
|
|
function detailsLink($aFeature, $sTitle = false, $sExtraProperties = false)
|
2016-09-04 04:19:48 +03:00
|
|
|
{
|
|
|
|
if (!$aFeature['place_id']) return '';
|
|
|
|
|
2020-02-09 18:05:22 +03:00
|
|
|
$sHtml = '<a ';
|
|
|
|
if ($sExtraProperties) {
|
|
|
|
$sHtml .= $sExtraProperties.' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
$sHtml .= 'href="details.php?place_id='.$aFeature['place_id'].'">'.($sTitle?$sTitle:$aFeature['place_id']).'</a>';
|
|
|
|
|
|
|
|
return $sHtml;
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
2018-04-06 17:11:54 +03:00
|
|
|
|
2020-02-09 18:05:22 +03:00
|
|
|
function detailsPermaLink($aFeature, $sRefText = false, $sExtraProperties = false)
|
2018-04-06 17:11:54 +03:00
|
|
|
{
|
|
|
|
$sOSMType = formatOSMType($aFeature['osm_type'], false);
|
|
|
|
|
|
|
|
if ($sOSMType) {
|
2020-02-09 18:05:22 +03:00
|
|
|
$sHtml = '<a ';
|
|
|
|
if ($sExtraProperties) {
|
|
|
|
$sHtml .= $sExtraProperties.' ';
|
|
|
|
}
|
|
|
|
$sHtml .= 'href="details.php?osmtype='.$aFeature['osm_type']
|
|
|
|
.'&osmid='.$aFeature['osm_id'].'&class='.$aFeature['class'].'">';
|
|
|
|
|
|
|
|
if ($sRefText) {
|
|
|
|
$sHtml .= $sRefText.'</a>';
|
|
|
|
} else {
|
|
|
|
$sHtml .= $sOSMType.' '.$aFeature['osm_id'].'</a>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $sHtml;
|
2018-04-06 17:11:54 +03:00
|
|
|
}
|
2020-02-09 18:05:22 +03:00
|
|
|
return detailsLink($aFeature, $sRefText, $sExtraProperties);
|
2018-04-06 17:11:54 +03:00
|
|
|
}
|