aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-04-14 23:58:51 +0200
committerEven Rouault <even.rouault@spatialys.com>2020-04-14 23:58:51 +0200
commit1409b0031709598204d5d81cf9eb7d433545025d (patch)
tree713a259d2a1694103c565098870c60ee9980f08a /src
parent767a9976587491f3a90b744376f8d5601c803e4b (diff)
downloadPROJ-1409b0031709598204d5d81cf9eb7d433545025d.tar.gz
PROJ-1409b0031709598204d5d81cf9eb7d433545025d.zip
createOperations(): do not remove ballpark transformation if there are only grid based operations, even if they cover the whole area of use (fixes #2143)
Diffstat (limited to 'src')
-rw-r--r--src/iso19111/coordinateoperation.cpp55
1 files changed, 41 insertions, 14 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp
index 822d09ac..8c47050d 100644
--- a/src/iso19111/coordinateoperation.cpp
+++ b/src/iso19111/coordinateoperation.cpp
@@ -10464,6 +10464,7 @@ struct CoordinateOperationContext::Private {
std::vector<std::pair<std::string, std::string>>
intermediateCRSAuthCodes_{};
bool discardSuperseded_ = true;
+ bool allowBallpark_ = true;
};
//! @endcond
@@ -10518,6 +10519,20 @@ void CoordinateOperationContext::setDesiredAccuracy(double accuracy) {
// ---------------------------------------------------------------------------
+/** \brief Return whether ballpark transformations are allowed */
+bool CoordinateOperationContext::getAllowBallparkTransformations() const {
+ return d->allowBallpark_;
+}
+
+// ---------------------------------------------------------------------------
+
+/** \brief Set whether ballpark transformations are allowed */
+void CoordinateOperationContext::setAllowBallparkTransformations(bool allow) {
+ d->allowBallpark_ = allow;
+}
+
+// ---------------------------------------------------------------------------
+
/** \brief Set how source and target CRS extent should be used
* when considering if a transformation can be used (only takes effect if
* no area of interest is explicitly defined).
@@ -11187,7 +11202,7 @@ struct FilterResults {
const CoordinateOperationContext::SourceTargetCRSExtentUse
sourceAndTargetCRSExtentUse;
- bool hasOpThatContainsAreaOfInterest = false;
+ bool hasOpThatContainsAreaOfInterestAndNoGrid = false;
std::vector<CoordinateOperationNNPtr> res{};
// ----------------------------------------------------------------------
@@ -11233,6 +11248,7 @@ struct FilterResults {
STRICT_CONTAINMENT
: context->getSpatialCriterion();
bool hasFoundOpWithExtent = false;
+ const bool allowBallpark = context->getAllowBallparkTransformations();
for (const auto &op : sourceList) {
if (desiredAccuracy != 0) {
const double accuracy = getAccuracy(op);
@@ -11240,6 +11256,9 @@ struct FilterResults {
continue;
}
}
+ if (!allowBallpark && op->hasBallparkTransformation()) {
+ continue;
+ }
if (areaOfInterest) {
bool emptyIntersection = false;
auto extent = getExtent(op, true, emptyIntersection);
@@ -11248,9 +11267,11 @@ struct FilterResults {
hasFoundOpWithExtent = true;
bool extentContains =
extent->contains(NN_NO_CHECK(areaOfInterest));
- if (extentContains) {
- if (!op->hasBallparkTransformation()) {
- hasOpThatContainsAreaOfInterest = true;
+ if (!hasOpThatContainsAreaOfInterestAndNoGrid &&
+ extentContains) {
+ if (!op->hasBallparkTransformation() &&
+ op->gridsNeeded(nullptr, true).empty()) {
+ hasOpThatContainsAreaOfInterestAndNoGrid = true;
}
}
if (spatialCriterion ==
@@ -11277,9 +11298,11 @@ struct FilterResults {
!extent1 || extent->contains(NN_NO_CHECK(extent1));
bool extentContainsExtent2 =
!extent2 || extent->contains(NN_NO_CHECK(extent2));
- if (extentContainsExtent1 && extentContainsExtent2) {
- if (!op->hasBallparkTransformation()) {
- hasOpThatContainsAreaOfInterest = true;
+ if (!hasOpThatContainsAreaOfInterestAndNoGrid &&
+ extentContainsExtent1 && extentContainsExtent2) {
+ if (!op->hasBallparkTransformation() &&
+ op->gridsNeeded(nullptr, true).empty()) {
+ hasOpThatContainsAreaOfInterestAndNoGrid = true;
}
}
if (spatialCriterion ==
@@ -11313,6 +11336,9 @@ struct FilterResults {
continue;
}
}
+ if (!allowBallpark && op->hasBallparkTransformation()) {
+ continue;
+ }
res.emplace_back(op);
}
}
@@ -11446,12 +11472,13 @@ struct FilterResults {
// If we have more than one result, and than the last result is the
// default "Ballpark geographic offset" or "Ballpark geocentric
- // translation"
- // operations we have synthetized, and that at least one operation
- // has the desired area of interest, remove it as
- // all previous results are necessarily better
- if (hasOpThatContainsAreaOfInterest && res.size() > 1) {
- const std::string &name = res.back()->nameStr();
+ // translation" operations we have synthetized, and that at least one
+ // operation has the desired area of interest and does not require the
+ // use of grids, remove it as all previous results are necessarily
+ // better
+ if (hasOpThatContainsAreaOfInterestAndNoGrid && res.size() > 1) {
+ const auto &opLast = res.back();
+ const std::string &name = opLast->nameStr();
if (name.find(BALLPARK_GEOGRAPHIC_OFFSET) != std::string::npos ||
name.find(NULL_GEOGRAPHIC_OFFSET) != std::string::npos ||
name.find(NULL_GEOCENTRIC_TRANSLATION) != std::string::npos ||
@@ -14772,7 +14799,7 @@ void CoordinateOperationFactory::Private::createOperationsCompoundToCompound(
}
}
- // If we didn't find a non-ballbark transformation between
+ // If we didn't find a non-ballpark transformation between
// the 2 vertical CRS, then try through intermediate geographic CRS
// For example
// WGS 84 + EGM96 --> ETRS89 + Belfast height where