Quantum GIS API Documentation
1.8
|
00001 /*************************************************************************** 00002 qgsrasterprojector.h - Raster projector 00003 -------------------------------------- 00004 Date : Jan 16, 2011 00005 Copyright : (C) 2005 by Radim Blazek 00006 email : radim dot blazek at gmail dot com 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 00018 /* This code takes ideas from WarpBuilder in Geotools. 00019 * Thank you to Ing. Andrea Aime, Ing. Simone Giannecchini and GeoSolutions S.A.S. 00020 * See : http://geo-solutions.blogspot.com/2011/01/developers-corner-improving.html 00021 */ 00022 00023 #ifndef QGSRASTERPROJECTOR_H 00024 #define QGSRASTERPROJECTOR_H 00025 00026 #include <QVector> 00027 #include <QList> 00028 00029 00030 #include "qgsrectangle.h" 00031 #include "qgscoordinatereferencesystem.h" 00032 #include "qgscoordinatetransform.h" 00033 00034 #include <cmath> 00035 00036 //class QgsRectangle; 00037 class QgsPoint; 00038 00039 //class CORE_EXPORT QgsRasterProjector 00040 class QgsRasterProjector 00041 { 00042 // Q_OBJECT 00043 public: 00048 QgsRasterProjector( 00049 QgsCoordinateReferenceSystem theSrcCRS, 00050 QgsCoordinateReferenceSystem theDestCRS, 00051 QgsRectangle theDestExtent, 00052 int theDestRows, int theDestCols, 00053 double theMaxSrcXRes, double theMaxSrcYRes, 00054 QgsRectangle theExtent 00055 ); 00056 00058 ~QgsRasterProjector(); 00059 00060 00062 void destPointOnCPMatrix( int theRow, int theCol, double *theX, double *theY ); 00063 00065 int matrixRow( int theDestRow ); 00066 int matrixCol( int theDestCol ); 00067 00069 QgsPoint srcPoint( int theRow, int theCol ); 00070 00072 inline void preciseSrcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol ); 00073 00075 inline void approximateSrcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol ); 00076 00078 void srcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol ); 00079 00081 void insertRows(); 00082 00084 void insertCols(); 00085 00086 /* calculate single control point in current matrix */ 00087 void calcCP( int theRow, int theCol ); 00088 00090 bool calcRow( int theRow ); 00091 00093 bool calcCol( int theCol ); 00094 00096 void calcSrcExtent(); 00097 00099 void calcSrcRowsCols(); 00100 00103 bool checkCols(); 00104 00107 bool checkRows(); 00108 00110 //void calcHelper ( int theMatrixRow, QList<QgsPoint> *thePoints ); 00111 void calcHelper( int theMatrixRow, QgsPoint *thePoints ); 00112 00114 void nextHelper(); 00115 00117 QgsRectangle srcExtent() { return mSrcExtent; } 00118 00120 int srcRows() { return mSrcRows; } 00121 int srcCols() { return mSrcCols; } 00122 void setSrcRows( int theRows ) { mSrcRows = theRows; mSrcXRes = mSrcExtent.height() / mSrcRows; } 00123 void setSrcCols( int theCols ) { mSrcCols = theCols; mSrcYRes = mSrcExtent.width() / mSrcCols; } 00124 00126 QString cpToString(); 00127 00128 private: 00130 QgsCoordinateReferenceSystem mSrcCRS; 00131 00133 QgsCoordinateReferenceSystem mDestCRS; 00134 00136 QgsCoordinateTransform mCoordinateTransform; 00137 00139 QgsRectangle mDestExtent; 00140 00142 QgsRectangle mSrcExtent; 00143 00145 QgsRectangle mExtent; 00146 00148 int mDestRows; 00149 00151 int mDestCols; 00152 00154 double mDestXRes; 00155 00157 double mDestYRes; 00158 00160 int mSrcRows; 00161 00163 int mSrcCols; 00164 00166 double mSrcXRes; 00167 00169 double mSrcYRes; 00170 00172 double mDestRowsPerMatrixRow; 00173 00175 double mDestColsPerMatrixCol; 00176 00178 QList< QList<QgsPoint> > mCPMatrix; 00179 00181 /* Warning: using QList is slow on access */ 00182 QgsPoint *pHelperTop; 00183 00185 /* Warning: using QList is slow on access */ 00186 QgsPoint *pHelperBottom; 00187 00189 int mHelperTopRow; 00190 00192 int mCPCols; 00194 int mCPRows; 00195 00197 double mSqrTolerance; 00198 00200 double mMaxSrcXRes; 00201 double mMaxSrcYRes; 00202 00204 bool mApproximate; 00205 }; 00206 00207 #endif 00208