diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-12-16 22:53:57 +0100 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-12-16 22:54:01 +0100 |
| commit | eb0d804cdb44ec10795a5b591214d1cdd419a11c (patch) | |
| tree | ad53c2d847676b21287811e9b6158fb877a1a2c1 /src/iso19111 | |
| parent | e210258e679094159791aa2eeb36a53ab270ce4c (diff) | |
| download | PROJ-eb0d804cdb44ec10795a5b591214d1cdd419a11c.tar.gz PROJ-eb0d804cdb44ec10795a5b591214d1cdd419a11c.zip | |
WKT1 import: correctly deal with missing rectified_grid_angle parameter
by setting its value from the azimuth angle.
and on export to PROJ.4 string do not emit a erroneous +gamma=0 when the
parameter it is missing.
Fixes https://lists.osgeo.org/pipermail/proj/2021-December/010475.html
Diffstat (limited to 'src/iso19111')
| -rw-r--r-- | src/iso19111/io.cpp | 42 | ||||
| -rw-r--r-- | src/iso19111/operation/conversion.cpp | 10 |
2 files changed, 52 insertions, 0 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index 4dcceba2..67877206 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -3968,6 +3968,48 @@ ConversionNNPtr WKTParser::Private::buildProjectionStandard( } } + if (mapping && (mapping->epsg_code == + EPSG_CODE_METHOD_HOTINE_OBLIQUE_MERCATOR_VARIANT_A || + mapping->epsg_code == + EPSG_CODE_METHOD_HOTINE_OBLIQUE_MERCATOR_VARIANT_B)) { + // Special case when importing some GDAL WKT of Hotine Oblique Mercator + // that have a Azimuth parameter but lacks the Rectified Grid Angle. + // We have code in the exportToPROJString() to deal with that situation, + // but also adds the rectified grid angle from the azimuth on import. + bool foundAngleRecifiedToSkewGrid = false; + bool foundAzimuth = false; + for (size_t idx = 0; mapping->params[idx] != nullptr; ++idx) { + if (foundParameters[idx] && + mapping->params[idx]->epsg_code == + EPSG_CODE_PARAMETER_ANGLE_RECTIFIED_TO_SKEW_GRID) { + foundAngleRecifiedToSkewGrid = true; + } else if (foundParameters[idx] && + mapping->params[idx]->epsg_code == + EPSG_CODE_PARAMETER_AZIMUTH_INITIAL_LINE) { + foundAzimuth = true; + } + } + if (!foundAngleRecifiedToSkewGrid && foundAzimuth) { + for (size_t idx = 0; idx < parameters.size(); ++idx) { + if (parameters[idx]->getEPSGCode() == + EPSG_CODE_PARAMETER_AZIMUTH_INITIAL_LINE) { + PropertyMap propertiesParameter; + propertiesParameter.set( + Identifier::CODE_KEY, + EPSG_CODE_PARAMETER_ANGLE_RECTIFIED_TO_SKEW_GRID); + propertiesParameter.set(Identifier::CODESPACE_KEY, + Identifier::EPSG); + propertiesParameter.set( + IdentifiedObject::NAME_KEY, + EPSG_NAME_PARAMETER_ANGLE_RECTIFIED_TO_SKEW_GRID); + parameters.push_back( + OperationParameter::create(propertiesParameter)); + values.push_back(values[idx]); + } + } + } + } + return Conversion::create( PropertyMap().set(IdentifiedObject::NAME_KEY, "unnamed"), propertiesMethod, parameters, values) diff --git a/src/iso19111/operation/conversion.cpp b/src/iso19111/operation/conversion.cpp index 9927892d..77e703f3 100644 --- a/src/iso19111/operation/conversion.cpp +++ b/src/iso19111/operation/conversion.cpp @@ -4005,6 +4005,16 @@ void Conversion::_exportToPROJString( EPSG_CODE_PARAMETER_SCALE_FACTOR_AT_NATURAL_ORIGIN) { valueConverted = 1.0; } + if ((mapping->epsg_code == + EPSG_CODE_METHOD_HOTINE_OBLIQUE_MERCATOR_VARIANT_A || + mapping->epsg_code == + EPSG_CODE_METHOD_HOTINE_OBLIQUE_MERCATOR_VARIANT_B) && + param->epsg_code == + EPSG_CODE_PARAMETER_ANGLE_RECTIFIED_TO_SKEW_GRID) { + // Do not use 0 as the default value for +gamma of + // proj=omerc + continue; + } } else if (param->unit_type == common::UnitOfMeasure::Type::ANGULAR) { valueConverted = |
