From: Sarah Hoffmann Date: Sun, 9 Feb 2020 14:45:38 +0000 (+0100) Subject: return place_id link to details when not an OSM object X-Git-Tag: v3.5.0~86^2~3 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/57ae3d03a1ccfb464216b58e7e70abaf3a3d8c48?hp=3737712044b50ec1319afeebcd24d0ca2d0b181d return place_id link to details when not an OSM object Stop-gap solution to find the right object for Tiger and interpolation objects. --- 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' + ); + } + + + + +}