Utils.h
Go to the documentation of this file.
1 
2 /*!
3 \file terralib/mnt/core/Utils.h
4 
5 \brief Utility functions for MNT support.
6 */
7 
8 #ifndef __TERRALIB_MNT_INTERNAL_UTILS_H
9 #define __TERRALIB_MNT_INTERNAL_UTILS_H
10 
11 #include "Config.h"
12 #include "Enums.h"
13 
14 #include "../../common/UnitsOfMeasureManager.h"
15 
16 #include "../../dataaccess/dataset/DataSet.h"
17 #include "../../dataaccess/dataset/DataSetType.h"
18 #include "../../dataaccess/datasource/DataSource.h"
19 
20 #include "../../geometry/Coord2D.h"
21 #include "../../geometry/LineString.h"
22 #include "../../geometry/MultiLineString.h"
23 #include "../../geometry/MultiPoint.h"
24 #include "../../geometry/Point.h"
25 
26 
27 #ifndef MIN
28 #define MIN(x, y) ( ((x) < (y)) ? (x) : (y) )
29 #endif
30 
31 #ifndef MAX
32 #define MAX(x, y) ( ((x) > (y)) ? (x) : (y) )
33 #endif
34 
35 
36 namespace te
37 {
38  namespace mnt
39  {
40  size_t ReadPoints( std::string &inDsetName, te::da::DataSourcePtr &inDsrc, std::string &atrZ, double tol, te::gm::MultiPoint &mpt, std::string &geostype,
41  te::gm::Envelope &env);
42 
43  size_t ReadSamples( std::string &inDsetName, te::da::DataSourcePtr &inDsrc, std::string &atrZ, double tol, double max, Simplify alg, te::gm::MultiPoint &mpt,
44  te::gm::MultiLineString &isolines, std::string &geostype, te::gm::Envelope &env, int srid = 0);
45 
46  double Distance(const te::gm::Coord2D &pt1, const te::gm::Coord2D &pt2);
47 
48  double Distance(const double pt1x, const double pt1y, const double pt2x, const double pt2y);
49 
50  bool Equal(te::gm::Point &p1, te::gm::Point &p2, double &tol);
51 
52  //DouglasPeucker from TerraAmazon 4
53  te::gm::LineString* DouglasPeuckerTA(te::gm::LineString *lineIn, double simpFactor, double Zvalue);
54 
55  //DouglasPeucker from libgeos
56  te::gm::LineString* GEOS_DouglasPeucker(te::gm::LineString *ls, double snap, double Zvalue);
57 
58  TEMNTEXPORT te::gm::LineString* pointListSimplify(te::gm::LineString *ls, double snap, double maxdist, double Zvalue);
59 
60  double SegmentDistance(double fx, double fy, double lx, double ly, double ptx, double pty, double *pix, double *piy);
61 
63 
65 
66  // Find center point of triangle using its vertices.
67  short findCenter(te::gm::Point* vert, double* pcx, double* pcy);
68 
71 
72  // Test Vertex values for valid and special cases, returns TRUE if normal, FALSE otherwise.
73  bool testVertexValues(double, te::gm::Point*);
74 
75  // Define intersections of contour with edges of triangle
76  bool defineInterTriangle(std::vector<te::gm::Point>&, te::gm::Point*, double );
77 
78  // Define intersection point of contour with edge between two points
79  bool defineInterEdge(std::vector<te::gm::Point>&, te::gm::Point&, te::gm::Point&, double);
80 
81  //Extract lines from pline and store connected ones in clinlist.
82  bool extractLines(std::vector<te::gm::Point> &pline, std::vector<te::gm::LineString> &clinlist, double scale);
83 
84  bool initLineVector(std::vector<te::gm::Point> &pline, std::vector<te::gm::Point> &vect);
85  bool assembLine(std::vector<te::gm::LineString> &linlout, std::vector<te::gm::Point> &vect);
86 
87  bool equalFptSpt(te::gm::Point & fpt, te::gm::Point &spt, double scale);
88 
91 
92  // Calculate Normal vector of Triangle
93  bool triangleNormalVector(te::gm::Point*, double*);
94 
95  bool normalizeVector(double*);
96 
97  bool onSegment(te::gm::Point& pt, te::gm::Point& fseg, te::gm::Point& lseg, double tol);
98 
100 
101  bool point3dListFilter(std::vector<te::gm::Point> &p3dl, std::vector<bool> &fixed, double tol);
102 
103  bool Least_square_fitting(double *vectx, double *vecty, short np, short deg, double *coef);
104 
105  bool Gauss_elimination(short m, short n, double mat[6][6]);
106 
107  bool SaveIso(std::string& outDsetName, te::da::DataSourcePtr &outDsrc, std::vector<te::gm::LineString> &isolist, std::vector<double> &guidevalues, int srid);
108 
109  void Save(te::da::DataSource* source, te::da::DataSet* result, te::da::DataSetType* outDsType);
110 
111  TEMNTEXPORT bool convertAngleToPlanar(double& val, te::common::UnitOfMeasurePtr planar, int type);
113 
114  TEMNTEXPORT void getMinMax(te::rst::Raster* inputRst, double &vmin, double &vmax);
115 
117 
119  }
120 }
121 
122 #endif
bool Least_square_fitting(double *vectx, double *vecty, short np, short deg, double *coef)
bool initLineVector(std::vector< te::gm::Point > &pline, std::vector< te::gm::Point > &vect)
boost::shared_ptr< DataSource > DataSourcePtr
Definition: DataSource.h:1438
Simplify
Definition: Enums.h:87
A class that models the description of a dataset.
Definition: DataSetType.h:72
bool normalizeVector(double *)
bool Equal(te::gm::Point &p1, te::gm::Point &p2, double &tol)
double Distance(const te::gm::Coord2D &pt1, const te::gm::Coord2D &pt2)
te::gm::Point Max(te::gm::Point &p1, te::gm::Point &p2)
bool Gauss_elimination(short m, short n, double mat[6][6])
#define TEMNTEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:41
bool extractLines(std::vector< te::gm::Point > &pline, std::vector< te::gm::LineString > &clinlist, double scale)
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:119
double pointToSegmentDistance(te::gm::Point &fseg, te::gm::Point &lseg, te::gm::Point &pt, te::gm::Point *pti)
TEMNTEXPORT bool convertAngleToPlanar(double &val, te::common::UnitOfMeasurePtr planar, int type)
double PerpendicularDistance(te::gm::Coord2D &first, te::gm::Coord2D &last, te::gm::Coord2D &pin, te::gm::Coord2D &pinter)
size_t ReadPoints(std::string &inDsetName, te::da::DataSourcePtr &inDsrc, std::string &atrZ, double tol, te::gm::MultiPoint &mpt, std::string &geostype, te::gm::Envelope &env)
TEMNTEXPORT bool convertPlanarToAngle(double &val, te::common::UnitOfMeasurePtr unit)
bool SaveIso(std::string &outDsetName, te::da::DataSourcePtr &outDsrc, std::vector< te::gm::LineString > &isolist, std::vector< double > &guidevalues, int srid)
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
TEMNTEXPORT void getMinMax(te::rst::Raster *inputRst, double &vmin, double &vmax)
An abstract class for raster data strucutures.
Definition: Raster.h:71
bool equalFptSpt(te::gm::Point &fpt, te::gm::Point &spt, double scale)
mntType
Definition: Enums.h:78
URI C++ Library.
bool point3dListFilter(std::vector< te::gm::Point > &p3dl, std::vector< bool > &fixed, double tol)
bool defineInterEdge(std::vector< te::gm::Point > &, te::gm::Point &, te::gm::Point &, double)
void Save(te::da::DataSource *source, te::da::DataSet *result, te::da::DataSetType *outDsType)
bool testVertexValues(double, te::gm::Point *)
TEMNTEXPORT te::mnt::mntType getMNTType(const te::da::DataSetType *dt)
size_t ReadSamples(std::string &inDsetName, te::da::DataSourcePtr &inDsrc, std::string &atrZ, double tol, double max, Simplify alg, te::gm::MultiPoint &mpt, te::gm::MultiLineString &isolines, std::string &geostype, te::gm::Envelope &env, int srid=0)
MultiLineString is a MultiCurve whose elements are LineStrings.
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
boost::shared_ptr< UnitOfMeasure > UnitOfMeasurePtr
double SegmentDistance(double fx, double fy, double lx, double ly, double ptx, double pty, double *pix, double *piy)
int onSameSide(te::gm::Coord2D pt1, te::gm::Coord2D pt2, te::gm::Coord2D fseg, te::gm::Coord2D lseg)
short segIntersect(te::gm::Point &pfr, te::gm::Point &pto, te::gm::Point &lfr, te::gm::Point &lto)
te::gm::Point Min(te::gm::Point &p1, te::gm::Point &p2)
bool defineInterTriangle(std::vector< te::gm::Point > &, te::gm::Point *, double)
double coordToSegmentDistance(te::gm::Coord2D &fseg, te::gm::Coord2D &lseg, te::gm::Coord2D &pt, te::gm::Coord2D *pti)
bool segInterPoint(te::gm::Point &pfr, te::gm::Point &pto, te::gm::Point &lfr, te::gm::Point &lto, te::gm::Point *pt)
bool onSegment(te::gm::Point &pt, te::gm::Point &fseg, te::gm::Point &lseg, double tol)
bool triangleNormalVector(te::gm::Point *, double *)
bool assembLine(std::vector< te::gm::LineString > &linlout, std::vector< te::gm::Point > &vect)
short findCenter(te::gm::Point *vert, double *pcx, double *pcy)
te::gm::LineString * GEOS_DouglasPeucker(te::gm::LineString *ls, double snap, double Zvalue)
TEMNTEXPORT te::gm::LineString * pointListSimplify(te::gm::LineString *ls, double snap, double maxdist, double Zvalue)
General enumerations.
te::gm::LineString * DouglasPeuckerTA(te::gm::LineString *lineIn, double simpFactor, double Zvalue)