mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-11-27 00:49:55 +03:00
remove unused output formatting functions
This commit is contained in:
parent
171ed36e36
commit
f9c43137c9
@ -16,58 +16,3 @@ function formatOSMType($sType, $bIncludeExternal = true)
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
function osmLink($aFeature, $sRefText = false)
|
||||
{
|
||||
$sOSMType = formatOSMType($aFeature['osm_type'], false);
|
||||
if ($sOSMType) {
|
||||
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']);
|
||||
return '<a href="https://'.$sLanguage.'.wikipedia.org/wiki/'.urlencode($sArticle).'" target="_blank">'.$aFeature['wikipedia'].'</a>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function detailsLink($aFeature, $sTitle = false, $sExtraProperties = false)
|
||||
{
|
||||
if (!$aFeature['place_id']) return '';
|
||||
|
||||
$sHtml = '<a ';
|
||||
if ($sExtraProperties) {
|
||||
$sHtml .= $sExtraProperties.' ';
|
||||
}
|
||||
|
||||
$sHtml .= 'href="details.php?place_id='.$aFeature['place_id'].'">'.($sTitle?$sTitle:$aFeature['place_id']).'</a>';
|
||||
|
||||
return $sHtml;
|
||||
}
|
||||
|
||||
function detailsPermaLink($aFeature, $sRefText = false, $sExtraProperties = false)
|
||||
{
|
||||
$sOSMType = formatOSMType($aFeature['osm_type'], false);
|
||||
|
||||
if ($sOSMType) {
|
||||
$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;
|
||||
}
|
||||
return detailsLink($aFeature, $sRefText, $sExtraProperties);
|
||||
}
|
||||
|
@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Nominatim;
|
||||
|
||||
require_once(CONST_LibDir.'/output.php');
|
||||
|
||||
class OutputTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testDetailsPermaLinkNode()
|
||||
{
|
||||
$aFeature = array('osm_type' => 'N', 'osm_id'=> 38274, 'class' => 'place');
|
||||
$this->assertSame(
|
||||
detailsPermaLink($aFeature),
|
||||
'<a href="details.php?osmtype=N&osmid=38274&class=place">node 38274</a>'
|
||||
);
|
||||
}
|
||||
|
||||
public function testDetailsPermaLinkWay()
|
||||
{
|
||||
$aFeature = array('osm_type' => 'W', 'osm_id'=> 65, 'class' => 'highway');
|
||||
$this->assertSame(
|
||||
detailsPermaLink($aFeature),
|
||||
'<a href="details.php?osmtype=W&osmid=65&class=highway">way 65</a>'
|
||||
);
|
||||
}
|
||||
|
||||
public function testDetailsPermaLinkRelation()
|
||||
{
|
||||
$aFeature = array('osm_type' => 'R', 'osm_id'=> 9908, 'class' => 'waterway');
|
||||
$this->assertSame(
|
||||
detailsPermaLink($aFeature),
|
||||
'<a href="details.php?osmtype=R&osmid=9908&class=waterway">relation 9908</a>'
|
||||
);
|
||||
}
|
||||
|
||||
public function testDetailsPermaLinkTiger()
|
||||
{
|
||||
$aFeature = array('osm_type' => 'T', 'osm_id'=> 2, 'place_id' => 334);
|
||||
$this->assertSame(
|
||||
detailsPermaLink($aFeature, 'foo'),
|
||||
'<a href="details.php?place_id=334">foo</a>'
|
||||
);
|
||||
}
|
||||
|
||||
public function testDetailsPermaLinkInterpolation()
|
||||
{
|
||||
$aFeature = array('osm_type' => 'I', 'osm_id'=> 400, 'place_id' => 3);
|
||||
$this->assertSame(
|
||||
detailsPermaLink($aFeature, 'foo'),
|
||||
'<a href="details.php?place_id=3">foo</a>'
|
||||
);
|
||||
}
|
||||
|
||||
public function testDetailsPermaLinkWithExtraPropertiesNode()
|
||||
{
|
||||
$aFeature = array('osm_type' => 'N', 'osm_id'=> 2, 'class' => 'amenity');
|
||||
$this->assertSame(
|
||||
detailsPermaLink($aFeature, 'something', 'class="xtype"'),
|
||||
'<a class="xtype" href="details.php?osmtype=N&osmid=2&class=amenity">something</a>'
|
||||
);
|
||||
}
|
||||
|
||||
public function testDetailsPermaLinkWithExtraPropertiesTiger()
|
||||
{
|
||||
$aFeature = array('osm_type' => 'T', 'osm_id'=> 5, 'place_id' => 46);
|
||||
$this->assertSame(
|
||||
detailsPermaLink($aFeature, 'something', 'class="xtype"'),
|
||||
'<a class="xtype" href="details.php?place_id=46">something</a>'
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user