27 int theDestRows,
int theDestCols,
28 double theMaxSrcXRes,
double theMaxSrcYRes,
31 , mSrcCRS( theSrcCRS )
32 , mDestCRS( theDestCRS )
33 , mCoordinateTransform( theDestCRS, theSrcCRS )
34 , mDestExtent( theDestExtent )
35 , mExtent( theExtent )
36 , mDestRows( theDestRows ), mDestCols( theDestCols )
37 , pHelperTop( 0 ), pHelperBottom( 0 )
38 , mMaxSrcXRes( theMaxSrcXRes ), mMaxSrcYRes( theMaxSrcYRes )
49 double theMaxSrcXRes,
double theMaxSrcYRes,
52 , mSrcCRS( theSrcCRS )
53 , mDestCRS( theDestCRS )
54 , mCoordinateTransform( theDestCRS, theSrcCRS )
55 , mExtent( theExtent )
56 , pHelperTop( 0 ), pHelperBottom( 0 )
57 , mMaxSrcXRes( theMaxSrcXRes ), mMaxSrcYRes( theMaxSrcYRes )
64 , pHelperTop( 0 ), pHelperBottom( 0 )
83 if ( &projector !=
this )
171 for (
int i = 0; i <
mCPRows; i++ )
173 QList<QgsPoint> myRow;
179 QList<bool> myLegalRow;
180 myLegalRow.append(
bool(
false ) );
181 myLegalRow.append(
bool(
false ) );
182 myLegalRow.append(
bool(
false ) );
185 for (
int i = 0; i <
mCPRows; i++ )
202 if ( myColsOK && myRowsOK )
217 QgsDebugMsg( QString(
"CPMatrix size: mCPRows = %1 mCPCols = %2" ).arg( mCPRows ).arg(
mCPCols ) );
248 for (
int i = 0; i <
mCPRows; i++ )
250 for (
int j = 0; j <
mCPCols ; j++ )
300 for (
int i = 0; i <
mCPRows; i++ )
304 for (
int j = 0; j <
mCPCols; j++ )
333 QgsDebugMsg( QString(
"myDestColsPerMatrixCell = %1 myDestRowsPerMatrixCell = %2" ).arg( myDestColsPerMatrixCell ).arg( myDestRowsPerMatrixCell ) );
335 double myMinSize = DBL_MAX;
337 for (
int i = 0; i <
mCPRows - 1; i++ )
339 for (
int j = 0; j <
mCPCols - 1; j++ )
346 double mySize = sqrt( myPointA.
sqrDist( myPointB ) ) / myDestColsPerMatrixCell;
347 if ( mySize < myMinSize )
350 mySize = sqrt( myPointA.
sqrDist( myPointC ) ) / myDestRowsPerMatrixCell;
351 if ( mySize < myMinSize )
366 QgsDebugMsg( QString(
"myMinXSize = %1 myMinYSize = %2" ).arg( myMinXSize ).arg( myMinYSize ) );
394 Q_UNUSED( theDestRow );
402 for (
int myDestCol = 0; myDestCol <
mDestCols; myDestCol++ )
406 int myMatrixCol =
matrixCol( myDestCol );
408 double myDestXMin, myDestYMin, myDestXMax, myDestYMax;
413 double xfrac = ( myDestX - myDestXMin ) / ( myDestXMax - myDestXMin );
417 double s = mySrcPoint0.
x() + ( mySrcPoint1.
x() - mySrcPoint0.
x() ) * xfrac;
418 double t = mySrcPoint0.
y() + ( mySrcPoint1.
y() - mySrcPoint0.
y() ) * xfrac;
420 thePoints[myDestCol].
setX( s );
421 thePoints[myDestCol].
setY( t );
474 QgsDebugMsgLevel( QString(
"theSrcRow = %1 theSrcCol = %2" ).arg( *theSrcRow ).arg( *theSrcCol ), 5 );
482 if ( *theSrcRow < 0 )
486 if ( *theSrcCol < 0 )
495 int myMatrixRow =
matrixRow( theDestRow );
496 int myMatrixCol =
matrixCol( theDestCol );
508 double myDestXMin, myDestYMin, myDestXMax, myDestYMax;
513 double yfrac = ( myDestY - myDestYMin ) / ( myDestYMax - myDestYMin );
522 double tx = myTop.
x();
523 double ty = myTop.
y();
524 double bx = myBot.
x();
525 double by = myBot.
y();
526 double mySrcX = bx + ( tx - bx ) * yfrac;
527 double mySrcY = by + ( ty - by ) * yfrac;
538 if ( *theSrcRow < 0 )
542 if ( *theSrcCol < 0 )
550 for (
int r = 0; r <
mCPRows - 1; r++ )
552 QList<QgsPoint> myRow;
553 QList<bool> myLegalRow;
554 for (
int c = 0; c <
mCPCols; c++ )
557 myLegalRow.append(
false );
563 mCPRows += mCPRows - 1;
564 for (
int r = 1; r < mCPRows - 1; r += 2 )
572 for (
int r = 0; r <
mCPRows; r++ )
574 QList<QgsPoint> myRow;
575 QList<bool> myLegalRow;
576 for (
int c = 0; c <
mCPCols - 1; c++ )
583 for (
int c = 1; c <
mCPCols - 1; c += 2 )
592 double myDestX, myDestY;
594 QgsPoint myDestPoint( myDestX, myDestY );
611 for (
int i = 0; i <
mCPCols; i++ )
622 for (
int i = 0; i <
mCPRows; i++ )
632 for (
int c = 0; c <
mCPCols; c++ )
634 for (
int r = 1; r <
mCPRows - 1; r += 2 )
636 double myDestX, myDestY;
638 QgsPoint myDestPoint( myDestX, myDestY );
644 QgsPoint mySrcApprox(( mySrcPoint1.
x() + mySrcPoint3.
x() ) / 2, ( mySrcPoint1.
y() + mySrcPoint3.
y() ) / 2 );
653 double mySqrDist = myDestApprox.
sqrDist( myDestPoint );
672 for (
int r = 0; r <
mCPRows; r++ )
674 for (
int c = 1; c <
mCPCols - 1; c += 2 )
676 double myDestX, myDestY;
679 QgsPoint myDestPoint( myDestX, myDestY );
684 QgsPoint mySrcApprox(( mySrcPoint1.
x() + mySrcPoint3.
x() ) / 2, ( mySrcPoint1.
y() + mySrcPoint3.
y() ) / 2 );
693 double mySqrDist = myDestApprox.
sqrDist( myDestPoint );
713 QgsDebugMsg( QString(
"width = %1 height = %2" ).arg( width ).arg( height ) );
723 return mInput->
block( bandNo, extent, width, height );
742 if ( !inputBlock || inputBlock->
isEmpty() )
760 if ( !outputBlock->isValid() )
779 for (
int i = 0; i < height; ++i )
781 for (
int j = 0; j < width; ++j )
784 size_t srcIndex = ( size_t )srcRow *
mSrcCols + srcCol;
785 QgsDebugMsgLevel( QString(
"row = %1 col = %2 srcRow = %3 srcCol = %4" ).arg( i ).arg( j ).arg( srcRow ).arg( srcCol ), 5 );
788 if ( doNoData && inputBlock->
isNoData( srcRow, srcCol ) )
790 outputBlock->setIsNoData( srcRow, srcCol );
794 size_t destIndex = ( size_t )i * width + j;
795 char *srcBits = inputBlock->
bits( srcIndex );
796 char *destBits = outputBlock->bits( destIndex );
799 QgsDebugMsg( QString(
"Cannot get input block data: row = %1 col = %2" ).arg( i ).arg( j ) );
804 QgsDebugMsg( QString(
"Cannot set output block data: srcRow = %1 srcCol = %2" ).arg( srcRow ).arg( srcCol ) );
807 memcpy( destBits, srcBits, pixelSize );