diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2020-06-06 21:09:21 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2020-06-06 22:24:13 +0200 |
| commit | c6ff686bf8334efce9995dacc899022d3a5b813b (patch) | |
| tree | c1c008b5e20fc5a9cd49f1ba6ed1d978556c9c1e /src | |
| parent | a96e8f5f4e2a2145656c533271d1461ea077a35d (diff) | |
| download | PROJ-c6ff686bf8334efce9995dacc899022d3a5b813b.tar.gz PROJ-c6ff686bf8334efce9995dacc899022d3a5b813b.zip | |
createOperations(): improve name of inverse transformation when there are registered transformations between compoundCRS and something else
Diffstat (limited to 'src')
| -rw-r--r-- | src/iso19111/coordinateoperation.cpp | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp index c64dab5f..ecc3df06 100644 --- a/src/iso19111/coordinateoperation.cpp +++ b/src/iso19111/coordinateoperation.cpp @@ -7822,9 +7822,34 @@ createPropertiesForInverse(const CoordinateOperation *op, bool derivedFrom, auto targetCRS = op->targetCRS(); std::string name; if (!forwardName.empty()) { - if (starts_with(forwardName, INVERSE_OF) || - forwardName.find(" + ") != std::string::npos) { - auto tokens = split(forwardName, " + "); + if (dynamic_cast<const Transformation *>(op) == nullptr && + dynamic_cast<const ConcatenatedOperation *>(op) == nullptr && + (starts_with(forwardName, INVERSE_OF) || + forwardName.find(" + ") != std::string::npos)) { + std::vector<std::string> tokens; + std::string curToken; + bool inString = false; + for (size_t i = 0; i < forwardName.size(); ++i) { + if (inString) { + curToken += forwardName[i]; + if (forwardName[i] == '\'') { + inString = false; + } + } else if (i + 3 < forwardName.size() && + memcmp(&forwardName[i], " + ", 3) == 0) { + tokens.push_back(curToken); + curToken.clear(); + i += 2; + } else if (forwardName[i] == '\'') { + inString = true; + curToken += forwardName[i]; + } else { + curToken += forwardName[i]; + } + } + if (!curToken.empty()) { + tokens.push_back(curToken); + } for (size_t i = tokens.size(); i > 0;) { i--; if (!name.empty()) { @@ -7841,7 +7866,11 @@ createPropertiesForInverse(const CoordinateOperation *op, bool derivedFrom, } } else if (!sourceCRS || !targetCRS || forwardName != buildOpName(opType, sourceCRS, targetCRS)) { - name = INVERSE_OF + forwardName; + if (forwardName.find(" + ") != std::string::npos) { + name = INVERSE_OF + '\'' + forwardName + '\''; + } else { + name = INVERSE_OF + forwardName; + } } } if (name.empty() && sourceCRS && targetCRS) { |
