Skip to content

Commit

Permalink
avoid fragile pointer
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15646 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Mar 31, 2011
1 parent 01ebf04 commit b138d2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/core/qgsrasterprojector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ QgsRasterProjector::QgsRasterProjector(
, mExtent( theExtent )
, mDestRows( theDestRows ), mDestCols( theDestCols )
, mMaxSrcXRes( theMaxSrcXRes ), mMaxSrcYRes( theMaxSrcYRes )
, mCoordinateTransform( theDestCRS, theSrcCRS )
{
QgsDebugMsg( "Entered" );
QgsDebugMsg( "theDestExtent = " + theDestExtent.toString() );

// reverse transformation
mCoordinateTransform = new QgsCoordinateTransform( theDestCRS, theSrcCRS );

mDestXRes = mDestExtent.width() / ( mDestCols );
mDestYRes = mDestExtent.height() / ( mDestRows );

Expand Down Expand Up @@ -115,7 +113,7 @@ QgsRasterProjector::QgsRasterProjector(

QgsRasterProjector::~QgsRasterProjector()
{
delete mCoordinateTransform;
//delete mCoordinateTransform;
}

void QgsRasterProjector::calcSrcExtent()
Expand Down Expand Up @@ -381,7 +379,7 @@ void QgsRasterProjector::calcCP( int theRow, int theCol )
destPointOnCPMatrix( theRow, theCol, &myDestX, &myDestY );
QgsPoint myDestPoint( myDestX, myDestY );

mCPMatrix[theRow][theCol] = mCoordinateTransform->transform( myDestPoint );
mCPMatrix[theRow][theCol] = mCoordinateTransform.transform( myDestPoint );
}

bool QgsRasterProjector::calcRow( int theRow )
Expand Down Expand Up @@ -421,7 +419,7 @@ bool QgsRasterProjector::checkCols()
QgsPoint mySrcPoint3 = mCPMatrix[r+1][c];

QgsPoint mySrcApprox(( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, ( mySrcPoint1.y() + mySrcPoint3.y() ) / 2 );
QgsPoint myDestApprox = mCoordinateTransform->transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
double mySqrDist = myDestApprox.sqrDist( myDestPoint );
if ( mySqrDist > mSqrTolerance ) { return false; }
}
Expand All @@ -444,7 +442,7 @@ bool QgsRasterProjector::checkRows()
QgsPoint mySrcPoint3 = mCPMatrix[r][c+1];

QgsPoint mySrcApprox(( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, ( mySrcPoint1.y() + mySrcPoint3.y() ) / 2 );
QgsPoint myDestApprox = mCoordinateTransform->transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
double mySqrDist = myDestApprox.sqrDist( myDestPoint );
if ( mySqrDist > mSqrTolerance ) { return false; }
}
Expand Down
3 changes: 1 addition & 2 deletions src/core/qgsrasterprojector.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ class QgsRasterProjector
QgsCoordinateReferenceSystem mDestCRS;

/** Coordinate transform */
/* QgsCoordinateTransform inherits from QObject and that is not copyable */
QgsCoordinateTransform *mCoordinateTransform;
QgsCoordinateTransform mCoordinateTransform;

/** Destination extent */
QgsRectangle mDestExtent;
Expand Down

0 comments on commit b138d2c

Please sign in to comment.