aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-09-11 19:25:35 +0200
committerEven Rouault <even.rouault@spatialys.com>2019-09-11 19:25:35 +0200
commite22dbb571e6c721c1e3edb33735b6b51ade9f1dc (patch)
tree9713df3a7cfb370b3685d481c8fc46f303189d31 /src
parentbd39128c3e278331980adf02377e9347269cb820 (diff)
downloadPROJ-e22dbb571e6c721c1e3edb33735b6b51ade9f1dc.tar.gz
PROJ-e22dbb571e6c721c1e3edb33735b6b51ade9f1dc.zip
createOperations(): fix conversion from/to PROJ.4 CRS strings with non-ISO-cosher options and towgs84/nadgrids
This actually fixes a regression introduced in PROJ 6.2.0 per 78302efb70eb4b49610cda6a60bf9ce39b82264f that made a conversion like EPSG:4326 to "+proj=something +towgs84/+nadgrids +over +type=crs" apply the towgs84/nadgrids operation twice.
Diffstat (limited to 'src')
-rw-r--r--src/iso19111/coordinateoperation.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp
index 01707a90..e86f1850 100644
--- a/src/iso19111/coordinateoperation.cpp
+++ b/src/iso19111/coordinateoperation.cpp
@@ -12048,14 +12048,23 @@ CoordinateOperationFactory::Private::createOperations(
std::vector<CoordinateOperationNNPtr> res;
const bool allowEmptyIntersection = true;
- const auto &sourceProj4Ext = sourceCRS->getExtensionProj4();
- const auto &targetProj4Ext = targetCRS->getExtensionProj4();
+ auto boundSrc = dynamic_cast<const crs::BoundCRS *>(sourceCRS.get());
+ auto boundDst = dynamic_cast<const crs::BoundCRS *>(targetCRS.get());
+
+ const auto &sourceProj4Ext = boundSrc
+ ? boundSrc->baseCRS()->getExtensionProj4()
+ : sourceCRS->getExtensionProj4();
+ const auto &targetProj4Ext = boundDst
+ ? boundDst->baseCRS()->getExtensionProj4()
+ : targetCRS->getExtensionProj4();
if (!sourceProj4Ext.empty() || !targetProj4Ext.empty()) {
auto sourceProjExportable =
- dynamic_cast<io::IPROJStringExportable *>(sourceCRS.get());
+ dynamic_cast<const io::IPROJStringExportable *>(
+ boundSrc ? boundSrc : sourceCRS.get());
auto targetProjExportable =
- dynamic_cast<io::IPROJStringExportable *>(targetCRS.get());
+ dynamic_cast<const io::IPROJStringExportable *>(
+ boundDst ? boundDst : targetCRS.get());
if (!sourceProjExportable) {
throw InvalidOperation("Source CRS is not PROJ exportable");
}
@@ -12284,7 +12293,6 @@ CoordinateOperationFactory::Private::createOperations(
return applyInverse(createOperations(targetCRS, sourceCRS, context));
}
- auto boundSrc = dynamic_cast<const crs::BoundCRS *>(sourceCRS.get());
auto geogDst = dynamic_cast<const crs::GeographicCRS *>(targetCRS.get());
if (boundSrc && geogDst) {
const auto &hubSrc = boundSrc->hubCRS();
@@ -12474,7 +12482,6 @@ CoordinateOperationFactory::Private::createOperations(
}
// reverse of previous case
- auto boundDst = dynamic_cast<const crs::BoundCRS *>(targetCRS.get());
auto geogSrc = dynamic_cast<const crs::GeographicCRS *>(sourceCRS.get());
if (geogSrc && boundDst) {
return applyInverse(createOperations(targetCRS, sourceCRS, context));