CalculateGrid.h
Go to the documentation of this file.
1 
2 /*!
3 \file terralib/mnt/core/CalculateGrid.h
4 
5 \brief This file contains a class to calculate retangular grid from Samples.
6 Adapted from SPRING
7 
8 */
9 
10 #ifndef __TERRALIB_MNT_INTERNAL_CALCULATEGRID_H
11 #define __TERRALIB_MNT_INTERNAL_CALCULATEGRID_H
12 
13 // Terralib Includes
14 #include "Config.h"
15 #include "Enums.h"
16 
17 #include "../../dataaccess/dataset/DataSet.h"
18 #include "../../dataaccess/dataset/DataSetType.h"
19 #include "../../dataaccess/datasource/DataSource.h"
20 
21 #include "../../raster/Raster.h"
22 #include "../../sam.h"
23 
24 
27 
28 //MITASOVA PARAMETERS
29 #define mitasovaMINPOINTS 50
30 #define mitasovaTENSION 40.
31 #define mitasovaSMOOTH 0.100000
32 
33 namespace te
34 {
35  namespace mnt
36  {
37 
39  {
40  public:
41  /*! \brief Default constructor. */
43 
45 
46  /*!
47  \brief Calculate GRID
48  \ return true or false.
49  */
50  bool run();
51 
52  /*!
53  \brief It sets the Datasource that is being used to generate TIN.
54  \param inDsrc The datasource being used.
55  \param inDsetName datasource name
56  \param inDsetType input DataSetType
57  \param type Input type: Sample or Isoline
58  */
60  std::string inDsetName,
61  std::unique_ptr<te::da::DataSetType> inDsetType,
62  InputType type);
63 
64  /*!
65  \brief It sets the Datasource that is being used to save TIN.
66  */
67  void setOutput(std::map<std::string, std::string> &dsinfo);
68 
69  /*!
70  \brief It sets the parameters that is being used to save TIN.
71  \param resx, resy resolution X and Y.
72  \param gt interpolator
73  */
74  void setParams(const std::string &attriso, const std::string &attrpt, double resx, double resy, Interpolator gt, double rad, int pow);
75 
76  /*! Function used to set the Spatial Reference System ID */
77  void setSRID(int srid);
78 
79  /*! Function used to set the envelope parameter */
81 
82  std::unique_ptr<te::rst::Raster> Initialize(bool spline, unsigned int &nro_neighb, double &rx1, double &ry2, unsigned int &outputWidth, unsigned int &outputHeight);
83 
84  /*!
85  \brief Interpolates the z value of the pg point3d.
86  \ This method interpolates the z value of the pg point3d using the
87  \ information on the current partition, the dist double vector and
88  \param pg: points to an point3d whose z value must be calculated
89  \param points: vector that contains points from point pg to the partition points
90  \param distq: points to a double vector that contains distance values from point pg to the partition points.
91  */
92  void Interpolation(te::gm::Point& pg, std::vector<te::gm::Point>& points, std::vector<double>& distq);
93 
94  /*!
95  \brief Interpolates the z value of the pg point3d using an weighted average by quadrant.
96  \ Implements the interpolator that uses the average, weighted by the inverse
97  \ square distance, of the nearest neighbours by quadrant.*/
98  double Interpwq(te::gm::Point& pg, std::vector<te::gm::Point>& points, std::vector<double>& distq);
99 
100  /*!
101  \brief Interpolates the z value of the pg point3d using an weighted average by quadrant and by z values.
102  \ Implements the interpolator tha uses the average, weighted by the inverse
103  \ square distance, of the nearest neighbours by z values and by quadrant.
104  \ This method accepts no repeated z values in the interpolation.*/
105  double Interpwqz(te::gm::Point& pg, std::vector<te::gm::Point>& points, std::vector<double>& distq);
106 
107  /*!
108  \brief Method to calculate a grid from a vector of samples using a Spline (GRASS) fitting algorithm
109  \return true when the z grid value is succesfully evaluated
110  \return false when a z grid value could not be evaluated or some error is encountered
111  */
113 
114  /*!
115  \brief Method to calculate a grid from a vector of samples using a Spline (Mitasova) fitting algorithm
116  \return true when the z grid value is succesfully evaluated
117  \return false when a z grid value could not be evaluated or some error is encountered
118  */
120 
121  double getMin() { return m_min; }
122  double getMax() { return m_max; }
123 
124  protected:
125 
126  int m_srid; //!< Attribute with spatial reference information
127  te::gm::Envelope m_env; //!< Attribute used to restrict the area to generate the raster.
128 
130  std::string m_inDsetName_sample;
131  std::unique_ptr<te::da::DataSetType> m_inDsetType_sample;
132 
134  std::string m_inDsetName_point;
135  std::unique_ptr<te::da::DataSetType> m_inDsetType_point;
136 
137  std::string m_atrZ_sample; //!< Attribute used to calculate grid
138  std::string m_atrZ_point; //!< Attribute used to calculate grid
139 
140  std::map<std::string, std::string> m_dsinfo; //!<
141 
142  double m_resx, m_resy; //!< grid resolution in X and Y
143  Interpolator m_inter; //!< selected interpolation method
144  double m_radius; //!< radius
145  int m_power; //!< power
146  int m_tension; //!< the tension spline factor considered in the spline fitting process
147  int m_smoothM; //!< smooth factor used
148 
150 
151  double m_tolerance; //!< tolerance used to simplify lines
152  double m_nodatavalue; //!< no data value
153 
155  std::vector<std::pair<te::gm::Coord2D, te::gm::Point> > m_dataset; //!<
156 
157  double m_min, m_max; //!< Output DTM limits
158  }; //class CalculateGrid
159 
160  } //mnt
161 } //te
162 
163 #endif
te::gm::Envelope
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
te::mnt::CalculateGrid::GenerateGridSplineMitasova
bool GenerateGridSplineMitasova()
Method to calculate a grid from a vector of samples using a Spline (Mitasova) fitting algorithm.
te::mnt::CalculateGrid::Interpwq
double Interpwq(te::gm::Point &pg, std::vector< te::gm::Point > &points, std::vector< double > &distq)
Interpolates the z value of the pg point3d using an weighted average by quadrant. \ Implements the in...
te
TerraLib.
Definition: AddressGeocodingOp.h:52
te::mnt::CalculateGrid::m_atrZ_sample
std::string m_atrZ_sample
Attribute used to calculate grid.
Definition: CalculateGrid.h:137
te::mnt::CalculateGrid::getMin
double getMin()
Definition: CalculateGrid.h:121
KD_ADAPTATIVE_NODE
te::sam::kdtree::AdaptativeNode< te::gm::Coord2D, std::vector< te::gm::Point >, te::gm::Point > KD_ADAPTATIVE_NODE
Definition: CalculateGrid.h:25
te::rst::Raster
An abstract class for raster data strucutures.
Definition: Raster.h:72
te::mnt::CalculateGrid::setParams
void setParams(const std::string &attriso, const std::string &attrpt, double resx, double resy, Interpolator gt, double rad, int pow)
It sets the parameters that is being used to save TIN.
te::mnt::CalculateGrid::m_radius
double m_radius
radius
Definition: CalculateGrid.h:144
te::mnt::CalculateGrid::m_inDsetName_point
std::string m_inDsetName_point
Definition: CalculateGrid.h:134
te::mnt::CalculateGrid::m_env
te::gm::Envelope m_env
Attribute used to restrict the area to generate the raster.
Definition: CalculateGrid.h:127
te::mnt::CalculateGrid::CalculateGrid
CalculateGrid()
Default constructor.
te::mnt::CalculateGrid
Definition: CalculateGrid.h:39
te::mnt::CalculateGrid::m_inDsetType_point
std::unique_ptr< te::da::DataSetType > m_inDsetType_point
Definition: CalculateGrid.h:135
KD_ADAPTATIVE_TREE
te::sam::kdtree::AdaptativeIndex< KD_ADAPTATIVE_NODE > KD_ADAPTATIVE_TREE
Definition: CalculateGrid.h:26
te::mnt::CalculateGrid::m_tension
int m_tension
the tension spline factor considered in the spline fitting process
Definition: CalculateGrid.h:146
te::mnt::CalculateGrid::m_inDsetType_sample
std::unique_ptr< te::da::DataSetType > m_inDsetType_sample
Definition: CalculateGrid.h:131
Enums.h
Enumerations of XML module.
te::mnt::CalculateGrid::m_rst
te::rst::Raster * m_rst
Definition: CalculateGrid.h:149
te::mnt::InputType
InputType
Input types.
Definition: Enums.h:49
te::mnt::CalculateGrid::m_nodatavalue
double m_nodatavalue
no data value
Definition: CalculateGrid.h:152
te::mnt::CalculateGrid::m_inDsrc_sample
te::da::DataSourcePtr m_inDsrc_sample
Definition: CalculateGrid.h:129
te::mnt::CalculateGrid::setOutput
void setOutput(std::map< std::string, std::string > &dsinfo)
It sets the Datasource that is being used to save TIN.
te::sam::kdtree::AdaptativeIndex
A class that represents a two dimensional K-d Tree (2-d Tree) that store data-elements into the leafs...
Definition: Index.h:375
te::mnt::CalculateGrid::m_dataset
std::vector< std::pair< te::gm::Coord2D, te::gm::Point > > m_dataset
Definition: CalculateGrid.h:155
te::mnt::CalculateGrid::setEnvelope
void setEnvelope(te::gm::Envelope &env)
te::mnt::CalculateGrid::m_resy
double m_resy
grid resolution in X and Y
Definition: CalculateGrid.h:142
te::mnt::CalculateGrid::m_min
double m_min
Definition: CalculateGrid.h:157
te::mnt::CalculateGrid::m_smoothM
int m_smoothM
smooth factor used
Definition: CalculateGrid.h:147
te::mnt::CalculateGrid::Interpolation
void Interpolation(te::gm::Point &pg, std::vector< te::gm::Point > &points, std::vector< double > &distq)
Interpolates the z value of the pg point3d. \ This method interpolates the z value of the pg point3d ...
te::mnt::CalculateGrid::m_inDsetName_sample
std::string m_inDsetName_sample
Definition: CalculateGrid.h:130
te::mnt::CalculateGrid::m_power
int m_power
power
Definition: CalculateGrid.h:145
te::mnt::CalculateGrid::setInput
void setInput(te::da::DataSourcePtr inDsrc, std::string inDsetName, std::unique_ptr< te::da::DataSetType > inDsetType, InputType type)
It sets the Datasource that is being used to generate TIN.
te::mnt::Interpolator
Interpolator
Definition: Enums.h:55
te::sam::kdtree::AdaptativeNode
A class that represents an Kd-tree node.
Definition: Node.h:207
te::mnt::CalculateGrid::m_tolerance
double m_tolerance
tolerance used to simplify lines
Definition: CalculateGrid.h:151
te::mnt::CalculateGrid::Initialize
std::unique_ptr< te::rst::Raster > Initialize(bool spline, unsigned int &nro_neighb, double &rx1, double &ry2, unsigned int &outputWidth, unsigned int &outputHeight)
te::mnt::CalculateGrid::m_adaptativeTree
KD_ADAPTATIVE_TREE * m_adaptativeTree
Definition: CalculateGrid.h:154
te::mnt::CalculateGrid::GenerateGridSplineGrass
bool GenerateGridSplineGrass()
Method to calculate a grid from a vector of samples using a Spline (GRASS) fitting algorithm.
te::da::DataSourcePtr
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1449
te::mnt::CalculateGrid::getMax
double getMax()
Definition: CalculateGrid.h:122
Config.h
Proxy configuration file for TerraView (see terraview_config.h).
te::mnt::CalculateGrid::m_inDsrc_point
te::da::DataSourcePtr m_inDsrc_point
Definition: CalculateGrid.h:133
te::mnt::CalculateGrid::m_srid
int m_srid
Attribute with spatial reference information.
Definition: CalculateGrid.h:126
te::mnt::CalculateGrid::m_dsinfo
std::map< std::string, std::string > m_dsinfo
Definition: CalculateGrid.h:140
te::mnt::CalculateGrid::Interpwqz
double Interpwqz(te::gm::Point &pg, std::vector< te::gm::Point > &points, std::vector< double > &distq)
Interpolates the z value of the pg point3d using an weighted average by quadrant and by z values....
te::mnt::CalculateGrid::setSRID
void setSRID(int srid)
TEMNTEXPORT
#define TEMNTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:41
te::mnt::CalculateGrid::m_atrZ_point
std::string m_atrZ_point
Attribute used to calculate grid.
Definition: CalculateGrid.h:138
te::gm::Point
A point with x and y coordinate values.
Definition: Point.h:51
te::mnt::CalculateGrid::run
bool run()
Calculate GRID \ return true or false.
te::mnt::CalculateGrid::~CalculateGrid
~CalculateGrid()
te::mnt::CalculateGrid::m_inter
Interpolator m_inter
selected interpolation method
Definition: CalculateGrid.h:143