fix a few warnings and indentation

git-svn-id: http://svn.osgeo.org/qgis/trunk@15393 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
jef 2011-03-08 22:28:34 +00:00
parent 3109508503
commit 4dc5e26d5a
18 changed files with 773 additions and 701 deletions

View File

@ -516,7 +516,7 @@ void QgsRasterLayerProperties::sync()
break;
}
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterDataProvider::ARGBDataType )
{
delete tabPageSymbology;
delete tabPageColormap;
@ -525,12 +525,12 @@ void QgsRasterLayerProperties::sync()
tabBar->setCurrentWidget( tabPageMetadata );
}
if ( ! ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::BuildPyramids ) )
if ( !( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::BuildPyramids ) )
{
delete tabPagePyramids;
}
if ( ! ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Histogram ) )
if ( !( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Histogram ) )
{
delete tabPageHistogram;
}
@ -562,8 +562,8 @@ void QgsRasterLayerProperties::sync()
//
// Populate the various controls on the form
//
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
{
if ( mRasterLayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGBDataType )
{
QgsDebugMsg( "colorShadingAlgorithm = " + QString::number( mRasterLayer->colorShadingAlgorithm() ) );
if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandPseudoColor ||
mRasterLayer->drawingStyle() == QgsRasterLayer::PalettedColor ||
@ -593,7 +593,7 @@ void QgsRasterLayerProperties::sync()
}
}
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
if ( mRasterLayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGBDataType )
{
if ( rbtnThreeBand->isChecked() )
{
@ -782,7 +782,7 @@ void QgsRasterLayerProperties::sync()
//display the raster dimensions and no data value
if ( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Size )
{
{
lblColumns->setText( tr( "Columns: %1" ).arg( mRasterLayer->width() ) );
lblRows->setText( tr( "Rows: %1" ).arg( mRasterLayer->height() ) );
}
@ -793,8 +793,8 @@ void QgsRasterLayerProperties::sync()
lblRows->setText( tr( "Rows: " ) + tr( "n/a" ) );
}
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
{
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterDataProvider::ARGBDataType )
{
lblNoData->setText( tr( "No-Data Value: " ) + tr( "n/a" ) );
}
else
@ -843,7 +843,7 @@ void QgsRasterLayerProperties::syncColormapTab()
return;
}
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterDataProvider::ARGBDataType )
{
return;
}
@ -935,7 +935,7 @@ bool QgsRasterLayerProperties::validUserDefinedMinMax()
*/
void QgsRasterLayerProperties::apply()
{
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
if ( mRasterLayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGBDataType )
{
QgsDebugMsg( "apply processing symbology tab" );
/*
@ -1425,7 +1425,7 @@ void QgsRasterLayerProperties::apply()
mRasterLayer->triggerRepaint();
//Because Min Max values can be set during the redraw if a strech is requested we need to resync after apply
if ( mRasterLayer->dataProvider()->dataType(1) != QgsRasterDataProvider::ARGBDataType )
if ( mRasterLayer->dataProvider()->dataType( 1 ) != QgsRasterDataProvider::ARGBDataType )
{
if ( QgsContrastEnhancement::NoEnhancement != mRasterLayer->contrastEnhancementAlgorithm() )
{
@ -1668,7 +1668,7 @@ void QgsRasterLayerProperties::on_pbnChangeSpatialRefSys_clicked()
void QgsRasterLayerProperties::on_cboxColorMap_currentIndexChanged( const QString& theText )
{
if ( mRasterLayer->dataProvider()->dataType(1) == QgsRasterDataProvider::ARGBDataType )
if ( mRasterLayer->dataProvider()->dataType( 1 ) == QgsRasterDataProvider::ARGBDataType )
{
return;
}
@ -2586,9 +2586,9 @@ void QgsRasterLayerProperties::on_pbtnLoadColorMapFromFile_clicked()
void QgsRasterLayerProperties::on_pbtnLoadMinMax_clicked()
{
if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandGray
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandSingleBandGray
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandColor )
if ( mRasterLayer->drawingStyle() == QgsRasterLayer::SingleBandGray
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandSingleBandGray
|| mRasterLayer->drawingStyle() == QgsRasterLayer::MultiBandColor )
{
QgsRasterBandStats myRasterBandStats;
double myMinimumMaximum[2];

View File

@ -23,12 +23,13 @@
#include <QTime>
#include <QMap>
void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *data )
void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *data )
{
QgsDebugMsg("Entered");
QgsDebugMsg( "Entered" );
QgsDebugMsg( "viewExtent = " + viewExtent.toString() );
if ( ! theSrcCRS.isValid() || ! theDestCRS.isValid() ) {
if ( ! theSrcCRS.isValid() || ! theDestCRS.isValid() )
{
readBlock( bandNo, viewExtent, width, height, data );
return;
}
@ -38,21 +39,21 @@ void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & viewExt
double mMaxSrcXRes = 0;
double mMaxSrcYRes = 0;
if ( capabilities() & QgsRasterDataProvider::ExactResolution )
if ( capabilities() & QgsRasterDataProvider::ExactResolution )
{
mMaxSrcXRes = extent().width()/xSize();
mMaxSrcYRes = extent().height()/ySize();
mMaxSrcXRes = extent().width() / xSize();
mMaxSrcYRes = extent().height() / ySize();
}
QgsRasterProjector myProjector = QgsRasterProjector ( theSrcCRS, theDestCRS, viewExtent, height, width, mMaxSrcXRes, mMaxSrcYRes );
QgsRasterProjector myProjector = QgsRasterProjector( theSrcCRS, theDestCRS, viewExtent, height, width, mMaxSrcXRes, mMaxSrcYRes );
QgsDebugMsg( QString( "create projector time (ms): %1" ).arg( time.elapsed() ) );
// TODO: init data by nulls
// Allocate memory for not projected source data
int mySize = dataTypeSize(bandNo)/8;
int mySize = dataTypeSize( bandNo ) / 8;
void *mySrcData = malloc( mySize * myProjector.srcRows() * myProjector.srcCols() );
time.restart();
@ -67,13 +68,15 @@ void QgsRasterDataProvider::readBlock( int bandNo, QgsRectangle const & viewExt
int mySrcCol;
int mySrcOffset;
int myDestOffset;
for ( int r = 0; r < height; r++) {
for ( int c = 0; c < width; c++) {
myProjector.srcRowCol ( r, c, &mySrcRow, &mySrcCol );
for ( int r = 0; r < height; r++ )
{
for ( int c = 0; c < width; c++ )
{
myProjector.srcRowCol( r, c, &mySrcRow, &mySrcCol );
mySrcOffset = mySize * ( mySrcRow * myProjector.srcCols() + mySrcCol );
myDestOffset = mySize * ( r * width + c );
// retype to char is just to avoid g++ warning
memcpy( (char*) data + myDestOffset, (char*)mySrcData + mySrcOffset, mySize );
// retype to char is just to avoid g++ warning
memcpy(( char* ) data + myDestOffset, ( char* )mySrcData + mySrcOffset, mySize );
}
}
QgsDebugMsg( QString( "reproject block time (ms): %1" ).arg( time.elapsed() ) );

View File

@ -81,29 +81,29 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
/*! Complex Float64 */ CFloat64 = 11,
/*! Color, alpha, red, green, blue, 4 bytes */ ARGBDataType = 12,
TypeCount = 13 /* maximum type # + 1 */
};
};
// This is modified copy of GDALColorInterp
enum ColorInterpretation
{
UndefinedColorInterpretation=0,
/*! Greyscale */ GrayIndex=1,
/*! Paletted (see associated color table) */ PaletteIndex=2,
/*! Red band of RGBA image */ RedBand=3,
/*! Green band of RGBA image */ GreenBand=4,
/*! Blue band of RGBA image */ BlueBand=5,
/*! Alpha (0=transparent, 255=opaque) */ AlphaBand=6,
/*! Hue band of HLS image */ HueBand=7,
/*! Saturation band of HLS image */ SaturationBand=8,
/*! Lightness band of HLS image */ LightnessBand=9,
/*! Cyan band of CMYK image */ CyanBand=10,
/*! Magenta band of CMYK image */ MagentaBand=11,
/*! Yellow band of CMYK image */ YellowBand=12,
/*! Black band of CMLY image */ BlackBand=13,
/*! Y Luminance */ YCbCr_YBand=14,
/*! Cb Chroma */ YCbCr_CbBand=15,
/*! Cr Chroma */ YCbCr_CrBand=16,
/*! Max current value */ ColorInterpretationMax=16
UndefinedColorInterpretation = 0,
/*! Greyscale */ GrayIndex = 1,
/*! Paletted (see associated color table) */ PaletteIndex = 2,
/*! Red band of RGBA image */ RedBand = 3,
/*! Green band of RGBA image */ GreenBand = 4,
/*! Blue band of RGBA image */ BlueBand = 5,
/*! Alpha (0=transparent, 255=opaque) */ AlphaBand = 6,
/*! Hue band of HLS image */ HueBand = 7,
/*! Saturation band of HLS image */ SaturationBand = 8,
/*! Lightness band of HLS image */ LightnessBand = 9,
/*! Cyan band of CMYK image */ CyanBand = 10,
/*! Magenta band of CMYK image */ MagentaBand = 11,
/*! Yellow band of CMYK image */ YellowBand = 12,
/*! Black band of CMLY image */ BlackBand = 13,
/*! Y Luminance */ YCbCr_YBand = 14,
/*! Cb Chroma */ YCbCr_CbBand = 15,
/*! Cr Chroma */ YCbCr_CrBand = 16,
/*! Max current value */ ColorInterpretationMax = 16
};
QgsRasterDataProvider();
@ -164,23 +164,23 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
// TODO: Get the file masks supported by this provider, suitable for feeding into the file open dialog box
/** Returns data type for the band specified by number */
virtual int dataType ( int bandNo ) const
virtual int dataType( int bandNo ) const
{
return srcDataType ( bandNo );
return srcDataType( bandNo );
}
/** Returns source data type for the band specified by number,
* source data type may be shorter than dataType
* source data type may be shorter than dataType
*/
virtual int srcDataType ( int bandNo ) const
virtual int srcDataType( int bandNo ) const
{
return QgsRasterDataProvider::UnknownDataType;
}
int typeSize ( int dataType ) const
int typeSize( int dataType ) const
{
// modified copy from GDAL
switch( dataType )
switch ( dataType )
{
case Byte:
return 8;
@ -210,24 +210,27 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
return 0;
}
}
int dataTypeSize ( int bandNo ) const
int dataTypeSize( int bandNo ) const
{
return typeSize ( dataType ( bandNo ) );
return typeSize( dataType( bandNo ) );
}
/** Get numbur of bands */
virtual int bandCount() const {
virtual int bandCount() const
{
return 1;
}
/** Returns data type for the band specified by number */
virtual int colorInterpretation ( int theBandNo ) const {
virtual int colorInterpretation( int theBandNo ) const
{
return QgsRasterDataProvider::UndefinedColorInterpretation;
}
QString colorName ( int colorInterpretation ) const {
QString colorName( int colorInterpretation ) const
{
// Modified copy from GDAL
switch( colorInterpretation )
switch ( colorInterpretation )
{
case UndefinedColorInterpretation:
return "Undefined";
@ -285,23 +288,24 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
}
}
/** Reload data (data could change) */
virtual bool reload ( ) { return true; }
virtual bool reload( ) { return true; }
virtual QString colorInterpretationName ( int theBandNo ) const {
return colorName ( colorInterpretation ( theBandNo ) );
virtual QString colorInterpretationName( int theBandNo ) const
{
return colorName( colorInterpretation( theBandNo ) );
}
/** Get block size */
virtual int xBlockSize() const { return 0; }
virtual int yBlockSize() const { return 0; }
/** Get raster size */
virtual int xSize() const { return 0; }
virtual int ySize() const { return 0; }
/** read block of data */
// TODO clarify what happens on the last block (the part outside raster)
virtual void readBlock( int bandNo, int xBlock, int yBlock, void *data ){}
virtual void readBlock( int bandNo, int xBlock, int yBlock, void *data ) {}
/** read block of data using give extent and size */
virtual void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, void *data ) {};
@ -312,30 +316,31 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
/** value representing null data */
virtual double noDataValue() const { return 0; }
virtual double minimumValue(int bandNo)const { return 0; }
virtual double maximumValue(int bandNo)const { return 0; }
virtual double minimumValue( int bandNo )const { return 0; }
virtual double maximumValue( int bandNo )const { return 0; }
virtual QList<QgsColorRampShader::ColorRampItem> colorTable(int bandNo)const { return QList<QgsColorRampShader::ColorRampItem>(); }
virtual QList<QgsColorRampShader::ColorRampItem> colorTable( int bandNo )const { return QList<QgsColorRampShader::ColorRampItem>(); }
// Defined in parent
/** \brief Returns the sublayers of this layer - Useful for providers that manage their own layers, such as WMS */
virtual QStringList subLayers() const {
virtual QStringList subLayers() const
{
return QStringList();
}
/** \brief Populate the histogram vector for a given band */
virtual void populateHistogram( int theBandNoInt,
QgsRasterBandStats & theBandStats,
int theBinCountInt = 256,
bool theIgnoreOutOfRangeFlag = true,
bool theThoroughBandScanFlag = false
) {};
QgsRasterBandStats & theBandStats,
int theBinCountInt = 256,
bool theIgnoreOutOfRangeFlag = true,
bool theThoroughBandScanFlag = false
) {};
/** \brief Create pyramid overviews */
virtual QString buildPyramids( const QList<QgsRasterPyramid> & thePyramidList,
const QString & theResamplingMethod = "NEAREST",
bool theTryInternalFlag = false ) { return "FAILED_NOT_SUPPORTED"; };
const QString & theResamplingMethod = "NEAREST",
bool theTryInternalFlag = false ) { return "FAILED_NOT_SUPPORTED"; };
/** \brief Accessor for ths raster layers pyramid list. A pyramid list defines the
* POTENTIAL pyramids that can be in a raster. To know which of the pyramid layers
@ -346,7 +351,7 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
/** \brief helper function to create zero padded band names */
QString generateBandName( int theBandNumber )
QString generateBandName( int theBandNumber )
{
return tr( "Band" ) + QString( " %1" ) .arg( theBandNumber, 1 + ( int ) log10(( float ) bandCount() ), 10, QChar( '0' ) );
}

View File

@ -22,73 +22,78 @@
#include "qgsrasterprojector.h"
#include "qgscoordinatetransform.h"
QgsRasterProjector::QgsRasterProjector (
QgsCoordinateReferenceSystem theSrcCRS,
QgsCoordinateReferenceSystem theDestCRS,
QgsRectangle theDestExtent,
QgsRasterProjector::QgsRasterProjector(
QgsCoordinateReferenceSystem theSrcCRS,
QgsCoordinateReferenceSystem theDestCRS,
QgsRectangle theDestExtent,
int theDestRows, int theDestCols,
double theMaxSrcXRes, double theMaxSrcYRes )
: mSrcCRS ( theSrcCRS )
, mDestCRS ( theDestCRS )
, mDestExtent ( theDestExtent )
, mDestRows ( theDestRows ), mDestCols ( theDestCols )
, mMaxSrcXRes ( theMaxSrcXRes), mMaxSrcYRes ( theMaxSrcYRes )
: mSrcCRS( theSrcCRS )
, mDestCRS( theDestCRS )
, mDestExtent( theDestExtent )
, mDestRows( theDestRows ), mDestCols( theDestCols )
, mMaxSrcXRes( theMaxSrcXRes ), mMaxSrcYRes( theMaxSrcYRes )
{
QgsDebugMsg("Entered");
QgsDebugMsg("theDestExtent = " + theDestExtent.toString() );
QgsDebugMsg( "Entered" );
QgsDebugMsg( "theDestExtent = " + theDestExtent.toString() );
// reverse transformation
mCoordinateTransform = new QgsCoordinateTransform( theDestCRS, theSrcCRS );
mDestXRes = mDestExtent.width() / (mDestCols);
mDestYRes = mDestExtent.height() / (mDestRows);
mDestXRes = mDestExtent.width() / ( mDestCols );
mDestYRes = mDestExtent.height() / ( mDestRows );
// Calculate tolerance
// TODO: Think it over better
// Note: we are checking on matrix each even point, that means taht the real error
// in that moment is approximately half size
// Note: we are checking on matrix each even point, that means taht the real error
// in that moment is approximately half size
double myDestRes = mDestXRes < mDestYRes ? mDestXRes : mDestYRes;
mSqrTolerance = myDestRes * myDestRes;
// Initialize the matrix by corners and middle points
mCPCols = mCPRows = 3;
for ( int i = 0; i < mCPRows; i++) {
for ( int i = 0; i < mCPRows; i++ )
{
QList<QgsPoint> myRow;
myRow.append( QgsPoint() );
myRow.append( QgsPoint() );
myRow.append( QgsPoint() );
mCPMatrix.insert(i, myRow );
mCPMatrix.insert( i, myRow );
}
for ( int i = 0; i < mCPRows; i++) {
for ( int i = 0; i < mCPRows; i++ )
{
calcRow( i );
}
while (true)
while ( true )
{
bool myColsOK = checkCols();
if ( !myColsOK ) {
if ( !myColsOK )
{
insertRows();
}
bool myRowsOK = checkRows();
if ( !myRowsOK ) {
if ( !myRowsOK )
{
insertCols();
}
if ( myColsOK && myRowsOK ) {
QgsDebugMsg("CP matrix within tolerance");
break;
}
// What is the maximum reasonable size of transformatio matrix?
// TODO: consider better when to break - ratio
if ( mCPRows * mCPCols > 0.25 * mDestRows * mDestCols )
if ( myColsOK && myRowsOK )
{
QgsDebugMsg("Too large CP matrix");
QgsDebugMsg( "CP matrix within tolerance" );
break;
}
// What is the maximum reasonable size of transformatio matrix?
// TODO: consider better when to break - ratio
if ( mCPRows * mCPCols > 0.25 * mDestRows * mDestCols )
{
QgsDebugMsg( "Too large CP matrix" );
break;
}
}
QgsDebugMsg( QString("CPMatrix size: mCPRows = %1 mCPCols = %2").arg(mCPRows).arg(mCPCols) );
mDestRowsPerMatrixRow = (float)mDestRows / (mCPRows - 1);
mDestColsPerMatrixCol = (float)mDestCols / (mCPCols - 1);
QgsDebugMsg( QString( "CPMatrix size: mCPRows = %1 mCPCols = %2" ).arg( mCPRows ).arg( mCPCols ) );
mDestRowsPerMatrixRow = ( float )mDestRows / ( mCPRows - 1 );
mDestColsPerMatrixCol = ( float )mDestCols / ( mCPCols - 1 );
QgsDebugMsg( "CPMatrix:\n" + cpToString() );
@ -98,47 +103,51 @@ QgsRasterProjector::QgsRasterProjector (
mSrcXRes = mSrcExtent.height() / mSrcRows;
mSrcYRes = mSrcExtent.width() / mSrcCols;
// init helper points
// init helper points
pHelperTop = new QgsPoint[mDestCols];
pHelperBottom = new QgsPoint[mDestCols];
calcHelper ( 0, pHelperTop );
calcHelper ( 1, pHelperBottom );
calcHelper( 0, pHelperTop );
calcHelper( 1, pHelperBottom );
mHelperTopRow = 0;
}
QgsRasterProjector::~QgsRasterProjector ()
QgsRasterProjector::~QgsRasterProjector()
{
delete mCoordinateTransform;
}
void QgsRasterProjector::calcSrcExtent ()
void QgsRasterProjector::calcSrcExtent()
{
/* Run around the mCPMatrix and find source extent */
QgsPoint myPoint = mCPMatrix[0][0];
mSrcExtent = QgsRectangle ( myPoint.x(), myPoint.y(), myPoint.x(), myPoint.y() );
for ( int i = 0; i < mCPRows; i++) {
mSrcExtent = QgsRectangle( myPoint.x(), myPoint.y(), myPoint.x(), myPoint.y() );
for ( int i = 0; i < mCPRows; i++ )
{
myPoint = mCPMatrix[i][0];
mSrcExtent.combineExtentWith ( myPoint.x(), myPoint.y() );
mSrcExtent.combineExtentWith( myPoint.x(), myPoint.y() );
myPoint = mCPMatrix[i][mCPCols-1];
mSrcExtent.combineExtentWith ( myPoint.x(), myPoint.y() );
mSrcExtent.combineExtentWith( myPoint.x(), myPoint.y() );
}
for ( int i = 1; i < mCPCols-1; i++) {
for ( int i = 1; i < mCPCols - 1; i++ )
{
myPoint = mCPMatrix[0][i];
mSrcExtent.combineExtentWith ( myPoint.x(), myPoint.y() );
mSrcExtent.combineExtentWith( myPoint.x(), myPoint.y() );
myPoint = mCPMatrix[mCPRows-1][i];
mSrcExtent.combineExtentWith ( myPoint.x(), myPoint.y() );
mSrcExtent.combineExtentWith( myPoint.x(), myPoint.y() );
}
// Expand a bit to avoid possible approx coords falling out because of representation error
QgsDebugMsg( "mSrcExtent = " + mSrcExtent.toString() );
QgsDebugMsg( "mSrcExtent = " + mSrcExtent.toString() );
}
QString QgsRasterProjector::cpToString()
{
QString myString;
for ( int i = 0; i < mCPRows; i++) {
for ( int i = 0; i < mCPRows; i++ )
{
if ( i > 0 ) myString += "\n";
for ( int j = 0; j < mCPCols; j++) {
for ( int j = 0; j < mCPCols; j++ )
{
if ( j > 0 ) myString += " ";
QgsPoint myPoint = mCPMatrix[i][j];
myString += myPoint.toString();
@ -147,114 +156,118 @@ QString QgsRasterProjector::cpToString()
return myString;
}
void QgsRasterProjector::calcSrcRowsCols ()
void QgsRasterProjector::calcSrcRowsCols()
{
// Wee need to calculate minimum cell size in the source
// Wee need to calculate minimum cell size in the source
// TODO: Think it over better, what is the right source resolution?
// Taking distances between cell centers projected to source along source
// Taking distances between cell centers projected to source along source
// axis would result in very high resolution
// TODO: different resolution for rows and cols ?
// For now, we take cell sizes projected to source but not to source axes
double myDestColsPerMatrixCell = mDestCols / mCPCols;
double myDestRowsPerMatrixCell = mDestRows / mCPRows;
QgsDebugMsg( QString("myDestColsPerMatrixCell = %1 myDestRowsPerMatrixCell = %2" ).arg ( myDestColsPerMatrixCell ).arg( myDestRowsPerMatrixCell ) );
QgsDebugMsg( QString( "myDestColsPerMatrixCell = %1 myDestRowsPerMatrixCell = %2" ).arg( myDestColsPerMatrixCell ).arg( myDestRowsPerMatrixCell ) );
double myMinSize = DBL_MAX;
for ( int i = 0; i < mCPRows-1; i++) {
for ( int j = 0; j < mCPCols-1; j++) {
for ( int i = 0; i < mCPRows - 1; i++ )
{
for ( int j = 0; j < mCPCols - 1; j++ )
{
QgsPoint myPointA = mCPMatrix[i][j];
QgsPoint myPointB = mCPMatrix[i][j+1];
QgsPoint myPointC = mCPMatrix[i+1][j];
double mySize = sqrt(myPointA.sqrDist( myPointB )) / myDestColsPerMatrixCell;
double mySize = sqrt( myPointA.sqrDist( myPointB ) ) / myDestColsPerMatrixCell;
if ( mySize < myMinSize ) { myMinSize = mySize; }
mySize = sqrt(myPointA.sqrDist( myPointC )) / myDestRowsPerMatrixCell;
mySize = sqrt( myPointA.sqrDist( myPointC ) ) / myDestRowsPerMatrixCell;
if ( mySize < myMinSize ) { myMinSize = mySize; }
}
}
// Make it a bit higher resolution
// TODO: find the best coefficient, attention, increasing resolution for WMS
// is changing WMS content
myMinSize *= 0.75;
QgsDebugMsg( QString("mMaxSrcXRes = %1 mMaxSrcYRes = %2" ).arg ( mMaxSrcXRes ).arg( mMaxSrcYRes ) );
// Make it a bit higher resolution
// TODO: find the best coefficient, attention, increasing resolution for WMS
// is changing WMS content
myMinSize *= 0.75;
QgsDebugMsg( QString( "mMaxSrcXRes = %1 mMaxSrcYRes = %2" ).arg( mMaxSrcXRes ).arg( mMaxSrcYRes ) );
// mMaxSrcXRes, mMaxSrcYRes may be 0 - no limit (WMS)
double myMinXSize = mMaxSrcXRes > myMinSize ? mMaxSrcXRes : myMinSize;
double myMinYSize = mMaxSrcYRes > myMinSize ? mMaxSrcYRes : myMinSize;
QgsDebugMsg( QString("myMinXSize = %1 myMinYSize = %2" ).arg ( myMinXSize ).arg( myMinYSize ) );
QgsDebugMsg( QString("mSrcExtent.width = %1 mSrcExtent.height = %2" ).arg ( mSrcExtent.width() ).arg( mSrcExtent.height() ) );
mSrcRows = (int) ceil ( mSrcExtent.height() / myMinYSize );
mSrcCols = (int) ceil ( mSrcExtent.width() / myMinXSize );
QgsDebugMsg( QString( "myMinXSize = %1 myMinYSize = %2" ).arg( myMinXSize ).arg( myMinYSize ) );
QgsDebugMsg( QString( "mSrcExtent.width = %1 mSrcExtent.height = %2" ).arg( mSrcExtent.width() ).arg( mSrcExtent.height() ) );
mSrcRows = ( int ) ceil( mSrcExtent.height() / myMinYSize );
mSrcCols = ( int ) ceil( mSrcExtent.width() / myMinXSize );
QgsDebugMsg( QString("mSrcRows = %1 mSrcCols = %2").arg(mSrcRows).arg(mSrcCols) );
QgsDebugMsg( QString( "mSrcRows = %1 mSrcCols = %2" ).arg( mSrcRows ).arg( mSrcCols ) );
}
inline void QgsRasterProjector::destPointOnCPMatrix ( int theRow, int theCol, double *theX, double *theY )
inline void QgsRasterProjector::destPointOnCPMatrix( int theRow, int theCol, double *theX, double *theY )
{
*theX = mDestExtent.xMinimum() + theCol * mDestExtent.width() / (mCPCols-1);
*theY = mDestExtent.yMaximum() - theRow * mDestExtent.height() / (mCPRows-1);
*theX = mDestExtent.xMinimum() + theCol * mDestExtent.width() / ( mCPCols - 1 );
*theY = mDestExtent.yMaximum() - theRow * mDestExtent.height() / ( mCPRows - 1 );
}
inline int QgsRasterProjector::matrixRow ( int theDestRow )
inline int QgsRasterProjector::matrixRow( int theDestRow )
{
return (int) ( floor ( (theDestRow + 0.5) / mDestRowsPerMatrixRow ) );
return ( int )( floor(( theDestRow + 0.5 ) / mDestRowsPerMatrixRow ) );
}
inline int QgsRasterProjector::matrixCol ( int theDestCol )
inline int QgsRasterProjector::matrixCol( int theDestCol )
{
return (int) ( floor ( (theDestCol + 0.5) / mDestColsPerMatrixCol ) );
return ( int )( floor(( theDestCol + 0.5 ) / mDestColsPerMatrixCol ) );
}
QgsPoint QgsRasterProjector::srcPoint ( int theDestRow, int theCol )
QgsPoint QgsRasterProjector::srcPoint( int theDestRow, int theCol )
{
return QgsPoint();
}
void QgsRasterProjector::calcHelper ( int theMatrixRow, QgsPoint *thePoints )
void QgsRasterProjector::calcHelper( int theMatrixRow, QgsPoint *thePoints )
{
// TODO?: should we also precalc dest cell center coordinates for x and y?
for ( int myDestCol = 0; myDestCol < mDestCols; myDestCol++) {
for ( int myDestCol = 0; myDestCol < mDestCols; myDestCol++ )
{
double myDestX = mDestExtent.xMinimum() + ( myDestCol + 0.5 ) * mDestXRes;
int myMatrixCol = matrixCol ( myDestCol );
int myMatrixCol = matrixCol( myDestCol );
double myDestXMin, myDestYMin, myDestXMax, myDestYMax;
destPointOnCPMatrix ( theMatrixRow, myMatrixCol, &myDestXMin, &myDestYMin );
destPointOnCPMatrix ( theMatrixRow, myMatrixCol + 1, &myDestXMax, &myDestYMax );
destPointOnCPMatrix( theMatrixRow, myMatrixCol, &myDestXMin, &myDestYMin );
destPointOnCPMatrix( theMatrixRow, myMatrixCol + 1, &myDestXMax, &myDestYMax );
double xfrac = ( myDestX - myDestXMin ) / ( myDestXMax - myDestXMin );
QgsPoint &mySrcPoint0 = mCPMatrix[theMatrixRow][myMatrixCol];
QgsPoint &mySrcPoint1 = mCPMatrix[theMatrixRow][myMatrixCol+1];
double s = mySrcPoint0.x() + ( mySrcPoint1.x() - mySrcPoint0.x() ) * xfrac;
double t = mySrcPoint0.y() + ( mySrcPoint1.y() - mySrcPoint0.y() ) * xfrac;
double t = mySrcPoint0.y() + ( mySrcPoint1.y() - mySrcPoint0.y() ) * xfrac;
thePoints[myDestCol].setX ( s );
thePoints[myDestCol].setY ( t );
thePoints[myDestCol].setX( s );
thePoints[myDestCol].setY( t );
}
}
void QgsRasterProjector::nextHelper ()
void QgsRasterProjector::nextHelper()
{
QgsPoint *tmp;
tmp = pHelperTop;
pHelperTop = pHelperBottom;
pHelperBottom = tmp;
calcHelper ( mHelperTopRow+2, pHelperBottom );
calcHelper( mHelperTopRow + 2, pHelperBottom );
mHelperTopRow++;
}
void QgsRasterProjector::srcRowCol ( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol )
void QgsRasterProjector::srcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol )
{
int myMatrixRow = matrixRow ( theDestRow );
int myMatrixCol = matrixCol ( theDestCol );
int myMatrixRow = matrixRow( theDestRow );
int myMatrixCol = matrixCol( theDestCol );
if ( myMatrixRow > mHelperTopRow ) {
if ( myMatrixRow > mHelperTopRow )
{
// TODO: make it more robust (for random, not sequential reading)
nextHelper ();
nextHelper();
}
double myDestY = mDestExtent.yMaximum() - ( theDestRow + 0.5 ) * mDestYRes;
@ -263,11 +276,11 @@ void QgsRasterProjector::srcRowCol ( int theDestRow, int theDestCol, int *theSrc
// TODO: use some kind of cache of values which can be reused
double myDestXMin, myDestYMin, myDestXMax, myDestYMax;
destPointOnCPMatrix ( myMatrixRow + 1, myMatrixCol, &myDestXMin, &myDestYMin );
destPointOnCPMatrix ( myMatrixRow, myMatrixCol + 1, &myDestXMax, &myDestYMax );
destPointOnCPMatrix( myMatrixRow + 1, myMatrixCol, &myDestXMin, &myDestYMin );
destPointOnCPMatrix( myMatrixRow, myMatrixCol + 1, &myDestXMax, &myDestYMax );
double yfrac = ( myDestY - myDestYMin ) / ( myDestYMax - myDestYMin );
QgsPoint &myTop = pHelperTop[theDestCol];
QgsPoint &myBot = pHelperBottom[theDestCol];
@ -279,87 +292,101 @@ void QgsRasterProjector::srcRowCol ( int theDestRow, int theDestCol, int *theSrc
double ty = myTop.y();
double bx = myBot.x();
double by = myBot.y();
double mySrcX = bx + (tx - bx) * yfrac;
double mySrcY = by + (ty - by) * yfrac;
double mySrcX = bx + ( tx - bx ) * yfrac;
double mySrcY = by + ( ty - by ) * yfrac;
// TODO: check again cell selection (coor is in the middle)
*theSrcRow = (int) floor ( ( mSrcExtent.yMaximum() - mySrcY ) / mSrcXRes );
*theSrcCol = (int) floor ( ( mySrcX - mSrcExtent.xMinimum() ) / mSrcYRes );
*theSrcRow = ( int ) floor(( mSrcExtent.yMaximum() - mySrcY ) / mSrcXRes );
*theSrcCol = ( int ) floor(( mySrcX - mSrcExtent.xMinimum() ) / mSrcYRes );
assert ( *theSrcRow < mSrcRows );
assert ( *theSrcCol < mSrcCols );
assert( *theSrcRow < mSrcRows );
assert( *theSrcCol < mSrcCols );
}
void QgsRasterProjector::insertRows()
{
for ( int r = 0; r < mCPRows-1; r++) {
for ( int r = 0; r < mCPRows - 1; r++ )
{
QList<QgsPoint> myRow;
for ( int c = 0; c < mCPCols; c++) {
for ( int c = 0; c < mCPCols; c++ )
{
myRow.append( QgsPoint() );
}
QgsDebugMsg( QString("insert new row at %1" ).arg(1+r*2) );
mCPMatrix.insert( 1+r*2, myRow );
QgsDebugMsg( QString( "insert new row at %1" ).arg( 1 + r*2 ) );
mCPMatrix.insert( 1 + r*2, myRow );
}
mCPRows += mCPRows-1;
for ( int r = 1; r < mCPRows-1; r += 2) {
mCPRows += mCPRows - 1;
for ( int r = 1; r < mCPRows - 1; r += 2 )
{
calcRow( r );
}
}
void QgsRasterProjector::insertCols()
{
for ( int r = 0; r < mCPRows; r++) {
for ( int r = 0; r < mCPRows; r++ )
{
QList<QgsPoint> myRow;
for ( int c = 0; c < mCPCols-1; c++) {
mCPMatrix[r].insert( 1+c*2, QgsPoint() );
for ( int c = 0; c < mCPCols - 1; c++ )
{
mCPMatrix[r].insert( 1 + c*2, QgsPoint() );
}
}
mCPCols += mCPCols-1;
for ( int c = 1; c < mCPCols-1; c += 2) {
mCPCols += mCPCols - 1;
for ( int c = 1; c < mCPCols - 1; c += 2 )
{
calcCol( c );
}
}
void QgsRasterProjector::calcCP ( int theRow, int theCol )
void QgsRasterProjector::calcCP( int theRow, int theCol )
{
double myDestX, myDestY;
destPointOnCPMatrix ( theRow, theCol, &myDestX, &myDestY );
QgsPoint myDestPoint ( myDestX, myDestY );
destPointOnCPMatrix( theRow, theCol, &myDestX, &myDestY );
QgsPoint myDestPoint( myDestX, myDestY );
mCPMatrix[theRow][theCol] = mCoordinateTransform->transform( myDestPoint );
mCPMatrix[theRow][theCol] = mCoordinateTransform->transform( myDestPoint );
}
bool QgsRasterProjector::calcRow( int theRow )
{
QgsDebugMsg( QString("theRow = %1").arg(theRow) );
for ( int i = 0; i < mCPCols; i++) {
calcCP ( theRow, i );
QgsDebugMsg( QString( "theRow = %1" ).arg( theRow ) );
for ( int i = 0; i < mCPCols; i++ )
{
calcCP( theRow, i );
}
return true;
}
bool QgsRasterProjector::calcCol( int theCol )
{
QgsDebugMsg( QString("theCol = %1").arg(theCol) );
for ( int i = 0; i < mCPRows; i++) {
calcCP ( i, theCol );
QgsDebugMsg( QString( "theCol = %1" ).arg( theCol ) );
for ( int i = 0; i < mCPRows; i++ )
{
calcCP( i, theCol );
}
return true;
}
bool QgsRasterProjector::checkCols()
{
for ( int c = 0; c < mCPCols; c++) {
for ( int r = 1; r < mCPRows-1; r += 2 ) {
for ( int c = 0; c < mCPCols; c++ )
{
for ( int r = 1; r < mCPRows - 1; r += 2 )
{
double myDestX, myDestY;
destPointOnCPMatrix ( r, c, &myDestX, &myDestY );
QgsPoint myDestPoint ( myDestX, myDestY );
destPointOnCPMatrix( r, c, &myDestX, &myDestY );
QgsPoint myDestPoint( myDestX, myDestY );
QgsPoint mySrcPoint1 = mCPMatrix[r-1][c];
QgsPoint mySrcPoint2 = mCPMatrix[r][c];
QgsPoint mySrcPoint3 = mCPMatrix[r+1][c];
QgsPoint mySrcApprox( ( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, (mySrcPoint1.y() + mySrcPoint3.y() ) / 2 );
QgsPoint mySrcApprox(( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, ( mySrcPoint1.y() + mySrcPoint3.y() ) / 2 );
QgsPoint myDestApprox = mCoordinateTransform->transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
double mySqrDist = myDestApprox.sqrDist( myDestPoint );
if ( mySqrDist > mSqrTolerance ) { return false; }
@ -370,17 +397,19 @@ bool QgsRasterProjector::checkCols()
bool QgsRasterProjector::checkRows()
{
for ( int r = 0; r < mCPRows; r++) {
for ( int c = 1; c < mCPCols-1; c += 2 ) {
for ( int r = 0; r < mCPRows; r++ )
{
for ( int c = 1; c < mCPCols - 1; c += 2 )
{
double myDestX, myDestY;
destPointOnCPMatrix ( r, c, &myDestX, &myDestY );
destPointOnCPMatrix( r, c, &myDestX, &myDestY );
QgsPoint myDestPoint ( myDestX, myDestY );
QgsPoint myDestPoint( myDestX, myDestY );
QgsPoint mySrcPoint1 = mCPMatrix[r][c-1];
QgsPoint mySrcPoint2 = mCPMatrix[r][c];
QgsPoint mySrcPoint3 = mCPMatrix[r][c+1];
QgsPoint mySrcApprox( ( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, (mySrcPoint1.y() + mySrcPoint3.y() ) / 2 );
QgsPoint mySrcApprox(( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, ( mySrcPoint1.y() + mySrcPoint3.y() ) / 2 );
QgsPoint myDestApprox = mCoordinateTransform->transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
double mySqrDist = myDestApprox.sqrDist( myDestPoint );
if ( mySqrDist > mSqrTolerance ) { return false; }

View File

@ -37,19 +37,19 @@
//class QgsRectangle;
class QgsPoint;
//class CORE_EXPORT QgsRasterProjector
class QgsRasterProjector
//class CORE_EXPORT QgsRasterProjector
class QgsRasterProjector
{
// Q_OBJECT
public:
/** \brief QgsRasterProjector implements approximate projection support for
/** \brief QgsRasterProjector implements approximate projection support for
* it calculates grid of points in source CRS for target CRS + extent
* which are used to calculate affine transformation matrices.
* */
QgsRasterProjector(
QgsCoordinateReferenceSystem theSrcCRS,
QgsCoordinateReferenceSystem theDestCRS,
QgsRectangle theDestExtent,
QgsRasterProjector(
QgsCoordinateReferenceSystem theSrcCRS,
QgsCoordinateReferenceSystem theDestCRS,
QgsRectangle theDestExtent,
int theDestRows, int theDestCols,
double theMaxSrcXRes, double theMaxSrcYRes
);
@ -59,17 +59,17 @@ class QgsRasterProjector
/** \brief get destination point for _current_ destination position */
void destPointOnCPMatrix ( int theRow, int theCol, double *theX, double *theY );
void destPointOnCPMatrix( int theRow, int theCol, double *theX, double *theY );
/** \brief Get matrix upper left row/col indexes for destination row/col */
int matrixRow ( int theDestRow );
int matrixCol ( int theDestCol );
int matrixRow( int theDestRow );
int matrixCol( int theDestCol );
/** \brief get destination point for _current_ matrix position */
QgsPoint srcPoint ( int theRow, int theCol );
QgsPoint srcPoint( int theRow, int theCol );
/** \brief Get source row and column indexes for current source extent and resolution */
void srcRowCol ( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol );
void srcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol );
/** \brief insert rows to matrix */
void insertRows();
@ -78,7 +78,7 @@ class QgsRasterProjector
void insertCols();
/* calculate single control point in current matrix */
void calcCP ( int theRow, int theCol );
void calcCP( int theRow, int theCol );
/** \brief calculate matrix row */
bool calcRow( int theRow );
@ -90,25 +90,25 @@ class QgsRasterProjector
void calcSrcExtent();
/** \brief calculate minimum source width and height */
void calcSrcRowsCols ();
void calcSrcRowsCols();
/** \brief check error along columns
* returns true if within threshold */
bool checkCols ();
bool checkCols();
/** \brief check error along rows
* returns true if within threshold */
bool checkRows ();
bool checkRows();
/** Calculate array of src helper points */
//void calcHelper ( int theMatrixRow, QList<QgsPoint> *thePoints );
void calcHelper ( int theMatrixRow, QgsPoint *thePoints );
void calcHelper( int theMatrixRow, QgsPoint *thePoints );
/** Calc / switch helper */
void nextHelper();
/** get source extent */
QgsRectangle srcExtent() { return mSrcExtent; }
QgsRectangle srcExtent() { return mSrcExtent; }
/** get/set source width/height */
int srcRows() { return mSrcRows; }

View File

@ -6,7 +6,7 @@ copyright : (C) 2003 by Tim Sutton, Steve Halasz and Gary E.Sherman
email : tim at linfiniti.com
***************************************************************************/
/* **************************************************************************
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
@ -96,7 +96,7 @@ QgsRasterLayer::QgsRasterLayer(
, mHeight( std::numeric_limits<int>::max() )
, mInvertColor( false )
{
QgsDebugMsg("Entered");
QgsDebugMsg( "Entered" );
// TODO, call constructor with provider key for now
init();
@ -136,7 +136,7 @@ QgsRasterLayer::QgsRasterLayer( int dummy,
init();
// if we're given a provider type, try to create and bind one to this layer
bool loadDefaultStyleFlag = false ; // ???
setDataProvider( providerKey, layers, styles, format, crs, loadDefaultStyleFlag);
setDataProvider( providerKey, layers, styles, format, crs, loadDefaultStyleFlag );
// Default for the popup menu
// TODO: popMenu = 0;
@ -178,7 +178,7 @@ QgsRasterLayer::~QgsRasterLayer()
/////////////////////////////////////////////////////////
/**
Builds the list of file filter strings to later be used by
QgisApp::addRasterLayer()
QgisApp::addRasterLayer()
We query GDAL for a list of supported raster formats; we then build
a list of file filter strings from that list. We return a string
that contains this list that is suitable for use in a
@ -188,17 +188,18 @@ void QgsRasterLayer::buildSupportedRasterFileFilter( QString & theFileFiltersStr
{
QgsDebugMsg( "Entered" );
QLibrary* myLib = QgsRasterLayer::loadProviderLibrary( "gdal" );
if ( !myLib )
if ( !myLib )
{
QgsDebugMsg( "Could not load gdal provider library" );
return;
}
buildsupportedrasterfilefilter_t *pBuild = ( buildsupportedrasterfilefilter_t * ) cast_to_fptr( myLib->resolve( "buildSupportedRasterFileFilter" ) );
if ( ! pBuild ) {
QgsDebugMsg( "Could not resolve buildSupportedRasterFileFilter in gdal provider library");
if ( ! pBuild )
{
QgsDebugMsg( "Could not resolve buildSupportedRasterFileFilter in gdal provider library" );
return;
}
pBuild( theFileFiltersString );
delete myLib;
}
@ -208,20 +209,21 @@ void QgsRasterLayer::buildSupportedRasterFileFilter( QString & theFileFiltersStr
*/
bool QgsRasterLayer::isValidRasterFileName( QString const & theFileNameQString, QString & retErrMsg )
{
QLibrary* myLib = QgsRasterLayer::loadProviderLibrary( "gdal");
if ( !myLib )
QLibrary* myLib = QgsRasterLayer::loadProviderLibrary( "gdal" );
if ( !myLib )
{
QgsDebugMsg( "Could not load gdal provider library" );
return false;
}
isvalidrasterfilename_t *pValid = ( isvalidrasterfilename_t * ) cast_to_fptr( myLib->resolve( "isValidRasterFileName" ) );
if ( ! pValid ) {
QgsDebugMsg( "Could not resolve isValidRasterFileName in gdal provider library");
if ( ! pValid )
{
QgsDebugMsg( "Could not resolve isValidRasterFileName in gdal provider library" );
return false;
}
bool myIsValid = pValid( theFileNameQString, retErrMsg );
bool myIsValid = pValid( theFileNameQString, retErrMsg );
delete myLib;
return myIsValid;
}
@ -267,7 +269,7 @@ const QString QgsRasterLayer::bandName( int theBandNo )
{
if ( theBandNo <= mRasterStatsList.size() && theBandNo > 0 )
{
//vector starts at base 0, band counts at base1 !
//vector starts at base 0, band counts at base1!
return mRasterStatsList[theBandNo - 1].bandName;
}
else
@ -319,8 +321,8 @@ int QgsRasterLayer::bandNumber( QString const & theBandName )
*/
const QgsRasterBandStats QgsRasterLayer::bandStatistics( int theBandNo )
{
QgsDebugMsg( "theBandNo = " + QString::number(theBandNo) );
QgsDebugMsg( "mRasterType = " + QString::number(mRasterType) );
QgsDebugMsg( "theBandNo = " + QString::number( theBandNo ) );
QgsDebugMsg( "mRasterType = " + QString::number( mRasterType ) );
if ( mRasterType == ColorLayer )
{
// Statistics have no sense for ColorLayer
@ -369,7 +371,7 @@ const QgsRasterBandStats QgsRasterLayer::bandStatistics( int theBandNo )
//reset the main app progress bar
emit drawingProgress( 0, 0 );
int myDataType = mDataProvider->dataType ( theBandNo );
int myDataType = mDataProvider->dataType( theBandNo );
int myNXBlocks, myNYBlocks, myXBlockSize, myYBlockSize;
myXBlockSize = mDataProvider->xBlockSize();
@ -378,7 +380,7 @@ const QgsRasterBandStats QgsRasterLayer::bandStatistics( int theBandNo )
myNXBlocks = ( mDataProvider->xSize() + myXBlockSize - 1 ) / myXBlockSize;
myNYBlocks = ( mDataProvider->ySize() + myYBlockSize - 1 ) / myYBlockSize;
void *myData = CPLMalloc( myXBlockSize * myYBlockSize * ( mDataProvider->dataTypeSize(theBandNo ) / 8 ) );
void *myData = CPLMalloc( myXBlockSize * myYBlockSize * ( mDataProvider->dataTypeSize( theBandNo ) / 8 ) );
// unfortunately we need to make two passes through the data to calculate stddev
bool myFirstIterationFlag = true;
@ -544,7 +546,7 @@ const QgsRasterBandStats QgsRasterLayer::bandStatistics( QString const & theBand
QString QgsRasterLayer::buildPyramids( RasterPyramidList const & theRasterPyramidList,
QString const & theResamplingMethod, bool theTryInternalFlag )
{
return mDataProvider->buildPyramids( theRasterPyramidList, theResamplingMethod, theTryInternalFlag );
return mDataProvider->buildPyramids( theRasterPyramidList, theResamplingMethod, theTryInternalFlag );
}
@ -586,8 +588,8 @@ void QgsRasterLayer::computeMinimumMaximumEstimates( int theBand, double* theMin
if ( 0 < theBand && theBand <= ( int ) bandCount() )
{
theMinMax[0] = mDataProvider->minimumValue(theBand);
theMinMax[1] = mDataProvider->maximumValue(theBand);
theMinMax[0] = mDataProvider->minimumValue( theBand );
theMinMax[1] = mDataProvider->maximumValue( theBand );
}
}
@ -768,17 +770,17 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
const QgsMapToPixel& theQgsMapToPixel = rendererContext.mapToPixel();
const QgsRectangle& theViewExtent = rendererContext.extent();
QgsRectangle myProjectedViewExtent;
QgsRectangle myProjectedLayerExtent;
if ( rendererContext.coordinateTransform() )
if ( rendererContext.coordinateTransform() )
{
QgsDebugMsg( "coordinateTransform set -> project extents." );
myProjectedViewExtent = rendererContext.coordinateTransform()->transformBoundingBox (
rendererContext.extent() );
myProjectedLayerExtent = rendererContext.coordinateTransform()->transformBoundingBox (
mLayerExtent );
myProjectedViewExtent = rendererContext.coordinateTransform()->transformBoundingBox(
rendererContext.extent() );
myProjectedLayerExtent = rendererContext.coordinateTransform()->transformBoundingBox(
mLayerExtent );
}
else
{
@ -819,11 +821,13 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
QgsRasterViewPort *myRasterViewPort = new QgsRasterViewPort();
myRasterViewPort->mDrawnExtent = myRasterExtent;
if ( rendererContext.coordinateTransform() )
if ( rendererContext.coordinateTransform() )
{
myRasterViewPort->mSrcCRS = crs();
myRasterViewPort->mDestCRS = rendererContext.coordinateTransform()->destCRS();
} else {
}
else
{
myRasterViewPort->mSrcCRS = QgsCoordinateReferenceSystem(); // will be invalid
myRasterViewPort->mDestCRS = QgsCoordinateReferenceSystem(); // will be invalid
}
@ -835,38 +839,39 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
// align to output device grid, i.e. floor/ceil to integers
// TODO: this should only be done if paint device is raster - screen, image
// for other devices (pdf) it can have floating point origin
// we could use floating point for raster devices as well, but respecting the
// output device grid should make it more effective as the resampling is done in
// the provider anyway
if ( true )
// we could use floating point for raster devices as well, but respecting the
// output device grid should make it more effective as the resampling is done in
// the provider anyway
if ( true )
{
myRasterViewPort->topLeftPoint.setX( floor( myRasterViewPort->topLeftPoint.x() ) );
myRasterViewPort->topLeftPoint.setY( floor( myRasterViewPort->topLeftPoint.y() ) );
myRasterViewPort->bottomRightPoint.setX( ceil( myRasterViewPort->bottomRightPoint.x() ) );
myRasterViewPort->bottomRightPoint.setY( ceil( myRasterViewPort->bottomRightPoint.y() ) );
// recalc myRasterExtent to aligned values
myRasterExtent.set (
theQgsMapToPixel.toMapCoordinatesF ( myRasterViewPort->topLeftPoint.x(),
myRasterViewPort->bottomRightPoint.y() ),
theQgsMapToPixel.toMapCoordinatesF ( myRasterViewPort->bottomRightPoint.x(),
myRasterViewPort->topLeftPoint.y() )
myRasterExtent.set(
theQgsMapToPixel.toMapCoordinatesF( myRasterViewPort->topLeftPoint.x(),
myRasterViewPort->bottomRightPoint.y() ),
theQgsMapToPixel.toMapCoordinatesF( myRasterViewPort->bottomRightPoint.x(),
myRasterViewPort->topLeftPoint.y() )
);
}
myRasterViewPort->drawableAreaXDim = static_cast<int>( qAbs(( myRasterExtent.width() / theQgsMapToPixel.mapUnitsPerPixel() ) ));
myRasterViewPort->drawableAreaYDim = static_cast<int>( qAbs(( myRasterExtent.height() / theQgsMapToPixel.mapUnitsPerPixel() ) ));
myRasterViewPort->drawableAreaXDim = static_cast<int>( qAbs(( myRasterExtent.width() / theQgsMapToPixel.mapUnitsPerPixel() ) ) );
myRasterViewPort->drawableAreaYDim = static_cast<int>( qAbs(( myRasterExtent.height() / theQgsMapToPixel.mapUnitsPerPixel() ) ) );
//the drawable area can start to get very very large when you get down displaying 2x2 or smaller, this is becasue
//theQgsMapToPixel.mapUnitsPerPixel() is less then 1,
//so we will just get the pixel data and then render these special cases differently in paintImageToCanvas()
/*
#if 0
if ( 2 >= myRasterViewPort->clippedWidth && 2 >= myRasterViewPort->clippedHeight )
{
myRasterViewPort->drawableAreaXDim = myRasterViewPort->clippedWidth;
myRasterViewPort->drawableAreaYDim = myRasterViewPort->clippedHeight;
}
*/
#endif
QgsDebugMsgLevel( QString( "mapUnitsPerPixel = %1" ).arg( theQgsMapToPixel.mapUnitsPerPixel() ), 3 );
QgsDebugMsgLevel( QString( "mWidth = %1" ).arg( mWidth ), 3 );
QgsDebugMsgLevel( QString( "mHeight = %1" ).arg( mHeight ), 3 );
@ -882,7 +887,7 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
QgsDebugMsgLevel( QString( "drawableAreaXDim = %1" ).arg( myRasterViewPort->drawableAreaXDim ), 3 );
QgsDebugMsgLevel( QString( "drawableAreaYDim = %1" ).arg( myRasterViewPort->drawableAreaYDim ), 3 );
QgsDebugMsgLevel( "ReadXml: gray band name : " + mGrayBandName, 3 );
QgsDebugMsgLevel( "ReadXml: red band name : " + mRedBandName, 3 );
QgsDebugMsgLevel( "ReadXml: green band name : " + mGreenBandName, 3 );
@ -917,7 +922,7 @@ void QgsRasterLayer::draw( QPainter * theQPainter,
// procedure to use :
//
QgsDebugMsg( "mDrawingStyle = " + QString::number(mDrawingStyle) );
QgsDebugMsg( "mDrawingStyle = " + QString::number( mDrawingStyle ) );
switch ( mDrawingStyle )
{
// a "Gray" or "Undefined" layer drawn as a range of gray colors
@ -1055,7 +1060,7 @@ void QgsRasterLayer::draw( QPainter * theQPainter,
else
{
drawSingleBandColorData( theQPainter, theRasterViewPort,
theQgsMapToPixel, bandNumber( mGrayBandName ) );
theQgsMapToPixel, bandNumber( mGrayBandName ) );
break;
}
@ -1109,7 +1114,7 @@ QString QgsRasterLayer::drawingStyleAsString() const
}
/**
* @note Note implemented yet
* @note Not implemented yet
* @return always returns false
*/
bool QgsRasterLayer::hasCompatibleSymbology( const QgsMapLayer& theOther ) const
@ -1130,7 +1135,7 @@ bool QgsRasterLayer::hasStatistics( int theBandNo )
{
if ( theBandNo <= mRasterStatsList.size() && theBandNo > 0 )
{
//vector starts at base 0, band counts at base1 !
//vector starts at base 0, band counts at base1!
return mRasterStatsList[theBandNo - 1].statsGathered;
}
else
@ -1150,7 +1155,7 @@ bool QgsRasterLayer::identify( const QgsPoint& thePoint, QMap<QString, QString>&
QgsDebugMsg( "identify provider : " + mProviderKey ) ;
return ( mDataProvider->identify( thePoint, theResults ) );
}
}
/**
* @note The arbitraryness of the returned document is enforced by WMS standards up to at least v1.3.0
@ -1249,7 +1254,7 @@ QPixmap QgsRasterLayer::legendAsPixmap( bool theWithNameFlag )
//
// Get the adjusted matrix stats
//
QString myColorerpretation = mDataProvider->colorInterpretationName ( 1 );
QString myColorerpretation = mDataProvider->colorInterpretationName( 1 );
//
// Create the legend pixmap - note it is generated on the preadjusted stats
@ -1502,7 +1507,7 @@ QPixmap QgsRasterLayer::legendAsPixmap( int theLabelCount )
//
// Get the adjusted matrix stats
//
QString myColorerpretation = mDataProvider->colorInterpretationName ( 1 );
QString myColorerpretation = mDataProvider->colorInterpretationName( 1 );
QPixmap myLegendQPixmap; //will be initialised once we know what drawing style is active
QPainter myQPainter;
//
@ -1995,7 +2000,7 @@ QPixmap QgsRasterLayer::paletteAsPixmap( int theBandNumber )
//QList<QgsColorRampShader::ColorRampItem> myColorRampItemList = myShader.colorRampItemList();
//if ( readColorTable( 1, &myColorRampItemList ) )
QList<QgsColorRampShader::ColorRampItem> myColorRampItemList = mDataProvider->colorTable ( 1 );
QList<QgsColorRampShader::ColorRampItem> myColorRampItemList = mDataProvider->colorTable( 1 );
// TODO: add CT capability? It can depends on band (?)
if ( myColorRampItemList.size() > 0 )
{
@ -2047,7 +2052,7 @@ QPixmap QgsRasterLayer::paletteAsPixmap( int theBandNumber )
*/
void QgsRasterLayer::populateHistogram( int theBandNo, int theBinCount, bool theIgnoreOutOfRangeFlag, bool theHistogramEstimatedFlag )
{
QgsRasterBandStats myRasterBandStats = bandStatistics( theBandNo );
QgsRasterBandStats myRasterBandStats = bandStatistics( theBandNo );
mDataProvider->populateHistogram( theBandNo, myRasterBandStats, theBinCount, theIgnoreOutOfRangeFlag, theHistogramEstimatedFlag );
}
@ -2089,10 +2094,9 @@ void QgsRasterLayer::resetNoDataValue()
mValidNoDataValue = false;
if ( mDataProvider != NULL && mDataProvider->bandCount() > 0 )
{
int myRequestValid;
// TODO: add 'has null value' to capabilities
/*
#if 0
int myRequestValid;
myRequestValid = 1;
double myValue = mDataProvider->noDataValue();
@ -2104,11 +2108,11 @@ void QgsRasterLayer::resetNoDataValue()
{
setNoDataValue( -9999.0 );
mValidNoDataValue = false;
}
*/
setNoDataValue ( mDataProvider->noDataValue() );
mValidNoDataValue = mDataProvider->isNoDataValueValid();
#endif
setNoDataValue( mDataProvider->noDataValue() );
mValidNoDataValue = mDataProvider->isNoDataValueValid();
}
}
@ -2120,7 +2124,7 @@ void QgsRasterLayer::setBlueBandName( QString const & theBandName )
void QgsRasterLayer::init()
{
// keep this until mGeoTransform occurences are removed !
// keep this until mGeoTransform occurences are removed!
mGeoTransform[0] = 0;
mGeoTransform[1] = 1;
mGeoTransform[2] = 0;
@ -2158,7 +2162,7 @@ void QgsRasterLayer::init()
mLastViewPort.drawableAreaYDim = 0;
}
QLibrary* QgsRasterLayer::loadProviderLibrary( QString theProviderKey )
QLibrary* QgsRasterLayer::loadProviderLibrary( QString theProviderKey )
{
QgsDebugMsg( "theProviderKey = " + theProviderKey );
// load the plugin
@ -2185,7 +2189,7 @@ QLibrary* QgsRasterLayer::loadProviderLibrary( QString theProviderKey )
// load the data provider
QLibrary* myLib = new QLibrary( myLibPath );
QgsDebugMsg( "Library name is " + myLib->fileName() );
bool loaded = myLib->load();
@ -2199,7 +2203,7 @@ QLibrary* QgsRasterLayer::loadProviderLibrary( QString theProviderKey )
}
// This code should be shared also by vector layer -> move it to QgsMapLayer
QgsRasterDataProvider* QgsRasterLayer::loadProvider( QString theProviderKey, QString theDataSource )
QgsRasterDataProvider* QgsRasterLayer::loadProvider( QString theProviderKey, QString theDataSource )
{
QgsDebugMsg( "Entered" );
QLibrary* myLib = QgsRasterLayer::loadProviderLibrary( theProviderKey );
@ -2215,8 +2219,8 @@ QgsRasterDataProvider* QgsRasterLayer::loadProvider( QString theProviderKey, QSt
if ( !classFactory )
{
QgsLogger::warning( "QgsRasterLayer::setDataProvider: Cannot resolve the classFactory function" );
return NULL;
QgsLogger::warning( "QgsRasterLayer::setDataProvider: Cannot resolve the classFactory function" );
return NULL;
}
QgsDebugMsg( "Getting pointer to a mDataProvider object from the library" );
//XXX - This was a dynamic cast but that kills the Windows
@ -2240,8 +2244,9 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
QStringList const & layers,
QStringList const & styles,
QString const & format,
QString const & crs) {
setDataProvider ( provider, layers, styles, format, crs, false );
QString const & crs )
{
setDataProvider( provider, layers, styles, format, crs, false );
}
/** Copied from QgsVectorLayer::setDataProvider
@ -2257,7 +2262,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
// XXX should I check for and possibly delete any pre-existing providers?
// XXX How often will that scenario occur?
mProviderKey = provider;
mProviderKey = provider;
mValid = false; // assume the layer is invalid until we determine otherwise
// set the layer name (uppercase first character)
@ -2270,17 +2275,17 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
mBandCount = 0;
mRasterShader = new QgsRasterShader();
mDataProvider = QgsRasterLayer::loadProvider ( mProviderKey, mDataSource );
if ( !mDataProvider )
mDataProvider = QgsRasterLayer::loadProvider( mProviderKey, mDataSource );
if ( !mDataProvider )
{
return;
}
QgsDebugMsg( "Instantiated the data provider plugin"
+ QString( " with layer list of " ) + layers.join( ", " )
+ " and style list of " + styles.join( ", " )
+ " and format of " + format + " and CRS of " + crs );
QgsDebugMsg( "Instantiated the data provider plugin"
+ QString( " with layer list of " ) + layers.join( ", " )
+ " and style list of " + styles.join( ", " )
+ " and format of " + format + " and CRS of " + crs );
if ( ! mDataProvider->isValid() )
{
QgsLogger::warning( "QgsRasterLayer::setDataProvider: Data provider is invalid." );
@ -2307,7 +2312,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
mWidth = mDataProvider->xSize();
mHeight = mDataProvider->ySize();
// upper case the first letter of the layer name
QgsDebugMsg( "mLayerName: " + name() );
@ -2347,7 +2352,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
//Store the default color table
//readColorTable( i, &myRasterBandStats.colorTable );
QList<QgsColorRampShader::ColorRampItem> ct;
ct = mDataProvider->colorTable(i);
ct = mDataProvider->colorTable( i );
myRasterBandStats.colorTable = ct;
mRasterStatsList.push_back( myRasterBandStats );
@ -2366,8 +2371,8 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
//decide what type of layer this is...
//TODO Change this to look at the color interp and palette interp to decide which type of layer it is
QgsDebugMsg("bandCount = " + QString::number( mDataProvider->bandCount()));
QgsDebugMsg("dataType = " + QString::number( mDataProvider->dataType( 1 )));
QgsDebugMsg( "bandCount = " + QString::number( mDataProvider->bandCount() ) );
QgsDebugMsg( "dataType = " + QString::number( mDataProvider->dataType( 1 ) ) );
if (( mDataProvider->bandCount() > 1 ) )
{
mRasterType = Multiband;
@ -2375,13 +2380,13 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
else if ( mDataProvider->dataType( 1 ) == QgsRasterDataProvider::ARGBDataType )
{
mRasterType = ColorLayer;
}
}
//TODO hasBand is really obsolete and only used in the Palette instance, change to new function hasPalette(int)
//else if ( hasBand( "Palette" ) ) //don't tr() this its a gdal word!
// not sure if is worth to add colorTable capability - CT can be empty in any case
// Calc bandStatistics is very slow!!!
//else if ( bandStatistics(1).colorTable.count() > 0 )
else if ( mDataProvider->colorInterpretation(1) == QgsRasterDataProvider::PaletteIndex )
//else if ( bandStatistics(1).colorTable.count() > 0 )
else if ( mDataProvider->colorInterpretation( 1 ) == QgsRasterDataProvider::PaletteIndex )
{
mRasterType = Palette;
}
@ -2390,10 +2395,10 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
mRasterType = GrayOrUndefined;
}
QgsDebugMsg("mRasterType = " + QString::number(mRasterType));
QgsDebugMsg( "mRasterType = " + QString::number( mRasterType ) );
if ( mRasterType == ColorLayer )
{
QgsDebugMsg("Setting mDrawingStyle to SingleBandColorDataStyle " + QString::number ( SingleBandColorDataStyle ) );
QgsDebugMsg( "Setting mDrawingStyle to SingleBandColorDataStyle " + QString::number( SingleBandColorDataStyle ) );
mDrawingStyle = SingleBandColorDataStyle;
mGrayBandName = bandName( 1 ); //sensible default
}
@ -2486,12 +2491,12 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
// TODO ???
//if ( loadDefaultStyleFlag )
//{
//bool defaultLoadedFlag = false;
//loadDefaultStyle( defaultLoadedFlag );
//if ( defaultLoadedFlag )
//{
//return;
//}
//bool defaultLoadedFlag = false;
//loadDefaultStyle( defaultLoadedFlag );
//if ( defaultLoadedFlag )
//{
//return;
//}
//}
QgsDebugMsg( "exiting." );
@ -2648,11 +2653,11 @@ void QgsRasterLayer::setDrawingStyle( QString const & theDrawingStyleQString )
}
else if ( theDrawingStyleQString == "SingleBandColorDataStyle" )//no need to tr() this its not shown in ui
{
QgsDebugMsg("Setting mDrawingStyle to SingleBandColorDataStyle " + QString::number ( SingleBandColorDataStyle ) );
QgsDebugMsg( "Setting mDrawingStyle to SingleBandColorDataStyle " + QString::number( SingleBandColorDataStyle ) );
mDrawingStyle = SingleBandColorDataStyle;
QgsDebugMsg("Setted mDrawingStyle to " + QString::number ( mDrawingStyle ) );
QgsDebugMsg( "Setted mDrawingStyle to " + QString::number( mDrawingStyle ) );
}
else
else
{
mDrawingStyle = UndefinedDrawingStyle;
}
@ -2682,7 +2687,7 @@ void QgsRasterLayer::setLayerOrder( QStringList const & layers )
void QgsRasterLayer::setMaximumValue( unsigned int theBand, double theValue, bool theGenerateLookupTableFlag )
{
QgsDebugMsg( "setMaximumValue theValue = " + QString::number(theValue) );
QgsDebugMsg( "setMaximumValue theValue = " + QString::number( theValue ) );
if ( 0 < theBand && theBand <= bandCount() )
{
mContrastEnhancementList[theBand - 1].setMaximumValue( theValue, theGenerateLookupTableFlag );
@ -2728,7 +2733,7 @@ void QgsRasterLayer::setMinimumMaximumUsingLastExtent()
void QgsRasterLayer::setMinimumValue( unsigned int theBand, double theValue, bool theGenerateLookupTableFlag )
{
QgsDebugMsg( "setMinimumValue theValue = " + QString::number(theValue) );
QgsDebugMsg( "setMinimumValue theValue = " + QString::number( theValue ) );
if ( 0 < theBand && theBand <= bandCount() )
{
mContrastEnhancementList[theBand - 1].setMinimumValue( theValue, theGenerateLookupTableFlag );
@ -2823,23 +2828,23 @@ void QgsRasterLayer::thumbnailAsPixmap( QPixmap * theQPixmap )
//TODO: This should be depreciated and a new function written that just returns a new QPixmap, it will be safer
if ( 0 == theQPixmap ) { return; }
theQPixmap->fill ( ); //defaults to white
theQPixmap->fill( ); //defaults to white
QgsRasterViewPort *myRasterViewPort = new QgsRasterViewPort();
double myMapUnitsPerPixel;
double myX = 0.0;
double myY = 0.0;
QgsRectangle myExtent = mDataProvider->extent();
if ( myExtent.width()/myExtent.height() >= theQPixmap->width() / theQPixmap->height() )
if ( myExtent.width() / myExtent.height() >= theQPixmap->width() / theQPixmap->height() )
{
myMapUnitsPerPixel = myExtent.width() / theQPixmap->width();
myY = (theQPixmap->height() - myExtent.height() / myMapUnitsPerPixel ) / 2;
myY = ( theQPixmap->height() - myExtent.height() / myMapUnitsPerPixel ) / 2;
}
else
{
myMapUnitsPerPixel = myExtent.height() / theQPixmap->height();
myX = (theQPixmap->width() - myExtent.width() / myMapUnitsPerPixel ) / 2;
myX = ( theQPixmap->width() - myExtent.width() / myMapUnitsPerPixel ) / 2;
}
double myPixelWidth = myExtent.width() / myMapUnitsPerPixel;
@ -2849,7 +2854,7 @@ void QgsRasterLayer::thumbnailAsPixmap( QPixmap * theQPixmap )
myRasterViewPort->topLeftPoint = QgsPoint( myX, myY );
//myRasterViewPort->bottomRightPoint = QgsPoint( theQPixmap->width(), theQPixmap->height() );
myRasterViewPort->bottomRightPoint = QgsPoint( myPixelWidth, myPixelHeight );
myRasterViewPort->drawableAreaXDim = theQPixmap->width();
myRasterViewPort->drawableAreaYDim = theQPixmap->height();
@ -2860,7 +2865,7 @@ void QgsRasterLayer::thumbnailAsPixmap( QPixmap * theQPixmap )
myRasterViewPort->mSrcCRS = QgsCoordinateReferenceSystem(); // will be invalid
myRasterViewPort->mDestCRS = QgsCoordinateReferenceSystem(); // will be invalid
QgsMapToPixel *myMapToPixel = new QgsMapToPixel( myMapUnitsPerPixel);
QgsMapToPixel *myMapToPixel = new QgsMapToPixel( myMapUnitsPerPixel );
QPainter * myQPainter = new QPainter( theQPixmap );
draw( myQPainter, myRasterViewPort, myMapToPixel );
@ -3181,9 +3186,7 @@ bool QgsRasterLayer::readXml( QDomNode & layer_node )
QString format = rpNode.namedItem( "wmsFormat" ).toElement().text();
// Collect CRS
QString crs = srs().authid();
setDataProvider( mProviderKey, layers, styles, format, crs );
setDataProvider( mProviderKey, layers, styles, format, crs().authid() );
}
else
{
@ -3654,14 +3657,14 @@ void QgsRasterLayer::drawMultiBandColor( QPainter * theQPainter, QgsRasterViewPo
//from calling generate raster band stats
mRGBMinimumMaximumEstimated = true;
setMinimumValue( myRedBandNo, mDataProvider->minimumValue ( myRedBandNo ) );
setMaximumValue( myRedBandNo, mDataProvider->maximumValue ( myRedBandNo ) );
setMinimumValue( myRedBandNo, mDataProvider->minimumValue( myRedBandNo ) );
setMaximumValue( myRedBandNo, mDataProvider->maximumValue( myRedBandNo ) );
setMinimumValue( myGreenBandNo, mDataProvider->minimumValue ( myGreenBandNo ) );
setMaximumValue( myGreenBandNo, mDataProvider->maximumValue ( myGreenBandNo ) );
setMinimumValue( myGreenBandNo, mDataProvider->minimumValue( myGreenBandNo ) );
setMaximumValue( myGreenBandNo, mDataProvider->maximumValue( myGreenBandNo ) );
setMinimumValue( myBlueBandNo, mDataProvider->minimumValue ( myBlueBandNo ) );
setMaximumValue( myBlueBandNo, mDataProvider->maximumValue ( myBlueBandNo ) );
setMinimumValue( myBlueBandNo, mDataProvider->minimumValue( myBlueBandNo ) );
setMaximumValue( myBlueBandNo, mDataProvider->maximumValue( myBlueBandNo ) );
}
//Read and display pixels
@ -3840,7 +3843,7 @@ void QgsRasterLayer::drawPalettedSingleBandColor( QPainter * theQPainter, QgsRas
* @param theRasterViewPort pointer to the ViewPort struct containing dimensions of viewable area and subset area to be extracted from data file.
* @param theQgsMapToPixel transformation between map coordinates and canvas pixels
* @param theBandNo band number
*/
*/
void QgsRasterLayer::drawPalettedSingleBandGray( QPainter * theQPainter, QgsRasterViewPort * theRasterViewPort,
const QgsMapToPixel* theQgsMapToPixel, int theBandNo )
{
@ -3924,7 +3927,6 @@ void QgsRasterLayer::drawPalettedSingleBandGray( QPainter * theQPainter, QgsRast
* @param theBandNo band number
gray.
*/
void QgsRasterLayer::drawPalettedSingleBandPseudoColor( QPainter * theQPainter, QgsRasterViewPort * theRasterViewPort,
const QgsMapToPixel* theQgsMapToPixel, int theBandNo )
{
@ -4034,7 +4036,7 @@ void QgsRasterLayer::drawSingleBandGray( QPainter * theQPainter, QgsRasterViewPo
}
int myDataType = mDataProvider->dataType( theBandNo );
QgsDebugMsg( "myDataType = " + QString::number( myDataType) );
QgsDebugMsg( "myDataType = " + QString::number( myDataType ) );
QgsRasterImageBuffer imageBuffer( mDataProvider, theBandNo, theQPainter, theRasterViewPort, theQgsMapToPixel, &mGeoTransform[0] );
imageBuffer.reset();
@ -4061,12 +4063,12 @@ void QgsRasterLayer::drawSingleBandGray( QPainter * theQPainter, QgsRasterViewPo
//This case will be true the first time the image is loaded, so just approimate the min max to keep
//from calling generate raster band stats
mGrayMinimumMaximumEstimated = true;
setMaximumValue( theBandNo, mDataProvider->maximumValue ( theBandNo ) );
setMinimumValue( theBandNo, mDataProvider->minimumValue ( theBandNo ) );
setMaximumValue( theBandNo, mDataProvider->maximumValue( theBandNo ) );
setMinimumValue( theBandNo, mDataProvider->minimumValue( theBandNo ) );
}
QgsDebugMsg( " -> imageBuffer.nextScanLine");
QgsDebugMsg( " -> imageBuffer.nextScanLine" );
while ( imageBuffer.nextScanLine( &imageScanLine, &rasterScanLine ) )
{
//QgsDebugMsg( " rendering line");
@ -4075,7 +4077,7 @@ void QgsRasterLayer::drawSingleBandGray( QPainter * theQPainter, QgsRasterViewPo
myGrayValue = readValue( rasterScanLine, myDataType, i );
//QgsDebugMsg( QString( "i = %1 myGrayValue = %2 ").arg(i).arg( myGrayValue ) );
//if ( myGrayValue != -2147483647 ) {
//QgsDebugMsg( "myGrayValue = " + QString::number( myGrayValue ) );
//QgsDebugMsg( "myGrayValue = " + QString::number( myGrayValue ) );
//}
if ( mValidNoDataValue && ( qAbs( myGrayValue - mNoDataValue ) <= TINY_VALUE || myGrayValue != myGrayValue ) )
@ -4202,10 +4204,12 @@ void QgsRasterLayer::drawSingleBandPseudoColor( QPainter * theQPainter,
}
}
//QString QgsRasterLayer::generateBandName( int theBandNumber )
//{
//return tr( "Band" ) + QString( " %1" ) .arg( theBandNumber, 1 + ( int ) log10(( float ) bandCount() ), 10, QChar( '0' ) );
//}
#if 0
QString QgsRasterLayer::generateBandName( int theBandNumber )
{
return tr( "Band" ) + QString( " %1" ) .arg( theBandNumber, 1 + ( int ) log10(( float ) bandCount() ), 10, QChar( '0' ) );
}
#endif
/**
* This method looks to see if a given band name exists.
@ -4218,7 +4222,7 @@ bool QgsRasterLayer::hasBand( QString const & theBandName )
for ( int i = 1; i <= mDataProvider->bandCount(); i++ )
{
QString myColorQString = mDataProvider->colorInterpretationName ( i );
QString myColorQString = mDataProvider->colorInterpretationName( i );
#ifdef QGISDEBUG
QgsLogger::debug( "band", i, __FILE__, __FUNCTION__, __LINE__, 2 );
#endif
@ -4249,9 +4253,9 @@ QString QgsRasterLayer::projectionWkt()
*/
void *QgsRasterLayer::readData( int bandNo, QgsRasterViewPort *viewPort )
{
int size = mDataProvider->dataTypeSize(bandNo)/8;
int size = mDataProvider->dataTypeSize( bandNo ) / 8;
/*
#if 0
QgsDebugMsg( "calling RasterIO with " +
QString( ", source NW corner: " ) + QString::number( viewPort->rectXOffset ) +
", " + QString::number( viewPort->rectYOffset ) +
@ -4259,7 +4263,7 @@ void *QgsRasterLayer::readData( int bandNo, QgsRasterViewPort *viewPort )
", " + QString::number( viewPort->clippedHeight ) +
", dest size: " + QString::number( viewPort->drawableAreaXDim ) +
", " + QString::number( viewPort->drawableAreaYDim ) );
*/
#endif
void *data = VSIMalloc( size * viewPort->drawableAreaXDim * viewPort->drawableAreaYDim );
/* Abort if out of memory */
@ -4270,13 +4274,13 @@ void *QgsRasterLayer::readData( int bandNo, QgsRasterViewPort *viewPort )
else
{
// TODO: check extent
QgsRectangle partExtent (
viewPort->mDrawnExtent.xMinimum(),
QgsRectangle partExtent(
viewPort->mDrawnExtent.xMinimum(),
viewPort->mDrawnExtent.yMinimum(),
viewPort->mDrawnExtent.xMaximum(),
viewPort->mDrawnExtent.yMaximum()
viewPort->mDrawnExtent.xMaximum(),
viewPort->mDrawnExtent.yMaximum()
);
mDataProvider->readBlock ( bandNo, partExtent, viewPort->drawableAreaXDim, viewPort->drawableAreaYDim, QgsCoordinateReferenceSystem(), QgsCoordinateReferenceSystem(), data );
mDataProvider->readBlock( bandNo, partExtent, viewPort->drawableAreaXDim, viewPort->drawableAreaYDim, QgsCoordinateReferenceSystem(), QgsCoordinateReferenceSystem(), data );
}
return data;
}
@ -4422,7 +4426,7 @@ QString QgsRasterLayer::validateBandName( QString const & theBandName )
}
QgsRasterImageBuffer::QgsRasterImageBuffer( QgsRasterDataProvider *dataProvider, int bandNo, QPainter* p, QgsRasterViewPort* viewPort, const QgsMapToPixel* mapToPixel, double* geoTransform ):
mDataProvider( dataProvider ), mBandNo(bandNo), mPainter( p ), mViewPort( viewPort ), mMapToPixel( mapToPixel ), mGeoTransform( geoTransform ), mValid( false ), mWritingEnabled( true ), mDrawPixelRect( false ), mCurrentImage( 0 ), mCurrentGDALData( 0 )
mDataProvider( dataProvider ), mBandNo( bandNo ), mPainter( p ), mViewPort( viewPort ), mMapToPixel( mapToPixel ), mGeoTransform( geoTransform ), mValid( false ), mWritingEnabled( true ), mDrawPixelRect( false ), mCurrentImage( 0 ), mCurrentGDALData( 0 )
{
}
@ -4496,7 +4500,7 @@ bool QgsRasterImageBuffer::nextScanLine( QRgb** imageScanLine, void** rasterScan
{
*imageScanLine = 0;
}
int size = mDataProvider->dataTypeSize(mBandNo)/8;
int size = mDataProvider->dataTypeSize( mBandNo ) / 8;
*rasterScanLine = ( unsigned char * )mCurrentGDALData + mCurrentPartImageRow * mViewPort->drawableAreaXDim * size;
++mCurrentPartImageRow;
@ -4512,7 +4516,7 @@ bool QgsRasterImageBuffer::createNextPartImage()
{
if ( mWritingEnabled )
{
// TODO: consider similar system with raster providers, see the comment
// TODO: consider similar system with raster providers, see the comment
// in QgsRasterImageBuffer::drawPixelRectangle()
// e.g request the block with raster resolution and draw pixels as rectangles
//if ( 2 >= mViewPort->clippedWidth && 2 >= mViewPort->clippedHeight )
@ -4533,9 +4537,9 @@ bool QgsRasterImageBuffer::createNextPartImage()
imageY = mViewPort->topLeftPoint.y() + mCurrentPartRasterMin / mMapToPixel->mapUnitsPerPixel();
}
QgsDebugMsg( QString("mCurrentPartRasterMin = %1").arg( mCurrentPartRasterMin) );
QgsDebugMsg( QString("imageX = %1 imageY = %2").arg(imageX).arg(imageY) );
mPainter->drawImage( QPointF ( imageX, imageY ), //the top-left point in the paint device
QgsDebugMsg( QString( "mCurrentPartRasterMin = %1" ).arg( mCurrentPartRasterMin ) );
QgsDebugMsg( QString( "imageX = %1 imageY = %2" ).arg( imageX ).arg( imageY ) );
mPainter->drawImage( QPointF( imageX, imageY ), //the top-left point in the paint device
*mCurrentImage );
}
}
@ -4545,7 +4549,7 @@ bool QgsRasterImageBuffer::createNextPartImage()
CPLFree( mCurrentGDALData ); mCurrentGDALData = 0;
mCurrentPart++; // NEW
QgsDebugMsg( QString("mCurrentPartRasterMax = %1 mViewPort->drawableAreaYDim = %2").arg(mCurrentPartRasterMax).arg(mViewPort->drawableAreaYDim) );
QgsDebugMsg( QString( "mCurrentPartRasterMax = %1 mViewPort->drawableAreaYDim = %2" ).arg( mCurrentPartRasterMax ).arg( mViewPort->drawableAreaYDim ) );
if ( mCurrentPartRasterMax >= mViewPort->drawableAreaYDim )
{
return false; //already at the end...
@ -4561,7 +4565,7 @@ bool QgsRasterImageBuffer::createNextPartImage()
mCurrentPartImageRow = 0;
//read GDAL image data
int size = mDataProvider->dataTypeSize ( mBandNo ) / 8 ;
int size = mDataProvider->dataTypeSize( mBandNo ) / 8 ;
int xSize = mViewPort->drawableAreaXDim;
int ySize = mViewPort->drawableAreaYDim;
@ -4578,7 +4582,7 @@ bool QgsRasterImageBuffer::createNextPartImage()
overlapRows = 0;
}
int rasterYSize = mCurrentPartRasterMax - mCurrentPartRasterMin + overlapRows;
QgsDebugMsg( "rasterYSize = " + QString::number( rasterYSize ));
QgsDebugMsg( "rasterYSize = " + QString::number( rasterYSize ) );
// TODO: consider something like this
//if ( 2 >= mViewPort->clippedWidth && 2 >= mViewPort->clippedHeight ) //for zoomed in rasters
@ -4595,23 +4599,23 @@ bool QgsRasterImageBuffer::createNextPartImage()
//ySize = qAbs((( rasterYSize ) / mMapToPixel->mapUnitsPerPixel() * mGeoTransform[5] ) ) + 0.5;
}
}
QgsDebugMsg( QString("xSize = %1 ySize = %2").arg(xSize).arg(ySize) );
QgsDebugMsg( QString( "xSize = %1 ySize = %2" ).arg( xSize ).arg( ySize ) );
if ( ySize < 1 || xSize < 1 )
{
return false;
}
mNumCurrentImageRows = ySize;
QgsDebugMsg( "alloc " + QString::number( size * xSize * ySize) );
QgsDebugMsg( "alloc " + QString::number( size * xSize * ySize ) );
mCurrentGDALData = VSIMalloc( size * xSize * ySize );
double yMax = mViewPort->mDrawnExtent.yMaximum() - mCurrentRow * mMapToPixel->mapUnitsPerPixel();
double yMin = yMax - ySize * mMapToPixel->mapUnitsPerPixel();
QgsDebugMsg( QString("mCurrentRow = %1 yMaximum = %2 ySize = %3 mapUnitsPerPixel = %4").arg(mCurrentRow).arg(mViewPort->mDrawnExtent.yMaximum()).arg(ySize).arg(mMapToPixel->mapUnitsPerPixel()) );
QgsRectangle myPartExtent ( mViewPort->mDrawnExtent.xMinimum(), yMin,
mViewPort->mDrawnExtent.xMaximum(), yMax );
QgsDebugMsg( QString( "mCurrentRow = %1 yMaximum = %2 ySize = %3 mapUnitsPerPixel = %4" ).arg( mCurrentRow ).arg( mViewPort->mDrawnExtent.yMaximum() ).arg( ySize ).arg( mMapToPixel->mapUnitsPerPixel() ) );
QgsRectangle myPartExtent( mViewPort->mDrawnExtent.xMinimum(), yMin,
mViewPort->mDrawnExtent.xMaximum(), yMax );
QgsDebugMsg( "myPartExtent is " + myPartExtent.toString() );
mDataProvider->readBlock ( mBandNo, myPartExtent, xSize, ySize, mViewPort->mSrcCRS, mViewPort->mDestCRS, mCurrentGDALData );
mDataProvider->readBlock( mBandNo, myPartExtent, xSize, ySize, mViewPort->mSrcCRS, mViewPort->mDestCRS, mCurrentGDALData );
//create the QImage
if ( mWritingEnabled )
@ -4630,9 +4634,9 @@ void QgsRasterImageBuffer::drawPixelRectangle()
{
// TODO: consider using similar with raster providers, originaly it was used only with
// 2 >= mViewPort->clippedWidth && 2 >= mViewPort->clippedHeight
// but why? but I believe that it should be used always if the ration of original
// but why? but I believe that it should be used always if the ration of original
// raster resolution and device resolution is under certain limit
/*
#if 0
// Set up the initial offset into the myQImage we want to copy to the map canvas
// This is useful when the source image pixels are larger than the screen image.
int paintXoffset = 0;
@ -4654,7 +4658,7 @@ void QgsRasterImageBuffer::drawPixelRectangle()
* qAbs( mGeoTransform[5] )
);
}
//fix for zoomed in rasters
@ -4753,7 +4757,7 @@ void QgsRasterImageBuffer::drawPixelRectangle()
}
}
}
*/
#endif
}
// Keep this for now, it is used by Python interface!!!
@ -4767,8 +4771,9 @@ void QgsRasterLayer::registerGdalDrivers()
bool QgsRasterLayer::readColorTable( int theBandNumber, QList<QgsColorRampShader::ColorRampItem>* theList )
{
// TODO : check if exists - returned vale?
QList<QgsColorRampShader::ColorRampItem> myColorRampItemList = mDataProvider->colorTable ( theBandNumber );
if ( myColorRampItemList.size() == 0 ) {
QList<QgsColorRampShader::ColorRampItem> myColorRampItemList = mDataProvider->colorTable( theBandNumber );
if ( myColorRampItemList.size() == 0 )
{
return false;
}
*theList = myColorRampItemList;

View File

@ -298,14 +298,14 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
//
/** \brief Initialize default values */
void init ();
void init();
// For backward compatibility (Python) get rid of it once python is updated
void setDataProvider( const QString & provider,
const QStringList & layers,
const QStringList & styles,
const QString & format,
const QString & crs);
const QString & crs );
/** [ data provider interface ] Set the data provider */
void setDataProvider( const QString & provider,
const QStringList & layers,
@ -314,9 +314,9 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
const QString & crs,
bool loadDefaultStyleFlag );
static QLibrary* loadProviderLibrary( QString theProviderKey);
static QgsRasterDataProvider* loadProvider( QString theProviderKey, QString theDataSource = 0);
static QLibrary* loadProviderLibrary( QString theProviderKey );
static QgsRasterDataProvider* loadProvider( QString theProviderKey, QString theDataSource = 0 );
/** \brief Accessor for blue band name mapping */
QString blueBandName() const { return mBlueBandName; }
@ -657,7 +657,7 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
bool theTryInternalFlag = false );
/** \brief Populate the histogram vector for a given band */
void populateHistogram( int theBandNoInt,
int theBinCountInt = 256,
bool theIgnoreOutOfRangeFlag = true,
@ -692,9 +692,9 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
//
/** \brief Drawing routine for color type data */
void drawSingleBandColorData( QPainter * theQPainter,
QgsRasterViewPort * theRasterViewPort,
const QgsMapToPixel* theQgsMapToPixel,
int theBandNoInt );
QgsRasterViewPort * theRasterViewPort,
const QgsMapToPixel* theQgsMapToPixel,
int theBandNoInt );
/** \brief Drawing routine for multiband image */
void drawMultiBandColor( QPainter * theQPainter,
@ -912,7 +912,7 @@ class CORE_EXPORT QgsRasterImageBuffer
{
public:
QgsRasterImageBuffer( QgsRasterDataProvider *dataProvider, int bandNo, QPainter* p,
QgsRasterViewPort* viewPort, const QgsMapToPixel* mapToPixel, double* mGeoTransform );
QgsRasterViewPort* viewPort, const QgsMapToPixel* mapToPixel, double* mGeoTransform );
~QgsRasterImageBuffer();
void reset( int maxPixelsInVirtualMemory = 5000000 );
/**Returns a pointer to the next scan line (or 0 if end)*/
@ -948,7 +948,7 @@ class CORE_EXPORT QgsRasterImageBuffer
int mCurrentPartImageRow; //current image row
int mNumCurrentImageRows; //number of image rows for the current part
int mCurrentPart;
int mCurrentPart;
//current memory image and gdal scan data
QImage* mCurrentImage;

View File

@ -40,7 +40,7 @@ struct QgsRasterViewPort
QgsPoint bottomRightPoint;
/** \brief Distance in map units from left edge to right edge for the part of the raster that
* is to be rendered.*/
int drawableAreaXDim;
/** \brief Distance in map units from bottom edge to top edge for the part of the raster that
* is to be rendered.*/

View File

@ -85,13 +85,13 @@ int CPL_STDCALL progressCallback( double dfComplete,
if ( nPercent == 100 )
{
fprintf( stdout, "%d - done.\n", (int) floor(dfComplete*100) );
fprintf( stdout, "%d - done.\n", ( int ) floor( dfComplete*100 ) );
//mypLayer->showProgress( 100 );
}
else
{
int myProgress = ( int ) floor( dfComplete * 100 );
fprintf( stdout, "%d.", myProgress);
fprintf( stdout, "%d.", myProgress );
//mypLayer->showProgress( myProgress );
fflush( stdout );
}
@ -134,18 +134,18 @@ QgsGdalProvider::QgsGdalProvider( QString const & uri )
if ( mGdalBaseDataset == NULL )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot open GDAL dataset ") + uri + " : "
+ QString::fromUtf8( CPLGetLastErrorMsg() ) );
return;
QObject::tr( "Cannot open GDAL dataset " ) + uri + " : "
+ QString::fromUtf8( CPLGetLastErrorMsg() ) );
return;
}
QgsDebugMsg ("GdalDataset opened" );
QgsDebugMsg( "GdalDataset opened" );
for ( int i = 0; i < GDALGetRasterCount( mGdalBaseDataset ); i++ )
{
mMinMaxComputed.append(false);
mMinimum.append(0);
mMaximum.append(0);
mMinMaxComputed.append( false );
mMinimum.append( 0 );
mMaximum.append( 0 );
}
// Check if we need a warped VRT for this file.
if (( GDALGetGeoTransform( mGdalBaseDataset, mGeoTransform ) == CE_None
@ -179,8 +179,8 @@ QgsGdalProvider::QgsGdalProvider( QString const & uri )
if ( myGDALBand == NULL )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot get GDAL raster band : " )
+ QString::fromUtf8( CPLGetLastErrorMsg() ) ) ;
QObject::tr( "Cannot get GDAL raster band : " )
+ QString::fromUtf8( CPLGetLastErrorMsg() ) ) ;
GDALDereferenceDataset( mGdalBaseDataset );
mGdalBaseDataset = NULL;
@ -251,23 +251,24 @@ QgsGdalProvider::QgsGdalProvider( QString const & uri )
mValidNoDataValue = true;
for ( int i = 1; i <= GDALGetRasterCount( mGdalBaseDataset ); i++ )
{
computeMinMax ( i );
computeMinMax( i );
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, i );
GDALDataType myGdalDataType = GDALGetRasterDataType( myGdalBand );
int isValid = false;
double myNoDataValue = GDALGetRasterNoDataValue( GDALGetRasterBand( mGdalDataset, i ), &isValid );
if ( isValid )
{
QgsDebugMsg( QString("GDALGetRasterNoDataValue = %1").arg( myNoDataValue ) ) ;
QgsDebugMsg( QString( "GDALGetRasterNoDataValue = %1" ).arg( myNoDataValue ) ) ;
mGdalDataType.append( myGdalDataType );
}
else
}
else
{
// But we need a null value in case of reprojection and BTW also for
// But we need a null value in case of reprojection and BTW also for
// aligned margines
switch ( srcDataType( i ) ) {
switch ( srcDataType( i ) )
{
case QgsRasterDataProvider::Byte:
// Use longer data type to avoid conflict with real data
myNoDataValue = -32768.0;
@ -291,58 +292,58 @@ QgsGdalProvider::QgsGdalProvider( QString const & uri )
break;
default:
myNoDataValue = std::numeric_limits<int>::max();
// Would NaN work well?
//myNoDataValue = std::numeric_limits<double>::quiet_NaN();
// Would NaN work well?
//myNoDataValue = std::numeric_limits<double>::quiet_NaN();
mGdalDataType.append( myGdalDataType );
}
}
mNoDataValue.append( myNoDataValue );
QgsDebugMsg( QString("mNoDataValue[%1] = %1").arg(i-1).arg ( mNoDataValue[i-1] ) );
QgsDebugMsg( QString( "mNoDataValue[%1] = %1" ).arg( i - 1 ).arg( mNoDataValue[i-1] ) );
}
// This block of code was in old version in QgsRasterLayer::bandStatistics
// This block of code was in old version in QgsRasterLayer::bandStatistics
//ifdefs below to remove compiler warning about unused vars
#ifdef QGISDEBUG
/*
int success;
double GDALminimum = GDALGetRasterMinimum( myGdalBand, &success );
/*
int success;
double GDALminimum = GDALGetRasterMinimum( myGdalBand, &success );
if ( ! success )
{
QgsDebugMsg( "myGdalBand->GetMinimum() failed" );
}
if ( ! success )
{
QgsDebugMsg( "myGdalBand->GetMinimum() failed" );
}
double GDALmaximum = GDALGetRasterMaximum( myGdalBand, &success );
double GDALmaximum = GDALGetRasterMaximum( myGdalBand, &success );
if ( ! success )
{
QgsDebugMsg( "myGdalBand->GetMaximum() failed" );
}
if ( ! success )
{
QgsDebugMsg( "myGdalBand->GetMaximum() failed" );
}
double GDALnodata = GDALGetRasterNoDataValue( myGdalBand, &success );
double GDALnodata = GDALGetRasterNoDataValue( myGdalBand, &success );
if ( ! success )
{
QgsDebugMsg( "myGdalBand->GetNoDataValue() failed" );
}
if ( ! success )
{
QgsDebugMsg( "myGdalBand->GetNoDataValue() failed" );
}
QgsLogger::debug( "GDALminium: ", GDALminimum, __FILE__, __FUNCTION__, __LINE__ );
QgsLogger::debug( "GDALmaximum: ", GDALmaximum, __FILE__, __FUNCTION__, __LINE__ );
QgsLogger::debug( "GDALnodata: ", GDALnodata, __FILE__, __FUNCTION__, __LINE__ );
QgsLogger::debug( "GDALminium: ", GDALminimum, __FILE__, __FUNCTION__, __LINE__ );
QgsLogger::debug( "GDALmaximum: ", GDALmaximum, __FILE__, __FUNCTION__, __LINE__ );
QgsLogger::debug( "GDALnodata: ", GDALnodata, __FILE__, __FUNCTION__, __LINE__ );
double GDALrange[2]; // calculated min/max, as opposed to the
// dataset provided
double GDALrange[2]; // calculated min/max, as opposed to the
// dataset provided
GDALComputeRasterMinMax( myGdalBand, 1, GDALrange );
QgsLogger::debug( "approximate computed GDALminium:", GDALrange[0], __FILE__, __FUNCTION__, __LINE__, 1 );
QgsLogger::debug( "approximate computed GDALmaximum:", GDALrange[1], __FILE__, __FUNCTION__, __LINE__, 1 );
GDALComputeRasterMinMax( myGdalBand, 1, GDALrange );
QgsLogger::debug( "approximate computed GDALminium:", GDALrange[0], __FILE__, __FUNCTION__, __LINE__, 1 );
QgsLogger::debug( "approximate computed GDALmaximum:", GDALrange[1], __FILE__, __FUNCTION__, __LINE__, 1 );
GDALComputeRasterMinMax( myGdalBand, 0, GDALrange );
QgsLogger::debug( "exactly computed GDALminium:", GDALrange[0] );
QgsLogger::debug( "exactly computed GDALmaximum:", GDALrange[1] );
GDALComputeRasterMinMax( myGdalBand, 0, GDALrange );
QgsLogger::debug( "exactly computed GDALminium:", GDALrange[0] );
QgsLogger::debug( "exactly computed GDALmaximum:", GDALrange[1] );
QgsDebugMsg( "starting manual stat computation" );
*/
QgsDebugMsg( "starting manual stat computation" );
*/
#endif
mValid = true;
@ -375,7 +376,7 @@ void QgsGdalProvider::closeDataset()
GDALClose( mGdalDataset );
mGdalDataset = NULL;
}
QString QgsGdalProvider::metadata()
{
QString myMetadata ;
@ -512,16 +513,16 @@ QImage* QgsGdalProvider::draw( QgsRectangle const & viewExtent, int pixelWidth,
void QgsGdalProvider::readBlock( int theBandNo, int xBlock, int yBlock, void *block )
{
QgsDebugMsg( "Entered" );
QgsDebugMsg( "yBlock = " + QString::number( yBlock ) );
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, theBandNo );
//GDALReadBlock( myGdalBand, xBlock, yBlock, block );
/* We have to read with correct data type consistent with other readBlock functions */
int xOff = xBlock * mXBlockSize;
int xOff = xBlock * mXBlockSize;
int yOff = yBlock * mYBlockSize;
GDALRasterIO ( myGdalBand, GF_Read, xOff, yOff, mXBlockSize, mYBlockSize, block, mXBlockSize, mYBlockSize, (GDALDataType) mGdalDataType[theBandNo-1], 0, 0 );
GDALRasterIO( myGdalBand, GF_Read, xOff, yOff, mXBlockSize, mYBlockSize, block, mXBlockSize, mYBlockSize, ( GDALDataType ) mGdalDataType[theBandNo-1], 0, 0 );
}
void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent, int thePixelWidth, int thePixelHeight, void *theBlock )
@ -531,46 +532,42 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
QgsDebugMsg( "theExtent: " + theExtent.toString() );
QgsDebugMsg( "crs(): " + crs().toWkt() );
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, theBandNo );
GDALDataType myGdalDataType = GDALGetRasterDataType( myGdalBand );
QString myMemDsn;
myMemDsn.sprintf ( "DATAPOINTER = %p", theBlock );
QgsDebugMsg( myMemDsn );
myMemDsn.sprintf ( "MEM:::DATAPOINTER=%lu,PIXELS=%d,LINES=%d,BANDS=1,DATATYPE=%s,PIXELOFFSET=0,LINEOFFSET=0,BANDOFFSET=0", (long)theBlock, thePixelWidth, thePixelHeight, GDALGetDataTypeName( (GDALDataType)mGdalDataType[theBandNo-1] ) );
myMemDsn.sprintf( "DATAPOINTER = %p", theBlock );
QgsDebugMsg( myMemDsn );
myMemDsn.sprintf( "MEM:::DATAPOINTER=%lu,PIXELS=%d,LINES=%d,BANDS=1,DATATYPE=%s,PIXELOFFSET=0,LINEOFFSET=0,BANDOFFSET=0", ( long )theBlock, thePixelWidth, thePixelHeight, GDALGetDataTypeName(( GDALDataType )mGdalDataType[theBandNo-1] ) );
QgsDebugMsg( "Open GDAL MEM : " + myMemDsn );
CPLErrorReset();
GDALDatasetH myGdalMemDataset = GDALOpen( TO8F( myMemDsn ), GA_Update );
if ( !myGdalMemDataset )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot open GDAL MEM dataset ") + myMemDsn + " : "
+ QString::fromUtf8( CPLGetLastErrorMsg() ) );
return;
QObject::tr( "Cannot open GDAL MEM dataset " ) + myMemDsn + " : "
+ QString::fromUtf8( CPLGetLastErrorMsg() ) );
return;
}
//GDALSetProjection( myGdalMemDataset, theDestCRS.toWkt().toAscii().constData() );
double myMemGeoTransform[6];
myMemGeoTransform[0] = theExtent.xMinimum(); /* top left x */
myMemGeoTransform[1] = theExtent.width()/thePixelWidth; /* w-e pixel resolution */
myMemGeoTransform[1] = theExtent.width() / thePixelWidth; /* w-e pixel resolution */
myMemGeoTransform[2] = 0; /* rotation, 0 if image is "north up" */
myMemGeoTransform[3] = theExtent.yMaximum(); /* top left y */
myMemGeoTransform[4] = 0; /* rotation, 0 if image is "north up" */
myMemGeoTransform[5] = -1. * theExtent.height()/thePixelHeight; /* n-s pixel resolution */
myMemGeoTransform[5] = -1. * theExtent.height() / thePixelHeight; /* n-s pixel resolution */
double myGeoTransform[6];
GDALGetGeoTransform( mGdalDataset, myGeoTransform );
GDALSetGeoTransform( myGdalMemDataset, myMemGeoTransform );
for ( int i = 0 ; i < 6; i++ )
for ( int i = 0 ; i < 6; i++ )
{
QgsDebugMsg ( QString("transform : %1 %2").arg(myGeoTransform[i]).arg ( myMemGeoTransform[i] ) );
QgsDebugMsg( QString( "transform : %1 %2" ).arg( myGeoTransform[i] ).arg( myMemGeoTransform[i] ) );
}
GDALWarpOptions *myWarpOptions = GDALCreateWarpOptions();
@ -579,44 +576,44 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
myWarpOptions->hDstDS = myGdalMemDataset;
myWarpOptions->nBandCount = 1;
myWarpOptions->panSrcBands =
(int *) CPLMalloc(sizeof(int) * myWarpOptions->nBandCount );
myWarpOptions->panSrcBands =
( int * ) CPLMalloc( sizeof( int ) * myWarpOptions->nBandCount );
myWarpOptions->panSrcBands[0] = theBandNo;
myWarpOptions->panDstBands =
(int *) CPLMalloc(sizeof(int) * myWarpOptions->nBandCount );
myWarpOptions->panDstBands =
( int * ) CPLMalloc( sizeof( int ) * myWarpOptions->nBandCount );
myWarpOptions->panDstBands[0] = 1;
// TODO move here progressCallback and use it
myWarpOptions->pfnProgress = GDALTermProgress;
myWarpOptions->pfnProgress = GDALTermProgress;
QgsDebugMsg ( "src wkt: " + QString (GDALGetProjectionRef(mGdalDataset) ) );
QgsDebugMsg ( "dst wkt: " + QString (GDALGetProjectionRef(myGdalMemDataset) ) );
myWarpOptions->pTransformerArg =
GDALCreateGenImgProjTransformer(
mGdalDataset,
NULL,
myGdalMemDataset,
NULL,
FALSE, 0.0, 1
);
QgsDebugMsg( "src wkt: " + QString( GDALGetProjectionRef( mGdalDataset ) ) );
QgsDebugMsg( "dst wkt: " + QString( GDALGetProjectionRef( myGdalMemDataset ) ) );
myWarpOptions->pTransformerArg =
GDALCreateGenImgProjTransformer(
mGdalDataset,
NULL,
myGdalMemDataset,
NULL,
FALSE, 0.0, 1
);
CPLAssert( myWarpOptions->pTransformerArg != NULL);
CPLAssert( myWarpOptions->pTransformerArg != NULL );
myWarpOptions->pfnTransformer = GDALGenImgProjTransform;
myWarpOptions->padfDstNoDataReal = (double *) CPLMalloc( myWarpOptions->nBandCount * sizeof(double));
myWarpOptions->padfDstNoDataImag = (double *) CPLMalloc( myWarpOptions->nBandCount * sizeof(double));
myWarpOptions->padfDstNoDataReal = ( double * ) CPLMalloc( myWarpOptions->nBandCount * sizeof( double ) );
myWarpOptions->padfDstNoDataImag = ( double * ) CPLMalloc( myWarpOptions->nBandCount * sizeof( double ) );
myWarpOptions->padfDstNoDataReal[0] = mNoDataValue[theBandNo-1];
myWarpOptions->padfDstNoDataImag[0] = 0.0;
GDALSetRasterNoDataValue( GDALGetRasterBand( myGdalMemDataset,
myWarpOptions->panDstBands[0] ),
myWarpOptions->padfDstNoDataReal[0] );
GDALSetRasterNoDataValue( GDALGetRasterBand( myGdalMemDataset,
myWarpOptions->panDstBands[0] ),
myWarpOptions->padfDstNoDataReal[0] );
// TODO optimize somehow to avoid no data init if not necessary
// TODO optimize somehow to avoid no data init if not necessary
// i.e. no projection, but there is also the problem with margine
myWarpOptions->papszWarpOptions =
CSLSetNameValue(myWarpOptions->papszWarpOptions,"INIT_DEST", "NO_DATA" );
myWarpOptions->papszWarpOptions =
CSLSetNameValue( myWarpOptions->papszWarpOptions, "INIT_DEST", "NO_DATA" );
myWarpOptions->eResampleAlg = GRA_NearestNeighbour;
@ -625,54 +622,56 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,
myOperation.Initialize( myWarpOptions );
CPLErrorReset();
CPLErr myErr;
myErr = myOperation.ChunkAndWarpImage( 0, 0, thePixelWidth, thePixelHeight );
myErr = myOperation.ChunkAndWarpImage( 0, 0, thePixelWidth, thePixelHeight );
if ( myErr != CPLE_None )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot ChunkAndWarpImage : " )
+ QString::fromUtf8( CPLGetLastErrorMsg() ) );
return;
QObject::tr( "Cannot ChunkAndWarpImage : " )
+ QString::fromUtf8( CPLGetLastErrorMsg() ) );
return;
}
GDALDestroyGenImgProjTransformer( myWarpOptions->pTransformerArg );
GDALDestroyWarpOptions( myWarpOptions );
// flush should not be necessary
// flush should not be necessary
//GDALFlushCache ( myGdalMemDataset );
// this was causing crash ???
// The MEM driver does not free() the memory passed as DATAPOINTER so we can closee the dataset
GDALClose( myGdalMemDataset );
GDALClose( myGdalMemDataset );
}
double QgsGdalProvider::noDataValue() const {
if ( mNoDataValue.size () > 0 ) {
double QgsGdalProvider::noDataValue() const
{
if ( mNoDataValue.size() > 0 )
{
return mNoDataValue[0];
}
return std::numeric_limits<int>::max(); // should not happen or be used
}
void QgsGdalProvider::computeMinMax ( int theBandNo )
void QgsGdalProvider::computeMinMax( int theBandNo )
{
QgsDebugMsg( QString("theBandNo = %1 mMinMaxComputed = %2").arg(theBandNo).arg(mMinMaxComputed[theBandNo-1]) );
if ( mMinMaxComputed[theBandNo-1] ) return;
QgsDebugMsg( QString( "theBandNo = %1 mMinMaxComputed = %2" ).arg( theBandNo ).arg( mMinMaxComputed[theBandNo-1] ) );
if ( mMinMaxComputed[theBandNo-1] ) return;
double GDALrange[2];
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, theBandNo );
GDALComputeRasterMinMax( myGdalBand, 1, GDALrange ); //Approximate
QgsDebugMsg( QString("GDALrange[0] = %1 GDALrange[1] = %2").arg(GDALrange[0]).arg(GDALrange[1]) );
mMinimum[theBandNo-1] = GDALrange[0];
mMaximum[theBandNo-1] = GDALrange[1];
QgsDebugMsg( QString( "GDALrange[0] = %1 GDALrange[1] = %2" ).arg( GDALrange[0] ).arg( GDALrange[1] ) );
mMinimum[theBandNo-1] = GDALrange[0];
mMaximum[theBandNo-1] = GDALrange[1];
}
double QgsGdalProvider::minimumValue( int theBandNo ) const
double QgsGdalProvider::minimumValue( int theBandNo ) const
{
QgsDebugMsg( QString("theBandNo = %1").arg(theBandNo) );
QgsDebugMsg( QString( "theBandNo = %1" ).arg( theBandNo ) );
//computeMinMax ( theBandNo );
return mMinimum[theBandNo-1];
}
double QgsGdalProvider::maximumValue( int theBandNo ) const
{
QgsDebugMsg( QString("theBandNo = %1").arg(theBandNo) );
QgsDebugMsg( QString( "theBandNo = %1" ).arg( theBandNo ) );
//computeMinMax ( theBandNo );
return mMaximum[theBandNo-1];
}
@ -682,11 +681,11 @@ double QgsGdalProvider::maximumValue( int theBandNo ) const
* @param theList a pointer the object that will hold the color table
* @return true of a color table was able to be read, false otherwise
*/
QList<QgsColorRampShader::ColorRampItem> QgsGdalProvider::colorTable(int theBandNumber)const
QList<QgsColorRampShader::ColorRampItem> QgsGdalProvider::colorTable( int theBandNumber )const
{
QgsDebugMsg( "entered." );
QList<QgsColorRampShader::ColorRampItem> ct;
//Invalid band number, segfault prevention
if ( 0 >= theBandNumber )
@ -784,14 +783,16 @@ QgsRectangle QgsGdalProvider::extent()
// this is only called once when statistics are calculated
// TODO
int QgsGdalProvider::xBlockSize() const {
return mXBlockSize;
}
int QgsGdalProvider::yBlockSize() const {
return mYBlockSize;
int QgsGdalProvider::xBlockSize() const
{
return mXBlockSize;
}
int QgsGdalProvider::yBlockSize() const
{
return mYBlockSize;
}
int QgsGdalProvider::xSize() const { return mWidth; }
int QgsGdalProvider::xSize() const { return mWidth; }
int QgsGdalProvider::ySize() const { return mHeight; }
bool QgsGdalProvider::identify( const QgsPoint& thePoint, QMap<QString, QString>& theResults )
@ -826,7 +827,7 @@ bool QgsGdalProvider::identify( const QgsPoint& thePoint, QMap<QString, QString>
double value;
CPLErr err = GDALRasterIO( gdalBand, GF_Read, col, row, 1, 1,
&value, 1, 1, GDT_Float64, 0, 0 );
&value, 1, 1, GDT_Float64, 0, 0 );
if ( err != CPLE_None )
{
@ -859,18 +860,19 @@ bool QgsGdalProvider::identify( const QgsPoint& thePoint, QMap<QString, QString>
int QgsGdalProvider::capabilities() const
{
int capability = QgsRasterDataProvider::Identify
| QgsRasterDataProvider::ExactResolution
| QgsRasterDataProvider::EstimatedMinimumMaximum
| QgsRasterDataProvider::BuildPyramids
| QgsRasterDataProvider::Histogram
| QgsRasterDataProvider::Size;
int capability = QgsRasterDataProvider::Identify
| QgsRasterDataProvider::ExactResolution
| QgsRasterDataProvider::EstimatedMinimumMaximum
| QgsRasterDataProvider::BuildPyramids
| QgsRasterDataProvider::Histogram
| QgsRasterDataProvider::Size;
return capability;
}
int QgsGdalProvider::dataTypeFormGdal( int theGdalDataType ) const
{
switch ( theGdalDataType ) {
switch ( theGdalDataType )
{
case GDT_Unknown:
return QgsRasterDataProvider::UnknownDataType;
break;
@ -916,23 +918,24 @@ int QgsGdalProvider::dataTypeFormGdal( int theGdalDataType ) const
int QgsGdalProvider::srcDataType( int bandNo ) const
{
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, bandNo );
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, bandNo );
GDALDataType myGdalDataType = GDALGetRasterDataType( myGdalBand );
return dataTypeFormGdal ( myGdalDataType );
return dataTypeFormGdal( myGdalDataType );
}
int QgsGdalProvider::dataType( int bandNo ) const
{
return dataTypeFormGdal ( mGdalDataType[bandNo-1] );
return dataTypeFormGdal( mGdalDataType[bandNo-1] );
}
int QgsGdalProvider::bandCount() const
{
return GDALGetRasterCount( mGdalDataset);
return GDALGetRasterCount( mGdalDataset );
}
int QgsGdalProvider::colorInterpretation ( int theBandNo ) const {
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, theBandNo );
int QgsGdalProvider::colorInterpretation( int theBandNo ) const
{
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, theBandNo );
return GDALGetRasterColorInterpretation( myGdalBand );
}
@ -945,7 +948,7 @@ void QgsGdalProvider::registerGdalDrivers()
bool QgsGdalProvider::isValid()
{
QgsDebugMsg ( QString("valid = %1").arg(mValid));
QgsDebugMsg( QString( "valid = %1" ).arg( mValid ) );
return mValid;
}
@ -1061,8 +1064,8 @@ void QgsGdalProvider::populateHistogram( int theBandNo, QgsRasterBandStats & t
* @param theTryInternalFlag - Try to make the pyramids internal if supported (e.g. geotiff). If not supported it will revert to creating external .ovr file anyway.
* @return null string on success, otherwise a string specifying error
*/
QString QgsGdalProvider::buildPyramids( QList<QgsRasterPyramid> const & theRasterPyramidList,
QString const & theResamplingMethod, bool theTryInternalFlag )
QString QgsGdalProvider::buildPyramids( QList<QgsRasterPyramid> const & theRasterPyramidList,
QString const & theResamplingMethod, bool theTryInternalFlag )
{
//TODO: Consider making theRasterPyramidList modifyable by this method to indicate if the pyramid exists after build attempt
//without requiring the user to rebuild the pyramid list to get the updated infomation
@ -1352,7 +1355,7 @@ QGISEXTERN bool isProvider()
*/
QGISEXTERN void buildSupportedRasterFileFilter( QString & theFileFiltersString )
{
QgsDebugMsg("Entered");
QgsDebugMsg( "Entered" );
// first get the GDAL driver manager
//registerGdalDrivers();

View File

@ -186,14 +186,14 @@ class QgsGdalProvider : public QgsRasterDataProvider
*/
int capabilities() const;
int dataType ( int bandNo ) const;
int srcDataType ( int bandNo ) const;
int dataType( int bandNo ) const;
int srcDataType( int bandNo ) const;
int dataTypeFormGdal ( int theGdalDataType ) const;
int dataTypeFormGdal( int theGdalDataType ) const;
int bandCount() const;
int colorInterpretation ( int bandNo ) const;
int colorInterpretation( int bandNo ) const;
int xBlockSize() const;
int yBlockSize() const;
@ -206,18 +206,18 @@ class QgsGdalProvider : public QgsRasterDataProvider
void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, void *data );
double noDataValue() const;
void computeMinMax(int bandNo);
double minimumValue(int bandNo) const;
double maximumValue(int bandNo) const;
void computeMinMax( int bandNo );
double minimumValue( int bandNo ) const;
double maximumValue( int bandNo ) const;
QList<QgsColorRampShader::ColorRampItem> colorTable(int bandNo)const;
QList<QgsColorRampShader::ColorRampItem> colorTable( int bandNo )const;
/**
* Get metadata in a format suitable for feeding directly
* into a subset of the GUI raster properties "Metadata" tab.
*/
QString metadata();
QString metadata();
// Following methods specific for WMS are not used at all in this provider and should be removed IMO from qgsdataprovider.h
void addLayers( QStringList const & layers, QStringList const & styles = QStringList() ) {}
@ -233,11 +233,11 @@ class QgsGdalProvider : public QgsRasterDataProvider
QStringList subLayers() const;
void populateHistogram( int theBandNoInt,
QgsRasterBandStats & theBandStats,
int theBinCountInt = 256,
bool theIgnoreOutOfRangeFlag = true,
bool theThoroughBandScanFlag = false
);
QgsRasterBandStats & theBandStats,
int theBinCountInt = 256,
bool theIgnoreOutOfRangeFlag = true,
bool theThoroughBandScanFlag = false
);
QString buildPyramids( const QList<QgsRasterPyramid> &,
const QString & theResamplingMethod = "NEAREST",
@ -258,9 +258,9 @@ class QgsGdalProvider : public QgsRasterDataProvider
/** \brief Whether this raster has overviews / pyramids or not */
bool mHasPyramids;
/** \brief Gdal data types used to represent data in in QGIS,
may be longer than source data type to keep nulls
indexed from 0
/** \brief Gdal data types used to represent data in in QGIS,
may be longer than source data type to keep nulls
indexed from 0
*/
QList<int>mGdalDataType;

View File

@ -80,7 +80,7 @@ int main( int argc, char **argv )
G_adjust_Cell_head( &window, 1, 1 );
G_set_window( &window );
raster_type = G_raster_map_type ( name, "" );
raster_type = G_raster_map_type( name, "" );
fp = G_raster_map_is_fp( name, mapset );
/* use DCELL even if the map is FCELL */
@ -180,7 +180,7 @@ static int cell_draw( char *name,
alpha = 0;
}
if ( strcmp(format,"color") == 0 )
if ( strcmp( format, "color" ) == 0 )
{
// We need data suitable for QImage 32-bpp
// the data are stored in QImage as QRgb which is unsigned int.
@ -198,28 +198,35 @@ static int cell_draw( char *name,
}
else
{
int *val;
val = (int*) (ptr);
//G_debug ( 0, "val = %d", *val );
if ( data_type == CELL_TYPE) {
//G_debug ( 0, "valx = %d", *((CELL *) ptr));
}
if ( G_is_null_value(ptr, data_type) ) {
if ( data_type == CELL_TYPE) {
int nul = -2147483647;
fwrite( &nul , 4, 1, fo );
} else if ( data_type == DCELL_TYPE) {
double nul = 2.2250738585072014e-308;
fwrite( &nul , 8, 1, fo );
} else if ( data_type == FCELL_TYPE) {
double nul = 1.17549435e-38F;
fwrite( &nul , 4, 1, fo );
}
}
else
int *val;
val = ( int* )( ptr );
//G_debug ( 0, "val = %d", *val );
if ( data_type == CELL_TYPE )
{
//G_debug ( 0, "valx = %d", *((CELL *) ptr));
}
if ( G_is_null_value( ptr, data_type ) )
{
if ( data_type == CELL_TYPE )
{
fwrite( ptr, raster_size, 1, fo );
int nul = -2147483647;
fwrite( &nul , 4, 1, fo );
}
else if ( data_type == DCELL_TYPE )
{
double nul = 2.2250738585072014e-308;
fwrite( &nul , 8, 1, fo );
}
else if ( data_type == FCELL_TYPE )
{
double nul = 1.17549435e-38F;
fwrite( &nul , 4, 1, fo );
}
}
else
{
fwrite( ptr, raster_size, 1, fo );
}
}
ptr = G_incr_void_ptr( ptr, raster_size );
}

View File

@ -95,44 +95,45 @@ int main( int argc, char **argv )
// raster informations
else if ( strcmp( "info", info_opt->answer ) == 0 )
{
struct FPRange range;
double zmin, zmax;
struct FPRange range;
double zmin, zmax;
// Data type
RASTER_MAP_TYPE raster_type = G_raster_map_type ( rast_opt->answer, "" );
fprintf( stdout, "TYPE:%d\n", raster_type );
// Data type
RASTER_MAP_TYPE raster_type = G_raster_map_type( rast_opt->answer, "" );
fprintf( stdout, "TYPE:%d\n", raster_type );
// Statistics
if (G_read_fp_range( rast_opt->answer, "", &range) < 0) {
G_fatal_error(("Unable to read range file"));
}
G_get_fp_range_min_max(&range, &zmin, &zmax);
fprintf( stdout, "MIN_VALUE:%f\n", zmin );
fprintf( stdout, "MAX_VALUE:%f\n", zmax );
// Statistics
if ( G_read_fp_range( rast_opt->answer, "", &range ) < 0 )
{
G_fatal_error(( "Unable to read range file" ) );
}
G_get_fp_range_min_max( &range, &zmin, &zmax );
fprintf( stdout, "MIN_VALUE:%f\n", zmin );
fprintf( stdout, "MAX_VALUE:%f\n", zmax );
}
else if ( strcmp( "colors", info_opt->answer ) == 0 )
{
// Color table
struct Colors colors;
int i, ccount;
if( G_read_colors( rast_opt->answer, "", &colors ) == 1 )
{
//int maxcolor;
//CELL min, max;
//G_get_color_range ( &min, &max, &colors);
ccount = G_colors_count ( &colors );
for( i = ccount-1; i >= 0; i-- )
{
DCELL val1, val2;
unsigned char r1, g1, b1, r2, g2, b2;
// Color table
struct Colors colors;
int i, ccount;
if ( G_read_colors( rast_opt->answer, "", &colors ) == 1 )
{
//int maxcolor;
//CELL min, max;
G_get_f_color_rule ( &val1, &r1, &g1, &b1, &val2, &r2, &g2, &b2, &colors, i );
fprintf ( stdout, "%e %e %d %d %d %d %d %d\n", val1, val2, r1, g1, b1, r2, g2, b2 );
}
}
//G_get_color_range ( &min, &max, &colors);
ccount = G_colors_count( &colors );
for ( i = ccount - 1; i >= 0; i-- )
{
DCELL val1, val2;
unsigned char r1, g1, b1, r2, g2, b2;
G_get_f_color_rule( &val1, &r1, &g1, &b1, &val2, &r2, &g2, &b2, &colors, i );
fprintf( stdout, "%e %e %d %d %d %d %d %d\n", val1, val2, r1, g1, b1, r2, g2, b2 );
}
}
}
else if ( strcmp( "query", info_opt->answer ) == 0 )
{
double x, y;

View File

@ -1194,7 +1194,7 @@ void GRASS_EXPORT QgsGrass::size( QString gisdbase, QString location, QString ma
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot get raster extent" ) + "\n" + e.what() );
}
QgsDebugMsg( QString( "raster size = %1 %2" ).arg( *cols ).arg( *rows ) );
}
@ -1208,8 +1208,9 @@ QHash<QString, QString> GRASS_EXPORT QgsGrass::info( QString gisdbase, QString l
QString str = QgsGrass::getInfo( "info", gisdbase, location, mapset, map, type );
QgsDebugMsg( str );
QStringList list = str.split( "\n" );
for ( int i = 0; i < list.size(); i++ ) {
QStringList keyVal = list[i].split(':');
for ( int i = 0; i < list.size(); i++ )
{
QStringList keyVal = list[i].split( ':' );
if ( list[i].isEmpty() ) { continue; }
if ( keyVal.size() != 2 )
{
@ -1223,7 +1224,7 @@ QHash<QString, QString> GRASS_EXPORT QgsGrass::info( QString gisdbase, QString l
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot get map info" ) + "\n" + e.what() );
}
return inf;
return inf;
}
QList<QgsGrass::Color> GRASS_EXPORT QgsGrass::colors( QString gisdbase, QString location, QString mapset, QString map )
@ -1236,16 +1237,15 @@ QList<QgsGrass::Color> GRASS_EXPORT QgsGrass::colors( QString gisdbase, QString
QString str = QgsGrass::getInfo( "colors", gisdbase, location, mapset, map, QgsGrass::Raster );
QgsDebugMsg( str );
QStringList list = str.split( "\n" );
for ( int i = 0; i < list.size(); i++ ) {
double v1, v2;
int r1, r2, g1, g2, b1, b2;
for ( int i = 0; i < list.size(); i++ )
{
QgsGrass::Color c;
if ( list[i].isEmpty() ) { continue; }
if ( sscanf( list[i].toUtf8().data(), "%lf %lf %d %d %d %d %d %d", &(c.value1), &(c.value2), &(c.red1), &(c.green1), &(c.blue1), &(c.red2), &(c.green2), &(c.blue2) ) != 8 )
if ( sscanf( list[i].toUtf8().data(), "%lf %lf %d %d %d %d %d %d", &( c.value1 ), &( c.value2 ), &( c.red1 ), &( c.green1 ), &( c.blue1 ), &( c.red2 ), &( c.green2 ), &( c.blue2 ) ) != 8 )
{
throw QgsGrass::Exception( "Cannot parse GRASS colors" + list[i] + " (" + str + " ) " );
}
ct.append( c);
ct.append( c );
}
}
catch ( QgsGrass::Exception &e )
@ -1253,7 +1253,7 @@ QList<QgsGrass::Color> GRASS_EXPORT QgsGrass::colors( QString gisdbase, QString
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot get colors" ) + "\n" + e.what() );
}
return ct;
return ct;
}
QMap<QString, QString> GRASS_EXPORT QgsGrass::query( QString gisdbase, QString location, QString mapset, QString map, MapType type, double x, double y )

View File

@ -52,7 +52,8 @@ class QgsGrass
Exception( const QString &msg ) : std::runtime_error( msg.toUtf8().constData() ) {}
};
struct Color {
struct Color
{
double value1, value2;
int red1, red2, green1, green2, blue1, blue2;
};
@ -196,7 +197,7 @@ class QgsGrass
// ! Get raster map size
static GRASS_EXPORT void size( QString gisdbase, QString location,
QString mapset, QString map, int *cols, int *rows );
QString mapset, QString map, int *cols, int *rows );
// ! Get raster info
static GRASS_EXPORT QHash<QString, QString> info( QString gisdbase, QString location,

View File

@ -76,7 +76,7 @@ QgsGrassRasterProvider::QgsGrassRasterProvider( QString const & uri )
QgsDebugMsg( QString( "mapset: %1" ).arg( mMapset ) );
QgsDebugMsg( QString( "mapName: %1" ).arg( mMapName ) );
mValidNoDataValue = true;
mValidNoDataValue = true;
mCrs = QgsGrass::crs( mGisdbase, mLocation );
@ -91,15 +91,15 @@ QgsGrassRasterProvider::QgsGrassRasterProvider( QString const & uri )
// TODO: refresh mRows and mCols if raster was rewritten
// We have to decide some reasonable block size, not to big to occupate too much
// memory, not too small to result in too many calls to readBlock -> qgis.d.rast
// memory, not too small to result in too many calls to readBlock -> qgis.d.rast
// for statistics
int cache_size = 10000000; // ~ 10 MB
mYBlockSize = cache_size / (dataTypeSize(dataType ( 1 ) )/8) / mCols;
if ( mYBlockSize > mRows )
mYBlockSize = cache_size / ( dataTypeSize( dataType( 1 ) ) / 8 ) / mCols;
if ( mYBlockSize > mRows )
{
mYBlockSize = mRows;
}
QgsDebugMsg( "mYBlockSize = " + QString::number ( mYBlockSize ) );
QgsDebugMsg( "mYBlockSize = " + QString::number( mYBlockSize ) );
}
QgsGrassRasterProvider::~QgsGrassRasterProvider()
@ -153,7 +153,7 @@ void QgsGrassRasterProvider::readBlock( int bandNo, int xBlock, int yBlock, void
{
QgsDebugMsg( "Entered" );
// TODO: optimize, see extent()
QgsDebugMsg( "yBlock = " + QString::number( yBlock ) );
QStringList arguments;
@ -167,13 +167,13 @@ void QgsGrassRasterProvider::readBlock( int bandNo, int xBlock, int yBlock, void
double yMaximum = ext.yMaximum() - cellHeight * yBlock * mYBlockSize;
double yMinimum = yMaximum - cellHeight * mYBlockSize;
QgsDebugMsg( "mYBlockSize = " + QString::number ( mYBlockSize ) );
QgsDebugMsg( "mYBlockSize = " + QString::number( mYBlockSize ) );
arguments.append(( QString( "window=%1,%2,%3,%4,%5,%6" )
.arg( ext.xMinimum() ).arg( yMinimum )
.arg( ext.xMaximum() ).arg( yMaximum )
.arg( mCols ).arg( mYBlockSize ) ) );
.arg( mCols ).arg( mYBlockSize ) ) );
arguments.append( "format=value");
arguments.append( "format=value" );
QProcess process( this );
QString cmd = QgsApplication::prefixPath() + "/" QGIS_LIBEXEC_SUBDIR "/grass/modules/qgis.d.rast";
QByteArray data;
@ -191,13 +191,14 @@ void QgsGrassRasterProvider::readBlock( int bandNo, int xBlock, int yBlock, void
QgsDebugMsg( QString( "%1 bytes read from modules stdout" ).arg( data.size() ) );
// byteCount() in Qt >= 4.6
//int size = image->byteCount() < data.size() ? image->byteCount() : data.size();
int size = mCols * mYBlockSize * dataTypeSize(bandNo) / 8;
QgsDebugMsg ( QString ( "mCols = %1 mYBlockSize = %2 dataTypeSize = %3" ).arg ( mCols ).arg ( mYBlockSize ).arg ( dataTypeSize(bandNo) ) );
if ( size != data.size() ) {
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QString( "%1 bytes expected but %2 byte were read from qgis.d.rast" ).arg(size).arg(data.size() ) );
int size = mCols * mYBlockSize * dataTypeSize( bandNo ) / 8;
QgsDebugMsg( QString( "mCols = %1 mYBlockSize = %2 dataTypeSize = %3" ).arg( mCols ).arg( mYBlockSize ).arg( dataTypeSize( bandNo ) ) );
if ( size != data.size() )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QString( "%1 bytes expected but %2 byte were read from qgis.d.rast" ).arg( size ).arg( data.size() ) );
size = size < data.size() ? size : data.size();
}
}
memcpy( block, data.data(), size );
}
@ -215,7 +216,7 @@ void QgsGrassRasterProvider::readBlock( int bandNo, QgsRectangle const & viewEx
.arg( viewExtent.xMinimum() ).arg( viewExtent.yMinimum() )
.arg( viewExtent.xMaximum() ).arg( viewExtent.yMaximum() )
.arg( pixelWidth ).arg( pixelHeight ) ) );
arguments.append( "format=value");
arguments.append( "format=value" );
QProcess process( this );
QString cmd = QgsApplication::prefixPath() + "/" QGIS_LIBEXEC_SUBDIR "/grass/modules/qgis.d.rast";
QByteArray data;
@ -234,61 +235,72 @@ void QgsGrassRasterProvider::readBlock( int bandNo, QgsRectangle const & viewEx
QgsDebugMsg( QString( "%1 bytes read from modules stdout" ).arg( data.size() ) );
// byteCount() in Qt >= 4.6
//int size = image->byteCount() < data.size() ? image->byteCount() : data.size();
int size = pixelWidth * pixelHeight * dataTypeSize(bandNo) / 8;
if ( size != data.size() ) {
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QString( "%1 bytes expected but %2 byte were read from qgis.d.rast" ).arg(size).arg(data.size() ) );
int size = pixelWidth * pixelHeight * dataTypeSize( bandNo ) / 8;
if ( size != data.size() )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QString( "%1 bytes expected but %2 byte were read from qgis.d.rast" ).arg( size ).arg( data.size() ) );
size = size < data.size() ? size : data.size();
}
}
memcpy( block, data.data(), size );
}
double QgsGrassRasterProvider::noDataValue() const {
double QgsGrassRasterProvider::noDataValue() const
{
double nul;
if ( mGrassDataType == CELL_TYPE ) {
if ( mGrassDataType == CELL_TYPE )
{
nul = -2147483647;
} else if ( mGrassDataType == DCELL_TYPE ) {
}
else if ( mGrassDataType == DCELL_TYPE )
{
nul = 2.2250738585072014e-308;
} else if ( mGrassDataType == FCELL_TYPE ) {
}
else if ( mGrassDataType == FCELL_TYPE )
{
nul = 1.17549435e-38F;
}
QgsDebugMsg( QString( "noDataValue = %1" ).arg( nul ) );
return nul;
}
double QgsGrassRasterProvider::minimumValue( int bandNo ) const {
double QgsGrassRasterProvider::minimumValue( int bandNo ) const
{
return mInfo["MIN_VALUE"].toDouble();
}
double QgsGrassRasterProvider::maximumValue( int bandNo ) const {
double QgsGrassRasterProvider::maximumValue( int bandNo ) const
{
return mInfo["MAX_VALUE"].toDouble();
}
QList<QgsColorRampShader::ColorRampItem> QgsGrassRasterProvider::colorTable(int bandNo)const {
QList<QgsColorRampShader::ColorRampItem> QgsGrassRasterProvider::colorTable( int bandNo )const
{
QList<QgsColorRampShader::ColorRampItem> ct;
// TODO: check if color can be realy discontinuous in GRASS,
// for now we just believe that they are continuous, i.e. end and beginning
// of the ramp with the same value has the same color
// we are also expecting ordered CT records in the list
QList<QgsGrass::Color> colors = QgsGrass::colors( mGisdbase, mLocation, mMapset, mMapName );
QList<QgsGrass::Color>::iterator i;
double v, r, g, b;
for (i = colors.begin(); i != colors.end(); ++i)
for ( i = colors.begin(); i != colors.end(); ++i )
{
if ( ct.count() == 0 || i->value1 != v || i->red1 != r || i->green1 != g || i->blue1 != b ) {
if ( ct.count() == 0 || i->value1 != v || i->red1 != r || i->green1 != g || i->blue1 != b )
{
// not added in previous rule
QgsColorRampShader::ColorRampItem ctItem1;
ctItem1.value = i->value1;
ctItem1.color = QColor::fromRgb( i->red1, i->green1, i->blue1);
ct.append(ctItem1);
QgsDebugMsg( QString("color %1 %2 %3 %4").arg(i->value1).arg(i->red1).arg(i->green1).arg(i->blue1) );
ctItem1.color = QColor::fromRgb( i->red1, i->green1, i->blue1 );
ct.append( ctItem1 );
QgsDebugMsg( QString( "color %1 %2 %3 %4" ).arg( i->value1 ).arg( i->red1 ).arg( i->green1 ).arg( i->blue1 ) );
}
QgsColorRampShader::ColorRampItem ctItem2;
ctItem2.value = i->value2;
ctItem2.color = QColor::fromRgb( i->red2, i->green2, i->blue2);
ct.append(ctItem2);
QgsDebugMsg( QString("color %1 %2 %3 %4").arg(i->value2).arg(i->red2).arg(i->green2).arg(i->blue2) );
ctItem2.color = QColor::fromRgb( i->red2, i->green2, i->blue2 );
ct.append( ctItem2 );
QgsDebugMsg( QString( "color %1 %2 %3 %4" ).arg( i->value2 ).arg( i->red2 ).arg( i->green2 ).arg( i->blue2 ) );
v = i->value2; r = i->red2; g = i->green2; b = i->blue2;
}
@ -311,14 +323,15 @@ QgsRectangle QgsGrassRasterProvider::extent()
}
// this is only called once when statistics are calculated
int QgsGrassRasterProvider::xBlockSize() const { return mCols; }
int QgsGrassRasterProvider::yBlockSize() const {
return mYBlockSize;
int QgsGrassRasterProvider::xBlockSize() const { return mCols; }
int QgsGrassRasterProvider::yBlockSize() const
{
return mYBlockSize;
}
// TODO this should be always refreshed if raster has changed ?
// maybe also only for stats
int QgsGrassRasterProvider::xSize() const { return mCols; }
int QgsGrassRasterProvider::xSize() const { return mCols; }
int QgsGrassRasterProvider::ySize() const { return mRows; }
bool QgsGrassRasterProvider::identify( const QgsPoint& thePoint, QMap<QString, QString>& theResults )
@ -331,10 +344,10 @@ bool QgsGrassRasterProvider::identify( const QgsPoint& thePoint, QMap<QString, Q
int QgsGrassRasterProvider::capabilities() const
{
int capability = QgsRasterDataProvider::Identify
| QgsRasterDataProvider::ExactResolution
| QgsRasterDataProvider::ExactMinimumMaximum
| QgsRasterDataProvider::Size;
int capability = QgsRasterDataProvider::Identify
| QgsRasterDataProvider::ExactResolution
| QgsRasterDataProvider::ExactMinimumMaximum
| QgsRasterDataProvider::Size;
return capability;
}
@ -345,7 +358,8 @@ int QgsGrassRasterProvider::dataType( int bandNo ) const
int QgsGrassRasterProvider::srcDataType( int bandNo ) const
{
switch ( mGrassDataType ) {
switch ( mGrassDataType )
{
case CELL_TYPE:
return QgsRasterDataProvider::Int32;
break;
@ -365,10 +379,12 @@ int QgsGrassRasterProvider::bandCount() const
return 1;
}
int QgsGrassRasterProvider::colorInterpretation ( int bandNo ) const {
int QgsGrassRasterProvider::colorInterpretation( int bandNo ) const
{
// TODO: avoid loading color table here or cache it
QList<QgsColorRampShader::ColorRampItem> ct = colorTable(bandNo);
if ( ct.size() > 0 ) {
QList<QgsColorRampShader::ColorRampItem> ct = colorTable( bandNo );
if ( ct.size() > 0 )
{
return QgsRasterDataProvider::PaletteIndex;
}
return QgsRasterDataProvider::GrayIndex;
@ -378,27 +394,27 @@ QString QgsGrassRasterProvider::metadata()
{
QString myMetadata ;
QStringList myList;
myList.append ( "GISDBASE: " + mGisdbase );
myList.append ( "LOCATION: " + mLocation );
myList.append ( "MAPSET: " + mMapset );
myList.append ( "MAP: " + mMapName );
myList.append( "GISDBASE: " + mGisdbase );
myList.append( "LOCATION: " + mLocation );
myList.append( "MAPSET: " + mMapset );
myList.append( "MAP: " + mMapName );
QHash<QString, QString>::iterator i;
for (i = mInfo.begin(); i != mInfo.end(); ++i)
for ( i = mInfo.begin(); i != mInfo.end(); ++i )
{
myList.append ( i.key() + " : " + i.value() );
myList.append( i.key() + " : " + i.value() );
}
myMetadata += QgsRasterDataProvider::makeTableCells( myList );
return myMetadata;
}
void QgsGrassRasterProvider::populateHistogram( int theBandNoInt,
QgsRasterBandStats & theBandStats,
int theBinCount,
bool theIgnoreOutOfRangeFlag,
bool theHistogramEstimatedFlag)
QgsRasterBandStats & theBandStats,
int theBinCount,
bool theIgnoreOutOfRangeFlag,
bool theHistogramEstimatedFlag )
{
// TODO: we could either implement it in QgsRasterDataProvider::populateHistogram
// or use r.stats (see d.histogram)
@ -414,8 +430,8 @@ void QgsGrassRasterProvider::populateHistogram( int theBandNoInt,
theBandStats.histogramVector->push_back( 0 );
}
}
QgsDebugMsg( ">>>>> Histogram vector now contains " +
QString::number( theBandStats.histogramVector->size() ) + " elements" );
QgsDebugMsg( ">>>>> Histogram vector now contains " +
QString::number( theBandStats.histogramVector->size() ) + " elements" );
}

View File

@ -177,12 +177,12 @@ class QgsGrassRasterProvider : public QgsRasterDataProvider
*/
int capabilities() const;
int dataType ( int bandNo ) const;
int srcDataType ( int bandNo ) const;
int dataType( int bandNo ) const;
int srcDataType( int bandNo ) const;
int bandCount() const;
int colorInterpretation ( int bandNo ) const;
int colorInterpretation( int bandNo ) const;
int xBlockSize() const;
int yBlockSize() const;
@ -195,18 +195,18 @@ class QgsGrassRasterProvider : public QgsRasterDataProvider
void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, void *data );
double noDataValue() const;
double minimumValue(int bandNo)const;
double maximumValue(int bandNo)const;
double minimumValue( int bandNo )const;
double maximumValue( int bandNo )const;
QList<QgsColorRampShader::ColorRampItem> colorTable(int bandNo)const;
QList<QgsColorRampShader::ColorRampItem> colorTable( int bandNo )const;
// void buildSupportedRasterFileFilter( QString & theFileFiltersString );
// void buildSupportedRasterFileFilter( QString & theFileFiltersString );
/**
* Get metadata in a format suitable for feeding directly
* into a subset of the GUI raster properties "Metadata" tab.
*/
QString metadata();
QString metadata();
// Following methods specific for WMS are not used at all in this provider and should be removed IMO from qgsdataprovider.h
void addLayers( QStringList const & layers, QStringList const & styles = QStringList() ) {}
@ -216,11 +216,11 @@ class QgsGrassRasterProvider : public QgsRasterDataProvider
void setImageCrs( QString const & crs ) {}
void populateHistogram( int theBandNoInt,
QgsRasterBandStats & theBandStats,
int theBinCountInt = 256,
bool theIgnoreOutOfRangeFlag = true,
bool theThoroughBandScanFlag = false
);
QgsRasterBandStats & theBandStats,
int theBinCountInt = 256,
bool theIgnoreOutOfRangeFlag = true,
bool theThoroughBandScanFlag = false
);
private:

View File

@ -693,14 +693,16 @@ void QgsWmsProvider::readBlock( int bandNo, QgsRectangle const & viewExtent, in
// TODO: optimize to avoid writing to QImage
QImage* image = draw( viewExtent, pixelWidth, pixelHeight );
if ( ! image ) { // should not happen
if ( ! image ) // should not happen
{
QgsDebugMsg( "image is NULL" );
return;
}
QgsDebugMsg( QString("image height = %1 bytesPerLine = %2").arg(image->height() ) . arg ( image->bytesPerLine() ) ) ;
QgsDebugMsg( QString( "image height = %1 bytesPerLine = %2" ).arg( image->height() ) . arg( image->bytesPerLine() ) ) ;
int myExpectedSize = pixelWidth * pixelHeight * 4;
int myImageSize = image->height() * image->bytesPerLine();
if ( myExpectedSize != myImageSize ) { // should not happen
if ( myExpectedSize != myImageSize ) // should not happen
{
QgsDebugMsg( "unexpected image size" );
return;
}
@ -1009,7 +1011,7 @@ int QgsWmsProvider::srcDataType( int bandNo ) const
int QgsWmsProvider::bandCount() const
{
return 1;
}
}
void QgsWmsProvider::capabilitiesReplyProgress( qint64 bytesReceived, qint64 bytesTotal )
{

View File

@ -529,10 +529,10 @@ class QgsWmsProvider : public QgsRasterDataProvider
*/
int capabilities() const;
int dataType ( int bandNo ) const;
int srcDataType ( int bandNo ) const;
int dataType( int bandNo ) const;
int srcDataType( int bandNo ) const;
int bandCount() const;
/**
* Get metadata in a format suitable for feeding directly