@@ -2187,12 +2187,20 @@ createSimilarPropertiesMethod(common::IdentifiedObjectNNPtr obj) {
2187
2187
2188
2188
// ---------------------------------------------------------------------------
2189
2189
2190
- static bool isRegularVerticalGridMethod (int methodEPSGCode) {
2190
+ static bool isRegularVerticalGridMethod (int methodEPSGCode,
2191
+ bool &reverseOffsetSign) {
2192
+ if (methodEPSGCode == EPSG_CODE_METHOD_VERTICALGRID_NRCAN_BYN) {
2193
+ // NRCAN vertical shift grids use a reverse convention from other
2194
+ // grids: the value in the grid is the value to subtract from the
2195
+ // source vertical CRS to get the target value.
2196
+ reverseOffsetSign = true ;
2197
+ return true ;
2198
+ }
2199
+ reverseOffsetSign = false ;
2191
2200
return methodEPSGCode == EPSG_CODE_METHOD_VERTICALGRID_NZLVD ||
2192
2201
methodEPSGCode == EPSG_CODE_METHOD_VERTICALGRID_BEV_AT ||
2193
2202
methodEPSGCode == EPSG_CODE_METHOD_VERTICALGRID_GTX ||
2194
- methodEPSGCode == EPSG_CODE_METHOD_VERTICALGRID_PL_TXT ||
2195
- methodEPSGCode == EPSG_CODE_METHOD_VERTICALGRID_NRCAN_BYN;
2203
+ methodEPSGCode == EPSG_CODE_METHOD_VERTICALGRID_PL_TXT;
2196
2204
}
2197
2205
2198
2206
// ---------------------------------------------------------------------------
@@ -2477,8 +2485,9 @@ TransformationNNPtr SingleOperation::substitutePROJAlternativeGridNames(
2477
2485
}
2478
2486
}
2479
2487
2488
+ bool reverseOffsetSign = false ;
2480
2489
if (methodEPSGCode == EPSG_CODE_METHOD_VERTCON ||
2481
- isRegularVerticalGridMethod (methodEPSGCode)) {
2490
+ isRegularVerticalGridMethod (methodEPSGCode, reverseOffsetSign )) {
2482
2491
auto fileParameter =
2483
2492
parameterValue (EPSG_NAME_PARAMETER_VERTICAL_OFFSET_FILE,
2484
2493
EPSG_CODE_PARAMETER_VERTICAL_OFFSET_FILE);
@@ -4146,15 +4155,16 @@ bool SingleOperation::exportToPROJStringGeneric(
4146
4155
}
4147
4156
}
4148
4157
4149
- if (isRegularVerticalGridMethod (methodEPSGCode)) {
4158
+ bool reverseOffsetSign = false ;
4159
+ if (isRegularVerticalGridMethod (methodEPSGCode, reverseOffsetSign)) {
4150
4160
auto fileParameter =
4151
4161
parameterValue (EPSG_NAME_PARAMETER_VERTICAL_OFFSET_FILE,
4152
4162
EPSG_CODE_PARAMETER_VERTICAL_OFFSET_FILE);
4153
4163
if (fileParameter &&
4154
4164
fileParameter->type () == ParameterValue::Type::FILENAME) {
4155
4165
formatter->addStep (" vgridshift" );
4156
4166
formatter->addParam (" grids" , fileParameter->valueFile ());
4157
- formatter->addParam (" multiplier" , 1.0 );
4167
+ formatter->addParam (" multiplier" , reverseOffsetSign ? - 1.0 : 1.0 );
4158
4168
return true ;
4159
4169
}
4160
4170
}
0 commit comments