From f5b5f7f527203f0c25dcbb8af1c0f0b6cbb6ba4a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 27 Jul 2006 16:41:22 +0000 Subject: [PATCH] From Jason Beverage, "This patch should fix Gert's problem that he posted on osg-users. I downloaded the sample he posted, reproduced the error, and added an additional check to make sure the GDAL window size was valid. Now his example works fine. Changes made against current CVS. " --- src/osgTerrain/DataSet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/osgTerrain/DataSet.cpp b/src/osgTerrain/DataSet.cpp index b3237d195..550acc8ba 100644 --- a/src/osgTerrain/DataSet.cpp +++ b/src/osgTerrain/DataSet.cpp @@ -225,9 +225,9 @@ float getInterpolatedValue(GDALRasterBand *band, double x, double y) int numCols = band->GetXSize(); int rowMin = osg::maximum((int)floor(r), 0); - int rowMax = osg::minimum((int)ceil(r), numRows-1); + int rowMax = osg::maximum(osg::minimum((int)ceil(r), numRows-1), 0); int colMin = osg::maximum((int)floor(c), 0); - int colMax = osg::minimum((int)ceil(c), numCols-1); + int colMax = osg::maximum(osg::minimum((int)ceil(c), numCols-1), 0); if (rowMin > rowMax) rowMin = rowMax; if (colMin > colMax) colMin = colMax;