Skip to content

Commit

Permalink
+ QgsRasterBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Oct 11, 2012
1 parent b3dcc3d commit 7cb523a
Show file tree
Hide file tree
Showing 69 changed files with 1,771 additions and 1,427 deletions.
5 changes: 3 additions & 2 deletions python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
%Include qgsprovidermetadata.sip
%Include qgsproviderregistry.sip
%Include qgspythonrunner.sip
%Include qgsrasterdataprovider.sip
%Include qgsrasterprojector.sip
%Include qgsrectangle.sip
%Include qgsrenderchecker.sip
%Include qgsrendercontext.sip
Expand Down Expand Up @@ -130,14 +128,17 @@
%Include raster/qgslinearminmaxenhancementwithclip.sip
%Include raster/qgspseudocolorshader.sip
%Include raster/qgsrasterbandstats.sip
%Include raster/qgsrasterblock.sip
%Include raster/qgsrasterchecker.sip
%Include raster/qgsrasterdataprovider.sip
%Include raster/qgsrasterfilewriter.sip
%Include raster/qgsrasterhistogram.sip
%Include raster/qgsrasterinterface.sip
%Include raster/qgsrasteriterator.sip
%Include raster/qgsrasterlayer.sip
%Include raster/qgsrasternuller.sip
%Include raster/qgsrasterpipe.sip
%Include raster/qgsrasterprojector.sip
%Include raster/qgsrasterpyramid.sip
%Include raster/qgsrasterrenderer.sip
%Include raster/qgsrasterresamplefilter.sip
Expand Down
187 changes: 0 additions & 187 deletions python/core/qgsrasterrenderer.sip

This file was deleted.

2 changes: 1 addition & 1 deletion python/core/raster/qgsmultibandcolorrenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class QgsMultiBandColorRenderer: QgsRasterRenderer

static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterDataProvider* provider ) /Factory/;

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

int redBand() const;
void setRedBand( int band );
Expand Down
2 changes: 1 addition & 1 deletion python/core/raster/qgspaletterasterrenderer.sip
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class QgsPalettedRasterRenderer: QgsRasterRenderer
QgsRasterInterface * clone() /Factory/;
static QgsRasterRenderer* create( const QDomElement& elem, QgsRasterDataProvider* provider ) /Factory/;

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

/**Returns number of colors*/
int nColors() const;
Expand Down
95 changes: 95 additions & 0 deletions python/core/raster/qgsrasterblock.sip
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
class QgsRasterBlock
{
%TypeHeaderCode
#include <qgsrasterblock.h>
%End

public:

/** Data types.
* This is modified and extended copy of GDALDataType.
*/
enum DataType
{
/*! Unknown or unspecified type */ UnknownDataType = 0,
/*! Eight bit unsigned integer */ Byte = 1,
/*! Sixteen bit unsigned integer */ UInt16 = 2,
/*! Sixteen bit signed integer */ Int16 = 3,
/*! Thirty two bit unsigned integer */ UInt32 = 4,
/*! Thirty two bit signed integer */ Int32 = 5,
/*! Thirty two bit floating point */ Float32 = 6,
/*! Sixty four bit floating point */ Float64 = 7,
/*! Complex Int16 */ CInt16 = 8,
/*! Complex Int32 */ CInt32 = 9,
/*! Complex Float32 */ CFloat32 = 10,
/*! Complex Float64 */ CFloat64 = 11,
/*! Color, alpha, red, green, blue, 4 bytes the same as
QImage::Format_ARGB32 */ ARGB32 = 12,
/*! Color, alpha, red, green, blue, 4 bytes the same as
QImage::Format_ARGB32_Premultiplied */ ARGB32_Premultiplied = 13
};

struct Range
{
double min;
double max;
bool operator==( const QgsRasterBlock::Range &o ) const;
};

QgsRasterBlock();

QgsRasterBlock( DataType theDataType, int theWidth, int theHeight, double theNoDataValue );

virtual ~QgsRasterBlock();

bool reset( DataType theDataType, int theWidth, int theHeight, double theNoDataValue );

bool isEmpty() const;

int typeSize( int dataType ) const;

int dataTypeSize( int bandNo ) const;

/** Returns true if data type is numeric */
bool typeIsNumeric( QgsRasterBlock::DataType type ) const;

/** Returns true if data type is color */
bool typeIsColor( QgsRasterBlock::DataType type ) const;

/** Returns data type for the band specified by number */
virtual QgsRasterBlock::DataType dataType() const;

/** For given data type returns wider type and sets no data value */
static QgsRasterBlock::DataType typeWithNoDataValue( DataType dataType, double *noDataValue );

double noDataValue( ) const;

void setNoDataValue( double noDataValue );

static bool isNoDataValue( double value, double noDataValue );

bool isNoDataValue( double value ) const;

double value( int row, int column ) const;
double value( size_t index) const;
QRgb color( int row, int column ) const;
QRgb color( size_t index) const;
bool isNoData( int row, int column );
bool isNoData( size_t index );
bool setValue( int row, int column, double value );
bool setValue( size_t index, double value );
bool setColor( int row, int column, QRgb color );
bool setColor( size_t index, QRgb color );
// Not desired to give direct access to data in Python, could cause crash
//char * bits( int row, int column );
//char * bits( size_t index );
static QString printValue( double value );

bool convert( QgsRasterBlock::DataType destDataType );
QImage image() const;
bool setImage( const QImage * image );

static bool valueInRange( double value, const QList<QgsRasterBlock::Range> &rangeList );

};

Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
// TODO: Get the file masks supported by this provider, suitable for feeding into the file open dialog box

/** Returns data type for the band specified by number */
virtual QgsRasterInterface::DataType dataType( int bandNo ) const;
virtual QgsRasterBlock::DataType dataType( int bandNo ) const;

/** Returns source data type for the band specified by number,
* source data type may be shorter than dataType
*/
virtual QgsRasterInterface::DataType srcDataType( int bandNo ) const;
virtual QgsRasterBlock::DataType srcDataType( int bandNo ) const;

/** Returns data type for the band specified by number */
virtual int colorInterpretation( int theBandNo ) const;
Expand Down Expand Up @@ -172,6 +172,7 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface

/** 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 );
Expand All @@ -196,10 +197,10 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
/** Value representing no data value. */
virtual double srcNoDataValue( int bandNo ) const;

virtual void setUserNoDataValue( int bandNo, QList<QgsRasterInterface::Range> noData );
virtual void setUserNoDataValue( int bandNo, QList<QgsRasterBlock::Range> noData );

/** Get list of user no data value ranges */
virtual QList<QgsRasterInterface::Range> userNoDataValue( int bandNo ) const;
virtual QList<QgsRasterBlock::Range> userNoDataValue( int bandNo ) const;

virtual double minimumValue( int bandNo ) const;
virtual double maximumValue( int bandNo ) const;
Expand Down Expand Up @@ -403,7 +404,7 @@ class QgsRasterDataProvider : QgsDataProvider, QgsRasterInterface
/** Creates a new dataset with mDataSourceURI
@return true in case of success*/
virtual bool create( const QString& format, int nBands,
QgsRasterInterface::DataType type,
QgsRasterBlock::DataType type,
int width, int height, double* geoTransform,
const QgsCoordinateReferenceSystem& crs,
QStringList createOptions = QStringList() /*e.v. color table*/ );
Expand Down

0 comments on commit 7cb523a

Please sign in to comment.