Skip to content
Permalink
Browse files

Consider datum transform in raster projector

  • Loading branch information
mhugent committed Nov 16, 2013
1 parent 836e1a8 commit dc3272a7efbb976f59aeca95b2a708df7fae2a52
@@ -13,6 +13,18 @@ class QgsRasterProjector : QgsRasterInterface
* it calculates grid of points in source CRS for target CRS + extent
* which are used to calculate affine transformation matrices.
*/

QgsRasterProjector(
QgsCoordinateReferenceSystem theSrcCRS,
QgsCoordinateReferenceSystem theDestCRS,
int theSrcDatumTransform,
int theDestDatumTransform,
QgsRectangle theDestExtent,
int theDestRows, int theDestCols,
double theMaxSrcXRes, double theMaxSrcYRes,
QgsRectangle theExtent
);

QgsRasterProjector(
QgsCoordinateReferenceSystem theSrcCRS,
QgsCoordinateReferenceSystem theDestCRS,
@@ -39,7 +51,7 @@ class QgsRasterProjector : QgsRasterInterface
int dataType( int bandNo ) const;

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

/** \brief Get source CRS */
QgsCoordinateReferenceSystem srcCrs() const;
@@ -333,11 +333,15 @@ bool QgsRasterLayer::draw( QgsRenderContext& rendererContext )
{
myRasterViewPort->mSrcCRS = crs();
myRasterViewPort->mDestCRS = rendererContext.coordinateTransform()->destCRS();
myRasterViewPort->mSrcDatumTransform = rendererContext.coordinateTransform()->sourceDatumTransform();
myRasterViewPort->mDestDatumTransform = rendererContext.coordinateTransform()->destinationDatumTransform();
}
else
{
myRasterViewPort->mSrcCRS = QgsCoordinateReferenceSystem(); // will be invalid
myRasterViewPort->mDestCRS = QgsCoordinateReferenceSystem(); // will be invalid
myRasterViewPort->mSrcDatumTransform = -1;
myRasterViewPort->mDestDatumTransform = -1;
}

// 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,
// params in QgsRasterProjector
if ( projector )
{
projector->setCRS( theRasterViewPort->mSrcCRS, theRasterViewPort->mDestCRS );
projector->setCRS( theRasterViewPort->mSrcCRS, theRasterViewPort->mDestCRS, theRasterViewPort->mSrcDatumTransform, theRasterViewPort->mDestDatumTransform );
}

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

QgsMapToPixel *myMapToPixel = new QgsMapToPixel( myMapUnitsPerPixel );

0 comments on commit dc3272a

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