From a68c146d7f3c1efb0f42b46c708a0a195e51a2ff Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 16 Dec 2019 13:24:11 +0100 Subject: BoundCRS::identify(): improvements to discard CRS that aren't relevant (fixes #1801) Fix for ``` projinfo --identify "+proj=utm +zone=48 +a=6377276.345 +b=6356075.41314024 +towgs84=198,881,317,0,0,0,0 +units=m +no_defs +type=crs" ``` to only return BoundCRS of EPSG:3148: 70 % Previously it also returned EPSG:23948 and EPSG:24048 whose projected CRS-only parts where likely matches, but those 2 CRSs don't have a +towgs84=198,881,317,0,0,0,0, so discard them. --- test/unit/test_crs.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/unit/test_crs.cpp') diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp index 33d67e0a..df1c257d 100644 --- a/test/unit/test_crs.cpp +++ b/test/unit/test_crs.cpp @@ -3825,6 +3825,21 @@ TEST(crs, boundCRS_identify_db) { WKTFormatter::create(WKTFormatter::Convention::WKT1_GDAL).get()); EXPECT_TRUE(wkt.find("32122") != std::string::npos) << wkt; } + + { + // Identify from a PROJ string with +towgs84 + auto obj = PROJStringParser().createFromPROJString( + "+proj=utm +zone=48 +a=6377276.345 +b=6356075.41314024 " + "+towgs84=198,881,317,0,0,0,0 +units=m +no_defs +type=crs"); + auto crs = nn_dynamic_pointer_cast(obj); + ASSERT_TRUE(crs != nullptr); + auto res = crs->identify(factoryEPSG); + ASSERT_EQ(res.size(), 1U); + auto boundCRS = dynamic_cast(res.front().first.get()); + ASSERT_TRUE(boundCRS != nullptr); + EXPECT_EQ(boundCRS->baseCRS()->getEPSGCode(), 3148); + EXPECT_EQ(res.front().second, 70); + } } // --------------------------------------------------------------------------- -- cgit v1.2.3