SplineGrass.h
Go to the documentation of this file.
1 
2 /*!
3 \file terralib/mnt/core/SplineGrass.h
4 
5 \brief This file contains a class to calculate retangular grid from Samples using Spline Grass Interpolation.
6 Adapted from SPRING
7 
8 */
9 
10 #ifndef __TERRALIB_MNT_INTERNAL_SPLINEGRASS_H
11 #define __TERRALIB_MNT_INTERNAL_SPLINEGRASS_H
12 
13 #include "CalculateGrid.h"
14 
15 namespace te
16 {
17  namespace mnt
18  {
19 
21  {
22  public:
23  //! Contructors
24  SplineInterpolationGrass(unsigned int nPartsX, unsigned int nPartsY, unsigned int minPoints, double overlappin) :
25  m_nPartsX(nPartsX), m_nPartsY(nPartsY), m_minpoints(minPoints), m_overlapping(overlappin) {}
26 
27  //! Destructor
29 
30  void setControlPoints(double xMin, double yMin);
31  unsigned int nPointInterest() { return m_npoints; }
32 
33  void initInterpolation(int beginLine, int endLine, int beginCol, int endCol);
34 
35  bool calculateGrid(double xMin, double yMin);
36  bool generateGrid();
37 
38  double pointsControlMean() { return m_mean; }
39 
40  double dataInterpolateBicubic(double x, double y, double xMin, double yMin, bool &interp);
41 
42  double dataInterpolateBilin(double x, double y, double xMin, double yMin, bool &interp);
43 
44  static te::gm::LineString* pointListSimplify(te::gm::LineString *ls, double snap, double Zvalue);
45 
46  private:
47 
48  /* GRASS */
49  /*!
50  * \brief Ordinate node index computation
51  */
52  void node_x(double x, int &i_x, double &csi_x, double xMin, double deltaX)
53  {
54  i_x = (int)((x - xMin) / deltaX);
55  csi_x = (double)((x - xMin) - (i_x * deltaX));
56  }
57 
58  /*!
59  * \brief Ordinate node index computation
60  */
61  void node_y(double y, int &i_y, double &csi_y, double yMin, double deltaY)
62  {
63  i_y = (int)((y - yMin) / deltaY);
64  csi_y = (double)((y - yMin) - (i_y * deltaY));
65  }
66 
67  /*!
68  * \brief Node order computation
69  */
70  int order(int i_x, int i_y, unsigned int yNum){ return (i_y + i_x * (int)yNum); }
71 
72  /*!
73  * \brief Design matrix coefficients computation
74  */
75  double phi_3(double csi) { return ((pow(2 - csi, 3.) - pow(1 - csi, 3.) * 4) / 6.); }
76  /*!
77  * \brief Design matrix coefficients computation
78  */
79  double phi_4(double csi){ return (pow(2 - csi, 3.) / 6.); }
80  /*!
81  * \brief Design matrix coefficients computation
82  */
83  double phi_33(double csi_x, double csi_y){ return (phi_3(csi_x) * phi_3(csi_y)); }
84  /*!
85  * \brief Design matrix coefficients computation
86  */
87  double phi_34(double csi_x, double csi_y){ return (phi_3(csi_x) * phi_4(csi_y)); }
88  /*!
89  * \brief Design matrix coefficients computation
90  */
91  double phi_43(double csi_x, double csi_y){ return (phi_4(csi_x) * phi_3(csi_y)); }
92  /*!
93  * \brief Design matrix coefficients computation
94  */
95  double phi_44(double csi_x, double csi_y){ return (phi_4(csi_x) * phi_4(csi_y)); }
96  /*!
97  * \brief Design matrix coefficients computation
98  */
99  double phi(double csi_x, double csi_y){ return ((1 - csi_x)*(1 - csi_y)); }
100 
101  /*tcholBand*/
102  bool tcholSolve();
103  bool tcholDec(std::vector< std::vector<double> > &);
104 
105  /*interpSpline*/
106  void nCorrectGrad();
107 
108  void normalDefBilin(double xMin, double yMin);
109 
110  void normalDefBicubic(double xMin, double yMin);
111 
112  /*!
113  \brief METHOD TO ADJUST A LINEAR CURVE TO A SET OF LINE POINTS
114  \param ptpol is a pointer to a PointList
115  \param maxDist is the maximum distance to the line fitted for a set of points
116  \return FALSE if there is no memory available, the number of points are lower than 2 or maxDist == 0.0
117  \return TRUE if the curve is adjusted with no errors
118  */
119  static bool AdjustLinear(te::gm::LineString *ptol, double maxDist);
120 
121  protected:
122  unsigned int m_nPartsX, m_nPartsY; //!< number of parts considered in the x and y directions
123  unsigned int m_minpoints; //!< minimum of points considered
124  double m_overlapping; //!< overlap value considered
125  unsigned int m_nsplx; //!< Numero de colunas do spline
126  unsigned int m_nsply; //!< Numero de linhas do spline
127  unsigned int m_nparameters;
128  unsigned int m_BW;
129  double m_mean; //!< Media da area local
130  unsigned int m_npoints; //!< Numero de pontos de interesse
131  double m_passoWidth, m_passoHeight, m_lambda;
132  std::vector<te::gm::Point> m_obsVect; //!< Interpolation and least-square vectors
133  std::vector<double> m_TN, m_parVect; //!< Interpolating and least-square vectors
134  std::vector< std::vector<double> > m_N; //!< Interpolation and least-square matrix
135 
136  }; // class SplineInterpolationGrass
137 
138  } //mnt
139 } //te
140 
141 #endif
double m_mean
Media da area local.
Definition: SplineGrass.h:129
int order(int i_x, int i_y, unsigned int yNum)
Node order computation.
Definition: SplineGrass.h:70
unsigned int m_nsplx
Numero de colunas do spline.
Definition: SplineGrass.h:125
double phi_3(double csi)
Design matrix coefficients computation.
Definition: SplineGrass.h:75
unsigned int m_nPartsY
number of parts considered in the x and y directions
Definition: SplineGrass.h:122
std::vector< te::gm::Point > m_obsVect
Interpolation and least-square vectors.
Definition: SplineGrass.h:132
#define TEMNTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:41
std::vector< double > m_TN
Definition: SplineGrass.h:133
double phi_34(double csi_x, double csi_y)
Design matrix coefficients computation.
Definition: SplineGrass.h:87
double phi(double csi_x, double csi_y)
Design matrix coefficients computation.
Definition: SplineGrass.h:99
~SplineInterpolationGrass()
Destructor.
Definition: SplineGrass.h:28
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
void node_y(double y, int &i_y, double &csi_y, double yMin, double deltaY)
Ordinate node index computation.
Definition: SplineGrass.h:61
URI C++ Library.
unsigned int m_npoints
Numero de pontos de interesse.
Definition: SplineGrass.h:130
unsigned int m_nsply
Numero de linhas do spline.
Definition: SplineGrass.h:126
double phi_4(double csi)
Design matrix coefficients computation.
Definition: SplineGrass.h:79
This file contains a class to calculate retangular grid from Samples. Adapted from SPRING...
double phi_43(double csi_x, double csi_y)
Design matrix coefficients computation.
Definition: SplineGrass.h:91
std::vector< std::vector< double > > m_N
Interpolation and least-square matrix.
Definition: SplineGrass.h:134
void node_x(double x, int &i_x, double &csi_x, double xMin, double deltaX)
Ordinate node index computation.
Definition: SplineGrass.h:52
double phi_44(double csi_x, double csi_y)
Design matrix coefficients computation.
Definition: SplineGrass.h:95
double m_overlapping
overlap value considered
Definition: SplineGrass.h:124
unsigned int m_minpoints
minimum of points considered
Definition: SplineGrass.h:123
SplineInterpolationGrass(unsigned int nPartsX, unsigned int nPartsY, unsigned int minPoints, double overlappin)
Contructors.
Definition: SplineGrass.h:24
TEMNTEXPORT te::gm::LineString * pointListSimplify(te::gm::LineString *ls, double snap, double maxdist, double Zvalue)
double phi_33(double csi_x, double csi_y)
Design matrix coefficients computation.
Definition: SplineGrass.h:83