Skip to content

Commit 22e54b9

Browse files
committed
raster cleanup
1 parent d3a7e04 commit 22e54b9

14 files changed

+139
-512
lines changed

python/core/raster/qgsrasterdataprovider.sip

+1-33
Original file line numberDiff line numberDiff line change
@@ -120,22 +120,8 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
120120
virtual int ySize() const;
121121

122122
/** read block of data */
123-
// TODO clarify what happens on the last block (the part outside raster)
124-
// virtual void readBlock( int bandNo, int xBlock, int yBlock, void *data );
125-
126-
/** read block of data using give extent and size */
127-
// virtual void readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, void *data );
128-
129-
/** read block of data using give extent and size */
130-
// virtual void *readBlock( int bandNo, QgsRectangle const & viewExtent, int width, int height, QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS, void *data );
131-
132-
/** Read block of data using given extent and size. */
133-
// virtual void *readBlock( int bandNo, QgsRectangle const & extent, int width, int height );
134123
virtual QgsRasterBlock *block( int bandNo, const QgsRectangle &extent, int width, int height ) / Factory /;
135124

136-
/* Read a value from a data block at a given index. */
137-
//virtual double readValue( void *data, int type, int index );
138-
139125
/* Return true if source band has no data value */
140126
virtual bool srcHasNoDataValue( int bandNo ) const;
141127

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

148-
/** value representing null data */
149-
//virtual double noDataValue() const;
150-
151-
/** Value representing currentno data.
152-
* WARNING: this value returned by this method is not constant. It may change
153-
* for example if user disable use of source no data value. */
154-
//virtual double noDataValue( int bandNo ) const;
155-
156134
/** Value representing no data value. */
157135
virtual double srcNoDataValue( int bandNo ) const;
158136

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

164-
virtual double minimumValue( int bandNo ) const;
165-
virtual double maximumValue( int bandNo ) const;
166-
167142
virtual QList<QgsColorRampShader::ColorRampItem> colorTable( int bandNo ) const;
168143

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

238-
static QStringList cStringList2Q_( char ** stringList );
239-
240-
static QString makeTableCell( const QString & value );
241-
static QString makeTableCells( const QStringList & values );
242-
243213
/** Time stamp of data source in the moment when data/metadata were loaded by provider */
244214
virtual QDateTime timestamp() const;
245215

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

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

280248
/** Validates creation options for a specific dataset and destination format.
281249
* @note used by GDAL provider only

src/app/qgsrasterlayerproperties.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,11 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
164164
{
165165
// initialize resampling methods
166166
cboResamplingMethod->clear();
167-
foreach ( QString method, QgsRasterDataProvider::pyramidResamplingMethods( mRasterLayer->providerType() ) )
168-
cboResamplingMethod->addItem( method );
169-
167+
QPair<QString, QString> method;
168+
foreach ( method, QgsRasterDataProvider::pyramidResamplingMethods( mRasterLayer->providerType() ) )
169+
{
170+
cboResamplingMethod->addItem( method.second, method.first );
171+
}
170172
// build pyramid list
171173
QList< QgsRasterPyramid > myPyramidList = provider->buildPyramidList();
172174
QList< QgsRasterPyramid >::iterator myRasterPyramidIterator;
@@ -936,7 +938,7 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
936938
QApplication::setOverrideCursor( Qt::WaitCursor );
937939
QString res = provider->buildPyramids(
938940
myPyramidList,
939-
cboResamplingMethod->currentText(),
941+
cboResamplingMethod->itemData( cboResamplingMethod->currentIndex() ).toString(),
940942
( QgsRasterDataProvider::RasterPyramidsFormat ) cbxPyramidsFormat->currentIndex() );
941943
QApplication::restoreOverrideCursor();
942944
mPyramidProgress->setValue( 0 );

src/core/raster/qgsrasterchecker.cpp

+13-9
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,16 @@ bool QgsRasterChecker::runTest( QString theVerifiedKey, QString theVerifiedUri,
145145

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

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

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

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

183187
mReport += htmlTable;
184188

185-
free( expectedData );
186-
free( verifiedData );
189+
delete expectedBlock;
190+
delete verifiedBlock;
187191
}
188192
delete verifiedProvider;
189193
delete expectedProvider;

0 commit comments

Comments
 (0)