aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-10-10 14:23:42 +0200
committerEven Rouault <even.rouault@spatialys.com>2020-10-10 14:23:50 +0200
commit5163741254088b7f3fbb651349463cd2942df4f6 (patch)
treef99750451df364d1410c6e17073d8b513cb6b82e /test
parenta5dd7bbb8512a10280001491bd3fecc599fd4eca (diff)
downloadPROJ-5163741254088b7f3fbb651349463cd2942df4f6.tar.gz
PROJ-5163741254088b7f3fbb651349463cd2942df4f6.zip
WKT2:2019 import/export: handle DATUM (at top level object) with PRIMEM
This is a peculiarity of the WKT grammar. Despite ISO 19111 saying that the prime meridian is a component of the datum, in WKT, they are placed at the same level, for backward compatibility with earlier WKT versions. So handle exporting and importing that. The fix is only for situation where DATUM is the top level object (was working fine otherwise), which is a uncommon use case. And to limit the amount of issue, on export emit the prime meridian only if it is not Greenwich.
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_io.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp
index 34396fcf..47e574c5 100644
--- a/test/unit/test_io.cpp
+++ b/test/unit/test_io.cpp
@@ -190,6 +190,28 @@ TEST(wkt_parse, datum_with_ANCHOR) {
// ---------------------------------------------------------------------------
+TEST(wkt_parse, datum_with_pm) {
+ const char *wkt =
+ "DATUM[\"Nouvelle Triangulation Francaise (Paris)\",\n"
+ " ELLIPSOID[\"Clarke 1880 (IGN)\",6378249.2,293.466021293627,\n"
+ " LENGTHUNIT[\"metre\",1]],\n"
+ " ID[\"EPSG\",6807]],\n"
+ "PRIMEM[\"Paris\",2.5969213,\n"
+ " ANGLEUNIT[\"grad\",0.0157079632679489],\n"
+ " ID[\"EPSG\",8903]]";
+
+ auto obj = WKTParser().createFromWKT(wkt);
+ auto datum = nn_dynamic_pointer_cast<GeodeticReferenceFrame>(obj);
+ ASSERT_TRUE(datum != nullptr);
+ EXPECT_EQ(datum->primeMeridian()->nameStr(), "Paris");
+ EXPECT_EQ(
+ datum->exportToWKT(
+ WKTFormatter::create(WKTFormatter::Convention::WKT2_2019).get()),
+ wkt);
+}
+
+// ---------------------------------------------------------------------------
+
TEST(wkt_parse, datum_no_pm_not_earth) {
auto obj = WKTParser().createFromWKT("DATUM[\"unnamed\",\n"
" ELLIPSOID[\"unnamed\",1,0,\n"