Skip to content
Permalink
Browse files

raster sip fix for test unit

  • Loading branch information
blazek committed Sep 13, 2012
1 parent c6a29fa commit 24a047d283f85ccbf603417283a67fb844804c30
@@ -220,6 +220,8 @@ public:
void setRenderer( QgsRasterRenderer* renderer /Transfer/ );
QgsRasterRenderer* renderer();

QgsRasterPipe * pipe();

/** \brief Accessor to find out how many standard deviations are being plotted */
double standardDeviations() const;

@@ -33,6 +33,8 @@ class QgsRasterRenderer : QgsRasterInterface
virtual QString type() const;
virtual void * readBlock( int bandNo, const QgsRectangle & extent, int width, int height );

QgsRasterInterface::DataType dataType( int bandNo ) const;

bool usesTransparency() const;

void setOpacity( double opacity );
@@ -22,6 +22,7 @@

#include <QImage>

#include "qgslogger.h"
#include "qgsrectangle.h"

#include "gdal.h"
@@ -116,6 +117,7 @@ class CORE_EXPORT QgsRasterInterface
virtual DataType dataType( int bandNo ) const
{
Q_UNUSED( bandNo );
QgsDebugMsg( "Entered" );
return UnknownDataType;
}

@@ -123,12 +123,15 @@ bool QgsRasterPipe::replace( int idx, QgsRasterInterface* theInterface )

QgsRasterPipe::Role QgsRasterPipe::interfaceRole( QgsRasterInterface * interface ) const
{
if ( dynamic_cast<QgsRasterDataProvider *>( interface ) ) return ProviderRole;
if ( dynamic_cast<QgsRasterRenderer *>( interface ) ) return RendererRole;
if ( dynamic_cast<QgsRasterResampleFilter *>( interface ) ) return ResamplerRole;
if ( dynamic_cast<QgsRasterProjector *>( interface ) ) return ProjectorRole;
if ( dynamic_cast<QgsRasterNuller *>( interface ) ) return NullerRole;
return UnknownRole;
Role role = UnknownRole;
if ( dynamic_cast<QgsRasterDataProvider *>( interface ) ) role = ProviderRole;
else if ( dynamic_cast<QgsRasterRenderer *>( interface ) ) role = RendererRole;
else if ( dynamic_cast<QgsRasterResampleFilter *>( interface ) ) role = ResamplerRole;
else if ( dynamic_cast<QgsRasterProjector *>( interface ) ) role = ProjectorRole;
else if ( dynamic_cast<QgsRasterNuller *>( interface ) ) role = NullerRole;

QgsDebugMsg( QString( "%1 role = %2" ).arg( typeid( *interface ).name() ).arg( role ) );
return role;
}

void QgsRasterPipe::setRole( QgsRasterInterface * theInterface, int idx )
@@ -53,6 +53,8 @@ int QgsRasterRenderer::bandCount() const

QgsRasterInterface::DataType QgsRasterRenderer::dataType( int bandNo ) const
{
QgsDebugMsg( "Entered" );

if ( mOn ) return QgsRasterInterface::ARGB32_Premultiplied;

if ( mInput ) return mInput->dataType( bandNo );
@@ -104,7 +104,8 @@ bool QgsRasterResampleFilter::setInput( QgsRasterInterface* input )
return false;
}

if ( input->dataType( 1 ) != QgsRasterInterface::ARGB32_Premultiplied )
if ( input->dataType( 1 ) != QgsRasterInterface::ARGB32_Premultiplied &&
input->dataType( 1 ) != QgsRasterInterface::ARGB32 )
{
QgsDebugMsg( "Unknown input data type" );
return false;
@@ -31,7 +31,10 @@ def testCase(self):
rasterFileInfo = QFileInfo(TEST_DATA_DIR+QDir().separator().toAscii()+"landsat.tif")
mRasterLayer = QgsRasterLayer(rasterFileInfo.filePath(), rasterFileInfo.completeBaseName())
rasterRenderer = QgsMultiBandColorRenderer( mRasterLayer.dataProvider(), 2, 3, 4 )
mRasterLayer.setRenderer( rasterRenderer )
#mRasterLayer.setRenderer( rasterRenderer )
pipe = mRasterLayer.pipe()
assert pipe.set( rasterRenderer ), "Cannot set pipe renderer"

QgsMapLayerRegistry.instance().addMapLayer( mRasterLayer )

# create composition with composer map

0 comments on commit 24a047d

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