Skip to content

Commit dc3272a

Browse files
committed
Consider datum transform in raster projector
1 parent 836e1a8 commit dc3272a

File tree

5 files changed

+144
-49
lines changed

5 files changed

+144
-49
lines changed

python/core/raster/qgsrasterprojector.sip

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ class QgsRasterProjector : QgsRasterInterface
1313
* it calculates grid of points in source CRS for target CRS + extent
1414
* which are used to calculate affine transformation matrices.
1515
*/
16+
17+
QgsRasterProjector(
18+
QgsCoordinateReferenceSystem theSrcCRS,
19+
QgsCoordinateReferenceSystem theDestCRS,
20+
int theSrcDatumTransform,
21+
int theDestDatumTransform,
22+
QgsRectangle theDestExtent,
23+
int theDestRows, int theDestCols,
24+
double theMaxSrcXRes, double theMaxSrcYRes,
25+
QgsRectangle theExtent
26+
);
27+
1628
QgsRasterProjector(
1729
QgsCoordinateReferenceSystem theSrcCRS,
1830
QgsCoordinateReferenceSystem theDestCRS,
@@ -39,7 +51,7 @@ class QgsRasterProjector : QgsRasterInterface
3951
int dataType( int bandNo ) const;
4052

4153
/** \brief set source and destination CRS */
42-
void setCRS( const QgsCoordinateReferenceSystem & theSrcCRS, const QgsCoordinateReferenceSystem & theDestCRS );
54+
void setCRS( const QgsCoordinateReferenceSystem & theSrcCRS, const QgsCoordinateReferenceSystem & theDestCRS, int srcDatumTransform = -1, int destDatumTransform = -1 );
4355

4456
/** \brief Get source CRS */
4557
QgsCoordinateReferenceSystem srcCrs() const;

src/core/raster/qgsrasterlayer.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,15 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
333333
{
334334
myRasterViewPort->mSrcCRS = crs();
335335
myRasterViewPort->mDestCRS = rendererContext.coordinateTransform()->destCRS();
336+
myRasterViewPort->mSrcDatumTransform = rendererContext.coordinateTransform()->sourceDatumTransform();
337+
myRasterViewPort->mDestDatumTransform = rendererContext.coordinateTransform()->destinationDatumTransform();
336338
}
337339
else
338340
{
339341
myRasterViewPort->mSrcCRS = QgsCoordinateReferenceSystem(); // will be invalid
340342
myRasterViewPort->mDestCRS = QgsCoordinateReferenceSystem(); // will be invalid
343+
myRasterViewPort->mSrcDatumTransform = -1;
344+
myRasterViewPort->mDestDatumTransform = -1;
341345
}
342346

343347
// get dimensions of clipped raster image in device coordinate space (this is the size of the viewport)
@@ -423,7 +427,7 @@ void QgsRasterLayer::draw( QPainter * theQPainter,
423427
// params in QgsRasterProjector
424428
if ( projector )
425429
{
426-
projector->setCRS( theRasterViewPort->mSrcCRS, theRasterViewPort->mDestCRS );
430+
projector->setCRS( theRasterViewPort->mSrcCRS, theRasterViewPort->mDestCRS, theRasterViewPort->mSrcDatumTransform, theRasterViewPort->mDestDatumTransform );
427431
}
428432

429433
// Drawer to pipe?
@@ -1257,6 +1261,8 @@ QPixmap QgsRasterLayer::previewAsPixmap( QSize size, QColor bgColor )
12571261
myRasterViewPort->mDrawnExtent = myExtent;
12581262
myRasterViewPort->mSrcCRS = QgsCoordinateReferenceSystem(); // will be invalid
12591263
myRasterViewPort->mDestCRS = QgsCoordinateReferenceSystem(); // will be invalid
1264+
myRasterViewPort->mSrcDatumTransform = -1;
1265+
myRasterViewPort->mDestDatumTransform = -1;
12601266

12611267
QgsMapToPixel *myMapToPixel = new QgsMapToPixel( myMapUnitsPerPixel );
12621268

0 commit comments

Comments
 (0)