Skip to content

Commit

Permalink
vgridshift/gridshift: accept hydroid_height as valid band description
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault authored and github-actions[bot] committed Mar 22, 2023
1 parent 8168911 commit 978c68a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 6 deletions.
Binary file added data/tests/test_hydroid_height.tif
Binary file not shown.
16 changes: 15 additions & 1 deletion docs/source/specifications/geodetictiffgrids.rst
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
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
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
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
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

0 comments on commit 978c68a

Please sign in to comment.