aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2020-06-16 22:50:35 +0200
committerGitHub <noreply@github.com>2020-06-16 22:50:35 +0200
commit963a4d4cae0aab265295bbfd738dbf806e925cc3 (patch)
treedf87f415cc39db08a4cc6b6edadfbe37ed417a93 /src
parent3005bcbc159d2a402eeecb6f568da4e85a7e0411 (diff)
parentad9efb19d37be616d69676e732abe44e78a8305b (diff)
downloadPROJ-963a4d4cae0aab265295bbfd738dbf806e925cc3.tar.gz
PROJ-963a4d4cae0aab265295bbfd738dbf806e925cc3.zip
Merge pull request #2248 from rouault/database_nzgd2000_defmodel
Database: register NZGD2000 -> ITRF96 transformation for NZGD2000 database
Diffstat (limited to 'src')
-rw-r--r--src/iso19111/coordinateoperation.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp
index 63363ff2..e33ad15e 100644
--- a/src/iso19111/coordinateoperation.cpp
+++ b/src/iso19111/coordinateoperation.cpp
@@ -10196,6 +10196,17 @@ void ConcatenatedOperation::fixStepsDirection(
// Set of heuristics to assign CRS to steps, and possibly reverse them.
+ const auto isGeographic = [](const crs::CRS *crs) -> bool {
+ return dynamic_cast<const crs::GeographicCRS *>(crs) != nullptr;
+ };
+
+ const auto isGeocentric = [](const crs::CRS *crs) -> bool {
+ auto geodCRS = dynamic_cast<const crs::GeodeticCRS *>(crs);
+ if (geodCRS && geodCRS->coordinateSystem()->axisList().size() == 3)
+ return true;
+ return false;
+ };
+
for (size_t i = 0; i < operationsInOut.size(); ++i) {
auto &op = operationsInOut[i];
auto l_sourceCRS = op->sourceCRS();
@@ -10286,18 +10297,6 @@ void ConcatenatedOperation::fixStepsDirection(
}
} else if (!conv && l_sourceCRS && l_targetCRS) {
- const auto isGeographic = [](const crs::CRS *crs) -> bool {
- return dynamic_cast<const crs::GeographicCRS *>(crs) != nullptr;
- };
-
- const auto isGeocentric = [](const crs::CRS *crs) -> bool {
- auto geodCRS = dynamic_cast<const crs::GeodeticCRS *>(crs);
- if (geodCRS &&
- geodCRS->coordinateSystem()->axisList().size() == 3)
- return true;
- return false;
- };
-
// Transformations might be mentioned in their forward directions,
// whereas we should instead use the reverse path.
auto prevOpTarget = (i == 0) ? concatOpSourceCRS.as_nullable()
@@ -10342,10 +10341,20 @@ void ConcatenatedOperation::fixStepsDirection(
auto l_targetCRS = operationsInOut.back()->targetCRS();
if (l_targetCRS &&
!compareStepCRS(l_targetCRS.get(), concatOpTargetCRS.get())) {
- throw InvalidOperation("The target CRS of the last step of "
- "concatenated operation is not the same "
- "as the target CRS of the concatenated "
- "operation itself");
+ if (l_targetCRS->nameStr() == concatOpTargetCRS->nameStr() &&
+ ((isGeographic(l_targetCRS.get()) &&
+ isGeocentric(concatOpTargetCRS.get())) ||
+ (isGeocentric(l_targetCRS.get()) &&
+ isGeographic(concatOpTargetCRS.get())))) {
+ auto newOp(Conversion::createGeographicGeocentric(
+ NN_NO_CHECK(l_targetCRS), concatOpTargetCRS));
+ operationsInOut.push_back(newOp);
+ } else {
+ throw InvalidOperation("The target CRS of the last step of "
+ "concatenated operation is not the same "
+ "as the target CRS of the concatenated "
+ "operation itself");
+ }
}
}
}