27 int theSrcDatumTransform,
28 int theDestDatumTransform,
30 int theDestRows,
int theDestCols,
31 double theMaxSrcXRes,
double theMaxSrcYRes,
34 , mSrcCRS( theSrcCRS )
35 , mDestCRS( theDestCRS )
36 , mSrcDatumTransform( theSrcDatumTransform )
37 , mDestDatumTransform( theDestDatumTransform )
38 , mDestExtent( theDestExtent )
39 , mExtent( theExtent )
40 , mDestRows( theDestRows ), mDestCols( theDestCols )
41 , pHelperTop( 0 ), pHelperBottom( 0 )
42 , mMaxSrcXRes( theMaxSrcXRes ), mMaxSrcYRes( theMaxSrcYRes )
54 int theDestRows,
int theDestCols,
55 double theMaxSrcXRes,
double theMaxSrcYRes,
58 , mSrcCRS( theSrcCRS )
59 , mDestCRS( theDestCRS )
60 , mSrcDatumTransform( -1 )
61 , mDestDatumTransform( -1 )
62 , mDestExtent( theDestExtent )
63 , mExtent( theExtent )
64 , mDestRows( theDestRows ), mDestCols( theDestCols )
65 , pHelperTop( 0 ), pHelperBottom( 0 )
66 , mMaxSrcXRes( theMaxSrcXRes ), mMaxSrcYRes( theMaxSrcYRes )
77 double theMaxSrcXRes,
double theMaxSrcYRes,
80 , mSrcCRS( theSrcCRS )
81 , mDestCRS( theDestCRS )
82 , mSrcDatumTransform( -1 )
83 , mDestDatumTransform( -1 )
84 , mExtent( theExtent )
85 , pHelperTop( 0 ), pHelperBottom( 0 )
86 , mMaxSrcXRes( theMaxSrcXRes ), mMaxSrcYRes( theMaxSrcYRes )
92 :
QgsRasterInterface( 0 ), mSrcDatumTransform( -1 ), mDestDatumTransform( -1 ) , pHelperTop( 0 ), pHelperBottom( 0 )
111 if ( &projector !=
this )
203 for (
int i = 0; i <
mCPRows; i++ )
205 QList<QgsPoint> myRow;
211 QList<bool> myLegalRow;
212 myLegalRow.append(
bool(
false ) );
213 myLegalRow.append(
bool(
false ) );
214 myLegalRow.append(
bool(
false ) );
217 for (
int i = 0; i <
mCPRows; i++ )
234 if ( myColsOK && myRowsOK )
249 QgsDebugMsg( QString(
"CPMatrix size: mCPRows = %1 mCPCols = %2" ).arg( mCPRows ).arg(
mCPCols ) );
280 for (
int i = 0; i <
mCPRows; i++ )
282 for (
int j = 0; j <
mCPCols ; j++ )
335 for (
int i = 0; i <
mCPRows; i++ )
339 for (
int j = 0; j <
mCPCols; j++ )
368 QgsDebugMsg( QString(
"myDestColsPerMatrixCell = %1 myDestRowsPerMatrixCell = %2" ).arg( myDestColsPerMatrixCell ).arg( myDestRowsPerMatrixCell ) );
370 double myMinSize = DBL_MAX;
372 for (
int i = 0; i <
mCPRows - 1; i++ )
374 for (
int j = 0; j <
mCPCols - 1; j++ )
381 double mySize = sqrt( myPointA.
sqrDist( myPointB ) ) / myDestColsPerMatrixCell;
382 if ( mySize < myMinSize )
385 mySize = sqrt( myPointA.
sqrDist( myPointC ) ) / myDestRowsPerMatrixCell;
386 if ( mySize < myMinSize )
401 QgsDebugMsg( QString(
"myMinXSize = %1 myMinYSize = %2" ).arg( myMinXSize ).arg( myMinYSize ) );
429 Q_UNUSED( theDestRow );
437 for (
int myDestCol = 0; myDestCol <
mDestCols; myDestCol++ )
441 int myMatrixCol =
matrixCol( myDestCol );
443 double myDestXMin, myDestYMin, myDestXMax, myDestYMax;
448 double xfrac = ( myDestX - myDestXMin ) / ( myDestXMax - myDestXMin );
452 double s = mySrcPoint0.
x() + ( mySrcPoint1.
x() - mySrcPoint0.
x() ) * xfrac;
453 double t = mySrcPoint0.
y() + ( mySrcPoint1.
y() - mySrcPoint0.
y() ) * xfrac;
455 thePoints[myDestCol].
setX( s );
456 thePoints[myDestCol].
setY( t );
478 return preciseSrcRowCol( theDestRow, theDestCol, theSrcRow, theSrcCol, ct );
516 QgsDebugMsgLevel( QString(
"theSrcRow = %1 theSrcCol = %2" ).arg( *theSrcRow ).arg( *theSrcCol ), 5 );
523 if ( *theSrcRow >=
mSrcRows )
return false;
524 if ( *theSrcRow < 0 )
return false;
525 if ( *theSrcCol >=
mSrcCols )
return false;
526 if ( *theSrcCol < 0 )
return false;
533 int myMatrixRow =
matrixRow( theDestRow );
534 int myMatrixCol =
matrixCol( theDestCol );
546 double myDestXMin, myDestYMin, myDestXMax, myDestYMax;
551 double yfrac = ( myDestY - myDestYMin ) / ( myDestYMax - myDestYMin );
560 double tx = myTop.
x();
561 double ty = myTop.
y();
562 double bx = myBot.
x();
563 double by = myBot.
y();
564 double mySrcX = bx + ( tx - bx ) * yfrac;
565 double mySrcY = by + ( ty - by ) * yfrac;
580 if ( *theSrcRow >=
mSrcRows )
return false;
581 if ( *theSrcRow < 0 )
return false;
582 if ( *theSrcCol >=
mSrcCols )
return false;
583 if ( *theSrcCol < 0 )
return false;
590 for (
int r = 0; r <
mCPRows - 1; r++ )
592 QList<QgsPoint> myRow;
593 QList<bool> myLegalRow;
594 for (
int c = 0; c <
mCPCols; c++ )
597 myLegalRow.append(
false );
603 mCPRows += mCPRows - 1;
604 for (
int r = 1; r < mCPRows - 1; r += 2 )
612 for (
int r = 0; r <
mCPRows; r++ )
614 QList<QgsPoint> myRow;
615 QList<bool> myLegalRow;
616 for (
int c = 0; c <
mCPCols - 1; c++ )
623 for (
int c = 1; c <
mCPCols - 1; c += 2 )
632 double myDestX, myDestY;
634 QgsPoint myDestPoint( myDestX, myDestY );
658 for (
int i = 0; i <
mCPCols; i++ )
669 for (
int i = 0; i <
mCPRows; i++ )
684 for (
int c = 0; c <
mCPCols; c++ )
686 for (
int r = 1; r <
mCPRows - 1; r += 2 )
688 double myDestX, myDestY;
690 QgsPoint myDestPoint( myDestX, myDestY );
696 QgsPoint mySrcApprox(( mySrcPoint1.
x() + mySrcPoint3.
x() ) / 2, ( mySrcPoint1.
y() + mySrcPoint3.
y() ) / 2 );
705 double mySqrDist = myDestApprox.
sqrDist( myDestPoint );
729 for (
int r = 0; r <
mCPRows; r++ )
731 for (
int c = 1; c <
mCPCols - 1; c += 2 )
733 double myDestX, myDestY;
736 QgsPoint myDestPoint( myDestX, myDestY );
741 QgsPoint mySrcApprox(( mySrcPoint1.
x() + mySrcPoint3.
x() ) / 2, ( mySrcPoint1.
y() + mySrcPoint3.
y() ) / 2 );
750 double mySqrDist = myDestApprox.
sqrDist( myDestPoint );
770 QgsDebugMsg( QString(
"width = %1 height = %2" ).arg( width ).arg( height ) );
780 return mInput->
block( bandNo, extent, width, height );
799 if ( !inputBlock || inputBlock->
isEmpty() )
817 if ( !outputBlock->isValid() )
845 outputBlock->setIsNoData();
848 for (
int i = 0; i < height; ++i )
850 for (
int j = 0; j < width; ++j )
852 bool inside =
srcRowCol( i, j, &srcRow, &srcCol, ct );
853 if ( !inside )
continue;
856 QgsDebugMsgLevel( QString(
"row = %1 col = %2 srcRow = %3 srcCol = %4" ).arg( i ).arg( j ).arg( srcRow ).arg( srcCol ), 5 );
859 if ( doNoData && inputBlock->
isNoData( srcRow, srcCol ) )
861 outputBlock->setIsNoData( i, j );
866 char *srcBits = inputBlock->
bits( srcIndex );
867 char *destBits = outputBlock->bits( destIndex );
870 QgsDebugMsg( QString(
"Cannot get input block data: row = %1 col = %2" ).arg( i ).arg( j ) );
875 QgsDebugMsg( QString(
"Cannot set output block data: srcRow = %1 srcCol = %2" ).arg( srcRow ).arg( srcCol ) );
878 memcpy( destBits, srcBits, pixelSize );