Skip to content

Commit

Permalink
Avoid out-of-bounds Doppler look ups in geocodeSlc.
Browse files Browse the repository at this point in the history
  • Loading branch information
bhawkins-jpl committed Aug 14, 2020
1 parent 5151f15 commit fda4e0a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 1 addition & 2 deletions cxx/isce3/core/LUT2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ eval(double y, double x) const {
double y_idx = (y - _ystart) / _dy;

// Check bounds or clamp indices to valid values
if (_boundsError && (x_idx < 0.0 || y_idx < 0.0
|| x_idx >= _data.width() || y_idx >= _data.length())) {
if (_boundsError && not contains(y, x)) {
pyre::journal::error_t errorChannel("isce.core.LUT2d");
errorChannel
<< "Out of bounds LUT2d evaluation at " << y << " " << x
Expand Down
9 changes: 9 additions & 0 deletions cxx/isce3/core/LUT2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@ class isce3::core::LUT2d {
// Evaluate LUT
T eval(double y, double x) const;

/** Check if point resides in domain of LUT */
inline bool contains(double y, double x) const
{
const auto i = (y - _ystart) / _dy;
const auto j = (x - _xstart) / _dx;
return (i >= 0.0) && (i < _data.length()) &&
(j >= 0.0) && (j < _data.width());
}

private:
// Flags
bool _haveData, _boundsError;
Expand Down
3 changes: 2 additions & 1 deletion cxx/isce3/geocode/geocodeSlc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ void isce3::geocode::geocodeSlc(
radarGrid.rangePixelSpacing();

if (rdrY < 0 || rdrX < 0 || rdrY >= radarGrid.length() ||
rdrX >= radarGrid.width())
rdrX >= radarGrid.width() ||
not nativeDoppler.contains(aztime, srange))
continue;

localAzimuthFirstLine = std::min(
Expand Down

0 comments on commit fda4e0a

Please sign in to comment.