[QGIS Commit] r15815 - trunk/qgis/src/analysis/raster
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Apr 23 15:55:59 EDT 2011
Author: mhugent
Date: 2011-04-23 12:55:59 -0700 (Sat, 23 Apr 2011)
New Revision: 15815
Modified:
trunk/qgis/src/analysis/raster/qgsrastercalculator.cpp
Log:
Use epsg number for output crs in rastercalculator if possible (ticket #3649)
Modified: trunk/qgis/src/analysis/raster/qgsrastercalculator.cpp
===================================================================
--- trunk/qgis/src/analysis/raster/qgsrastercalculator.cpp 2011-04-23 16:21:12 UTC (rev 15814)
+++ trunk/qgis/src/analysis/raster/qgsrastercalculator.cpp 2011-04-23 19:55:59 UTC (rev 15815)
@@ -23,6 +23,7 @@
#include <QProgressDialog>
#include "gdalwarper.h"
+#include <ogr_srs_api.h>
#if defined(GDAL_VERSION_NUM) && GDAL_VERSION_NUM >= 1800
#define TO8(x) (x).toUtf8().constData()
@@ -117,8 +118,21 @@
QgsRasterLayer* rl = mRasterEntries.at( 0 ).raster;
if ( rl )
{
- //proj format would be better, but is not supported e.g. for writing to GeoTiff
- GDALSetProjection( outputDataset, TO8( rl->crs().toWkt() ) );
+ char* crsWKT = 0;
+ OGRSpatialReferenceH ogrSRS = OSRNewSpatialReference( NULL );
+ const QgsCoordinateReferenceSystem& outputCrs = rl->crs();
+ int epsgCode = outputCrs.epsg();
+ if ( epsgCode > 0 && OSRImportFromEPSG( ogrSRS, epsgCode ) == CE_None )
+ {
+ OSRExportToWkt( ogrSRS, &crsWKT );
+ GDALSetProjection( outputDataset, crsWKT );
+ }
+ else
+ {
+ GDALSetProjection( outputDataset, TO8( rl->crs().toWkt() ) );
+ }
+ OSRDestroySpatialReference( ogrSRS );
+ CPLFree( crsWKT );
}
}
More information about the QGIS-commit
mailing list