aboutsummaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-01-04 19:25:04 +0100
committerEven Rouault <even.rouault@spatialys.com>2019-01-04 19:25:04 +0100
commitb62fdee0f34d960527af8fb0a8bf6344fcf78d4b (patch)
tree0341b02ba45f0a3d1761adde97d3c58a220e73ac /test/unit
parentd89a6ab2f3f26d1451971369b0ccfc4eb322729d (diff)
downloadPROJ-b62fdee0f34d960527af8fb0a8bf6344fcf78d4b.tar.gz
PROJ-b62fdee0f34d960527af8fb0a8bf6344fcf78d4b.zip
WKT export: no longer export Geographic 3D CRS in WKT1, unless strict mode is disabled
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/test_c_api.cpp19
-rw-r--r--test/unit/test_crs.cpp22
2 files changed, 27 insertions, 14 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp
index 096d970b..778c6bdf 100644
--- a/test/unit/test_c_api.cpp
+++ b/test/unit/test_c_api.cpp
@@ -420,6 +420,25 @@ TEST_F(CApi, proj_as_wkt) {
EXPECT_TRUE(std::string(wkt).find("AXIS") != std::string::npos) << wkt;
}
+ auto crs4979 = proj_create_from_wkt(
+ m_ctxt,
+ GeographicCRS::EPSG_4979->exportToWKT(WKTFormatter::create().get())
+ .c_str(),
+ nullptr, nullptr, nullptr);
+ ObjectKeeper keeper_crs4979(crs4979);
+ ASSERT_NE(crs4979, nullptr);
+
+ // STRICT=NO
+ {
+ EXPECT_EQ(proj_as_wkt(m_ctxt, crs4979, PJ_WKT1_GDAL, nullptr), nullptr);
+
+ const char *const options[] = {"STRICT=NO", nullptr};
+ auto wkt = proj_as_wkt(m_ctxt, crs4979, PJ_WKT1_GDAL, options);
+ ASSERT_NE(wkt, nullptr);
+ EXPECT_TRUE(std::string(wkt).find("GEOGCS[\"WGS 84\"") == 0)
+ << wkt;
+ }
+
// unsupported option
{
const char *const options[] = {"unsupported=yes", nullptr};
diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp
index 6eb0602e..fe0ac7e8 100644
--- a/test/unit/test_crs.cpp
+++ b/test/unit/test_crs.cpp
@@ -442,14 +442,16 @@ TEST(crs, EPSG_4979_as_WKT2_2018_SIMPLIFIED) {
// ---------------------------------------------------------------------------
-TEST(crs, EPSG_4979_as_WKT1_GDAL_with_axis) {
+TEST(crs, EPSG_4979_as_WKT1_GDAL_with_axis_not_strict_mode) {
auto crs = GeographicCRS::EPSG_4979;
auto wkt = crs->exportToWKT(
&(WKTFormatter::create(WKTFormatter::Convention::WKT1_GDAL)
- ->setOutputAxis(WKTFormatter::OutputAxisRule::YES)));
+ ->setStrict(false)
+ .setOutputAxis(WKTFormatter::OutputAxisRule::YES)));
// WKT1 only supports 2 axis for GEOGCS. So this is an extension of
// WKT1 as it
// and GDAL doesn't really export such as beast, although it can import it
+ // so allow it only in non-strict more
EXPECT_EQ(wkt, "GEOGCS[\"WGS 84\",\n"
" DATUM[\"WGS_1984\",\n"
" SPHEROID[\"WGS 84\",6378137,298.257223563,\n"
@@ -469,18 +471,10 @@ TEST(crs, EPSG_4979_as_WKT1_GDAL_with_axis) {
TEST(crs, EPSG_4979_as_WKT1_GDAL) {
auto crs = GeographicCRS::EPSG_4979;
- auto wkt = crs->exportToWKT(
- WKTFormatter::create(WKTFormatter::Convention::WKT1_GDAL).get());
- EXPECT_EQ(wkt, "GEOGCS[\"WGS 84\",\n"
- " DATUM[\"WGS_1984\",\n"
- " SPHEROID[\"WGS 84\",6378137,298.257223563,\n"
- " AUTHORITY[\"EPSG\",\"7030\"]],\n"
- " AUTHORITY[\"EPSG\",\"6326\"]],\n"
- " PRIMEM[\"Greenwich\",0,\n"
- " AUTHORITY[\"EPSG\",\"8901\"]],\n"
- " UNIT[\"degree\",0.0174532925199433,\n"
- " AUTHORITY[\"EPSG\",\"9122\"]],\n"
- " AUTHORITY[\"EPSG\",\"4979\"]]");
+ EXPECT_THROW(
+ crs->exportToWKT(
+ WKTFormatter::create(WKTFormatter::Convention::WKT1_GDAL).get()),
+ FormattingException);
}
// ---------------------------------------------------------------------------