Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 9.2] vgridshift/gridshift: accept hydroid_height as valid band description #3675

Merged
merged 1 commit into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added data/tests/test_hydroid_height.tif
Binary file not shown.
16 changes: 15 additions & 1 deletion docs/source/specifications/geodetictiffgrids.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,24 @@ is an easy way to inspect such grid files:
is expressed in the target CRS) to
get an ellipsoidal height (that is expressed in the source CRS), also
called the geoid undulation.
The value is positive upward from the reference ellipsoid.
Note the possible confusion related to what is the source CRS and target CRS and
the semantics of the value stored (to convert from the source to the target,
one must subtract the value contained in the grid). This is the convention
used by the `EPSG:9665 <https://www.epsg-registry.org/export.htm?gml=urn:ogc:def:method:EPSG::9665>`_
used by the `EPSG:9665 <https://epsg.org/coord-operation-method_9665/Geographic3D-to-GravityRelatedHeight-gtx.html>`_
operation method.

+ ``hydroid_height``: valid for TYPE=VERTICAL_OFFSET_GEOGRAPHIC_TO_VERTICAL.
For a source CRS being a geographic CRS and a target CRS being a vertical CRS
representing a tidal surface (typically Chart Datum, Highest/Lowest Astronomical
Tide (HAT/LAT), High/Low Waters, Mean Sea Level), the hydroid height is
the value to add to a height related to a tidal surface (that is expressed
in the target CRS) to get an ellipsoidal height (that is expressed in the source CRS).
The value is positive upward from the reference ellipsoid.
Note the possible confusion related to what is the source CRS and target CRS and
the semantics of the value stored (to convert from the source to the target,
one must subtract the value contained in the grid). This is the convention
used by the `EPSG:1115 <https://epsg.org/coord-operation-method_1115/Geographic3D-to-GravityRelatedDepth-txt.html>`_
operation method.

+ ``vertical_offset``: valid for TYPE=VERTICAL_OFFSET_VERTICAL_TO_VERTICAL.
Expand Down
12 changes: 8 additions & 4 deletions src/grids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1538,15 +1538,17 @@ GTiffVGridShiftSet::open(PJ_CONTEXT *ctx, std::unique_ptr<File> fp,
}
}

// Identify the index of the geoid_undulation/vertical_offset
// Identify the index of the vertical correction
bool foundDescriptionForAtLeastOneSample = false;
bool foundDescriptionForShift = false;
for (int i = 0; i < static_cast<int>(grid->samplesPerPixel()); ++i) {
const auto &desc = grid->metadataItem("DESCRIPTION", i);
if (!desc.empty()) {
foundDescriptionForAtLeastOneSample = true;
}
if (desc == "geoid_undulation" || desc == "vertical_offset") {
if (desc == "geoid_undulation" || desc == "vertical_offset" ||
desc == "hydroid_height" ||
desc == "ellipsoidal_height_offset") {
idxSample = static_cast<uint16_t>(i);
foundDescriptionForShift = true;
}
Expand All @@ -1561,13 +1563,15 @@ GTiffVGridShiftSet::open(PJ_CONTEXT *ctx, std::unique_ptr<File> fp,
// IFD for example
pj_log(ctx, PJ_LOG_DEBUG,
"Ignoring IFD %d as it has no "
"geoid_undulation/vertical_offset channel",
"geoid_undulation/vertical_offset/hydroid_height/"
"ellipsoidal_height_offset channel",
ifd);
continue;
} else {
pj_log(ctx, PJ_LOG_DEBUG,
"IFD 0 has channel descriptions, but no "
"geoid_undulation/vertical_offset channel");
"geoid_undulation/vertical_offset/hydroid_height/"
"ellipsoidal_height_offset channel");
return nullptr;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/transformations/gridshift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ PJ_LPZ gridshiftData::grid_interpolate(PJ_CONTEXT *ctx, const std::string &type,
return val;
}
} else if (desc == "ellipsoidal_height_offset" ||
desc == "geoid_undulation" ||
desc == "geoid_undulation" || desc == "hydroid_height" ||
desc == "vertical_offset") {
idxSampleZ = i;
const auto unit = grid->unit(idxSampleZ);
Expand Down
7 changes: 7 additions & 0 deletions test/gie/geotiff_grids.gie
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ accept 4.05 52.1 0
expect 4.05 52.1 10
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
operation +proj=vgridshift +grids=tests/test_hydroid_height.tif +multiplier=1
-------------------------------------------------------------------------------
accept 2 49 0
expect 2 49 44.643493652
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
operation +proj=vgridshift +grids=tests/test_vgrid_invalid_channel_type.tif +multiplier=1
-------------------------------------------------------------------------------
Expand Down
7 changes: 7 additions & 0 deletions test/gie/gridshift.gie
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ expect failure errno coord_transfm_outside_grid
accept -179.816 54.5 0
expect failure errno coord_transfm_outside_grid

-------------------------------------------------------------------------------
operation +proj=gridshift +grids=tests/test_hydroid_height.tif
-------------------------------------------------------------------------------
accept 2 49 0
expect 2 49 44.643493652
-------------------------------------------------------------------------------


----------------------------------------------------------------------
# Geographic 3D offsets with quadratic interpolation (defined in file)
Expand Down