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 | |
| 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
| -rw-r--r-- | src/iso19111/coordinateoperation.cpp | 37 | ||||
| -rw-r--r-- | test/unit/test_operation.cpp | 41 |
2 files changed, 74 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) { diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index 676ed8d7..630492e6 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -4927,6 +4927,9 @@ TEST(operation, geog3DCRS_to_geog2DCRS_plus_vertCRS_context) { "+grids=sk_gku_Slovakia_ETRS89h_to_Baltic1957.tif +multiplier=1 " "+step +proj=unitconvert +xy_in=rad +xy_out=deg " "+step +proj=axisswap +order=2,1"); + + EXPECT_EQ(list[0]->inverse()->nameStr(), + "Inverse of 'ETRS89 to ETRS89 + Baltic 1957 height (1)'"); } } @@ -8171,6 +8174,44 @@ TEST(operation, compoundCRS_to_compoundCRS_WGS84_EGM96_to_WGS84_Belfast) { // --------------------------------------------------------------------------- +TEST( + operation, + compoundCRS_to_compoundCRS_concatenated_operation_with_two_vert_transformation) { + auto authFactory = + AuthorityFactory::create(DatabaseContext::create(), "EPSG"); + { + auto ctxt = + CoordinateOperationContext::create(authFactory, nullptr, 0.0); + ctxt->setSpatialCriterion( + CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION); + auto list = CoordinateOperationFactory::create()->createOperations( + // ETRS89 + Baltic 1957 height + authFactory->createCoordinateReferenceSystem("8360"), + // ETRS89 + EVRF2007 height + authFactory->createCoordinateReferenceSystem("7423"), ctxt); + ASSERT_GE(list.size(), 1U); + EXPECT_EQ( + list[0]->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline " + "+step +proj=axisswap +order=2,1 " + "+step +proj=unitconvert +xy_in=deg +xy_out=rad " + "+step +proj=vgridshift " + "+grids=sk_gku_Slovakia_ETRS89h_to_Baltic1957.tif +multiplier=1 " + "+step +inv +proj=vgridshift " + "+grids=sk_gku_Slovakia_ETRS89h_to_EVRF2007.tif +multiplier=1 " + "+step +proj=unitconvert +xy_in=rad +xy_out=deg " + "+step +proj=axisswap +order=2,1"); + EXPECT_EQ( + list[0]->nameStr(), + "ETRS89 + Baltic 1957 height to ETRS89 + EVRF2007 height (1)"); + EXPECT_EQ(list[0]->inverse()->nameStr(), "Inverse of 'ETRS89 + Baltic " + "1957 height to ETRS89 + " + "EVRF2007 height (1)'"); + } +} + +// --------------------------------------------------------------------------- + TEST(operation, vertCRS_to_vertCRS) { auto vertcrs_m_obj = PROJStringParser().createFromPROJString("+vunits=m"); |
