Skip to content
Permalink
Browse files

raster cleanup

  • Loading branch information
blazek committed Apr 16, 2013
1 parent d3a7e04 commit 22e54b9210d60256ce49aa6637ce403eb4422659
@@ -120,22 +120,8 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
virtual int ySize() const;

/** 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 );

/** read block of data using give extent and size */
// virtual void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, void *data );

/** read block of data using give extent and size */
// virtual void *readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *data );

/** Read block of data using given extent and size. */
// virtual void *readBlock( int bandNo, QgsRectangle const & extent, int width, int height );
virtual QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height ) / Factory /;

/* Read a value from a data block at a given index. */
//virtual double readValue( void *data, int type, int index );

/* Return true if source band has no data value */
virtual bool srcHasNoDataValue( int bandNo ) const;

@@ -145,14 +131,6 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
/** \brief Set source nodata value usage */
virtual void setUseSrcNoDataValue( int bandNo, bool use );

/** value representing null data */
//virtual double noDataValue() const;

/** Value representing currentno data.
* WARNING: this value returned by this method is not constant. It may change
* for example if user disable use of source no data value. */
//virtual double noDataValue( int bandNo ) const;

/** Value representing no data value. */
virtual double srcNoDataValue( int bandNo ) const;

@@ -161,9 +139,6 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
/** Get list of user no data value ranges */
virtual QgsRasterRangeList userNoDataValue( int bandNo ) const;

virtual double minimumValue( int bandNo ) const;
virtual double maximumValue( int bandNo ) const;

virtual QList<QgsColorRampShader::ColorRampItem> colorTable( int bandNo ) const;

// Defined in parent
@@ -235,11 +210,6 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
@note: this method was added in version 1.2*/
void setDpi( int dpi );

static QStringList cStringList2Q_( char ** stringList );

static QString makeTableCell( const QString & value );
static QString makeTableCells( const QStringList & values );

/** Time stamp of data source in the moment when data/metadata were loaded by provider */
virtual QDateTime timestamp() const;

@@ -273,9 +243,7 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
virtual bool remove();

/** Returns a list of pyramid resampling method names for given provider */
static QStringList pyramidResamplingMethods( QString providerKey = "gdal" );
/** Returns the pyramid resampling argument that corresponds to a given method */
static QString pyramidResamplingArg( QString method, QString providerKey = "gdal" );
static QList<QPair<QString,QString> > pyramidResamplingMethods( QString providerKey );

/** Validates creation options for a specific dataset and destination format.
* @note used by GDAL provider only
@@ -164,9 +164,11 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
{
// initialize resampling methods
cboResamplingMethod->clear();
foreach ( QString method, QgsRasterDataProvider::pyramidResamplingMethods( mRasterLayer->providerType() ) )
cboResamplingMethod->addItem( method );

QPair<QString, QString> method;
foreach ( method, QgsRasterDataProvider::pyramidResamplingMethods( mRasterLayer->providerType() ) )
{
cboResamplingMethod->addItem( method.second, method.first );
}
// build pyramid list
QList< QgsRasterPyramid > myPyramidList = provider->buildPyramidList();
QList< QgsRasterPyramid >::iterator myRasterPyramidIterator;
@@ -936,7 +938,7 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
QApplication::setOverrideCursor( Qt::WaitCursor );
QString res = provider->buildPyramids(
myPyramidList,
cboResamplingMethod->currentText(),
cboResamplingMethod->itemData( cboResamplingMethod->currentIndex() ).toString(),
( QgsRasterDataProvider::RasterPyramidsFormat ) cbxPyramidsFormat->currentIndex() );
QApplication::restoreOverrideCursor();
mPyramidProgress->setValue( 0 );
@@ -145,12 +145,16 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,

int width = expectedProvider->xSize();
int height = expectedProvider->ySize();
int blockSize = width * height * QgsRasterBlock::typeSize( expectedProvider->dataType( band ) ) ;
void * expectedData = malloc( blockSize );
void * verifiedData = malloc( blockSize );
QgsRasterBlock *expectedBlock = expectedProvider->block( band, expectedProvider->extent(), width, height );
QgsRasterBlock *verifiedBlock = verifiedProvider->block( band, expectedProvider->extent(), width, height );

expectedProvider->readBlock( band, expectedProvider->extent(), width, height, expectedData );
verifiedProvider->readBlock( band, expectedProvider->extent(), width, height, verifiedData );
if ( !expectedBlock || !expectedBlock->isValid() ||
!verifiedBlock || !verifiedBlock->isValid() )
{
allOk = false;
mReport += "cannot read raster block";
continue;
}

// compare data values
QString htmlTable = QString( "<table style='%1'>" ).arg( mTabStyle );
@@ -160,8 +164,8 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,
for ( int col = 0; col < width; col ++ )
{
bool cellOk = true;
double verifiedVal = QgsRasterBlock::readValue( verifiedData, verifiedProvider->dataType( band ), row * width + col );
double expectedVal = QgsRasterBlock::readValue( expectedData, expectedProvider->dataType( band ), row * width + col );
double verifiedVal = verifiedBlock->value( row, col );
double expectedVal = expectedBlock->value( row, col );

QString valStr;
if ( compare( verifiedVal, expectedVal, 0 ) )
@@ -182,8 +186,8 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,

mReport += htmlTable;

free( expectedData );
free( verifiedData );
delete expectedBlock;
delete verifiedBlock;
}
delete verifiedProvider;
delete expectedProvider;

0 comments on commit 22e54b9

Please sign in to comment.
You can’t perform that action at this time.