Skip to content
Permalink
Browse files

fixes for QgsRasterInterface subclassing in Python

  • Loading branch information
blazek committed Sep 18, 2012
1 parent 5eb1e2d commit 9c6ebdd4ee245f72b3ba6798a1cd1aa98b5fc917
@@ -84,22 +84,31 @@ class QgsRasterInterface

virtual double noDataValue() const;

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

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

virtual bool setInput( QgsRasterInterface* input );

virtual QgsRasterInterface * input () const;

virtual bool on( );

virtual void setOn( bool on );

virtual QgsRasterInterface * srcInput();
QgsRasterInterface * srcInput();

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

void setStatsOn( bool on );

double time( bool cumulative = false );

static QString printValue( double value );

protected:
static double readValue( void *data, QgsRasterInterface::DataType type, int index );

static void writeValue( void *data, QgsRasterInterface::DataType type, int index, double value );
};

@@ -12,6 +12,8 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <typeinfo>

#include "qgsrasterfilewriter.h"
#include "qgsproviderregistry.h"
#include "qgsrasterinterface.h"
@@ -65,11 +67,14 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeRaster( const QgsRast
return SourceProviderError;
}

QgsDebugMsg( QString( "reading from %1" ).arg( typeid( *iface ).name() ) );

if ( !iface->srcInput() )
{
QgsDebugMsg( "iface->srcInput() == 0" );
return SourceProviderError;
}
QgsDebugMsg( QString( "srcInput = %1" ).arg( typeid( *( iface->srcInput() ) ).name() ) );

mProgressDialog = progressDialog;

@@ -178,6 +178,9 @@ class CORE_EXPORT QgsRasterInterface
* Returns true if set correctly, false if cannot use that input */
virtual bool setInput( QgsRasterInterface* input ) { mInput = input; return true; }

/** Current input */
virtual QgsRasterInterface * input() const { return mInput; }

/** Is on/off */
virtual bool on( ) { return mOn; }

@@ -188,8 +191,16 @@ class CORE_EXPORT QgsRasterInterface
* It may be used to get info about original data, e.g. resolution to decide
* resampling etc.
*/
virtual const QgsRasterInterface * srcInput() const { return mInput ? mInput->srcInput() : this; }
virtual QgsRasterInterface * srcInput() { return mInput ? mInput->srcInput() : this; }
virtual const QgsRasterInterface * srcInput() const
{
QgsDebugMsg( "Entered" );
return mInput ? mInput->srcInput() : this;
}
virtual QgsRasterInterface * srcInput()
{
QgsDebugMsg( "Entered" );
return mInput ? mInput->srcInput() : this;
}

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

0 comments on commit 9c6ebdd

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