aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-07-20 11:16:10 +0200
committergithub-actions[bot] <github-actions[bot]@users.noreply.github.com>2021-07-20 09:16:36 +0000
commit3126383bebf1f2a16bffda30680c79333d5bb9cc (patch)
tree318a8d919add94a09436a87b8c9509d26151f33c
parentff2d8357be7a2cf7d845aabca9f1141136c349be (diff)
downloadPROJ-3126383bebf1f2a16bffda30680c79333d5bb9cc.tar.gz
PROJ-3126383bebf1f2a16bffda30680c79333d5bb9cc.zip
Merge pull request #2782 from rouault/fix_crs_extent_use_none
createOperations(): fix SourceTargetCRSExtentUse::NONE mode
-rw-r--r--src/iso19111/operation/coordinateoperationfactory.cpp6
-rwxr-xr-xtest/cli/testprojinfo4
-rw-r--r--test/cli/testprojinfo_out.dist5
-rw-r--r--test/unit/test_operationfactory.cpp41
4 files changed, 56 insertions, 0 deletions
diff --git a/src/iso19111/operation/coordinateoperationfactory.cpp b/src/iso19111/operation/coordinateoperationfactory.cpp
index e04cdb8d..d63db19e 100644
--- a/src/iso19111/operation/coordinateoperationfactory.cpp
+++ b/src/iso19111/operation/coordinateoperationfactory.cpp
@@ -5346,6 +5346,12 @@ CoordinateOperationFactory::createOperations(
metadata::ExtentPtr targetCRSExtent;
auto l_resolvedTargetCRS =
crs::CRS::getResolvedCRS(l_targetCRS, authFactory, targetCRSExtent);
+ if (context->getSourceAndTargetCRSExtentUse() ==
+ CoordinateOperationContext::SourceTargetCRSExtentUse::NONE) {
+ // Make sure *not* to use CRS extent if requested to ignore it
+ sourceCRSExtent.reset();
+ targetCRSExtent.reset();
+ }
Private::Context contextPrivate(sourceCRSExtent, targetCRSExtent, context);
if (context->getSourceAndTargetCRSExtentUse() ==
diff --git a/test/cli/testprojinfo b/test/cli/testprojinfo
index a9bbfa37..3081966b 100755
--- a/test/cli/testprojinfo
+++ b/test/cli/testprojinfo
@@ -78,6 +78,10 @@ echo "Testing projinfo -s EPSG:4230 -t EPSG:4258 --bbox 8,54.51,15.24,57.8 --sum
$EXE -s EPSG:4230 -t EPSG:4258 --bbox 8,54.51,15.24,57.8 --summary >>${OUT}
echo "" >>${OUT}
+echo "Testing projinfo -s EPSG:23031 -t EPSG:4326 --bbox -13.87,34.91,-7.24,41.88 --crs-extent-use none --summary" >> ${OUT}
+$EXE -s EPSG:23031 -t EPSG:4326 --bbox -13.87,34.91,-7.24,41.88 --crs-extent-use none --summary >>${OUT}
+echo "" >>${OUT}
+
echo "Testing projinfo -s EPSG:4230 -t EPSG:4258 --area EPSG:3237 --summary" >> ${OUT}
$EXE -s EPSG:4230 -t EPSG:4258 --area EPSG:3237 --summary >>${OUT}
echo "" >>${OUT}
diff --git a/test/cli/testprojinfo_out.dist b/test/cli/testprojinfo_out.dist
index 9f2fb22b..6c3a37c4 100644
--- a/test/cli/testprojinfo_out.dist
+++ b/test/cli/testprojinfo_out.dist
@@ -904,6 +904,11 @@ Candidate operations found: 1
Note: using '--spatial-test intersects' would bring more results (2)
EPSG:1626, ED50 to ETRS89 (4), 1.0 m, Denmark - onshore.
+Testing projinfo -s EPSG:23031 -t EPSG:4326 --bbox -13.87,34.91,-7.24,41.88 --crs-extent-use none --summary
+Candidate operations found: 1
+Note: using '--spatial-test intersects' would bring more results (9)
+unknown id, Inverse of UTM zone 31N + ED50 to WGS 84 (42), 5 m, Portugal - mainland - offshore.
+
Testing projinfo -s EPSG:4230 -t EPSG:4258 --area EPSG:3237 --summary
Candidate operations found: 1
Note: using '--spatial-test intersects' would bring more results (2)
diff --git a/test/unit/test_operationfactory.cpp b/test/unit/test_operationfactory.cpp
index 8c79e308..47c6636c 100644
--- a/test/unit/test_operationfactory.cpp
+++ b/test/unit/test_operationfactory.cpp
@@ -2123,6 +2123,47 @@ TEST(
// ---------------------------------------------------------------------------
+TEST(operation, projCRS_to_geogCRS_crs_extent_use_none) {
+ auto authFactory =
+ AuthorityFactory::create(DatabaseContext::create(), "EPSG");
+ {
+ auto ctxt =
+ CoordinateOperationContext::create(authFactory, nullptr, 0.0);
+ auto list = CoordinateOperationFactory::create()->createOperations(
+ authFactory->createCoordinateReferenceSystem("23031"), // ED50 UTM31
+ authFactory->createCoordinateReferenceSystem("4326"), ctxt);
+ bool found_EPSG_15964 = false;
+ for (const auto &op : list) {
+ if (op->nameStr().find("ED50 to WGS 84 (42)") !=
+ std::string::npos) {
+ found_EPSG_15964 = true;
+ }
+ }
+ // not expected since doesn't intersect EPSG:23031 area of use
+ EXPECT_FALSE(found_EPSG_15964);
+ }
+ {
+ auto ctxt =
+ CoordinateOperationContext::create(authFactory, nullptr, 0.0);
+ // Ignore source and target CRS extent
+ ctxt->setSourceAndTargetCRSExtentUse(
+ CoordinateOperationContext::SourceTargetCRSExtentUse::NONE);
+ auto list = CoordinateOperationFactory::create()->createOperations(
+ authFactory->createCoordinateReferenceSystem("23031"), // ED50 UTM31
+ authFactory->createCoordinateReferenceSystem("4326"), ctxt);
+ bool found_EPSG_15964 = false;
+ for (const auto &op : list) {
+ if (op->nameStr().find("ED50 to WGS 84 (42)") !=
+ std::string::npos) {
+ found_EPSG_15964 = true;
+ }
+ }
+ EXPECT_TRUE(found_EPSG_15964);
+ }
+}
+
+// ---------------------------------------------------------------------------
+
TEST(operation, projCRS_to_projCRS_north_pole_inverted_axis) {
auto authFactory =