aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-06-16 20:07:40 +0200
committerEven Rouault <even.rouault@spatialys.com>2020-06-16 20:07:40 +0200
commit3d9aa5c82f667e93bee4d9d4b17a11df8842559b (patch)
treec5d3f80adefb74cfcdc33df00af92ba0085b40b7 /src
parent3005bcbc159d2a402eeecb6f568da4e85a7e0411 (diff)
downloadPROJ-3d9aa5c82f667e93bee4d9d4b17a11df8842559b.tar.gz
PROJ-3d9aa5c82f667e93bee4d9d4b17a11df8842559b.zip
createOperations(): fix transformations between BoundCRS and Geocentric CRS
Diffstat (limited to 'src')
-rw-r--r--src/iso19111/coordinateoperation.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp
index 63363ff2..b1c7e6b5 100644
--- a/src/iso19111/coordinateoperation.cpp
+++ b/src/iso19111/coordinateoperation.cpp
@@ -9084,6 +9084,12 @@ extractGeographicCRSIfGeographicCRSOrEquivalent(const crs::CRSNNPtr &crs) {
}
}
}
+ } else {
+ auto boundCRS = util::nn_dynamic_pointer_cast<crs::BoundCRS>(crs);
+ if (boundCRS) {
+ geogCRS = util::nn_dynamic_pointer_cast<crs::GeographicCRS>(
+ boundCRS->baseCRS());
+ }
}
}
return geogCRS;
@@ -11087,10 +11093,9 @@ struct CoordinateOperationFactory::Private {
const crs::GeographicCRS *geogDst,
std::vector<CoordinateOperationNNPtr> &res);
- static void createOperationsCompoundToGeod(
+ static void createOperationsToGeod(
const crs::CRSNNPtr &sourceCRS, const crs::CRSNNPtr &targetCRS,
- Private::Context &context, const crs::CompoundCRS *compoundSrc,
- const crs::GeodeticCRS *geodDst,
+ Private::Context &context, const crs::GeodeticCRS *geodDst,
std::vector<CoordinateOperationNNPtr> &res);
static void createOperationsCompoundToCompound(
@@ -13286,14 +13291,18 @@ CoordinateOperationFactory::Private::createOperations(
return applyInverse(createOperations(targetCRS, sourceCRS, context));
}
+ // Order of comparison between the geogDst vs geodDst is impotant
if (boundSrc && geogDst) {
createOperationsBoundToGeog(sourceCRS, targetCRS, context, boundSrc,
geogDst, res);
return res;
+ } else if (boundSrc && geodDst) {
+ createOperationsToGeod(sourceCRS, targetCRS, context, geodDst, res);
+ return res;
}
// reverse of previous case
- if (geogSrc && boundDst) {
+ if (geodSrc && boundDst) {
return applyInverse(createOperations(targetCRS, sourceCRS, context));
}
@@ -13343,8 +13352,7 @@ CoordinateOperationFactory::Private::createOperations(
compoundSrc, geogDst, res);
return res;
} else if (compoundSrc && geodDst) {
- createOperationsCompoundToGeod(sourceCRS, targetCRS, context,
- compoundSrc, geodDst, res);
+ createOperationsToGeod(sourceCRS, targetCRS, context, geodDst, res);
return res;
}
@@ -15048,10 +15056,9 @@ void CoordinateOperationFactory::Private::createOperationsCompoundToGeog(
// ---------------------------------------------------------------------------
-void CoordinateOperationFactory::Private::createOperationsCompoundToGeod(
+void CoordinateOperationFactory::Private::createOperationsToGeod(
const crs::CRSNNPtr &sourceCRS, const crs::CRSNNPtr &targetCRS,
- Private::Context &context, const crs::CompoundCRS * /*compoundSrc*/,
- const crs::GeodeticCRS *geodDst,
+ Private::Context &context, const crs::GeodeticCRS *geodDst,
std::vector<CoordinateOperationNNPtr> &res) {
auto datum = geodDst->datum();
if (datum) {
@@ -15070,8 +15077,11 @@ void CoordinateOperationFactory::Private::createOperationsCompoundToGeod(
createOperations(intermGeog3DCRS, targetCRS, context);
if (!geog3DToTargetOps.empty()) {
for (const auto &op : sourceToGeog3DOps) {
+ auto newOp = op->shallowClone();
+ setCRSs(newOp.get(), sourceCRS, intermGeog3DCRS);
res.emplace_back(ConcatenatedOperation::createComputeMetadata(
- {op, geog3DToTargetOps.front()}, !allowEmptyIntersection));
+ {newOp, geog3DToTargetOps.front()},
+ !allowEmptyIntersection));
}
}
}