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  */
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 te::gm::GeometryVectorConst& 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  */
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  \note The caller of this method must take the ownership of the returned geometries and delete then when appropriate.
246  */
247  TEGEOMEXPORT void Multi2Single(const te::gm::Geometry* g, std::vector<te::gm::Geometry*>& geoms);
248 
249  /*!
250  \brief Provides an efficient method of unioning a collection of Polygonal geometries.
251  This algorithm is faster and likely more robust than the simple iterated approach of repeatedly unioning each polygon to a result geometry.
252 
253  \param polygonVector A vector of polygons.
254 
255  \return a Geometry containing the union.
256  */
257  TEGEOMEXPORT te::gm::Geometry* CascadedPolygonUnion(const std::vector<te::gm::Polygon*>& polygonVector);
258 
259  /*!
260  \brief Provides an efficient method of unioning a collection of geometries.
261  This algorithm is faster and likely more robust than the simple iterated approach of repeatedly unioning each polygon to a result geometry.
262 
263  \param vecGeometries A vector of geometries.
264 
265  \return a Geometry containing the union.
266  */
267  TEGEOMEXPORT te::gm::Geometry* CascadedUnion(const std::vector<te::gm::Geometry*>& vecGeometries);
268 
269  /*!
270  \brief It will get the union of the input geometries.
271 
272  \param geom Input Geometry.
273 
274  \return a Geometry containing the union.
275 
276  \note If no input geometries were provided, an EMPTY POINTER is returned.
277  */
279 
280  /*!
281  \brief Compute the the closest points of two geometries.
282 
283  \param geomA Input Geometry A.
284  \param geomB Input Geometry B.
285  \param coordA Output coord on Geometry A.
286  \param coordB Output coord on Geometry B.
287 
288  */
290  te::gm::Coord2D& coordA, te::gm::Coord2D& coordB);
291 
293 
295 
297 
299 
300  /*!
301  \brief It will get a list of polygons formed by the polygonization.
302 
303  \param g Input Polygon.
304  \param pols Output Polygon Vector.
305  */
306  TEGEOMEXPORT void Polygonizer(te::gm::Geometry* g, std::vector<te::gm::Polygon*>& pols);
307 
308  /*!
309  \brief It will get a list of polygons formed by the polygonization.
310 
311  \param g Input Polygon.
312  \param pols Output Polygon Vector.
313  */
315 
316  /*!
317  \brief Add all line strings from the polygon given to the vector given.
318 
319  \param polygon polygon from which to extract line strings
320  \param pAdd A reference to a vector of geometries.
321  */
323 
324  /*!
325  \brief Add the linestring given to the vector.
326 
327  \param linestring line string
328  \param pAdd A reference to a vector of geometries.
329  */
331 
332  /*!
333  \brief Prepares the geometry A with intersection points in geometry B.
334 
335  \param geom_A Geometry used to be inserted new points of intersection.
336  \param geomB The geometry to be used to intersect with Geometry B.
337  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
338  \param tolerance Tolerance value to be used in geometric operations
339 
340  \return A new geometry based on geometry A with intersection points in geometry B.
341  */
343  bool& wasChanged, double tolerance = 0.000000001);
344 
346  bool checkValidityAndFix, bool& wasChanged, double tolerance = 0.000000001);
347 
348  /*!
349  \brief Prepares the geometry A with intersection points in geometry B.
350 
351  \param geom_A Geometry used to be inserted new points of intersection.
352  \param vecGeomB The list of Geometries used to intersects with Geometry A.
353  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
354  \param tolerance Tolerance value to be used in geometric operations
355 
356  \return A new geometry based on geometry A with intersection points in geometry B.
357  */
359  bool& wasChanged, double tolerance = 0.000000001);
360 
362  bool checkValidityAndFix, bool& wasChanged, double tolerance = 0.000000001);
363 
364  /*!
365  \brief Prepares the geometries vector to be used in overlay operations.
366  \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;
367  2 - It breaks crossing segments in the intersection coordinates, sometimes gerating new coordinates in both segments
368 
369  \param vecGeometries The vector to be prepared.
370  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
371  \param tolerance Tolerance value to be used in geometric operations
372 
373  \return A new geometry vector prepared to overlay operations.
374  */
376  bool& wasChanged, double tolerance = 0.000000001);
377 
378  /*!
379  \brief Prepares the MultiLineString A with intersection points in MultiLineString B.
380 
381  \param mline_A MultiLineString used to be inserted new points of intersection.
382  \param rtree Rtree indexing all the segments that must be used in the prepare algorithm.
383  \param vecRtreeSegments All the segments indexed in the rtree
384  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
385  \param tolerance Tolerance value to be used in geometric operations
386 
387  \return A new MultiLineString based on MultiLineString A with intersection points in MultiLineString B.
388  */
390  std::vector<te::gm::LineString>& vecRtreeSegments, bool& wasChanged, double tolerance = 0.000000001);
391 
392  /*!
393  \brief Prepares the LineString A with intersection points in LineString B.
394 
395  \param ls_A LineString used to be inserted new points of intersection.
396  \param rtree Rtree indexing all the segments that must be used in the prepare algorithm.
397  \param vecRtreeSegments All the segments indexed in the rtree
398  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
399  \param tolerance Tolerance value to be used in geometric operations
400 
401  \return A new LineString based on LineString A with intersection points in LineString B.
402  */
404  std::vector<te::gm::LineString>& vecRtreeSegments, bool& wasChanged, double tolerance = 0.000000001);
405 
406  /*!
407  \brief Snaps a LinearRing based on a set of LineString.
408 
409  \param rtree The R-tree contains the candidates envelopes as reference to snap.
410  \param referenceSegments A vector of LineString that is used as reference to snap.
411  \param setIndexesIgnored A set of indexes of candidates that had must be ignored in the processing. This set is used for optimization purposes
412  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
413  \param linearRingToSnap A LinearRing that will be snapped.
414  \param tolerance Tolerance value to be used in geometric operations
415 
416  \return A new snapped LinearRing.
417  */
419  const std::vector<te::gm::LineString>& referenceSegments,
420  const std::set<std::size_t>& setIndexesIgnored,
421  const te::gm::LineString& linearRingToSnap, bool& wasChanged,
422  double tolerance = 0.000000001);
423 
424  /*!
425  \brief Add intersection points in a LinearRing based on a Vector of LineString as reference.
426 
427  \param rtree The R-tree contains the candidates envelopes as reference to snap.
428  \param candidateSegments A vector of LineString that is used as reference to snap.
429  \param setIndexesIgnored A set of indexes of candidates that had must be ignored in the processing. This set is used for optimization purposes
430  \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
431  \param lr_Reference A LinearRing that will be added new points of intersection.
432  \param usePerpendicularDistance True if the new points are added by perpendicular distance algorithm.
433  \param tolerance Tolerance value to be used in geometric operations
434 
435  \return
436  */
438  const std::vector<te::gm::LineString>& candidateSegments,
439  const std::set<std::size_t>& setIndexesIgnored,
440  const te::gm::LineString& lr_Reference,
441  const bool& usePerpendicularDistance = false,
442  double tolerance = 0.000000001);
443 
444  /*!
445  \brief Gets a vector of LineString reference points including intersection points using GEOS operators.
446 
447  \param lsReference LineString used as reference.
448  \param candidates A Vector of LineString used to intersects the lsReference.
449  \param tolerance Tolerance value to be used in geometric operations
450 
451  \return A vector of LineString reference points including intersection points using GEOS operators.
452  */
453  TEGEOMEXPORT std::vector<te::gm::Coord2D> GetIntersectionPointsByOperators(const te::gm::LineString& lsReference, const std::vector<te::gm::LineString>& candidates, double tolerance = 0.000000001);
454 
455  /*!
456  \brief Gets a vector of LineString reference points including intersection points using perpendicular distance.
457 
458  \param lsReference LineString used as reference.
459  \param candidates A Vector of LineString used to intersects the lsReference.
460  \param tolerance Tolerance value to be used in geometric operations
461 
462  \return A vector of LineString reference points including intersection points using perpendicular distance.
463  */
464  TEGEOMEXPORT std::vector<te::gm::Coord2D> GetIntersectionPointsByPerpendicularDistance(const te::gm::LineString& lsReference, const std::vector<te::gm::LineString>& candidates, double tolerance = 0.000000001);
465 
466  /*!
467  \brief Get the vector of MultLineStrings that compose the Geometry
468 
469  \param geometry Used to get lineStrings.
470 
471  return A vector of MultiLineString based on geometry parameter.
472  */
473  TEGEOMEXPORT std::vector<MultiLineString *> GetAsMultiLineStringVector(const te::gm::Geometry& geometry);
474 
475 
476  /*!
477  \brief A geometry is built based on a Vector of MultiLineString and the origin geometry type.
478 
479  \param multiLineStringVector A vector of multiLineString that have all lines of a Geometry.
480 
481  return A geometry built based on a Vector of MultiLineString and the origin geometry type.
482  */
483  TEGEOMEXPORT te::gm::Geometry* MultiLineToDefinedType(const std::vector<te::gm::MultiLineString*>& multiLineStringVector,
484  te::gm::GeomType geometryType);
485 
486  /*!
487  \brief Get the LineStrings that compose the Geometry
488 
489  \param geometry Used to get lineStrings.
490 
491  return A LineString based on parameter geometry.
492  */
494 
495  /*!
496  \brief Verifies if the geomType is a collection type.
497 
498  \param geomType enum te::gm::GeomType.
499 
500  return True if the geomType is a collection type.
501  */
503 
504  /*!
505  \brief Get the simple type of GeomType.
506 
507  \param geomType enum te::gm::GeomType.
508 
509  return A simple type of GeomType.
510  */
512 
513  /*!
514  \brief Get the collection type of GeomType.
515 
516  \param geomType enum te::gm::GeomType.
517 
518  return A collection type of GeomType.
519  */
521 
522  /*!
523  \brief Creates a LineString between the given startCoord and endCoord with the given number of intermediate coordinates.
524 
525  \param startCoord The first coordinate of the line
526  \param endCoord The last coordinate of the line
527  \param srid The srid of the line
528  \param numberOfIntermediateCoords The number of intermediate coordinates of the line
529 
530  \return A LineString between startCoord and endCoord with the given number of intermediate coordinates
531  */
532  TEGEOMEXPORT te::gm::LineString CreateLine(const te::gm::Coord2D& startCoord, const te::gm::Coord2D& endCoord, const int& srid, const int& numberOfIntermediateCoords);
533 
534  /*!
535  \brief Creates a Polygon from the given envelope and with the given number of intermediate coordinates in each of its four borders lines.
536 
537  \param box The envelope from which the polygon will be created
538  \param srid The srid of the polygon
539  \param numberOfIntermediateCoords The number of intermediate coordinates of each border line
540 
541  \return A LineString between startCoord and endCoord with the given number of intermediate coordinates in each border line
542  */
543  TEGEOMEXPORT te::gm::Polygon CreatePolygon(const te::gm::Envelope& box, const int& srid, const int& numberOfIntermediateCoords);
544 
545  /*!
546  \brief Creates a parallel line from the given line. Here will use the distance for offset between the original line and the parallel.
547 
548  \param line Original line
549  \param distance for offset between the original line and the parallel. Left will be positive and right will be negative
550 
551  \return A LineString between startCoord and endCoord with the given number of intermediate coordinates in each border line
552  */
554 
555  /*!
556  \brief Checks if the given point in within the given polygon or multipolygon geometry
557 
558  \param coord The coord to be checked
559  \param geometry The Polygon or Multipolygon to be used as reference
560 
561  \return TRUE if the point is within the polygon. FALSE otherwise
562  */
563  TEGEOMEXPORT bool IsPointOnPolygon(const te::gm::Coord2D& coord, const te::gm::Geometry* geometry);
564 
565  /*!
566  \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.
567  Otherwise, the point may lie on the boundary of the geometry.
568 
569  \param geometry The input geometry
570 
571  \return An interior point inside the given Geometry, if possible.
572  */
574 
575 
576  /*!
577  \brief Normalizes and filters the given geometry based on the given simple type.
578  \description If the given geometry if already from the given simple type, it will clone the geometry and return it.
579  If the geometry is from the multi type related to the single, it will clone the geometry and return it.
580  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.
581 
582  \param geometry The geometry to be analysed
583  \param singleGeometryType The base single type to be used as filter
584 
585  \return The normalized geometry based onthe given singleGeometryType. Null if this given type could not be found in the given geometry.
586  */
588 
589  /*!
590  \brief Returns the appropriate precision to be used by spatial operations that adjust geometric data from other geometric systems
591 
592  \param srid The id of the SRS (Spatial Reference System)
593 
594  \return The precision appropriate to the given srid
595  */
597 
598  /*!
599  \brief Clips the given geometry to the given clipArea
600 
601  \param geometry The geometry to be clipped
602  \param clipArea The clipping area
603 
604  \return The clipped geometry
605  */
607 
608  /*!
609  \brief Checks if the geometry is null or empty
610 
611  \param geometry The geometry to be checked
612 
613  \return The result of the check. TRUE if the geometry is null or empty. FALSE otherwise
614  */
616 
617  /*!
618  \brief Checks if the geometry is null or empty
619 
620  \param geometry The geometry to be checked
621 
622  \return The result of the check. TRUE if the geometry is null or empty. FALSE otherwise
623  */
625 
626  /*!
627  \brief Creates a polygon from the given curve
628 
629  \param curve The curve to be used to create a polygon
630 
631  \return The created polygon
632  */
634 
635 
636  /*!
637  \brief Checks if a LinearRing is in Counter-clockwise orientation
638 
639  \param curve The LinearRing to be checked
640 
641  \return TRUE if the given LinearRing is in Counter-clockwise orientation. FALSE otherwise
642  */
644 
645  /*!
646  \brief Calculates the area of the given geometry. If the geometry is from dimension 0 or 1, it returns 0
647 
648  \param geometry The geometry to be analysed
649 
650  \return The area of the geometry or 0 if the dimension of the geometry is 0 or 1
651  */
652  TEGEOMEXPORT double GetArea(const te::gm::Geometry* geometry);
653 
654  /*!
655  \brief Creates a geometry collection based on the given geometryVector
656 
657  \param geometryVector The input geometry vector
658 
659  \return A geometry collection containing all the grometries from the geometry vector
660  */
662 
663  //!< Adapts a non const geometry vector to a const geometry vector. No geometry copy is made
665 
666  /*!
667  \brief Splits the given 'inputGeometry' (must be an area) using the given 'bladeLineGeometry' (must be a line)
668 
669  \param inputGeometry The input geometry to be splitted
670  \param inputGeometry The line to be used to split the input geoemtry
671 
672  \return The splitted geometry. Throws an exception if an error occur
673  */
674  TEGEOMEXPORT std::vector<te::gm::Geometry*> SplitGeometry(const te::gm::Geometry* inputGeometry, const te::gm::Geometry* bladeLineGeometry);
675 
676  } // end namespace gm
677 } // end namespace te
678 
679 #endif // __TERRALIB_GEOMETRY_INTERNAL_GEOMUTILS_H
680 
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
Definition: Curve.h:59
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
LineString is a curve with linear interpolation between points.
Definition: LineString.h:65
A Line is LineString with 2 points.
Definition: Line.h:51
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:54
MultiLineString is a MultiCurve whose elements are LineStrings.
A point with x and y coordinate values.
Definition: Point.h:51
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:51
TEGEOMEXPORT std::vector< te::gm::Coord2D > 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::Geometry * ClipGeometry(const te::gm::Geometry *geometry, const te::gm::Envelope &clipArea)
Clips the given geometry to the given clipArea.
TEGEOMEXPORT te::gm::Geometry * UnaryUnion(te::gm::Geometry *geom)
It will get the union of the input geometries.
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 bool IsMultiType(te::gm::GeomType geomType)
Verifies if the geomType is a collection type.
TEGEOMEXPORT std::unique_ptr< te::gm::Geometry > GetGeometryUnion(const te::gm::GeometryVectorConst &geomVec, double tolerance=0.000000001)
It returns the union of a geometry vector.
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 te::gm::GeometryVectorConst ToConstVector(const te::gm::GeometryVector &vecGeometries)
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:42
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 te::gm::GeomType GetMultiType(te::gm::GeomType geomType)
Get the collection type of GeomType.
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 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 ...
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
TEGEOMEXPORT te::gm::GeomType GetMultiLineStringType(const te::gm::Geometry &geometry)
Get the LineStrings that compose the Geometry.
SpatialRelation
Spatial relations between geometric objects.
Definition: Enums.h:128
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 double GetArea(const te::gm::Geometry *geometry)
Calculates the area of the given geometry. If the geometry is from dimension 0 or 1,...
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 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.
TEGEOMEXPORT bool Rotate(te::gm::Coord2D pr, te::gm::LineString *l, double angle, te::gm::LineString *lOut)
TEGEOMEXPORT te::gm::Line * GetIntersectionLine(te::gm::Geometry *geom, te::gm::Coord2D coord)
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.
TEGEOMEXPORT bool SatisfySpatialRelation(const Geometry *g1, const Geometry *g2, SpatialRelation relation)
It returns if two geometries satisfy a given spatial relation.
TEGEOMEXPORT te::gm::GeometryPtr CreateCollectionFromGeometryVector(const te::gm::GeometryVector &geometryVector)
Creates a geometry collection based on the given geometryVector.
TEGEOMEXPORT bool IsNullOrEmpty(const te::gm::GeometryPtr &geometry)
Checks if the geometry is null or empty.
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 std::vector< MultiLineString * > GetAsMultiLineStringVector(const te::gm::Geometry &geometry)
Get the vector of MultLineStrings that compose the Geometry.
TEGEOMEXPORT double GetAngle(te::gm::Coord2D coordA, te::gm::Coord2D coordB)
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 te::gm::GeomType GetSimpleType(te::gm::GeomType geomType)
Get the simple type of GeomType.
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 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.
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. \description If the given g...
TEGEOMEXPORT void AddPolygon(te::gm::Polygon *polygon, te::gm::GeometryVector &pAdd)
Add all line strings from the polygon given to the vector given.
TEGEOMEXPORT void AddLineString(te::gm::LineString *lineString, te::gm::GeometryVector &pAdd)
Add the linestring given to the vector.
TEGEOMEXPORT bool isCCW(const te::gm::LinearRing *ring)
Checks if a LinearRing is in Counter-clockwise orientation.
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...
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 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 std::vector< te::gm::Geometry * > SplitGeometry(const te::gm::Geometry *inputGeometry, const te::gm::Geometry *bladeLineGeometry)
Splits the given 'inputGeometry' (must be an area) using the given 'bladeLineGeometry' (must be a lin...
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...
TEGEOMEXPORT Coord2D * locateAlong(const LineString *line, double initial, double final, double target)
Make the line interpolation to find a target.
TEGEOMEXPORT GeomType Get2DGeomTypeId(const te::gm::GeomType &type)
It returns the 2D geometry subclass type identifier.
std::vector< te::gm::Geometry * > GeometryVector
std::vector< const te::gm::Geometry * > GeometryVectorConst
TEGEOMEXPORT std::vector< te::gm::Coord2D > 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 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...
Curve
Definition: Enums.h:72
TerraLib.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:41
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76
Proxy configuration file for TerraView (see terraview_config.h).
Utility classes, structures and definitions for Vector Processing.
Enumerations of XML module.