From 57ae3d03a1ccfb464216b58e7e70abaf3a3d8c48 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sun, 9 Feb 2020 15:45:38 +0100 Subject: [PATCH] return place_id link to details when not an OSM object Stop-gap solution to find the right object for Tiger and interpolation objects. --- lib/output.php | 2 +- test/php/Nominatim/OutputTest.php | 57 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 test/php/Nominatim/OutputTest.php diff --git a/lib/output.php b/lib/output.php index 9d4b7502..8715efbc 100644 --- a/lib/output.php +++ b/lib/output.php @@ -48,5 +48,5 @@ function detailsPermaLink($aFeature, $sRefText = false) $sLabel = $sRefText ? $sRefText : $sOSMType.' '.$aFeature['osm_id']; return ''.$sLabel.''; } - return ''; + return detailsLink($aFeature, $sRefText); } diff --git a/test/php/Nominatim/OutputTest.php b/test/php/Nominatim/OutputTest.php new file mode 100644 index 00000000..ce9bfa35 --- /dev/null +++ b/test/php/Nominatim/OutputTest.php @@ -0,0 +1,57 @@ + 'N', 'osm_id'=> 38274, 'class' => 'place'); + $this->assertSame( + detailsPermaLink($aFeature), + 'node 38274' + ); + } + + public function testDetailsPermaLinkWay() + { + $aFeature = array('osm_type' => 'W', 'osm_id'=> 65, 'class' => 'highway'); + $this->assertSame( + detailsPermaLink($aFeature), + 'way 65' + ); + } + + public function testDetailsPermaLinkRelation() + { + $aFeature = array('osm_type' => 'R', 'osm_id'=> 9908, 'class' => 'waterway'); + $this->assertSame( + detailsPermaLink($aFeature), + 'relation 9908' + ); + } + + public function testDetailsPermaLinkTiger() + { + $aFeature = array('osm_type' => 'T', 'osm_id'=> 2, 'place_id' => 334); + $this->assertSame( + detailsPermaLink($aFeature, 'foo'), + 'foo' + ); + } + + public function testDetailsPermaLinkInterpolation() + { + $aFeature = array('osm_type' => 'I', 'osm_id'=> 400, 'place_id' => 3); + $this->assertSame( + detailsPermaLink($aFeature, 'foo'), + 'foo' + ); + } + + + + +} -- 2.39.5