aboutsummaryrefslogtreecommitdiff
path: root/src/iso19111/io.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/iso19111/io.cpp')
-rw-r--r--src/iso19111/io.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp
index d3928a86..b317213a 100644
--- a/src/iso19111/io.cpp
+++ b/src/iso19111/io.cpp
@@ -7509,13 +7509,22 @@ const std::string &PROJStringFormatter::toString() const {
const auto paramCount = step.paramValues.size();
- // axisswap order=2,1 is its own inverse
+ // axisswap order=2,1 (or 1,-2) is its own inverse
if (step.name == "axisswap" && paramCount == 1 &&
- step.paramValues[0].equals("order", "2,1")) {
+ (step.paramValues[0].equals("order", "2,1") ||
+ step.paramValues[0].equals("order", "1,-2"))) {
step.inverted = false;
continue;
}
+ // axisswap inv order=2,-1 ==> axisswap order -2,1
+ if (step.name == "axisswap" && paramCount == 1 &&
+ step.paramValues[0].equals("order", "2,-1")) {
+ step.inverted = false;
+ step.paramValues[0] = Step::KeyValue("order", "-2,1");
+ continue;
+ }
+
// handle unitconvert inverse
if (step.name == "unitconvert" && paramCount == 2 &&
step.paramValues[0].keyEquals("xy_in") &&
@@ -7790,6 +7799,25 @@ const std::string &PROJStringFormatter::toString() const {
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
+ if (curStep.name == "axisswap" && prevStep.name == "axisswap" &&
+ curStepParamCount == 1 && prevStepParamCount == 1 &&
+ ((prevStep.paramValues[0].equals("order", "2,1") &&
+ !curStep.inverted &&
+ curStep.paramValues[0].equals("order", "2,-1")) ||
+ (prevStep.paramValues[0].equals("order", "-2,1") &&
+ !prevStep.inverted &&
+ curStep.paramValues[0].equals("order", "2,1")))) {
+
+ prevStep.inverted = false;
+ prevStep.paramValues[0] = Step::KeyValue("order", "1,-2");
+ // Delete this iter
+ iterCur = steps.erase(iterCur);
+ continue;
+ }
+
// axisswap order=2,1, unitconvert, axisswap order=2,1 -> can
// suppress axisswap
if (std::next(iterCur) != steps.end() &&