@@ -193,7 +193,7 @@ bool QgsAlignRaster::setParametersFromRaster( const RasterInfo& rasterInfo, cons
193
193
else
194
194
{
195
195
mGridOffsetX = customGridOffset.x ();
196
- mGridOffsetY = customGridOffset.x ();
196
+ mGridOffsetY = customGridOffset.y ();
197
197
}
198
198
}
199
199
else
@@ -253,8 +253,7 @@ bool QgsAlignRaster::checkInputParameters()
253
253
}
254
254
255
255
mXSize = mYSize = 0 ;
256
- for ( int i = 0 ; i < 6 ; ++i )
257
- mGeoTransform [i] = 0 ;
256
+ std::fill ( &mGeoTransform [0 ], &mGeoTransform [5 ], 0 );
Collapse comment Comment on line R256
Should end at &mGeoTransform[6]
otherwise:
$ cat test.cpp
#include <algorithm>
#include <stdio.h>
int main(int argc, char* argv[])
{
double mGeoTransform[6];
mGeoTransform[5] = -1;
std::fill( &mGeoTransform[0], &mGeoTransform[5], 1000 );
printf("%f\n", mGeoTransform[5]);
return 0;
}
$ g++ test.cpp -o test
$ ./test
-1.000000
good catch.
you wouldn't have a guess why the raster alignment fails, potentially related to gdal 2?
#2983 (comment)
Code has comments. Press enter to view. 258
257
259
258
double finalExtent[4 ] = { 0 , 0 , 0 , 0 };
260
259
@@ -432,7 +431,7 @@ bool QgsAlignRaster::createAndWarp( const Item& raster )
432
431
GDALDatasetH hSrcDS = GDALOpen ( raster.inputFilename .toLocal8Bit ().constData (), GA_ReadOnly );
433
432
if ( !hSrcDS )
434
433
{
435
- mErrorMessage = QObject::tr ( " Unable to open input file: " ) + raster.inputFilename ;
434
+ mErrorMessage = QObject::tr ( " Unable to open input file: %1 " ). arg ( raster.inputFilename ) ;
436
435
return false ;
437
436
}
438
437
@@ -448,13 +447,13 @@ bool QgsAlignRaster::createAndWarp( const Item& raster )
448
447
if ( !hDstDS )
449
448
{
450
449
GDALClose ( hSrcDS );
451
- mErrorMessage = QObject::tr ( " Unable to create output file: " ) + raster.outputFilename ;
450
+ mErrorMessage = QObject::tr ( " Unable to create output file: %1 " ). arg ( raster.outputFilename ) ;
452
451
return false ;
453
452
}
454
453
455
454
// Write out the projection definition.
456
455
GDALSetProjection ( hDstDS, mCrsWkt .toAscii ().constData () );
457
- GDALSetGeoTransform ( hDstDS, ( double * ) mGeoTransform );
456
+ GDALSetGeoTransform ( hDstDS, mGeoTransform );
458
457
459
458
// Copy the color table, if required.
460
459
GDALColorTableH hCT = GDALGetRasterColorTable ( GDALGetRasterBand ( hSrcDS, 1 ) );
0 commit comments