diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-02-17 19:40:38 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-02-17 19:42:35 +0100 |
| commit | e8b2e2a36324006146406fb1fc89ce6ed863807f (patch) | |
| tree | 5c2c0c9229958d63e77171f64f909864855afb5d /test/unit | |
| parent | a8cbe0c66974871f5a7bd7ef94001ebf461ac7ea (diff) | |
| download | PROJ-e8b2e2a36324006146406fb1fc89ce6ed863807f.tar.gz PROJ-e8b2e2a36324006146406fb1fc89ce6ed863807f.zip | |
Modify the default strategy of researching intermediate CRS to do it only if there is no direct transformation
Diffstat (limited to 'test/unit')
| -rw-r--r-- | test/unit/test_c_api.cpp | 4 | ||||
| -rw-r--r-- | test/unit/test_crs.cpp | 66 | ||||
| -rw-r--r-- | test/unit/test_factory.cpp | 3 | ||||
| -rw-r--r-- | test/unit/test_operation.cpp | 14 |
4 files changed, 62 insertions, 25 deletions
diff --git a/test/unit/test_c_api.cpp b/test/unit/test_c_api.cpp index 273a04e6..6205a9b8 100644 --- a/test/unit/test_c_api.cpp +++ b/test/unit/test_c_api.cpp @@ -1389,7 +1389,7 @@ TEST_F(CApi, proj_create_operations_with_pivot) { ASSERT_NE(ctxt, nullptr); ContextKeeper keeper_ctxt(ctxt); proj_operation_factory_context_set_allow_use_intermediate_crs( - m_ctxt, ctxt, false); + m_ctxt, ctxt, PROJ_INTERMEDIATE_CRS_USE_NEVER); auto res = proj_create_operations(m_ctxt, source_crs, target_crs, ctxt); ASSERT_NE(res, nullptr); @@ -1444,6 +1444,8 @@ TEST_F(CApi, proj_create_operations_with_pivot) { m_ctxt, ctxt, PROJ_SPATIAL_CRITERION_PARTIAL_INTERSECTION); proj_operation_factory_context_set_grid_availability_use( m_ctxt, ctxt, PROJ_GRID_AVAILABILITY_IGNORED); + proj_operation_factory_context_set_allow_use_intermediate_crs( + m_ctxt, ctxt, PROJ_INTERMEDIATE_CRS_USE_ALWAYS); auto res = proj_create_operations(m_ctxt, source_crs, target_crs, ctxt); ASSERT_NE(res, nullptr); diff --git a/test/unit/test_crs.cpp b/test/unit/test_crs.cpp index 26bcf621..4953529c 100644 --- a/test/unit/test_crs.cpp +++ b/test/unit/test_crs.cpp @@ -3436,8 +3436,12 @@ TEST(crs, boundCRS_crs_link) { EXPECT_TRUE(baseCRS->isEquivalentTo(GeographicCRS::EPSG_4267.get())); EXPECT_TRUE(baseCRS->canonicalBoundCRS() != nullptr); - EXPECT_TRUE(baseCRS->createBoundCRSToWGS84IfPossible(nullptr, false) - ->isEquivalentTo(baseCRS->canonicalBoundCRS().get())); + EXPECT_TRUE( + baseCRS + ->createBoundCRSToWGS84IfPossible( + nullptr, + CoordinateOperationContext::IntermediateCRSUse::NEVER) + ->isEquivalentTo(baseCRS->canonicalBoundCRS().get())); } { @@ -4725,27 +4729,35 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) { auto factory = AuthorityFactory::create(dbContext, "EPSG"); { auto crs_4326 = factory->createCoordinateReferenceSystem("4326"); - EXPECT_EQ(crs_4326->createBoundCRSToWGS84IfPossible(dbContext, false), + EXPECT_EQ(crs_4326->createBoundCRSToWGS84IfPossible( + dbContext, + CoordinateOperationContext::IntermediateCRSUse::NEVER), crs_4326); } { auto crs_32631 = factory->createCoordinateReferenceSystem("32631"); - EXPECT_EQ(crs_32631->createBoundCRSToWGS84IfPossible(dbContext, false), + EXPECT_EQ(crs_32631->createBoundCRSToWGS84IfPossible( + dbContext, + CoordinateOperationContext::IntermediateCRSUse::NEVER), crs_32631); } { // Pulkovo 42 East Germany auto crs_5670 = factory->createCoordinateReferenceSystem("5670"); - EXPECT_EQ(crs_5670->createBoundCRSToWGS84IfPossible(dbContext, false), + EXPECT_EQ(crs_5670->createBoundCRSToWGS84IfPossible( + dbContext, + CoordinateOperationContext::IntermediateCRSUse::NEVER), crs_5670); } { // Pulkovo 42 Romania auto crs_3844 = factory->createCoordinateReferenceSystem("3844"); - auto bound = - crs_3844->createBoundCRSToWGS84IfPossible(dbContext, false); + auto bound = crs_3844->createBoundCRSToWGS84IfPossible( + dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER); EXPECT_NE(bound, crs_3844); - EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible(dbContext, false), + EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible( + dbContext, + CoordinateOperationContext::IntermediateCRSUse::NEVER), bound); auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(bound); ASSERT_TRUE(boundCRS != nullptr); @@ -4759,10 +4771,12 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) { { // Pulkovo 42 Poland auto crs_2171 = factory->createCoordinateReferenceSystem("2171"); - auto bound = - crs_2171->createBoundCRSToWGS84IfPossible(dbContext, false); + auto bound = crs_2171->createBoundCRSToWGS84IfPossible( + dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER); EXPECT_NE(bound, crs_2171); - EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible(dbContext, false), + EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible( + dbContext, + CoordinateOperationContext::IntermediateCRSUse::NEVER), bound); auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(bound); ASSERT_TRUE(boundCRS != nullptr); @@ -4776,10 +4790,12 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) { { // NTF (Paris) auto crs_4807 = factory->createCoordinateReferenceSystem("4807"); - auto bound = - crs_4807->createBoundCRSToWGS84IfPossible(dbContext, false); + auto bound = crs_4807->createBoundCRSToWGS84IfPossible( + dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER); EXPECT_NE(bound, crs_4807); - EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible(dbContext, false), + EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible( + dbContext, + CoordinateOperationContext::IntermediateCRSUse::NEVER), bound); auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(bound); ASSERT_TRUE(boundCRS != nullptr); @@ -4791,10 +4807,12 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) { { // NTF (Paris) / Lambert zone II + NGF-IGN69 height auto crs_7421 = factory->createCoordinateReferenceSystem("7421"); - auto bound = - crs_7421->createBoundCRSToWGS84IfPossible(dbContext, false); + auto bound = crs_7421->createBoundCRSToWGS84IfPossible( + dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER); EXPECT_NE(bound, crs_7421); - EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible(dbContext, false), + EXPECT_EQ(bound->createBoundCRSToWGS84IfPossible( + dbContext, + CoordinateOperationContext::IntermediateCRSUse::NEVER), bound); auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(bound); ASSERT_TRUE(boundCRS != nullptr); @@ -4807,13 +4825,17 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) { } { auto crs = createVerticalCRS(); - EXPECT_EQ(crs->createBoundCRSToWGS84IfPossible(dbContext, false), crs); + EXPECT_EQ(crs->createBoundCRSToWGS84IfPossible( + dbContext, + CoordinateOperationContext::IntermediateCRSUse::NEVER), + crs); } { auto factoryIGNF = AuthorityFactory::create(DatabaseContext::create(), "IGNF"); auto crs = factoryIGNF->createCoordinateReferenceSystem("TERA50STEREO"); - auto bound = crs->createBoundCRSToWGS84IfPossible(dbContext, false); + auto bound = crs->createBoundCRSToWGS84IfPossible( + dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER); EXPECT_NE(bound, crs); auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(bound); ASSERT_TRUE(boundCRS != nullptr); @@ -4827,7 +4849,8 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) { auto factoryIGNF = AuthorityFactory::create(DatabaseContext::create(), "IGNF"); auto crs = factoryIGNF->createCoordinateReferenceSystem("PGP50"); - auto bound = crs->createBoundCRSToWGS84IfPossible(dbContext, false); + auto bound = crs->createBoundCRSToWGS84IfPossible( + dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER); EXPECT_NE(bound, crs); auto boundCRS = nn_dynamic_pointer_cast<BoundCRS>(bound); ASSERT_TRUE(boundCRS != nullptr); @@ -4838,7 +4861,8 @@ TEST(crs, crs_createBoundCRSToWGS84IfPossible) { } { auto crs = factory->createCoordinateReferenceSystem("4269"); // NAD83 - auto bound = crs->createBoundCRSToWGS84IfPossible(dbContext, false); + auto bound = crs->createBoundCRSToWGS84IfPossible( + dbContext, CoordinateOperationContext::IntermediateCRSUse::NEVER); EXPECT_EQ(bound, crs); } } diff --git a/test/unit/test_factory.cpp b/test/unit/test_factory.cpp index 40728f96..ec59dcbc 100644 --- a/test/unit/test_factory.cpp +++ b/test/unit/test_factory.cpp @@ -1612,7 +1612,8 @@ class FactoryWithTmpDatabase : public ::testing::Test { { auto ctxt = CoordinateOperationContext::create(factory, nullptr, 0); - ctxt->setAllowUseIntermediateCRS(false); + ctxt->setAllowUseIntermediateCRS( + CoordinateOperationContext::IntermediateCRSUse::NEVER); res = CoordinateOperationFactory::create()->createOperations( srcCRS, targetCRS, ctxt); EXPECT_EQ(res.size(), 1U); diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index 103b856c..c7f9cb7d 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -4181,7 +4181,8 @@ TEST(operation, geogCRS_to_geogCRS_context_default) { auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0); ctxt->setSpatialCriterion( CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION); - ctxt->setAllowUseIntermediateCRS(false); + ctxt->setAllowUseIntermediateCRS( + CoordinateOperationContext::IntermediateCRSUse::NEVER); // Directly found in database { @@ -4237,7 +4238,8 @@ TEST(operation, geogCRS_to_geogCRS_context_match_by_name) { auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0); ctxt->setSpatialCriterion( CoordinateOperationContext::SpatialCriterion::PARTIAL_INTERSECTION); - ctxt->setAllowUseIntermediateCRS(false); + ctxt->setAllowUseIntermediateCRS( + CoordinateOperationContext::IntermediateCRSUse::NEVER); auto NAD27 = GeographicCRS::create( PropertyMap().set(IdentifiedObject::NAME_KEY, GeographicCRS::EPSG_4267->nameStr()), @@ -4577,6 +4579,8 @@ TEST(operation, geogCRS_to_geogCRS_context_concatenated_operation) { auto authFactory = AuthorityFactory::create(DatabaseContext::create(), "EPSG"); auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0); + ctxt->setAllowUseIntermediateCRS( + CoordinateOperationContext::IntermediateCRSUse::ALWAYS); auto list = CoordinateOperationFactory::create()->createOperations( authFactory->createCoordinateReferenceSystem("4807"), // NTF(Paris) authFactory->createCoordinateReferenceSystem("4171"), // RGF93 @@ -4640,6 +4644,8 @@ TEST(operation, geogCRS_to_geogCRS_CH1903_to_CH1903plus_context) { auto authFactory = AuthorityFactory::create(DatabaseContext::create(), "EPSG"); auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0); + ctxt->setAllowUseIntermediateCRS( + CoordinateOperationContext::IntermediateCRSUse::ALWAYS); auto list = CoordinateOperationFactory::create()->createOperations( authFactory->createCoordinateReferenceSystem("4149"), // CH1903 authFactory->createCoordinateReferenceSystem("4150"), // CH1903+ @@ -5113,6 +5119,8 @@ TEST(operation, auto authFactory = AuthorityFactory::create(DatabaseContext::create(), "EPSG"); auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0); + ctxt->setAllowUseIntermediateCRS( + CoordinateOperationContext::IntermediateCRSUse::ALWAYS); auto list = CoordinateOperationFactory::create()->createOperations( authFactory->createCoordinateReferenceSystem("4807"), // NTF(Paris) authFactory->createCoordinateReferenceSystem("32631"), // UTM31 WGS84 @@ -6191,6 +6199,8 @@ TEST(operation, IGNF_LAMB1_TO_EPSG_4326) { auto authFactory = AuthorityFactory::create(DatabaseContext::create(), std::string()); auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0); + ctxt->setAllowUseIntermediateCRS( + CoordinateOperationContext::IntermediateCRSUse::ALWAYS); auto list = CoordinateOperationFactory::create()->createOperations( AuthorityFactory::create(DatabaseContext::create(), "IGNF") ->createCoordinateReferenceSystem("LAMB1"), |
