diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-10-22 19:30:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-22 19:30:00 +0200 |
| commit | 9aed9e0297ee049dfc92fe1dadc94302fcc44ca0 (patch) | |
| tree | 575906715503681d53e4f84e0ff28d31da2f6c89 /test | |
| parent | 01d503cb23b4cffe4435c1e915c4d0661bb16d74 (diff) | |
| parent | f5aed82fc6eee896606e95dc15e578cd9f058a2c (diff) | |
| download | PROJ-9aed9e0297ee049dfc92fe1dadc94302fcc44ca0.tar.gz PROJ-9aed9e0297ee049dfc92fe1dadc94302fcc44ca0.zip | |
Merge pull request #2907 from josch/tinshiftfallback
add fallback strategy for tinshift transform to use closest triangle for points not in any
Diffstat (limited to 'test')
| -rw-r--r-- | test/gie/tinshift.gie | 12 | ||||
| -rw-r--r-- | test/unit/test_tinshift.cpp | 67 |
2 files changed, 79 insertions, 0 deletions
diff --git a/test/gie/tinshift.gie b/test/gie/tinshift.gie index f16c16bb..85009537 100644 --- a/test/gie/tinshift.gie +++ b/test/gie/tinshift.gie @@ -47,4 +47,16 @@ accept 3210000.0000 6700000.0000 10.0 expect 3210000.0000 6700000.0000 10.2886 roundtrip 1 +# Test fallback strategy nearest_side +operation +proj=tinshift +file=tests/tinshift_fallback_nearest_side.json +accept 2 3 +expect 4 6 +roundtrip 1 + +# Test fallback strategy nearest_centroid +operation +proj=tinshift +file=tests/tinshift_fallback_nearest_centroid.json +accept 3 0 +expect 3 0 +roundtrip 1 + </gie-strict> diff --git a/test/unit/test_tinshift.cpp b/test/unit/test_tinshift.cpp index 96da6e25..2b42294f 100644 --- a/test/unit/test_tinshift.cpp +++ b/test/unit/test_tinshift.cpp @@ -65,6 +65,7 @@ TEST(tinshift, basic) { EXPECT_EQ(f->formatVersion(), "1.0"); EXPECT_EQ(f->inputCRS(), "EPSG:2393"); EXPECT_EQ(f->outputCRS(), "EPSG:3067"); + EXPECT_EQ(f->fallbackStrategy(), FALLBACK_NONE); auto eval = Evaluator(std::move(f)); double x_out = 0; @@ -206,6 +207,72 @@ TEST(tinshift, basic) { EXPECT_EQ(y_out, 0.75); EXPECT_EQ(z_out, 1000.0); } + + // invalid fallback_strategy field with 1.0 version + { + auto j(jMinValid); + j["fallback_strategy"] = "none"; + EXPECT_THROW(TINShiftFile::parse(j.dump()), ParsingException); + } + + // invalid fallback_strategy field with 1.1 version + { + auto j(jMinValid); + j["format_version"] = "1.1"; + j["fallback_strategy"] = "invalid"; + EXPECT_THROW(TINShiftFile::parse(j.dump()), ParsingException); + } + + // fail with no triangles and fallback nearest_side + { + auto j(jMinValid); + j["format_version"] = "1.1"; + j["fallback_strategy"] = "nearest_side"; + j["triangles"] = json::array(); // empty + + auto f = TINShiftFile::parse(j.dump()); + auto eval = Evaluator(std::move(f)); + double x_out = 0; + double y_out = 0; + double z_out = 0; + + EXPECT_FALSE(eval.forward(1.0, 1.0, 1.0, x_out, y_out, z_out)); + } + + // fail with only degenerate triangles (one size is zero length) and + // fallback nearest_side + { + auto j(jMinValid); + j["format_version"] = "1.1"; + j["fallback_strategy"] = "nearest_side"; + j["vertices"] = {{0, 0, 101, 101}, {0, 1, 100, 101}, {0, 1, 100, 100}}; + + auto f = TINShiftFile::parse(j.dump()); + auto eval = Evaluator(std::move(f)); + double x_out = 0; + double y_out = 0; + double z_out = 0; + + EXPECT_FALSE(eval.forward(1.0, 1.0, 1.0, x_out, y_out, z_out)); + } + + // fail with only degenerate triangles (two angles are 0°) and fallback + // nearest_side + { + auto j(jMinValid); + j["format_version"] = "1.1"; + j["fallback_strategy"] = "nearest_side"; + j["vertices"] = { + {0, 0, 101, 101}, {0, 0.5, 100, 101}, {0, 1, 100, 100}}; + + auto f = TINShiftFile::parse(j.dump()); + auto eval = Evaluator(std::move(f)); + double x_out = 0; + double y_out = 0; + double z_out = 0; + + EXPECT_FALSE(eval.forward(1.0, 1.0, 1.0, x_out, y_out, z_out)); + } } } // namespace |
