Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
raster cleanup
  • Loading branch information
blazek committed Apr 16, 2013
1 parent d3a7e04 commit 22e54b9
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 512 deletions.
34 changes: 1 addition & 33 deletions python/core/raster/qgsrasterdataprovider.sip
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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 );
Expand Down
22 changes: 13 additions & 9 deletions src/core/raster/qgsrasterchecker.cpp
Expand Up @@ -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 );
Expand All @@ -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 ) )
Expand All @@ -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;
Expand Down

0 comments on commit 22e54b9

Please sign in to comment.