aboutsummaryrefslogtreecommitdiff
path: root/src/iso19111/coordinateoperation.cpp
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2019-02-20 15:29:38 +0100
committerEven Rouault <even.rouault@spatialys.com>2019-02-20 15:29:38 +0100
commitca8f21ecbcc404b9e9c648784216846c048a3d69 (patch)
treeb565dd643577bb8d15e2777bb1d77287643c2e06 /src/iso19111/coordinateoperation.cpp
parent2272ba8f6a77903203632111a44b44e544fe332b (diff)
downloadPROJ-ca8f21ecbcc404b9e9c648784216846c048a3d69.tar.gz
PROJ-ca8f21ecbcc404b9e9c648784216846c048a3d69.zip
PROJStringFormatting: change order of emission of push/pop w.r.t axis swap/unitconvert to avoid useless simplification rules
Diffstat (limited to 'src/iso19111/coordinateoperation.cpp')
-rw-r--r--src/iso19111/coordinateoperation.cpp77
1 files changed, 33 insertions, 44 deletions
diff --git a/src/iso19111/coordinateoperation.cpp b/src/iso19111/coordinateoperation.cpp
index d66afd0d..fdcb6af8 100644
--- a/src/iso19111/coordinateoperation.cpp
+++ b/src/iso19111/coordinateoperation.cpp
@@ -8101,7 +8101,7 @@ static void ThrowExceptionNotGeodeticGeographic(const char *trfrm_name) {
// ---------------------------------------------------------------------------
static void setupPROJGeodeticSourceCRS(io::PROJStringFormatter *formatter,
- const crs::CRSNNPtr &crs,
+ const crs::CRSNNPtr &crs, bool addPushV3,
const char *trfrm_name) {
auto sourceCRSGeog = dynamic_cast<const crs::GeographicCRS *>(crs.get());
if (sourceCRSGeog) {
@@ -8109,6 +8109,11 @@ static void setupPROJGeodeticSourceCRS(io::PROJStringFormatter *formatter,
sourceCRSGeog->_exportToPROJString(formatter);
formatter->stopInversion();
+ if (addPushV3) {
+ formatter->addStep("push");
+ formatter->addParam("v_3");
+ }
+
formatter->addStep("cart");
sourceCRSGeog->ellipsoid()->_exportToPROJString(formatter);
} else {
@@ -8124,7 +8129,7 @@ static void setupPROJGeodeticSourceCRS(io::PROJStringFormatter *formatter,
// ---------------------------------------------------------------------------
static void setupPROJGeodeticTargetCRS(io::PROJStringFormatter *formatter,
- const crs::CRSNNPtr &crs,
+ const crs::CRSNNPtr &crs, bool addPopV3,
const char *trfrm_name) {
auto targetCRSGeog = dynamic_cast<const crs::GeographicCRS *>(crs.get());
if (targetCRSGeog) {
@@ -8132,6 +8137,11 @@ static void setupPROJGeodeticTargetCRS(io::PROJStringFormatter *formatter,
formatter->setCurrentStepInverted(true);
targetCRSGeog->ellipsoid()->_exportToPROJString(formatter);
+ if (addPopV3) {
+ formatter->addStep("pop");
+ formatter->addParam("v_3");
+ }
+
targetCRSGeog->_exportToPROJString(formatter);
} else {
auto targetCRSGeod = dynamic_cast<const crs::GeodeticCRS *>(crs.get());
@@ -8223,19 +8233,19 @@ void Transformation::_exportToPROJString(
double z =
parameterValueNumericAsSI(EPSG_CODE_PARAMETER_Z_AXIS_TRANSLATION);
- if (methodEPSGCode == EPSG_CODE_METHOD_COORDINATE_FRAME_GEOGRAPHIC_2D ||
- methodEPSGCode ==
- EPSG_CODE_METHOD_TIME_DEPENDENT_COORDINATE_FRAME_GEOGRAPHIC_2D ||
- methodEPSGCode == EPSG_CODE_METHOD_POSITION_VECTOR_GEOGRAPHIC_2D ||
- methodEPSGCode ==
- EPSG_CODE_METHOD_TIME_DEPENDENT_POSITION_VECTOR_GEOGRAPHIC_2D ||
- methodEPSGCode ==
- EPSG_CODE_METHOD_GEOCENTRIC_TRANSLATION_GEOGRAPHIC_2D) {
- formatter->addStep("push");
- formatter->addParam("v_3");
- }
+ bool addPushPopV3 =
+ (methodEPSGCode ==
+ EPSG_CODE_METHOD_COORDINATE_FRAME_GEOGRAPHIC_2D ||
+ methodEPSGCode ==
+ EPSG_CODE_METHOD_TIME_DEPENDENT_COORDINATE_FRAME_GEOGRAPHIC_2D ||
+ methodEPSGCode == EPSG_CODE_METHOD_POSITION_VECTOR_GEOGRAPHIC_2D ||
+ methodEPSGCode ==
+ EPSG_CODE_METHOD_TIME_DEPENDENT_POSITION_VECTOR_GEOGRAPHIC_2D ||
+ methodEPSGCode ==
+ EPSG_CODE_METHOD_GEOCENTRIC_TRANSLATION_GEOGRAPHIC_2D);
- setupPROJGeodeticSourceCRS(formatter, sourceCRS(), "Helmert");
+ setupPROJGeodeticSourceCRS(formatter, sourceCRS(), addPushPopV3,
+ "Helmert");
formatter->addStep("helmert");
formatter->addParam("x", x);
@@ -8299,19 +8309,8 @@ void Transformation::_exportToPROJString(
}
}
- setupPROJGeodeticTargetCRS(formatter, targetCRS(), "Helmert");
-
- if (methodEPSGCode == EPSG_CODE_METHOD_COORDINATE_FRAME_GEOGRAPHIC_2D ||
- methodEPSGCode ==
- EPSG_CODE_METHOD_TIME_DEPENDENT_COORDINATE_FRAME_GEOGRAPHIC_2D ||
- methodEPSGCode == EPSG_CODE_METHOD_POSITION_VECTOR_GEOGRAPHIC_2D ||
- methodEPSGCode ==
- EPSG_CODE_METHOD_TIME_DEPENDENT_POSITION_VECTOR_GEOGRAPHIC_2D ||
- methodEPSGCode ==
- EPSG_CODE_METHOD_GEOCENTRIC_TRANSLATION_GEOGRAPHIC_2D) {
- formatter->addStep("pop");
- formatter->addParam("v_3");
- }
+ setupPROJGeodeticTargetCRS(formatter, targetCRS(), addPushPopV3,
+ "Helmert");
return;
}
@@ -8359,15 +8358,13 @@ void Transformation::_exportToPROJString(
double pz = parameterValueNumericAsSI(
EPSG_CODE_PARAMETER_ORDINATE_3_EVAL_POINT);
- if (methodEPSGCode ==
- EPSG_CODE_METHOD_MOLODENSKY_BADEKAS_PV_GEOGRAPHIC_2D ||
- methodEPSGCode ==
- EPSG_CODE_METHOD_MOLODENSKY_BADEKAS_CF_GEOGRAPHIC_2D) {
- formatter->addStep("push");
- formatter->addParam("v_3");
- }
+ bool addPushPopV3 =
+ (methodEPSGCode ==
+ EPSG_CODE_METHOD_MOLODENSKY_BADEKAS_PV_GEOGRAPHIC_2D ||
+ methodEPSGCode ==
+ EPSG_CODE_METHOD_MOLODENSKY_BADEKAS_CF_GEOGRAPHIC_2D);
- setupPROJGeodeticSourceCRS(formatter, sourceCRS(),
+ setupPROJGeodeticSourceCRS(formatter, sourceCRS(), addPushPopV3,
"Molodensky-Badekas");
formatter->addStep("molobadekas");
@@ -8387,17 +8384,9 @@ void Transformation::_exportToPROJString(
formatter->addParam("convention", "coordinate_frame");
}
- setupPROJGeodeticTargetCRS(formatter, targetCRS(),
+ setupPROJGeodeticTargetCRS(formatter, targetCRS(), addPushPopV3,
"Molodensky-Badekas");
- if (methodEPSGCode ==
- EPSG_CODE_METHOD_MOLODENSKY_BADEKAS_PV_GEOGRAPHIC_2D ||
- methodEPSGCode ==
- EPSG_CODE_METHOD_MOLODENSKY_BADEKAS_CF_GEOGRAPHIC_2D) {
- formatter->addStep("pop");
- formatter->addParam("v_3");
- }
-
return;
}