diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2019-04-30 14:56:32 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2019-04-30 14:56:32 +0200 |
| commit | b4a9e65cec051ca3cb16b8cccfa012d70ce10570 (patch) | |
| tree | 819b78cdd3d32143519c4c9315ec231ea9584cb1 | |
| parent | cca27b1fae234a90df42ff5341121759846dc39b (diff) | |
| download | PROJ-b4a9e65cec051ca3cb16b8cccfa012d70ce10570.tar.gz PROJ-b4a9e65cec051ca3cb16b8cccfa012d70ce10570.zip | |
createOperations(): in SourceTargetCRSExtentUse::INTERSECTION mode, early return if the intersection of the areas is empty
| -rw-r--r-- | src/iso19111/coordinateoperation.cpp | 11 | ||||
| -rw-r--r-- | test/unit/test_operation.cpp | 18 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp index 2cab05bd..ca882f49 100644 --- a/src/iso19111/coordinateoperation.cpp +++ b/src/iso19111/coordinateoperation.cpp @@ -12669,6 +12669,17 @@ CoordinateOperationFactory::createOperations( auto l_resolvedTargetCRS = getResolvedCRS(l_targetCRS, context); Private::Context contextPrivate(l_resolvedSourceCRS, l_resolvedTargetCRS, context); + + if (context->getSourceAndTargetCRSExtentUse() == + CoordinateOperationContext::SourceTargetCRSExtentUse::INTERSECTION) { + auto sourceCRSExtent(getExtent(l_resolvedSourceCRS)); + auto targetCRSExtent(getExtent(l_resolvedTargetCRS)); + if (sourceCRSExtent && targetCRSExtent && + !sourceCRSExtent->intersects(NN_NO_CHECK(targetCRSExtent))) { + return std::vector<CoordinateOperationNNPtr>(); + } + } + return filterAndSort(Private::createOperations(l_resolvedSourceCRS, l_resolvedTargetCRS, contextPrivate), diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index e1ced807..730cd270 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -5411,6 +5411,24 @@ TEST(operation, projCRS_to_projCRS_context_incompatible_areas_ballpark) { // --------------------------------------------------------------------------- +TEST( + operation, + projCRS_to_projCRS_context_incompatible_areas_crs_extent_use_intersection) { + auto authFactory = + AuthorityFactory::create(DatabaseContext::create(), "EPSG"); + auto ctxt = CoordinateOperationContext::create(authFactory, nullptr, 0.0); + ctxt->setSourceAndTargetCRSExtentUse( + CoordinateOperationContext::SourceTargetCRSExtentUse::INTERSECTION); + auto list = CoordinateOperationFactory::create()->createOperations( + authFactory->createCoordinateReferenceSystem("26711"), // UTM 11 NAD27 + authFactory->createCoordinateReferenceSystem( + "3034"), // ETRS89 / LCC Europe + ctxt); + ASSERT_GE(list.size(), 0U); +} + +// --------------------------------------------------------------------------- + TEST(operation, projCRS_to_projCRS_north_pole_inverted_axis) { auto authFactory = |
