Skip to content
Permalink
Browse files

Remove hardcoded crs in raster writer

  • Loading branch information
mhugent committed Jul 11, 2012
1 parent f259830 commit 40e9b4d668b2bc731ee5780250bc68230a2fc8d0
Showing with 15 additions and 17 deletions.
  1. +3 −3 src/app/qgisapp.cpp
  2. +8 −12 src/core/raster/qgsrasterfilewriter.cpp
  3. +4 −2 src/core/raster/qgsrasterfilewriter.h
@@ -3779,14 +3779,14 @@ void QgisApp::saveAsRasterFile()
if ( d.tileMode() )
{
fileWriter.setTiledMode( true );
//fileWriter.setMaxTileWidth( d.maximumTileSizeX() );
//fileWriter.setMaxTileHeight( d.maximumTileSizeY() );
fileWriter.setMaxTileWidth( d.maximumTileSizeX() );
fileWriter.setMaxTileHeight( d.maximumTileSizeY() );
}

QProgressDialog pd( 0, tr( "Abort..." ), 0, 0 );
pd.setWindowModality( Qt::WindowModal );
QgsRasterIterator iterator( rasterLayer->pipe()->last() );
fileWriter.writeRaster( &iterator, d.nColumns(), d.outputRectangle(), &pd );
fileWriter.writeRaster( &iterator, d.nColumns(), d.outputRectangle(), rasterLayer->crs(), &pd );
}
}

@@ -25,7 +25,8 @@ QgsRasterFileWriter::~QgsRasterFileWriter()

}

QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeRaster( QgsRasterIterator* iter, int nCols, QgsRectangle outputExtent, QProgressDialog* p )
QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeRaster( QgsRasterIterator* iter, int nCols, QgsRectangle outputExtent,
const QgsCoordinateReferenceSystem& crs, QProgressDialog* p )
{
if ( !iter )
{
@@ -47,11 +48,9 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeRaster( QgsRasterIter

mProgressDialog = p;

QgsRasterInterface::DataType debug = iface->dataType( 1 );

if ( iface->dataType( 1 ) == QgsRasterInterface::ARGB32 )
{
WriterError e = writeARGBRaster( iter, nCols, outputExtent );
WriterError e = writeARGBRaster( iter, nCols, outputExtent, crs );
mProgressDialog = 0;
return e;
}
@@ -162,7 +161,8 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeRasterSingleTile( Qgs
return NoError;
}

QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeARGBRaster( QgsRasterIterator* iter, int nCols, const QgsRectangle& outputExtent )
QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeARGBRaster( QgsRasterIterator* iter, int nCols, const QgsRectangle& outputExtent,
const QgsCoordinateReferenceSystem& crs )
{
if ( !iter )
{
@@ -212,13 +212,9 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeARGBRaster( QgsRaster
geoTransform[4] = 0.0;
geoTransform[5] = -pixelSize;

//where to get CRS from?
QgsCoordinateReferenceSystem fakeCRS;
fakeCRS.createFromEpsg( 21781 );

if ( mTiledMode )
{
createVRT( nCols, nRows, fakeCRS, geoTransform );
createVRT( nCols, nRows, crs, geoTransform );
}
else
{
@@ -229,7 +225,7 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeARGBRaster( QgsRaster
}

if ( !destProvider->create( mOutputFormat, 4, QgsRasterInterface::Byte, nCols, nRows, geoTransform,
fakeCRS ) )
crs ) )
{
delete destProvider;
return CreateDatasourceError;
@@ -319,7 +315,7 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeARGBRaster( QgsRaster
geoTransform[4] = 0.0;
geoTransform[5] = -outputMapUnitsPerPixel;
if ( !destProvider->create( mOutputFormat, 4, QgsRasterInterface::Byte, iterCols, iterRows, geoTransform,
fakeCRS ) )
crs ) )
{
delete destProvider;
return CreateDatasourceError;
@@ -25,7 +25,8 @@ class CORE_EXPORT QgsRasterFileWriter
QgsRasterFileWriter( const QString& outputUrl );
~QgsRasterFileWriter();

WriterError writeRaster( QgsRasterIterator* iter, int nCols, QgsRectangle outputExtent = QgsRectangle(), QProgressDialog* p = 0 );
WriterError writeRaster( QgsRasterIterator* iter, int nCols, QgsRectangle outputExtent,
const QgsCoordinateReferenceSystem& crs, QProgressDialog* p = 0 );

void setOutputFormat( const QString& format ) { mOutputFormat = format; }
QString outputFormat() const { return mOutputFormat; }
@@ -45,7 +46,8 @@ class CORE_EXPORT QgsRasterFileWriter
private:
QgsRasterFileWriter(); //forbidden
WriterError writeRasterSingleTile( QgsRasterIterator* iter, int nCols );
WriterError writeARGBRaster( QgsRasterIterator* iter, int nCols, const QgsRectangle& outputExtent );
WriterError writeARGBRaster( QgsRasterIterator* iter, int nCols, const QgsRectangle& outputExtent,
const QgsCoordinateReferenceSystem& crs );

//initialize vrt member variables
void createVRT( int xSize, int ySize, const QgsCoordinateReferenceSystem& crs, double* geoTransform );

0 comments on commit 40e9b4d

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