Utils.h
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/geometry/Utils.h
22 
23  \brief Utility functions for the Geometry Module.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_GEOMUTILS_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_GEOMUTILS_H
28 
29 // TerraLib
30 #include "../sam/rtree.h"
31 #include "Config.h"
32 #include "CommonDataStructures.h"
33 #include "Enums.h"
34 
35 // STL
36 #include <memory>
37 #include <set>
38 #include <vector>
39 
40 namespace te
41 {
42  namespace gm
43  {
44 // Forward declarations
45  class Curve;
46  class Envelope;
47  class Geometry;
48  class GeometryPtr;
49  class Point;
50  class Polygon;
51  class Line;
52  class LinearRing;
53  class LineString;
54  class MultiLineString;
55 
56  struct Coord2D;
57 
58  /*!
59  \brief It returns the number of measurements or axes needed to describe a position in a coordinate system.
60 
61  It returns:
62  <ul>
63  <li>2 for a coordinate with x, y;</li>
64  <li>3 for a coordinate with x, y and z or x, y and m;</li>
65  <li>4 for a coordinate with x, y, z and m.</li>
66  </ul>
67 
68  \param t The geomeytric type.
69 
70  \return The number of measurements or axes needed to describe a position in a coordinate system.
71  */
73  {
74  if(t & 0x100) // may be z (0x300), m (0x700) or zm (0x800)
75  {
76  if(t & 0x800) // it must be zm
77  return 4;
78 
79  return 3; // it can be z (gType & 0x300) or m (gType & 0x700)
80  }
81 
82  return 2;
83  }
84 
85  /*!
86  \brief It returns the name of 2D geometry subclass.
87 
88  The name of the 2D geometry subclass may be one of the following:
89  <ul>
90  <li>Geometry </li>
91  <li>Point </li>
92  <li>LineString </li>
93  <li>Polygon </li>
94  <li>MultiPoint </li>
95  <li>MultiLineString </li>
96  <li>MultiPolygon </li>
97  <li>GeometryCollection </li>
98  <li>CircularString </li>
99  <li>CompoundCurve </li>
100  <li>CurvePolygon </li>
101  <li>MultiSurface </li>
102  </ul>
103 
104  \return The name of the geometry subclass type ide.
105  */
106  TEGEOMEXPORT const std::string Get2DGeometryType(const te::gm::GeomType& type);
107 
108  /*!
109  \brief It returns the 2D geometry subclass type identifier.
110 
111  <ul>
112  <li>GeometryType = 0</li>
113  <li>PointType = 1</li>
114  <li>LineStringType = 2</li>
115  <li>PolygonType = 3</li>
116  <li>MultiPointType = 4</li>
117  <li>MultiLineStringType = 5</li>
118  <li>MultiPolygonType = 6</li>
119  <li>GeometryCollectionType = 7</li>
120  <li>CircularStringType = 8</li>
121  <li>CompoundCurveType = 9</li>
122  <li>CurvePolygonType = 10</li>
123  <li>MultiSurfaceType = 12</li>
124  </ul>
125 
126  \return The 2D geometry subclass type identifier
127 
128  \note Please, see GeomType enumeration for possible return values.
129 
130  \note TerraLib extended method.
131  */
133 
134  /*!
135  \brief Creates an envelope that fits the given coordinates. It makes all the adjustments needed to return a valid envelope
136 
137  \param x1 The coordinate X of the first point
138  \param y1 The coordinate Y of the first point
139  \param x2 The coordinate X of the second point
140  \param y2 The coordinate Y of the second point
141 
142  \return A valid envelope containing the two given points
143  */
144  TEGEOMEXPORT te::gm::Envelope CreateEnvelope(double x1, double y1, double x2, double y2);
145 
146  /*!
147  \brief Creates an envelope that fits the given coordinates. It makes all the adjustments needed to return a valid envelope
148 
149  \param p1 The first point
150  \param p2 The second point
151 
152  \return A valid envelope containing the two given points
153  */
155 
156  /*!
157  \brief Creates an envelope by expanding the dimension of the given coordinate using the given extension.
158  The extension value will be used to expand the envelope in the four directions.
159  The result envelope will have width = (2 * extension) and height = (2 * extension)
160 
161  \param coord The reference coordinate
162  \param extension The extension to expand the the envelope
163 
164  \return A valid envelope
165  */
166  TEGEOMEXPORT te::gm::Envelope CreateEnvelope(const te::gm::Coord2D& coord, double extension);
167 
168  /*!
169  \brief It creates a Geometry (a polygon) from the given envelope.
170 
171  \param e The envelope to extract the coordinates. Don't call with a NULL envelope.
172  \param srid The Spatial Reference System ID to be associated to the polygon.
173 
174  \return A polygon (in counter-clock-wise) with rectangle coordinates: [(MINX, MINY), (MAXX, MINY), (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)].
175 
176  \note The caller of this method will take the ownership of the returned geometry.
177  */
178  TEGEOMEXPORT Geometry* GetGeomFromEnvelope(const Envelope* const e, int srid);
179 
180  /*!
181  \brief It returns the union of a geometry vector.
182 
183  \param items Vector of itens that represents a group.
184  \param tolerance Tolerance value to be used in geometric operations
185 
186  \return Union of the geometry.
187  */
188  TEGEOMEXPORT std::unique_ptr<te::gm::Geometry> GetGeometryUnion(const std::vector<te::gm::Geometry*>& geomVec, double tolerance = 0.000000001);
189 
190  /*!
191  \brief It returns if two geometries satisfy a given spatial relation.
192 
193  \param g1 The first geometry
194  \param g2 The second geometry
195  \param r A given spatial relation to be tested
196 
197  \return It returns true if the given two geometries satisfy the spatial relation. Otherwise, it returns false.
198 
199  \exception Exception It throws an exception if the spatial relation is not valid or if the test can not be evaluated.
200  */
201  TEGEOMEXPORT bool SatisfySpatialRelation(const Geometry* g1, const Geometry* g2, SpatialRelation relation);
202 
203  /*!
204  \brief Tests if the given relation matrix matches with the given relation pattern. This pattern is based on the Dimensionally Extended nine-Intersection Model (DE-9IM)
205 
206  \param relation The relation matrix to be checked
207  \param relationPattern The pattern to be match
208 
209  \return It returns TRUE if the given relation matches the given relationPattern. Otherwise, it returns FALSE.
210 
211  \exception Exception It throws an exception if the spatial relation is not valid or if the test can not be evaluated.
212  */
213  TEGEOMEXPORT bool RelationMatches(const std::string& relation, const std::string& relationPattern);
214 
215  /*!
216  \brief Finds the correspondent smallest box that allows a box to be cut in blocks of a given size
217 
218  \param env Reference envelope
219  \param bWidth Block width
220  \param bHeight Block height
221 
222  \return It returns a adjusted envelope
223  */
224  TEGEOMEXPORT Envelope AdjustToCut(const Envelope & env, double bWidth, double bHeight);
225 
226  /*!
227  \brief Make the line interpolation to find a target
228 
229  \param line LineString to make the interpolation
230  \param initial Initial value
231  \param final Final value
232  \param target Target value
233 
234  \return It returns a target Coord2D in the line.
235  */
236  TEGEOMEXPORT Coord2D* locateAlong(const LineString* line, double initial, double final, double target);
237 
238  /*!
239  \brief It will get a GeometryCollection and distribute in a vector.
240 
241  \param g Input GeometryCollection.
242  \param geoms Output Geometry Vector.
243 
244  \note If the geomSource is not a te::gm::GeometryCollectionType it will return vector with the input geometry.
245  */
246  TEGEOMEXPORT void Multi2Single(const te::gm::Geometry* g, std::vector<te::gm::Geometry*>& geoms);
247 
248  /*!
249  \brief Provides an efficient method of unioning a collection of Polygonal geometries.
250  This algorithm is faster and likely more robust than the simple iterated approach of repeatedly unioning each polygon to a result geometry.
251 
252  \param polygonVector A vector of polygons.
253 
254  \return a Geometry containing the union.
255  */
256  TEGEOMEXPORT te::gm::Geometry* CascadedPolygonUnion(const std::vector<te::gm::Polygon*>& polygonVector);
257 
258  /*!
259  \brief Provides an efficient method of unioning a collection of geometries.
260  This algorithm is faster and likely more robust than the simple iterated approach of repeatedly unioning each polygon to a result geometry.
261 
262  \param vecGeometries A vector of geometries.
263 
264  \return a Geometry containing the union.
265  */
266  TEGEOMEXPORT te::gm::Geometry* CascadedUnion(const std::vector<te::gm::Geometry*>& vecGeometries);
267 
268  /*!
269  \brief It will get the union of the input geometries.
270 
271  \param geom Input Geometry.
272 
273  \return a Geometry containing the union.
274 
275  \note If no input geometries were provided, an EMPTY POINTER is returned.
276  */
278 
279  /*!
280  \brief Compute the the closest points of two geometries.
281 
282  \param geomA Input Geometry A.
283  \param geomB Input Geometry B.
284  \param coordA Output coord on Geometry A.
285  \param coordB Output coord on Geometry B.
286 
287  */
289  te::gm::Coord2D& coordA, te::gm::Coord2D& coordB);
290 
292 
293  TEGEOMEXPORT double GetAngle(te::gm::Coord2D coordA, te::gm::Coord2D coordB);
294 
295  TEGEOMEXPORT bool Rotate(te::gm::Coord2D pr, te::gm::LineString* l, double angle, te::gm::LineString* lOut);
296 
297  TEGEOMEXPORT bool AdjustSegment(te::gm::Point* P0, te::gm::Point* P1, double d0, te::gm::Coord2D& P0out, te::gm::Coord2D& P1out);
298 
299  /*!
300  \brief It will get a list of polygons formed by the polygonization.
301 
302  \param g Input Polygon.
303  \param pols Output Polygon Vector.
304  */
305  TEGEOMEXPORT void Polygonizer(te::gm::Geometry* g, std::vector<te::gm::Polygon*>& pols);
306 
307  /*!
308  \brief It will get a list of polygons formed by the polygonization.
309 
310  \param g Input Polygon.
311  \param pols Output Polygon Vector.
312  */
313  TEGEOMEXPORT void Polygonizer(const te::gm::GeometryVector& vecInput, te::gm::GeometryVector& vecOutput);
314 
315  /*!
316  \brief Add all line strings from the polygon given to the vector given.
317 
318  \param polygon polygon from which to extract line strings
319  \param pAdd A reference to a vector of geometries.
320  */
322 
323  /*!
324  \brief Add the linestring given to the vector.
325 
326  \param linestring line string
327  \param pAdd A reference to a vector of geometries.
328  */
330 
331  /*!
332  \brief Prepares the geometry A with intersection points in geometry B.
333 
334  \param geom_A Geometry used to be inserted new points of intersection.
335  \param geomB The geometry to be used to intersect with Geometry B.
336  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
337  \param tolerance Tolerance value to be used in geometric operations
338 
339  \return A new geometry based on geometry A with intersection points in geometry B.
340  */
342  bool& wasChanged, double tolerance = 0.000000001);
343 
344  /*!
345  \brief Prepares the geometry A with intersection points in geometry B.
346 
347  \param geom_A Geometry used to be inserted new points of intersection.
348  \param vecGeomB The list of Geometries used to intersects with Geometry A.
349  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
350  \param tolerance Tolerance value to be used in geometric operations
351 
352  \return A new geometry based on geometry A with intersection points in geometry B.
353  */
355  bool& wasChanged, double tolerance = 0.000000001);
356 
357  /*!
358  \brief Prepares the geometries vector to be used in overlay operations.
359  \description It has two steps: 1 - Tries to snap the existing coordinates to make them be exactly the same if the are within the given tolerance;
360  2 - It breaks crossing segments in the intersection coordinates, sometimes gerating new coordinates in both segments
361 
362  \param vecGeometries The vector to be prepared.
363  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
364  \param tolerance Tolerance value to be used in geometric operations
365 
366  \return A new geometry vector prepared to overlay operations.
367  */
369  bool& wasChanged, double tolerance = 0.000000001);
370 
371  /*!
372  \brief Prepares the MultiLineString A with intersection points in MultiLineString B.
373 
374  \param mline_A MultiLineString used to be inserted new points of intersection.
375  \param rtree Rtree indexing all the segments that must be used in the prepare algorithm.
376  \param vecRtreeSegments All the segments indexed in the rtree
377  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
378  \param tolerance Tolerance value to be used in geometric operations
379 
380  \return A new MultiLineString based on MultiLineString A with intersection points in MultiLineString B.
381  */
383  std::vector<te::gm::LineString>& vecRtreeSegments, bool& wasChanged, double tolerance = 0.000000001);
384 
385  /*!
386  \brief Prepares the LineString A with intersection points in LineString B.
387 
388  \param ls_A LineString used to be inserted new points of intersection.
389  \param rtree Rtree indexing all the segments that must be used in the prepare algorithm.
390  \param vecRtreeSegments All the segments indexed in the rtree
391  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
392  \param tolerance Tolerance value to be used in geometric operations
393 
394  \return A new LineString based on LineString A with intersection points in LineString B.
395  */
397  std::vector<te::gm::LineString>& vecRtreeSegments, bool& wasChanged, double tolerance = 0.000000001);
398 
399  /*!
400  \brief Snaps a LinearRing based on a set of LineString.
401 
402  \param rtree The R-tree contains the candidates envelopes as reference to snap.
403  \param referenceSegments A vector of LineString that is used as reference to snap.
404  \param setIndexesIgnored A set of indexes of candidates that had must be ignored in the processing. This set is used for optimization purposes
405  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
406  \param linearRingToSnap A LinearRing that will be snapped.
407  \param tolerance Tolerance value to be used in geometric operations
408 
409  \return A new snapped LinearRing.
410  */
412  const std::vector<te::gm::LineString>& referenceSegments,
413  const std::set<std::size_t>& setIndexesIgnored,
414  const te::gm::LineString& linearRingToSnap, bool& wasChanged,
415  double tolerance = 0.000000001);
416 
417  /*!
418  \brief Add intersection points in a LinearRing based on a Vector of LineString as reference.
419 
420  \param rtree The R-tree contains the candidates envelopes as reference to snap.
421  \param candidateSegments A vector of LineString that is used as reference to snap.
422  \param setIndexesIgnored A set of indexes of candidates that had must be ignored in the processing. This set is used for optimization purposes
423  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
424  \param lr_Reference A LinearRing that will be added new points of intersection.
425  \param usePerpendicularDistance True if the new points are added by perpendicular distance algorithm.
426  \param tolerance Tolerance value to be used in geometric operations
427 
428  \return
429  */
431  const std::vector<te::gm::LineString>& candidateSegments,
432  const std::set<std::size_t>& setIndexesIgnored,
433  const te::gm::LineString& lr_Reference,
434  const bool& usePerpendicularDistance = false,
435  double tolerance = 0.000000001);
436 
437  /*!
438  \brief Gets a vector of LineString reference points including intersection points using GEOS operators.
439 
440  \param lsReference LineString used as reference.
441  \param candidates A Vector of LineString used to intersects the lsReference.
442  \param tolerance Tolerance value to be used in geometric operations
443 
444  \return A vector of LineString reference points including intersection points using GEOS operators.
445  */
446  TEGEOMEXPORT std::vector<te::gm::Point> GetIntersectionPointsByOperators(const te::gm::LineString& lsReference, const std::vector<te::gm::LineString>& candidates, double tolerance = 0.000000001);
447 
448  /*!
449  \brief Gets a vector of LineString reference points including intersection points using perpendicular distance.
450 
451  \param lsReference LineString used as reference.
452  \param candidates A Vector of LineString used to intersects the lsReference.
453  \param tolerance Tolerance value to be used in geometric operations
454 
455  \return A vector of LineString reference points including intersection points using perpendicular distance.
456  */
457  TEGEOMEXPORT std::vector<te::gm::Point> GetIntersectionPointsByPerpendicularDistance(const te::gm::LineString& lsReference, const std::vector<te::gm::LineString>& candidates, double tolerance = 0.000000001);
458 
459  /*!
460  \brief Get the vector of MultLineStrings that compose the Geometry
461 
462  \param geometry Used to get lineStrings.
463 
464  return A vector of MultiLineString based on geometry parameter.
465  */
466  TEGEOMEXPORT std::vector<MultiLineString *> GetAsMultiLineStringVector(const te::gm::Geometry& geometry);
467 
468 
469  /*!
470  \brief A geometry is built based on a Vector of MultiLineString and the origin geometry type.
471 
472  \param multiLineStringVector A vector of multiLineString that have all lines of a Geometry.
473 
474  return A geometry built based on a Vector of MultiLineString and the origin geometry type.
475  */
476  TEGEOMEXPORT te::gm::Geometry* MultiLineToDefinedType(const std::vector<te::gm::MultiLineString*>& multiLineStringVector,
477  te::gm::GeomType geometryType);
478 
479  /*!
480  \brief Get the LineStrings that compose the Geometry
481 
482  \param geometry Used to get lineStrings.
483 
484  return A LineString based on parameter geometry.
485  */
487 
488  /*!
489  \brief Verifies if the geomType is a collection type.
490 
491  \param geomType enum te::gm::GeomType.
492 
493  return True if the geomType is a collection type.
494  */
496 
497  /*!
498  \brief Get the simple type of GeomType.
499 
500  \param geomType enum te::gm::GeomType.
501 
502  return A simple type of GeomType.
503  */
505 
506  /*!
507  \brief Get the collection type of GeomType.
508 
509  \param geomType enum te::gm::GeomType.
510 
511  return A collection type of GeomType.
512  */
514 
515  /*!
516  \brief Creates a LineString between the given startCoord and endCoord with the given number of intermediate coordinates.
517 
518  \param startCoord The first coordinate of the line
519  \param endCoord The last coordinate of the line
520  \param srid The srid of the line
521  \param numberOfIntermediateCoords The number of intermediate coordinates of the line
522 
523  \return A LineString between startCoord and endCoord with the given number of intermediate coordinates
524  */
525  TEGEOMEXPORT te::gm::LineString CreateLine(const te::gm::Coord2D& startCoord, const te::gm::Coord2D& endCoord, const int& srid, const int& numberOfIntermediateCoords);
526 
527  /*!
528  \brief Creates a Polygon from the given envelope and with the given number of intermediate coordinates in each of its four borders lines.
529 
530  \param box The envelope from which the polygon will be created
531  \param srid The srid of the polygon
532  \param numberOfIntermediateCoords The number of intermediate coordinates of each border line
533 
534  \return A LineString between startCoord and endCoord with the given number of intermediate coordinates in each border line
535  */
536  TEGEOMEXPORT te::gm::Polygon CreatePolygon(const te::gm::Envelope& box, const int& srid, const int& numberOfIntermediateCoords);
537 
538  /*!
539  \brief Creates a parallel line from the given line. Here will use the distance for offset between the original line and the parallel.
540 
541  \param line Original line
542  \param distance for offset between the original line and the parallel. Left will be positive and right will be negative
543 
544  \return A LineString between startCoord and endCoord with the given number of intermediate coordinates in each border line
545  */
546  TEGEOMEXPORT te::gm::LineString* ParallelLine(const te::gm::LineString* line, double distance);
547 
548  /*!
549  \brief Checks if the given point in within the given polygon or multipolygon geometry
550 
551  \param coord The coord to be checked
552  \param geometry The Polygon or Multipolygon to be used as reference
553 
554  \return TRUE if the point is within the polygon. FALSE otherwise
555  */
556  TEGEOMEXPORT bool IsPointOnPolygon(const te::gm::Coord2D& coord, const te::gm::Geometry* geometry);
557 
558  /*!
559  \brief As geos Explanation: An interior point is guaranteed to lie in the interior of the Geometry, if it possible to calculate such a point exactly.
560  Otherwise, the point may lie on the boundary of the geometry.
561 
562  \param geometry The input geometry
563 
564  \return An interior point inside the given Geometry, if possible.
565  */
567 
568 
569  /*!
570  \brief Normalizes and filters the given geometry based on the given simple type.
571  \description If the given geometry if already from the given simple type, it will clone the geometry and return it.
572  If the geometry is from the multi type related to the single, it will clone the geometry and return it.
573  If the geometry is a collection, it will search for geometries from the given single type and multi type, and return them in a collection related to the given type.
574 
575  \param geometry The geometry to be analysed
576  \param singleGeometryType The base single type to be used as filter
577 
578  \return The normalized geometry based onthe given singleGeometryType. Null if this given type could not be found in the given geometry.
579  */
581 
582  /*!
583  \brief Returns the appropriate precision to be used by spatial operations that adjust geometric data from other geometric systems
584 
585  \param srid The id of the SRS (Spatial Reference System)
586 
587  \return The precision appropriate to the given srid
588  */
589  TEGEOMEXPORT double GetAppropriatePrecision(int srid);
590 
591  /*!
592  \brief Clips the given geometry to the given clipArea
593 
594  \param geometry The geometry to be clipped
595  \param clipArea The clipping area
596 
597  \return The clipped geometry
598  */
600 
601  /*!
602  \brief Checks if the geometry is null or empty
603 
604  \param geometry The geometry to be checked
605 
606  \return The result of the check. TRUE if the geometry is null or empty. FALSE otherwise
607  */
608  TEGEOMEXPORT bool IsNullOrEmpty(const te::gm::GeometryPtr& geometry);
609 
610  /*!
611  \brief Checks if the geometry is null or empty
612 
613  \param geometry The geometry to be checked
614 
615  \return The result of the check. TRUE if the geometry is null or empty. FALSE otherwise
616  */
617  TEGEOMEXPORT bool IsNullOrEmpty(const te::gm::Geometry* geometry);
618 
619  /*!
620  \brief Creates a polygon from the given curve
621 
622  \param curve The curve to be used to create a polygon
623 
624  \return The created polygon
625  */
627 
628 
629  /*!
630  \brief Checks if a LinearRing is in Counter-clockwise orientation
631 
632  \param curve The LinearRing to be checked
633 
634  \return TRUE if the given LinearRing is in Counter-clockwise orientation. FALSE otherwise
635  */
636  TEGEOMEXPORT bool isCCW(const te::gm::LinearRing* ring);
637 
638  /*!
639  \brief Calculates the area of the given geometry. If the geometry is from dimension 0 or 1, it returns 0
640 
641  \param geometry The geometry to be analysed
642 
643  \return The area of the geometry or 0 if the dimension of the geometry is 0 or 1
644  */
645  TEGEOMEXPORT double GetArea(const te::gm::Geometry* geometry);
646 
647  /*!
648  \brief Creates a geometry collection based on the given geometryVector
649 
650  \param geometryVector The input geometry vector
651 
652  \return A geometry collection containing all the grometries from the geometry vector
653  */
655 
656  } // end namespace gm
657 } // end namespace te
658 
659 #endif // __TERRALIB_GEOMETRY_INTERNAL_GEOMUTILS_H
660 
std::vector< te::gm::Geometry * > GeometryVector
TEGEOMEXPORT te::gm::GeomType GetMultiLineStringType(const te::gm::Geometry &geometry)
Get the LineStrings that compose the Geometry.
TEGEOMEXPORT te::gm::Geometry * CascadedUnion(const std::vector< te::gm::Geometry *> &vecGeometries)
Provides an efficient method of unioning a collection of geometries. This algorithm is faster and lik...
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
A Line is LineString with 2 points.
Definition: Line.h:50
TEGEOMEXPORT void AddPolygon(te::gm::Polygon *polygon, te::gm::GeometryVector &pAdd)
Add all line strings from the polygon given to the vector given.
TEGEOMEXPORT te::gm::Geometry * CascadedPolygonUnion(const std::vector< te::gm::Polygon *> &polygonVector)
Provides an efficient method of unioning a collection of Polygonal geometries. This algorithm is fast...
TEGEOMEXPORT void ClosestPoints(te::gm::Geometry *geomA, te::gm::Geometry *geomB, te::gm::Coord2D &coordA, te::gm::Coord2D &coordB)
Compute the the closest points of two geometries.
TEGEOMEXPORT bool IsNullOrEmpty(const te::gm::GeometryPtr &geometry)
Checks if the geometry is null or empty.
TEGEOMEXPORT te::gm::Geometry * NormalizeGeometryByType(const te::gm::Geometry *geometry, te::gm::GeomType singleGeometryType)
Normalizes and filters the given geometry based on the given simple type. If the given geometry if a...
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
Definition: Curve.h:58
TEGEOMEXPORT bool Rotate(te::gm::Coord2D pr, te::gm::LineString *l, double angle, te::gm::LineString *lOut)
TEGEOMEXPORT te::gm::Envelope CreateEnvelope(double x1, double y1, double x2, double y2)
Creates an envelope that fits the given coordinates. It makes all the adjustments needed to return a ...
TEGEOMEXPORT double GetArea(const te::gm::Geometry *geometry)
Calculates the area of the given geometry. If the geometry is from dimension 0 or 1...
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
TEGEOMEXPORT bool RelationMatches(const std::string &relation, const std::string &relationPattern)
Tests if the given relation matrix matches with the given relation pattern. This pattern is based on ...
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:127
TEGEOMEXPORT LineString * AddIntersectionPoints(const te::sam::rtree::Index< std::size_t, 8 > &rtree, const std::vector< te::gm::LineString > &candidateSegments, const std::set< std::size_t > &setIndexesIgnored, const te::gm::LineString &lr_Reference, const bool &usePerpendicularDistance=false, double tolerance=0.000000001)
Add intersection points in a LinearRing based on a Vector of LineString as reference.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
TEGEOMEXPORT te::gm::Geometry * ClipGeometry(const te::gm::Geometry *geometry, const te::gm::Envelope &clipArea)
Clips the given geometry to the given clipArea.
TEGEOMEXPORT std::vector< te::gm::Point > GetIntersectionPointsByPerpendicularDistance(const te::gm::LineString &lsReference, const std::vector< te::gm::LineString > &candidates, double tolerance=0.000000001)
Gets a vector of LineString reference points including intersection points using perpendicular distan...
TEGEOMEXPORT te::gm::Polygon CreatePolygon(const te::gm::Envelope &box, const int &srid, const int &numberOfIntermediateCoords)
Creates a Polygon from the given envelope and with the given number of intermediate coordinates in ea...
TEGEOMEXPORT te::gm::GeomType GetSimpleType(te::gm::GeomType geomType)
Get the simple type of GeomType.
int GetCoordDimension(GeomType t)
It returns the number of measurements or axes needed to describe a position in a coordinate system...
Definition: Utils.h:72
TEGEOMEXPORT bool IsMultiType(te::gm::GeomType geomType)
Verifies if the geomType is a collection type.
TEGEOMEXPORT te::gm::GeomType GetMultiType(te::gm::GeomType geomType)
Get the collection type of GeomType.
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76
Curve
Definition: Enums.h:71
TEGEOMEXPORT te::gm::Geometry * MultiLineToDefinedType(const std::vector< te::gm::MultiLineString *> &multiLineStringVector, te::gm::GeomType geometryType)
A geometry is built based on a Vector of MultiLineString and the origin geometry type.
TEGEOMEXPORT Envelope AdjustToCut(const Envelope &env, double bWidth, double bHeight)
Finds the correspondent smallest box that allows a box to be cut in blocks of a given size...
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
Enumerations related to Geometry module.
LineString is a curve with linear interpolation between points.
Definition: LineString.h:64
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
TEGEOMEXPORT void Polygonizer(te::gm::Geometry *g, std::vector< te::gm::Polygon *> &pols)
It will get a list of polygons formed by the polygonization.
TEGEOMEXPORT te::gm::GeometryPtr CreateCollectionFromGeometryVector(const te::gm::GeometryVector &geometryVector)
Creates a geometry collection based on the given geometryVector.
TerraLib.
TEGEOMEXPORT te::gm::Geometry * UnaryUnion(te::gm::Geometry *geom)
It will get the union of the input geometries.
TEGEOMEXPORT bool SatisfySpatialRelation(const Geometry *g1, const Geometry *g2, SpatialRelation relation)
It returns if two geometries satisfy a given spatial relation.
TEGEOMEXPORT std::vector< te::gm::Point > GetIntersectionPointsByOperators(const te::gm::LineString &lsReference, const std::vector< te::gm::LineString > &candidates, double tolerance=0.000000001)
Gets a vector of LineString reference points including intersection points using GEOS operators...
TEGEOMEXPORT bool isCCW(const te::gm::LinearRing *ring)
Checks if a LinearRing is in Counter-clockwise orientation.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:77
TEGEOMEXPORT te::gm::Geometry * PrepareGeometriesToIntersection(const te::gm::Geometry *geom_A, te::gm::Geometry *geomB, bool &wasChanged, double tolerance=0.000000001)
Prepares the geometry A with intersection points in geometry B.
MultiLineString is a MultiCurve whose elements are LineStrings.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
TEGEOMEXPORT void Multi2Single(const te::gm::Geometry *g, std::vector< te::gm::Geometry *> &geoms)
It will get a GeometryCollection and distribute in a vector.
TEGEOMEXPORT double GetAngle(te::gm::Coord2D coordA, te::gm::Coord2D coordB)
TEGEOMEXPORT te::gm::Coord2D GetInteriorPoint(const te::gm::Geometry *geometry)
As geos Explanation: An interior point is guaranteed to lie in the interior of the Geometry...
TEGEOMEXPORT const std::string Get2DGeometryType(const te::gm::GeomType &type)
It returns the name of 2D geometry subclass.
TEGEOMEXPORT LineString * SnapLineToPoints(const te::sam::rtree::Index< std::size_t, 8 > &rtree, const std::vector< te::gm::LineString > &referenceSegments, const std::set< std::size_t > &setIndexesIgnored, const te::gm::LineString &linearRingToSnap, bool &wasChanged, double tolerance=0.000000001)
Snaps a LinearRing based on a set of LineString.
TEGEOMEXPORT std::unique_ptr< te::gm::Geometry > GetGeometryUnion(const std::vector< te::gm::Geometry *> &geomVec, double tolerance=0.000000001)
It returns the union of a geometry vector.
TEGEOMEXPORT bool AdjustSegment(te::gm::Point *P0, te::gm::Point *P1, double d0, te::gm::Coord2D &P0out, te::gm::Coord2D &P1out)
TEGEOMEXPORT te::gm::LineString CreateLine(const te::gm::Coord2D &startCoord, const te::gm::Coord2D &endCoord, const int &srid, const int &numberOfIntermediateCoords)
Creates a LineString between the given startCoord and endCoord with the given number of intermediate ...
TEGEOMEXPORT bool IsPointOnPolygon(const te::gm::Coord2D &coord, const te::gm::Geometry *geometry)
Checks if the given point in within the given polygon or multipolygon geometry.
TEGEOMEXPORT Coord2D * locateAlong(const LineString *line, double initial, double final, double target)
Make the line interpolation to find a target.
Configuration flags for the Vector Geometry Model of TerraLib.
TEGEOMEXPORT std::vector< MultiLineString * > GetAsMultiLineStringVector(const te::gm::Geometry &geometry)
Get the vector of MultLineStrings that compose the Geometry.
TEGEOMEXPORT void AddLineString(te::gm::LineString *lineString, te::gm::GeometryVector &pAdd)
Add the linestring given to the vector.
TEGEOMEXPORT te::gm::LineString * ParallelLine(const te::gm::LineString *line, double distance)
Creates a parallel line from the given line. Here will use the distance for offset between the origin...
TEGEOMEXPORT double GetAppropriatePrecision(int srid)
Returns the appropriate precision to be used by spatial operations that adjust geometric data from ot...
TEGEOMEXPORT GeomType Get2DGeomTypeId(const te::gm::GeomType &type)
It returns the 2D geometry subclass type identifier.
TEGEOMEXPORT te::gm::Line * GetIntersectionLine(te::gm::Geometry *geom, te::gm::Coord2D coord)