Skip to content

Commit

Permalink
Fix a clamping bug in ElevationLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Dec 20, 2024
1 parent 59e26c6 commit 1d2e910
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 0 additions & 4 deletions src/osgEarth/ElevationLayer
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,6 @@ namespace osgEarth

private:
GeoHeightField assembleHeightField(const TileKey& key, ProgressCallback* progress);
//void assembleHeightField(
// const TileKey& key,
// osg::ref_ptr<osg::HeightField>& out_hf,
// ProgressCallback* progress) const;

void normalizeNoDataValues(osg::HeightField* hf) const;

Expand Down
10 changes: 7 additions & 3 deletions src/osgEarth/ElevationLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ ElevationLayer::assembleHeightField(const TileKey& key, ProgressCallback* progre
// If we got here, assert that there's a non-null layer profile.
if (!getProfile())
{
setStatus(Status::Error(Status::AssertionFailure, "assembleImage with undefined profile"));
setStatus(Status::Error(Status::AssertionFailure, "assembleHeightField with undefined profile"));
return { };
}

Expand Down Expand Up @@ -342,8 +342,12 @@ ElevationLayer::assembleHeightField(const TileKey& key, ProgressCallback* progre
auto& h = mosaic->getHeight(col, row);
for (unsigned k = 0; k < sources.size() && h == NO_DATA_VALUE; ++k)
{
h = sources[k].second.getElevation(points[i].x(), points[i].y(), INTERP_BILINEAR)
- points[i].z(); // apply vdatum offset
auto& source = sources[k].second;
if (source.getExtent().contains(points[i].x(), points[i].y())) // prevents clamping of out-of-bounds points
{
h = sources[k].second.getElevation(points[i].x(), points[i].y(), INTERP_BILINEAR)
- points[i].z(); // apply vdatum offset
}
}
}
}
Expand Down

0 comments on commit 1d2e910

Please sign in to comment.