From 9b2b96ef7a343831753679567893d85998e9c9ea Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Fri, 28 Dec 2018 22:58:59 +0100 Subject: Operation computation: better take into account when candidate operations have no declared extent --- src/iso19111/coordinateoperation.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/iso19111/coordinateoperation.cpp') 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 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); + } + } } // ---------------------------------------------------------------------- -- cgit v1.2.3