diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-12-17 01:17:50 +0100 |
|---|---|---|
| committer | github-actions[bot] <github-actions[bot]@users.noreply.github.com> | 2021-12-17 00:18:17 +0000 |
| commit | 4608ef43d6cf41f7acc61d228caab3234e04b28b (patch) | |
| tree | 2014bb128ee736184c46257d131c79aafa5d1ca0 /src | |
| parent | 0845df60254221e084cf76a894d9d87067ec29ed (diff) | |
| download | PROJ-4608ef43d6cf41f7acc61d228caab3234e04b28b.tar.gz PROJ-4608ef43d6cf41f7acc61d228caab3234e04b28b.zip | |
Merge pull request #2985 from rouault/wkt1_hotine_without_rectified_grid_angle
WKT1 import: correctly deal with missing rectified_grid_angle parameter
Diffstat (limited to 'src')
| -rw-r--r-- | src/iso19111/io.cpp | 55 | ||||
| -rw-r--r-- | src/iso19111/operation/conversion.cpp | 10 |
2 files changed, 58 insertions, 7 deletions
diff --git a/src/iso19111/io.cpp b/src/iso19111/io.cpp index f8a4672a..454800dd 100644 --- a/src/iso19111/io.cpp +++ b/src/iso19111/io.cpp @@ -3894,13 +3894,12 @@ ConversionNNPtr WKTParser::Private::buildProjectionStandard( if (mapping && mapping->epsg_code == EPSG_CODE_METHOD_MERCATOR_VARIANT_B && ci_equal(parameterName, "latitude_of_origin")) { - for (size_t idx = 0; mapping->params[idx] != nullptr; ++idx) { - if (mapping->params[idx]->epsg_code == - EPSG_CODE_PARAMETER_LATITUDE_OF_NATURAL_ORIGIN) { - foundParameters[idx] = true; - break; - } - } + // Some illegal formulations of Mercator_2SP have a unexpected + // latitude_of_origin parameter. We accept it on import, but + // do not accept it when exporting to PROJ string, unless it is + // zero. + // No need to try to update foundParameters[] as this is a + // unexpected one. parameterName = EPSG_NAME_PARAMETER_LATITUDE_OF_NATURAL_ORIGIN; propertiesParameter.set( Identifier::CODE_KEY, @@ -3969,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 = |
