Skip to content

Commit

Permalink
Allow overwriting of existing raster datasets
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jul 19, 2012
1 parent 8ba3a59 commit 7c9b2c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/gui/qgsrasterlayersaveasdialog.cpp
Expand Up @@ -69,7 +69,7 @@ void QgsRasterLayerSaveAsDialog::on_mBrowseButton_clicked()
}
else
{
fileName = QFileDialog::getOpenFileName( this, tr( "Select output file" ) );
fileName = QFileDialog::getSaveFileName( this, tr( "Select output file" ) );
}

if ( !fileName.isEmpty() )
Expand Down
17 changes: 6 additions & 11 deletions src/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -2055,11 +2055,6 @@ void QgsGdalProvider::initBaseDataset()
bool QgsGdalProvider::create( const QString& format, int nBands, QgsRasterDataProvider::DataType type, int width, int height,
double* geoTransform, const QgsCoordinateReferenceSystem& crs )
{
if ( isValid() ) //datasource already exists
{
return false;
}

//get driver
GDALDriverH driver = GDALGetDriverByName( format.toLocal8Bit().data() );
if ( !driver )
Expand Down Expand Up @@ -2091,12 +2086,12 @@ bool QgsGdalProvider::create( const QString& format, int nBands, QgsRasterDataPr

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 );
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
Expand Down

0 comments on commit 7c9b2c1

Please sign in to comment.