Skip to content
Permalink
Browse files

Align raster code improvements

 * Fix x/y mismatch
 * Improve strings for translation
 * Remove unrequired cast
  • Loading branch information
m-kuhn committed Apr 8, 2016
1 parent a6aa855 commit b6aee9356398e5d4c5a42d454bb2bf9401c70a50
Showing with 5 additions and 6 deletions.
  1. +5 −6 src/analysis/raster/qgsalignraster.cpp
@@ -193,7 +193,7 @@ bool QgsAlignRaster::setParametersFromRaster( const RasterInfo& rasterInfo, cons
else
{
mGridOffsetX = customGridOffset.x();
mGridOffsetY = customGridOffset.x();
mGridOffsetY = customGridOffset.y();
}
}
else
@@ -253,8 +253,7 @@ bool QgsAlignRaster::checkInputParameters()
}

mXSize = mYSize = 0;
for ( int i = 0; i < 6; ++i )
mGeoTransform[i] = 0;
std::fill( &mGeoTransform[0], &mGeoTransform[5], 0 );

This comment has been minimized.

Copy link
@rouault

rouault Apr 8, 2016

Contributor

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

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Apr 8, 2016

Author Member

good catch.

you wouldn't have a guess why the raster alignment fails, potentially related to gdal 2?
#2983 (comment)

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Apr 8, 2016

Collaborator

@m-kuhn try nyalldawson@282553e

That was intended to fix it for windows, but for some reason failed on the Travis builds


double finalExtent[4] = { 0, 0, 0, 0 };

@@ -432,7 +431,7 @@ bool QgsAlignRaster::createAndWarp( const Item& raster )
GDALDatasetH hSrcDS = GDALOpen( raster.inputFilename.toLocal8Bit().constData(), GA_ReadOnly );
if ( !hSrcDS )
{
mErrorMessage = QObject::tr( "Unable to open input file: " ) + raster.inputFilename;
mErrorMessage = QObject::tr( "Unable to open input file: %1" ).arg( raster.inputFilename );
return false;
}

@@ -448,13 +447,13 @@ bool QgsAlignRaster::createAndWarp( const Item& raster )
if ( !hDstDS )
{
GDALClose( hSrcDS );
mErrorMessage = QObject::tr( "Unable to create output file: " ) + raster.outputFilename;
mErrorMessage = QObject::tr( "Unable to create output file: %1" ).arg( raster.outputFilename );
return false;
}

// Write out the projection definition.
GDALSetProjection( hDstDS, mCrsWkt.toAscii().constData() );
GDALSetGeoTransform( hDstDS, ( double* )mGeoTransform );
GDALSetGeoTransform( hDstDS, mGeoTransform );

// Copy the color table, if required.
GDALColorTableH hCT = GDALGetRasterColorTable( GDALGetRasterBand( hSrcDS, 1 ) );

0 comments on commit b6aee93

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