Skip to content
Permalink
Browse files

Write operation for raster providers

  • Loading branch information
mhugent committed Jul 11, 2012
1 parent c985736 commit 3ba646f05d71930a9dff12e7b5c7c79142336007
Showing with 25 additions and 0 deletions.
  1. +12 −0 src/core/qgsrasterdataprovider.h
  2. +10 −0 src/providers/gdal/qgsgdalprovider.cpp
  3. +3 −0 src/providers/gdal/qgsgdalprovider.h
@@ -435,6 +435,18 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider, public QgsRast
/** Current time stamp of data source */
virtual QDateTime dataTimestamp() const { return QDateTime(); }

/**Writes into the provider datasource*/
virtual bool write( void* data, int band, int width, int height, int xOffset, int yOffset )
{
Q_UNUSED( data );
Q_UNUSED( band );
Q_UNUSED( width );
Q_UNUSED( height );
Q_UNUSED( xOffset );
Q_UNUSED( yOffset );
return false;
}

/** Creates a new dataset with mDataSourceURI
@return true in case of success*/
virtual bool create( const QString& format, int nBands,
@@ -2089,6 +2089,16 @@ bool QgsGdalProvider::create( const QString& format, int nBands, QgsRasterDataPr
return mValid;
}

bool QgsGdalProvider::write( void* data, int band, int width, int height, int xOffset, int yOffset )
{
GDALRasterBandH rasterBand = GDALGetRasterBand( mGdalDataset, band );
if ( rasterBand == NULL )
{
return false;
}
return ( GDALRasterIO( rasterBand, GF_Write, xOffset, yOffset, width, height, data, width, height, GDALGetRasterDataType( rasterBand ), 0, 0 ) == CE_None );
}

QStringList QgsGdalProvider::createFormats() const
{
return QStringList();
@@ -269,6 +269,9 @@ class QgsGdalProvider : public QgsRasterDataProvider
bool create( const QString& format, int nBands, QgsRasterDataProvider::DataType type, int width, int height,
double* geoTransform, const QgsCoordinateReferenceSystem& crs );

/**Writes into the provider datasource*/
bool write( void* data, int band, int width, int height, int xOffset, int yOffset );

/**Returns the formats supported by create()*/
QStringList createFormats() const;

0 comments on commit 3ba646f

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