aboutsummaryrefslogtreecommitdiff
path: root/src/iso19111/crs.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-09-18 13:31:36 +0200
committerGitHub <noreply@github.com>2020-09-18 13:31:36 +0200
commit81aaa47b4e1f7799ad59f07d738823184f20a9cf (patch)
tree448fb1ab3c3152224450b6a07f723ba14623b727 /src/iso19111/crs.cpp
parent1e11bf646d2cf9b731b02f2260c68fe2a5a21cf4 (diff)
parent75074ce863e36299ec39b39decdd435eed15ad63 (diff)
downloadPROJ-81aaa47b4e1f7799ad59f07d738823184f20a9cf.tar.gz
PROJ-81aaa47b4e1f7799ad59f07d738823184f20a9cf.zip
Merge pull request #2357 from rouault/fix_2356
Adjust createBoundCRSToWGS84IfPossible() and operation filtering (for POSGAR 2007 to WGS84 issues) (fixes #2356)
Diffstat (limited to 'src/iso19111/crs.cpp')
-rw-r--r--src/iso19111/crs.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/iso19111/crs.cpp b/src/iso19111/crs.cpp
index 88420c8a..e96b3cc9 100644
--- a/src/iso19111/crs.cpp
+++ b/src/iso19111/crs.cpp
@@ -378,7 +378,8 @@ VerticalCRSPtr CRS::extractVerticalCRS() const {
* a +towgs84 parameter or a WKT1:GDAL string with a TOWGS node.
*
* This method will fetch the GeographicCRS of this CRS and find a
- * transformation to EPSG:4326 using the domain of the validity of the main CRS.
+ * transformation to EPSG:4326 using the domain of the validity of the main CRS,
+ * and there's only one Helmert transformation.
*
* @return a CRS.
*/
@@ -456,6 +457,7 @@ CRSNNPtr CRS::createBoundCRSToWGS84IfPossible(
auto list =
operation::CoordinateOperationFactory::create()
->createOperations(NN_NO_CHECK(geodCRS), hubCRS, ctxt);
+ CRSPtr candidateBoundCRS;
for (const auto &op : list) {
auto transf =
util::nn_dynamic_pointer_cast<operation::Transformation>(
@@ -466,8 +468,13 @@ CRSNNPtr CRS::createBoundCRSToWGS84IfPossible(
} catch (const std::exception &) {
continue;
}
- return util::nn_static_pointer_cast<CRS>(BoundCRS::create(
- thisAsCRS, hubCRS, NN_NO_CHECK(transf)));
+ if (candidateBoundCRS) {
+ candidateBoundCRS = nullptr;
+ break;
+ }
+ candidateBoundCRS =
+ BoundCRS::create(thisAsCRS, hubCRS, NN_NO_CHECK(transf))
+ .as_nullable();
} else {
auto concatenated =
dynamic_cast<const operation::ConcatenatedOperation *>(
@@ -499,15 +506,23 @@ CRSNNPtr CRS::createBoundCRSToWGS84IfPossible(
} catch (const std::exception &) {
continue;
}
- return util::nn_static_pointer_cast<CRS>(
+ if (candidateBoundCRS) {
+ candidateBoundCRS = nullptr;
+ break;
+ }
+ candidateBoundCRS =
BoundCRS::create(thisAsCRS, hubCRS,
- NN_NO_CHECK(transf)));
+ NN_NO_CHECK(transf))
+ .as_nullable();
}
}
}
}
}
}
+ if (candidateBoundCRS) {
+ return NN_NO_CHECK(candidateBoundCRS);
+ }
} catch (const std::exception &) {
}
}