Skip to content

Commit 9c6ebdd

Browse files
committed
fixes for QgsRasterInterface subclassing in Python
1 parent 5eb1e2d commit 9c6ebdd

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

python/core/qgsrasterinterface.sip

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,31 @@ class QgsRasterInterface
8484

8585
virtual double noDataValue() const;
8686

87-
//void * block( int bandNo, QgsRectangle const & extent, int width, int height );
87+
virtual void * block( int bandNo, const QgsRectangle & extent, int width, int height );
8888

89-
//virtual void * readBlock( int bandNo, QgsRectangle const & extent, int width, int height );
89+
virtual void * readBlock( int bandNo, const QgsRectangle & extent, int width, int height );
9090

9191
virtual bool setInput( QgsRasterInterface* input );
9292

93+
virtual QgsRasterInterface * input () const;
94+
9395
virtual bool on( );
9496

9597
virtual void setOn( bool on );
9698

97-
virtual QgsRasterInterface * srcInput();
99+
QgsRasterInterface * srcInput();
98100

99101
QImage * createImage( int width, int height, QImage::Format format );
100102

101103
void setStatsOn( bool on );
102104

103105
double time( bool cumulative = false );
106+
107+
static QString printValue( double value );
108+
109+
protected:
110+
static double readValue( void *data, QgsRasterInterface::DataType type, int index );
111+
112+
static void writeValue( void *data, QgsRasterInterface::DataType type, int index, double value );
104113
};
105114

src/core/raster/qgsrasterfilewriter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* (at your option) any later version. *
1313
* *
1414
***************************************************************************/
15+
#include <typeinfo>
16+
1517
#include "qgsrasterfilewriter.h"
1618
#include "qgsproviderregistry.h"
1719
#include "qgsrasterinterface.h"
@@ -65,11 +67,14 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeRaster( const QgsRast
6567
return SourceProviderError;
6668
}
6769

70+
QgsDebugMsg( QString( "reading from %1" ).arg( typeid( *iface ).name() ) );
71+
6872
if ( !iface->srcInput() )
6973
{
7074
QgsDebugMsg( "iface->srcInput() == 0" );
7175
return SourceProviderError;
7276
}
77+
QgsDebugMsg( QString( "srcInput = %1" ).arg( typeid( *( iface->srcInput() ) ).name() ) );
7378

7479
mProgressDialog = progressDialog;
7580

src/core/raster/qgsrasterinterface.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ class CORE_EXPORT QgsRasterInterface
178178
* Returns true if set correctly, false if cannot use that input */
179179
virtual bool setInput( QgsRasterInterface* input ) { mInput = input; return true; }
180180

181+
/** Current input */
182+
virtual QgsRasterInterface * input() const { return mInput; }
183+
181184
/** Is on/off */
182185
virtual bool on( ) { return mOn; }
183186

@@ -188,8 +191,16 @@ class CORE_EXPORT QgsRasterInterface
188191
* It may be used to get info about original data, e.g. resolution to decide
189192
* resampling etc.
190193
*/
191-
virtual const QgsRasterInterface * srcInput() const { return mInput ? mInput->srcInput() : this; }
192-
virtual QgsRasterInterface * srcInput() { return mInput ? mInput->srcInput() : this; }
194+
virtual const QgsRasterInterface * srcInput() const
195+
{
196+
QgsDebugMsg( "Entered" );
197+
return mInput ? mInput->srcInput() : this;
198+
}
199+
virtual QgsRasterInterface * srcInput()
200+
{
201+
QgsDebugMsg( "Entered" );
202+
return mInput ? mInput->srcInput() : this;
203+
}
193204

194205
/** Create a new image with extraneous data, such data may be used
195206
* after the image is destroyed. The memory is not initialized.

0 commit comments

Comments
 (0)