diff options
| -rw-r--r-- | src/iso19111/coordinateoperation.cpp | 21 | ||||
| -rw-r--r-- | test/unit/test_operation.cpp | 19 |
2 files changed, 38 insertions, 2 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp index b0d26cc0..6a3062c5 100644 --- a/src/iso19111/coordinateoperation.cpp +++ b/src/iso19111/coordinateoperation.cpp @@ -9595,7 +9595,7 @@ struct FilterResults { sourceAndTargetCRSExtentUse( context->getSourceAndTargetCRSExtentUse()) { - computeAreaOfIntest(); + computeAreaOfInterest(); filterOut(forceStrictContainmentTest); } @@ -9634,7 +9634,7 @@ struct FilterResults { std::vector<CoordinateOperationNNPtr> res{}; // ---------------------------------------------------------------------- - void computeAreaOfIntest() { + void computeAreaOfInterest() { // Compute an area of interest from the CRS extent if the user did // not specify one @@ -9676,6 +9676,7 @@ struct FilterResults { ? CoordinateOperationContext::SpatialCriterion:: STRICT_CONTAINMENT : context->getSpatialCriterion(); + bool hasFoundOpWithExtent = false; for (const auto &op : sourceList) { if (desiredAccuracy != 0) { const double accuracy = getAccuracy(op); @@ -9688,6 +9689,7 @@ struct FilterResults { auto extent = getExtent(op, true, emptyIntersection); if (!extent) continue; + hasFoundOpWithExtent = true; bool extentContains = extent->contains(NN_NO_CHECK(areaOfInterest)); if (extentContains) { @@ -9712,6 +9714,7 @@ struct FilterResults { auto extent = getExtent(op, true, emptyIntersection); if (!extent) continue; + hasFoundOpWithExtent = true; bool extentContainsSource = !sourceCRSExtent || extent->contains(NN_NO_CHECK(sourceCRSExtent)); @@ -9743,6 +9746,20 @@ struct FilterResults { } res.emplace_back(op); } + + // In case no operation has an extent and no result is found, + // retain all initial operations that match accuracy criterion. + if (res.empty() && !hasFoundOpWithExtent) { + for (const auto &op : sourceList) { + if (desiredAccuracy != 0) { + const double accuracy = getAccuracy(op); + if (accuracy < 0 || accuracy > desiredAccuracy) { + continue; + } + } + res.emplace_back(op); + } + } } // ---------------------------------------------------------------------- diff --git a/test/unit/test_operation.cpp b/test/unit/test_operation.cpp index a26574fb..71ef666c 100644 --- a/test/unit/test_operation.cpp +++ b/test/unit/test_operation.cpp @@ -5340,6 +5340,25 @@ TEST(operation, boundCRS_of_geogCRS_to_geogCRS) { // --------------------------------------------------------------------------- +TEST(operation, boundCRS_of_geogCRS_to_geogCRS_with_area) { + auto boundCRS = BoundCRS::createFromTOWGS84( + GeographicCRS::EPSG_4267, std::vector<double>{1, 2, 3, 4, 5, 6, 7}); + auto authFactory = + AuthorityFactory::create(DatabaseContext::create(), "EPSG"); + auto op = CoordinateOperationFactory::create()->createOperation( + boundCRS, authFactory->createCoordinateReferenceSystem("4326")); + ASSERT_TRUE(op != nullptr); + EXPECT_EQ(op->exportToPROJString(PROJStringFormatter::create().get()), + "+proj=pipeline +step +proj=axisswap +order=2,1 +step " + "+proj=unitconvert +xy_in=deg +xy_out=rad +step +proj=cart " + "+ellps=clrk66 +step +proj=helmert +x=1 +y=2 +z=3 +rx=4 +ry=5 " + "+rz=6 +s=7 +convention=position_vector +step +inv +proj=cart " + "+ellps=WGS84 +step +proj=unitconvert +xy_in=rad +xy_out=deg " + "+step +proj=axisswap +order=2,1"); +} + +// --------------------------------------------------------------------------- + TEST(operation, boundCRS_of_geogCRS_to_unrelated_geogCRS) { auto boundCRS = BoundCRS::createFromTOWGS84( GeographicCRS::EPSG_4807, std::vector<double>{1, 2, 3, 4, 5, 6, 7}); |
