Skip to content

Commit

Permalink
Coord. operation factory: count identified concatenated operations as…
Browse files Browse the repository at this point in the history
… a single step
  • Loading branch information
rouault committed Mar 22, 2023
1 parent c0a3b1d commit 1e39be3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/iso19111/operation/coordinateoperationfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,12 @@ struct FilterResults {
const auto curAccuracy = getAccuracy(op);
bool dummy = false;
const auto curExtent = getExtent(op, true, dummy);
const auto curStepCount = getTransformationStepCount(op);
// If a concatenated operation has an identifier, consider it as
// a single step (to be opposed to synthetized concatenated
// operations). Helps for example to get EPSG:8537,
// "Egypt 1907 to WGS 84 (2)"
const auto curStepCount =
op->identifiers().empty() ? getTransformationStepCount(op) : 1;

if (first) {
resTemp.emplace_back(op);
Expand Down
20 changes: 19 additions & 1 deletion test/unit/test_operationfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ TEST(operation, geogCRS_to_geogCRS_context_concatenated_operation) {
authFactory->createCoordinateReferenceSystem("4807"), // NTF(Paris)
authFactory->createCoordinateReferenceSystem("4171"), // RGF93
ctxt);
ASSERT_EQ(list.size(), 4U);
ASSERT_EQ(list.size(), 2U);

EXPECT_EQ(list[0]->nameStr(), "NTF (Paris) to RGF93 v1 (1)");
EXPECT_EQ(list[0]->exportToPROJString(PROJStringFormatter::create().get()),
Expand Down Expand Up @@ -1092,6 +1092,24 @@ TEST(operation, geogCRS_to_geogCRS_context_concatenated_operation) {

// ---------------------------------------------------------------------------

TEST(operation,
geogCRS_to_geogCRS_context_concatenated_operation_Egypt1907_to_WGS84) {
auto authFactory =
AuthorityFactory::create(DatabaseContext::create(), "EPSG");
auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0);
auto list = CoordinateOperationFactory::create()->createOperations(
authFactory->createCoordinateReferenceSystem("4229"), // Egypt 1907
authFactory->createCoordinateReferenceSystem("4326"), // WGS84
ctxt);
ASSERT_EQ(list.size(), 3U);
// Concatenated operation
EXPECT_EQ(list[1]->nameStr(), "Egypt 1907 to WGS 84 (2)");
ASSERT_EQ(list[1]->coordinateOperationAccuracies().size(), 1U);
EXPECT_EQ(list[1]->coordinateOperationAccuracies()[0]->value(), "6.0");
}

// ---------------------------------------------------------------------------

TEST(operation, geogCRS_to_geogCRS_context_ED50_to_WGS72_no_NTF_intermediate) {
auto authFactory =
AuthorityFactory::create(DatabaseContext::create(), "EPSG");
Expand Down

0 comments on commit 1e39be3

Please sign in to comment.