|
15 | 15 | * *
|
16 | 16 | ***************************************************************************/
|
17 | 17 |
|
| 18 | +#include "qgsrasterdataprovider.h" |
18 | 19 | #include "qgslogger.h"
|
19 | 20 | #include "qgsrasterprojector.h"
|
20 | 21 | #include "qgscoordinatetransform.h"
|
@@ -59,35 +60,46 @@ QgsRasterProjector::QgsRasterProjector(
|
59 | 60 | }
|
60 | 61 |
|
61 | 62 | QgsRasterProjector::QgsRasterProjector()
|
62 |
| - : QgsRasterInterface( 0) |
| 63 | + : QgsRasterInterface( 0 ) |
63 | 64 | , pHelperTop( 0 ), pHelperBottom( 0 )
|
64 | 65 | {
|
65 | 66 | QgsDebugMsg( "Entered" );
|
66 | 67 | }
|
67 | 68 |
|
68 | 69 | QgsRasterProjector::~QgsRasterProjector()
|
69 | 70 | {
|
70 |
| - delete pHelperTop; |
71 |
| - delete pHelperBottom; |
| 71 | + delete[] pHelperTop; |
| 72 | + delete[] pHelperBottom; |
72 | 73 | }
|
73 | 74 |
|
74 | 75 | void QgsRasterProjector::setCRS( QgsCoordinateReferenceSystem theSrcCRS, QgsCoordinateReferenceSystem theDestCRS )
|
75 | 76 | {
|
76 | 77 | mSrcCRS = theSrcCRS;
|
77 | 78 | mDestCRS = theDestCRS;
|
78 |
| - mCoordinateTransform.setSourceCrs( theSrcCRS ); |
79 |
| - mCoordinateTransform.setDestCRS( theDestCRS ); |
| 79 | + mCoordinateTransform.setSourceCrs( theDestCRS ); |
| 80 | + mCoordinateTransform.setDestCRS( theSrcCRS ); |
80 | 81 | }
|
81 | 82 |
|
82 | 83 | void QgsRasterProjector::calc()
|
83 | 84 | {
|
84 | 85 | QgsDebugMsg( "Entered" );
|
85 | 86 | mCPMatrix.clear();
|
86 |
| - delete pHelperTop; |
| 87 | + delete[] pHelperTop; |
87 | 88 | pHelperTop = 0;
|
88 |
| - delete pHelperBottom; |
| 89 | + delete[] pHelperBottom; |
89 | 90 | pHelperBottom = 0;
|
90 | 91 |
|
| 92 | + // Get max source resolution if possible |
| 93 | + if ( mInput ) |
| 94 | + { |
| 95 | + QgsRasterDataProvider *provider = dynamic_cast<QgsRasterDataProvider*>( mInput->srcInput() ); |
| 96 | + if ( provider && ( provider->capabilities() & QgsRasterDataProvider::ExactResolution ) ) |
| 97 | + { |
| 98 | + mMaxSrcXRes = provider->extent().width() / provider->xSize(); |
| 99 | + mMaxSrcYRes = provider->extent().height() / provider->ySize(); |
| 100 | + } |
| 101 | + } |
| 102 | + |
91 | 103 | mDestXRes = mDestExtent.width() / ( mDestCols );
|
92 | 104 | mDestYRes = mDestExtent.height() / ( mDestRows );
|
93 | 105 |
|
@@ -139,13 +151,13 @@ void QgsRasterProjector::calc()
|
139 | 151 | mApproximate = false;
|
140 | 152 | break;
|
141 | 153 | }
|
142 |
| - |
143 | 154 | }
|
144 | 155 | QgsDebugMsg( QString( "CPMatrix size: mCPRows = %1 mCPCols = %2" ).arg( mCPRows ).arg( mCPCols ) );
|
145 | 156 | mDestRowsPerMatrixRow = ( float )mDestRows / ( mCPRows - 1 );
|
146 | 157 | mDestColsPerMatrixCol = ( float )mDestCols / ( mCPCols - 1 );
|
147 | 158 |
|
148 |
| - //QgsDebugMsg( "CPMatrix:\n" + cpToString() ); |
| 159 | + QgsDebugMsgLevel( "CPMatrix:", 5 ); |
| 160 | + QgsDebugMsgLevel( cpToString(), 5 ); |
149 | 161 |
|
150 | 162 | // Calculate source dimensions
|
151 | 163 | calcSrcExtent();
|
@@ -568,7 +580,8 @@ bool QgsRasterProjector::checkRows()
|
568 | 580 |
|
569 | 581 | void * QgsRasterProjector::readBlock( int bandNo, QgsRectangle const & extent, int width, int height )
|
570 | 582 | {
|
571 |
| - QgsDebugMsg( "Entered" ); |
| 583 | + QgsDebugMsg( QString( "extent:\n%1" ).arg( extent.toString() ) ); |
| 584 | + QgsDebugMsg( QString( "width = %1 height = %1" ).arg( width ).arg( height ) ); |
572 | 585 | if ( !mInput ) return 0;
|
573 | 586 |
|
574 | 587 | if ( ! mSrcCRS.isValid() || ! mDestCRS.isValid() || mSrcCRS == mDestCRS )
|
|
0 commit comments