diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-12-13 01:29:42 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-12-13 01:29:42 +0100 |
| commit | 2fd6f7fc0b2db4f5f7d54271e48577f3db7564bf (patch) | |
| tree | 6468c6983dc0fd1d3627a9bd80148ace2abf8799 | |
| parent | c86bd69147a289ead837e5400776393bd9072a82 (diff) | |
| download | PROJ-2fd6f7fc0b2db4f5f7d54271e48577f3db7564bf.tar.gz PROJ-2fd6f7fc0b2db4f5f7d54271e48577f3db7564bf.zip | |
PROJStringFormatter: make startInversion/stopInversion properly deal with omit_fwd/omit_inv
| -rw-r--r-- | src/iso19111/io.cpp | 6 | ||||
| -rw-r--r-- | test/unit/test_io.cpp | 24 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index b57d1de5..c704e1c1 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -7156,6 +7156,12 @@ void PROJStringFormatter::stopInversion() { // the current end of steps for (auto iter = startIter; iter != d->steps_.end(); ++iter) { iter->inverted = !iter->inverted; + for (auto ¶mValue : iter->paramValues) { + if (paramValue.key == "omit_fwd") + paramValue.key = "omit_inv"; + else if (paramValue.key == "omit_inv") + paramValue.key = "omit_fwd"; + } } // And reverse the order of steps in that range as well. std::reverse(startIter, d->steps_.end()); diff --git a/test/unit/test_io.cpp b/test/unit/test_io.cpp index 9fefaf9b..15ab8706 100644 --- a/test/unit/test_io.cpp +++ b/test/unit/test_io.cpp @@ -6867,6 +6867,30 @@ TEST(io, projstringformatter_optim_hgridshift_vgridshift_hgridshift_inv) { "+step +proj=pop +v_1 +v_2"); } + // Test omit_fwd->omit_inv when inversing the pipeline + { + auto fmt = PROJStringFormatter::create(); + fmt->startInversion(); + fmt->ingestPROJString("+proj=hgridshift +grids=foo +omit_fwd"); + fmt->stopInversion(); + + EXPECT_EQ(fmt->toString(), + "+proj=pipeline " + "+step +inv +proj=hgridshift +grids=foo +omit_inv"); + } + + // Test omit_inv->omit_fwd when inversing the pipeline + { + auto fmt = PROJStringFormatter::create(); + fmt->startInversion(); + fmt->ingestPROJString("+proj=hgridshift +grids=foo +omit_inv"); + fmt->stopInversion(); + + EXPECT_EQ(fmt->toString(), + "+proj=pipeline " + "+step +inv +proj=hgridshift +grids=foo +omit_fwd"); + } + // Variant with first hgridshift inverted, and second forward { auto fmt = PROJStringFormatter::create(); |
