aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-06-10 19:36:16 +0200
committerEven Rouault <even.rouault@spatialys.com>2021-06-10 19:36:16 +0200
commitdb10e86c2c4c4606ebf90961483d630ea81f748b (patch)
treecf8562a1ca3aec926642d5bb249fbc536509a709 /test
parent51ec5e346a35b8e55f1973be2ec05545102db16b (diff)
downloadPROJ-db10e86c2c4c4606ebf90961483d630ea81f748b.tar.gz
PROJ-db10e86c2c4c4606ebf90961483d630ea81f748b.zip
BoundCRS::identify(): avoid incompatible transformation for WKT1 / TOWGS84 export (fixes OSGeo/gdal#3958)
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_crs.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp
index 614580f2..10b21ee5 100644
--- a/test/unit/test_crs.cpp
+++ b/test/unit/test_crs.cpp
@@ -4646,9 +4646,10 @@ TEST(crs, boundCRS_identify_db) {
auto res = crs->identify(factoryEPSG);
ASSERT_EQ(res.size(), 1U);
EXPECT_EQ(res.front().second, 25);
- auto wkt = crs->exportToWKT(
- WKTFormatter::create(WKTFormatter::Convention::WKT1_GDAL).get());
- EXPECT_TRUE(wkt.find("32122") != std::string::npos) << wkt;
+ auto boundCRS = dynamic_cast<const BoundCRS *>(res.front().first.get());
+ ASSERT_TRUE(boundCRS != nullptr);
+ EXPECT_EQ(boundCRS->baseCRS()->getEPSGCode(), 32122);
+ EXPECT_EQ(boundCRS->transformation()->method()->getEPSGCode(), 9603);
}
{
@@ -4665,6 +4666,25 @@ TEST(crs, boundCRS_identify_db) {
EXPECT_EQ(boundCRS->baseCRS()->getEPSGCode(), 3148);
EXPECT_EQ(res.front().second, 70);
}
+
+ {
+ // Identify a WKT with datum WGS84 and TOWGS84
+ auto obj = WKTParser().attachDatabaseContext(dbContext).createFromWKT(
+ "GEOGCS[\"WGS84 Coordinate System\",DATUM[\"WGS 1984\","
+ "SPHEROID[\"WGS 1984\",6378137,298.257223563],"
+ "TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],"
+ "PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],"
+ "AUTHORITY[\"EPSG\",\"4326\"]]");
+ auto crs = nn_dynamic_pointer_cast<BoundCRS>(obj);
+ ASSERT_TRUE(crs != nullptr);
+ auto res = crs->identify(factoryEPSG);
+ ASSERT_EQ(res.size(), 1U);
+ EXPECT_EQ(res.front().second, 100);
+ auto boundCRS = dynamic_cast<const BoundCRS *>(res.front().first.get());
+ ASSERT_TRUE(boundCRS != nullptr);
+ EXPECT_EQ(boundCRS->baseCRS()->getEPSGCode(), 4326);
+ EXPECT_EQ(boundCRS->transformation()->method()->getEPSGCode(), 9606);
+ }
}
// ---------------------------------------------------------------------------