From 6d9a1a909886762cc99e1d8f289e2b60ea787bf7 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Thu, 29 Nov 2018 02:52:22 +0100 Subject: Preserve EPSG code when importFromWKT WKT1_GDAL of EPSG:3857 --- test/unit/test_operation.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/unit/test_operation.cpp') diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index 818c10ec..c2e35e89 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -3016,6 +3016,29 @@ TEST(operation, webmerc_import_from_GDAL_wkt1) { // --------------------------------------------------------------------------- +TEST(operation, webmerc_import_from_GDAL_wkt1_with_EPSG_code) { + + auto projCRS = ProjectedCRS::create( + PropertyMap() + .set(IdentifiedObject::NAME_KEY, "Pseudo-Mercator") + .set(Identifier::CODESPACE_KEY, "EPSG") + .set(Identifier::CODE_KEY, "3857"), + GeographicCRS::EPSG_4326, + Conversion::createPopularVisualisationPseudoMercator( + PropertyMap(), Angle(0), Angle(0), Length(0), Length(0)), + CartesianCS::createEastingNorthing(UnitOfMeasure::METRE)); + + auto wkt1 = projCRS->exportToWKT( + WKTFormatter::create(WKTFormatter::Convention::WKT1_GDAL).get()); + EXPECT_TRUE(wkt1.find("3857") != std::string::npos) << wkt1; + auto obj = WKTParser().createFromWKT(wkt1); + auto crs = nn_dynamic_pointer_cast(obj); + ASSERT_TRUE(crs != nullptr); + EXPECT_EQ(crs->identifiers().size(), 1); +} + +// --------------------------------------------------------------------------- + TEST(operation, webmerc_import_from_GDAL_wkt1_EPSG_3785_deprecated) { auto wkt1 = -- cgit v1.2.3