diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2018-12-04 17:49:51 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2018-12-04 17:49:51 +0100 |
| commit | ae2f7ad985e5da5d4f4006849b68fae7dde53375 (patch) | |
| tree | 067ed6276ced72b1cc66140cd7e23452c07a9212 /src | |
| parent | addfa5aa8539b3143c02a9cb23e213063021e75c (diff) | |
| download | PROJ-ae2f7ad985e5da5d4f4006849b68fae7dde53375.tar.gz PROJ-ae2f7ad985e5da5d4f4006849b68fae7dde53375.zip | |
Avoid negative zero in TOWGS84[]
Diffstat (limited to 'src')
| -rw-r--r-- | src/coordinateoperation.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/coordinateoperation.cpp b/src/coordinateoperation.cpp index bbe84698..79984c91 100644 --- a/src/coordinateoperation.cpp +++ b/src/coordinateoperation.cpp @@ -5626,6 +5626,13 @@ Transformation::getTOWGS84Parameters() const // throw(io::FormattingException) bool foundRotZ = false; bool foundScale = false; const double rotSign = invertRotSigns ? -1.0 : 1.0; + + const auto fixNegativeZero = [](double x) { + if (x == 0.0) + return 0.0; + return x; + }; + for (const auto &genOpParamvalue : parameterValues()) { auto opParamvalue = dynamic_cast<const OperationParameterValue *>( genOpParamvalue.get()); @@ -5648,21 +5655,24 @@ Transformation::getTOWGS84Parameters() const // throw(io::FormattingException) foundZ = true; } else if (epsg_code == EPSG_CODE_PARAMETER_X_AXIS_ROTATION) { - params[3] = rotSign * - measure.convertToUnit( - common::UnitOfMeasure::ARC_SECOND); + params[3] = fixNegativeZero( + rotSign * + measure.convertToUnit( + common::UnitOfMeasure::ARC_SECOND)); foundRotX = true; } else if (epsg_code == EPSG_CODE_PARAMETER_Y_AXIS_ROTATION) { - params[4] = rotSign * - measure.convertToUnit( - common::UnitOfMeasure::ARC_SECOND); + params[4] = fixNegativeZero( + rotSign * + measure.convertToUnit( + common::UnitOfMeasure::ARC_SECOND)); foundRotY = true; } else if (epsg_code == EPSG_CODE_PARAMETER_Z_AXIS_ROTATION) { - params[5] = rotSign * - measure.convertToUnit( - common::UnitOfMeasure::ARC_SECOND); + params[5] = fixNegativeZero( + rotSign * + measure.convertToUnit( + common::UnitOfMeasure::ARC_SECOND)); foundRotZ = true; } else if (epsg_code == EPSG_CODE_PARAMETER_SCALE_DIFFERENCE) { |
