29 int theDestRows,
int theDestCols,
30 double theMaxSrcXRes,
double theMaxSrcYRes,
32 : mSrcCRS( theSrcCRS )
33 , mDestCRS( theDestCRS )
34 , mCoordinateTransform( theDestCRS, theSrcCRS )
35 , mDestExtent( theDestExtent )
36 , mExtent( theExtent )
37 , mDestRows( theDestRows ), mDestCols( theDestCols )
38 , mMaxSrcXRes( theMaxSrcXRes ), mMaxSrcYRes( theMaxSrcYRes )
55 for (
int i = 0; i <
mCPRows; i++ )
57 QList<QgsPoint> myRow;
63 for (
int i = 0; i <
mCPRows; i++ )
80 if ( myColsOK && myRowsOK )
96 QgsDebugMsg( QString(
"CPMatrix size: mCPRows = %1 mCPCols = %2" ).arg( mCPRows ).arg(
mCPCols ) );
131 for (
int i = 0; i <
mCPRows; i++ )
133 for (
int j = 0; j <
mCPCols ; j++ )
177 for (
int i = 0; i <
mCPRows; i++ )
179 if ( i > 0 ) myString +=
"\n";
180 for (
int j = 0; j <
mCPCols; j++ )
182 if ( j > 0 ) myString +=
" ";
201 QgsDebugMsg( QString(
"myDestColsPerMatrixCell = %1 myDestRowsPerMatrixCell = %2" ).arg( myDestColsPerMatrixCell ).arg( myDestRowsPerMatrixCell ) );
203 double myMinSize = DBL_MAX;
205 for (
int i = 0; i <
mCPRows - 1; i++ )
207 for (
int j = 0; j <
mCPCols - 1; j++ )
212 double mySize = sqrt( myPointA.
sqrDist( myPointB ) ) / myDestColsPerMatrixCell;
213 if ( mySize < myMinSize ) { myMinSize = mySize; }
215 mySize = sqrt( myPointA.
sqrDist( myPointC ) ) / myDestRowsPerMatrixCell;
216 if ( mySize < myMinSize ) { myMinSize = mySize; }
229 QgsDebugMsg( QString(
"myMinXSize = %1 myMinYSize = %2" ).arg( myMinXSize ).arg( myMinYSize ) );
263 for (
int myDestCol = 0; myDestCol <
mDestCols; myDestCol++ )
267 int myMatrixCol =
matrixCol( myDestCol );
269 double myDestXMin, myDestYMin, myDestXMax, myDestYMax;
274 double xfrac = ( myDestX - myDestXMin ) / ( myDestXMax - myDestXMin );
278 double s = mySrcPoint0.
x() + ( mySrcPoint1.
x() - mySrcPoint0.
x() ) * xfrac;
279 double t = mySrcPoint0.
y() + ( mySrcPoint1.
y() - mySrcPoint0.
y() ) * xfrac;
281 thePoints[myDestCol].
setX( s );
282 thePoints[myDestCol].
setY( t );
325 if ( *theSrcRow < 0 ) *theSrcRow = 0;
327 if ( *theSrcCol < 0 ) *theSrcCol = 0;
335 int myMatrixRow =
matrixRow( theDestRow );
336 int myMatrixCol =
matrixCol( theDestCol );
348 double myDestXMin, myDestYMin, myDestXMax, myDestYMax;
353 double yfrac = ( myDestY - myDestYMin ) / ( myDestYMax - myDestYMin );
362 double tx = myTop.
x();
363 double ty = myTop.
y();
364 double bx = myBot.
x();
365 double by = myBot.
y();
366 double mySrcX = bx + ( tx - bx ) * yfrac;
367 double mySrcY = by + ( ty - by ) * yfrac;
377 if ( *theSrcRow < 0 ) *theSrcRow = 0;
379 if ( *theSrcCol < 0 ) *theSrcCol = 0;
386 for (
int r = 0; r <
mCPRows - 1; r++ )
388 QList<QgsPoint> myRow;
389 for (
int c = 0; c <
mCPCols; c++ )
396 mCPRows += mCPRows - 1;
397 for (
int r = 1; r < mCPRows - 1; r += 2 )
405 for (
int r = 0; r <
mCPRows; r++ )
407 QList<QgsPoint> myRow;
408 for (
int c = 0; c <
mCPCols - 1; c++ )
414 for (
int c = 1; c <
mCPCols - 1; c += 2 )
423 double myDestX, myDestY;
425 QgsPoint myDestPoint( myDestX, myDestY );
433 for (
int i = 0; i <
mCPCols; i++ )
444 for (
int i = 0; i <
mCPRows; i++ )
454 for (
int c = 0; c <
mCPCols; c++ )
456 for (
int r = 1; r <
mCPRows - 1; r += 2 )
458 double myDestX, myDestY;
460 QgsPoint myDestPoint( myDestX, myDestY );
466 QgsPoint mySrcApprox(( mySrcPoint1.
x() + mySrcPoint3.
x() ) / 2, ( mySrcPoint1.
y() + mySrcPoint3.
y() ) / 2 );
468 double mySqrDist = myDestApprox.
sqrDist( myDestPoint );
477 for (
int r = 0; r <
mCPRows; r++ )
479 for (
int c = 1; c <
mCPCols - 1; c += 2 )
481 double myDestX, myDestY;
484 QgsPoint myDestPoint( myDestX, myDestY );
489 QgsPoint mySrcApprox(( mySrcPoint1.
x() + mySrcPoint3.
x() ) / 2, ( mySrcPoint1.
y() + mySrcPoint3.
y() ) / 2 );
491 double mySqrDist = myDestApprox.
sqrDist( myDestPoint );