From 9db95ecde7ffa275697ce4921437bc8f7d475d25 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 24 Jan 2020 14:52:46 +0100 Subject: createObjectsFromName(): use alias as fallback only Fixes a regression of 6.3.0 found when creating with GDAL a TIFF with a Geographic3D CRS. As TIFF must also encode the Geographic2D CRS, the code of the Geographic2D CRS is searched from the name of the Geographic3D CRS. When doing createObjectsFromName( "ETRS89", {AuthorityFactory::ObjectType::GEOGRAPHIC_2D_CRS}, false, 1), the result returned was not EPSG:4258 as expected, but EPSG:4173 IRENET95 which is registered as an alias of ETRS89. So sort results such that non-alias results are returned first. --- test/unit/test_factory.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/unit/test_factory.cpp') diff --git a/test/unit/test_factory.cpp b/test/unit/test_factory.cpp index 33b72efd..d49db5bf 100644 --- a/test/unit/test_factory.cpp +++ b/test/unit/test_factory.cpp @@ -2869,6 +2869,16 @@ TEST(factory, createObjectsFromName) { factory->createObjectsFromName("i_dont_exist", {type}, false, 1); } factory->createObjectsFromName("i_dont_exist", types, false, 1); + + { + auto res = factoryEPSG->createObjectsFromName( + "ETRS89", {AuthorityFactory::ObjectType::GEOGRAPHIC_2D_CRS}, false, + 1); + EXPECT_EQ(res.size(), 1U); + if (!res.empty()) { + EXPECT_EQ(res.front()->getEPSGCode(), 4258); + } + } } // --------------------------------------------------------------------------- -- cgit v1.2.3