From 40ab72f2e9d913c7128fde24576183068dcd7ee2 Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Tue, 28 Sep 2021 14:47:10 +0200 Subject: PROJStringFormatter: add optimizations useful for IAU CRS transformation pipelines --- src/iso19111/io.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src') diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index 9e7f0580..1f193559 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -7868,6 +7868,32 @@ const std::string &PROJStringFormatter::toString() const { continue; } + // axisswap order=2,-1 followed by axisswap order=-2,1 is a no-op + if (curStep.name == "axisswap" && prevStep.name == "axisswap" && + curStepParamCount == 1 && prevStepParamCount == 1 && + !prevStep.inverted && + prevStep.paramValues[0].equals("order", "2,-1") && + !curStep.inverted && + curStep.paramValues[0].equals("order", "-2,1")) { + deletePrevAndCurIter(); + continue; + } + + // axisswap order=2,-1 followed by axisswap order=1,-2 is + // equivalent to axisswap order=2,1 + if (curStep.name == "axisswap" && prevStep.name == "axisswap" && + curStepParamCount == 1 && prevStepParamCount == 1 && + !prevStep.inverted && + prevStep.paramValues[0].equals("order", "2,-1") && + !curStep.inverted && + curStep.paramValues[0].equals("order", "1,-2")) { + prevStep.inverted = false; + prevStep.paramValues[0] = Step::KeyValue("order", "2,1"); + // Delete this iter + iterCur = steps.erase(iterCur); + continue; + } + // axisswap order=2,1 followed by axisswap order=2,-1 is // equivalent to axisswap order=1,-2 // Same for axisswap order=-2,1 followed by axisswap order=2,1 -- cgit v1.2.3