Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
qgsrasterprojector.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrasterprojector.h - Raster projector
3  --------------------------------------
4  Date : Jan 16, 2011
5  Copyright : (C) 2005 by Radim Blazek
6  email : radim dot blazek at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 /* $Id: qgsrasterprojector.h 15005 2011-01-08 16:35:21Z rblazek $ */
18 
19 /* This code takes ideas from WarpBuilder in Geotools.
20  * Thank you to Ing. Andrea Aime, Ing. Simone Giannecchini and GeoSolutions S.A.S.
21  * See : http://geo-solutions.blogspot.com/2011/01/developers-corner-improving.html
22  */
23 
24 #ifndef QGSRASTERPROJECTOR_H
25 #define QGSRASTERPROJECTOR_H
26 
27 #include <QVector>
28 #include <QList>
29 
30 
31 #include "qgsrectangle.h"
33 #include "qgscoordinatetransform.h"
34 
35 #include <cmath>
36 
37 //class QgsRectangle;
38 class QgsPoint;
39 
40 //class CORE_EXPORT QgsRasterProjector
42 {
43 // Q_OBJECT
44  public:
52  QgsRectangle theDestExtent,
53  int theDestRows, int theDestCols,
54  double theMaxSrcXRes, double theMaxSrcYRes,
55  QgsRectangle theExtent
56  );
57 
60 
61 
63  void destPointOnCPMatrix( int theRow, int theCol, double *theX, double *theY );
64 
66  int matrixRow( int theDestRow );
67  int matrixCol( int theDestCol );
68 
70  QgsPoint srcPoint( int theRow, int theCol );
71 
73  inline void preciseSrcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol );
74 
76  inline void approximateSrcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol );
77 
79  void srcRowCol( int theDestRow, int theDestCol, int *theSrcRow, int *theSrcCol );
80 
82  void insertRows();
83 
85  void insertCols();
86 
87  /* calculate single control point in current matrix */
88  void calcCP( int theRow, int theCol );
89 
91  bool calcRow( int theRow );
92 
94  bool calcCol( int theCol );
95 
97  void calcSrcExtent();
98 
100  void calcSrcRowsCols();
101 
104  bool checkCols();
105 
108  bool checkRows();
109 
111  //void calcHelper ( int theMatrixRow, QList<QgsPoint> *thePoints );
112  void calcHelper( int theMatrixRow, QgsPoint *thePoints );
113 
115  void nextHelper();
116 
119 
121  int srcRows() { return mSrcRows; }
122  int srcCols() { return mSrcCols; }
123  void setSrcRows( int theRows ) { mSrcRows = theRows; mSrcXRes = mSrcExtent.height() / mSrcRows; }
124  void setSrcCols( int theCols ) { mSrcCols = theCols; mSrcYRes = mSrcExtent.width() / mSrcCols; }
125 
127  QString cpToString();
128 
129  private:
132 
135 
138 
141 
144 
147 
150 
153 
155  double mDestXRes;
156 
158  double mDestYRes;
159 
161  int mSrcRows;
162 
164  int mSrcCols;
165 
167  double mSrcXRes;
168 
170  double mSrcYRes;
171 
174 
177 
179  QList< QList<QgsPoint> > mCPMatrix;
180 
182  /* Warning: using QList is slow on access */
184 
186  /* Warning: using QList is slow on access */
188 
191 
193  int mCPCols;
195  int mCPRows;
196 
199 
201  double mMaxSrcXRes;
202  double mMaxSrcYRes;
203 
206 };
207 
208 #endif
209