[QGIS Commit] r15697 - trunk/qgis/src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed Apr 13 14:04:31 EDT 2011
Author: rblazek
Date: 2011-04-13 11:04:31 -0700 (Wed, 13 Apr 2011)
New Revision: 15697
Modified:
trunk/qgis/src/core/qgsrasterprojector.cpp
trunk/qgis/src/core/qgsrasterprojector.h
Log:
fall to precise reprojection if thresh wasnt reached
Modified: trunk/qgis/src/core/qgsrasterprojector.cpp
===================================================================
--- trunk/qgis/src/core/qgsrasterprojector.cpp 2011-04-13 07:03:14 UTC (rev 15696)
+++ trunk/qgis/src/core/qgsrasterprojector.cpp 2011-04-13 18:04:31 UTC (rev 15697)
@@ -80,6 +80,7 @@
if ( myColsOK && myRowsOK )
{
QgsDebugMsg( "CP matrix within tolerance" );
+ mApproximate = true;
break;
}
// What is the maximum reasonable size of transformatio matrix?
@@ -87,6 +88,7 @@
if ( mCPRows * mCPCols > 0.25 * mDestRows * mDestCols )
{
QgsDebugMsg( "Too large CP matrix" );
+ mApproximate = false;
break;
}
@@ -293,6 +295,29 @@
void QgsRasterProjector::srcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol )
{
+ if ( mApproximate ) approximateSrcRowCol( theDestRow, theDestCol, theSrcRow, theSrcCol);
+ else preciseSrcRowCol( theDestRow, theDestCol, theSrcRow, theSrcCol);
+}
+
+void QgsRasterProjector::preciseSrcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol )
+{
+ // Get coordinate of center of destination cell
+ double x = mDestExtent.xMinimum() + ( theDestCol + 0.5 ) * mDestXRes;
+ double y = mDestExtent.yMaximum() - ( theDestRow + 0.5 ) * mDestYRes;
+ double z = 0;
+
+ mCoordinateTransform.transformInPlace( x, y, z );
+
+ // Get source row col
+ *theSrcRow = ( int ) floor(( mSrcExtent.yMaximum() - y ) / mSrcXRes );
+ *theSrcCol = ( int ) floor(( x - mSrcExtent.xMinimum() ) / mSrcYRes );
+
+ assert( *theSrcRow < mSrcRows );
+ assert( *theSrcCol < mSrcCols );
+}
+
+void QgsRasterProjector::approximateSrcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol )
+{
int myMatrixRow = matrixRow( theDestRow );
int myMatrixCol = matrixCol( theDestCol );
Modified: trunk/qgis/src/core/qgsrasterprojector.h
===================================================================
--- trunk/qgis/src/core/qgsrasterprojector.h 2011-04-13 07:03:14 UTC (rev 15696)
+++ trunk/qgis/src/core/qgsrasterprojector.h 2011-04-13 18:04:31 UTC (rev 15697)
@@ -69,6 +69,12 @@
/** \brief get destination point for _current_ matrix position */
QgsPoint srcPoint( int theRow, int theCol );
+ /** \brief Get precise source row and column indexes for current source extent and resolution */
+ inline void preciseSrcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol );
+
+ /** \brief Get approximate source row and column indexes for current source extent and resolution */
+ inline void approximateSrcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol );
+
/** \brief Get source row and column indexes for current source extent and resolution */
void srcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol );
@@ -194,6 +200,9 @@
/** Maximum source resolution */
double mMaxSrcXRes;
double mMaxSrcYRes;
+
+ /** Use approximation */
+ bool mApproximate;
};
#endif
More information about the QGIS-commit
mailing list