This is an automated email from the git hooks/post-receive script. sebastic-guest pushed a commit to branch upstream-master in repository pktools.
commit 24cc89baa83c5017228f0ef605eb9b405e8771bf Author: Pieter Kempeneers <kempe...@gmail.com> Date: Thu Aug 23 18:49:27 2012 +0200 support for mask values in pkinfo min/max values --- src/apps/pkinfo.cc | 2 +- src/imageclasses/ImgReaderGdal.cc | 71 +++++++++++++++++++++++++++++---------- 2 files changed, 54 insertions(+), 19 deletions(-) diff --git a/src/apps/pkinfo.cc b/src/apps/pkinfo.cc index 0e393e9..d3fa74e 100644 --- a/src/apps/pkinfo.cc +++ b/src/apps/pkinfo.cc @@ -266,7 +266,7 @@ int main(int argc, char *argv[]) if(minmax_opt[0]){ assert(band_opt[0]<imgReader.nrOfBand()); - imgReader.getMinMax(minValue,maxValue,band_opt[0]); + imgReader.getMinMax(minValue,maxValue,band_opt[0],true); std::cout << "--min " << minValue << " --max " << maxValue << " "; } if(hist_opt[0]){ diff --git a/src/imageclasses/ImgReaderGdal.cc b/src/imageclasses/ImgReaderGdal.cc index 047d9da..0456e74 100644 --- a/src/imageclasses/ImgReaderGdal.cc +++ b/src/imageclasses/ImgReaderGdal.cc @@ -308,37 +308,59 @@ bool ImgReaderGdal::covers(double ulx, double uly, double lrx, double lry) cons double ImgReaderGdal::getMin(int& x, int& y, int band) const{ double minValue=0; vector<double> lineBuffer(nrOfCol()); + bool init=false; for(int irow=0;irow<nrOfRow();++irow){ readData(lineBuffer,GDT_Float64,irow,band); - if(!irow)//initialize - minValue=lineBuffer[0]; for(int icol=0;icol<nrOfCol();++icol){ - if(minValue>lineBuffer[icol]){ - y=irow; - x=icol; - minValue=lineBuffer[icol]; + bool valid=(find(m_noDataValues.begin(),m_noDataValues.end(),lineBuffer[icol])==m_noDataValues.end()); + if(valid){ + if(!init){ + y=irow; + x=icol; + minValue=lineBuffer[icol]; + init=true; + } + else if(minValue>lineBuffer[icol]){ + y=irow; + x=icol; + minValue=lineBuffer[icol]; + } } } } - return minValue; + if(init) + return minValue; + else + throw(static_cast<string>("Warning: not initialized")); } double ImgReaderGdal::getMax(int& x, int& y, int band) const{ double maxValue=0; vector<double> lineBuffer(nrOfCol()); + bool init=false; for(int irow=0;irow<nrOfRow();++irow){ readData(lineBuffer,GDT_Float64,irow,band); - if(!irow)//initialize - maxValue=lineBuffer[0]; for(int icol=0;icol<nrOfCol();++icol){ - if(maxValue<lineBuffer[icol]){ - y=irow; - x=icol; - maxValue=lineBuffer[icol]; + bool valid=(find(m_noDataValues.begin(),m_noDataValues.end(),lineBuffer[icol])==m_noDataValues.end()); + if(valid){ + if(!init){ + y=irow; + x=icol; + maxValue=lineBuffer[icol]; + init=true; + } + else if(maxValue<lineBuffer[icol]){ + y=irow; + x=icol; + maxValue=lineBuffer[icol]; + } } } } - return maxValue; + if(init) + return maxValue; + else + throw(static_cast<string>("Warning: not initialized")); } void ImgReaderGdal::getMinMax(double& minValue, double& maxValue, int band, bool exhaustiveSearch) const @@ -357,15 +379,28 @@ void ImgReaderGdal::getMinMax(double& minValue, double& maxValue, int band, bool maxValue=adfMinMax[1]; if(exhaustiveSearch){//force exhaustive search vector<double> lineBuffer(nrOfCol()); + bool init=false; for(int irow=0;irow<nrOfRow();++irow){ readData(lineBuffer,GDT_Float64,irow,band); for(int icol=0;icol<nrOfCol();++icol){ - if(minValue>lineBuffer[icol]) - minValue=lineBuffer[icol]; - if(maxValue<lineBuffer[icol]) - maxValue=lineBuffer[icol]; + bool valid=(find(m_noDataValues.begin(),m_noDataValues.end(),lineBuffer[icol])==m_noDataValues.end()); + if(valid){ + if(!init){ + minValue=lineBuffer[icol]; + maxValue=lineBuffer[icol]; + init=true; + } + else{ + if(minValue>lineBuffer[icol]) + minValue=lineBuffer[icol]; + if(maxValue<lineBuffer[icol]) + maxValue=lineBuffer[icol]; + } + } } } + if(!init) + throw(static_cast<string>("Warning: not initialized")); } } -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/pktools.git _______________________________________________ Pkg-grass-devel mailing list Pkg-grass-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel