Loading...
Searching...
No Matches
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"
33#include "Enums.h"
34
35// STL
36#include <memory>
37#include <set>
38#include <vector>
39
40namespace 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 */
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 It will get geometry and return the related GeometryCollection type.
251
252 \param g Input Geometry.
253
254 \return The related GeometryCollection type or a nullptr if an error has occurred.
255
256 \note The caller of this method must take the ownership of the returned geometries and delete then when appropriate.
257 \note If the input geomtry is a geometry collection it will be clonned and returned.
258
259 */
261
262 /*!
263 \brief Provides an efficient method of unioning a collection of Polygonal geometries.
264 This algorithm is faster and likely more robust than the simple iterated approach of repeatedly unioning each polygon to a result geometry.
265
266 \param polygonVector A vector of polygons.
267
268 \return a Geometry containing the union.
269 */
270 TEGEOMEXPORT te::gm::Geometry* CascadedPolygonUnion(const std::vector<te::gm::Polygon*>& polygonVector);
271
272 /*!
273 \brief Provides an efficient method of unioning a collection of geometries.
274 This algorithm is faster and likely more robust than the simple iterated approach of repeatedly unioning each polygon to a result geometry.
275
276 \param vecGeometries A vector of geometries.
277
278 \return a Geometry containing the union.
279 */
280 TEGEOMEXPORT te::gm::Geometry* CascadedUnion(const std::vector<te::gm::Geometry*>& vecGeometries);
281
282 /*!
283 \brief It will get the union of the input geometries.
284
285 \param geom Input Geometry.
286
287 \return a Geometry containing the union.
288
289 \note If no input geometries were provided, an EMPTY POINTER is returned.
290 */
292
293 /*!
294 \brief Compute the the closest points of two geometries.
295
296 \param geomA Input Geometry A.
297 \param geomB Input Geometry B.
298 \param coordA Output coord on Geometry A.
299 \param coordB Output coord on Geometry B.
300
301 */
303 te::gm::Coord2D& coordA, te::gm::Coord2D& coordB);
304
306
308
310
312
313 /*!
314 \brief It will get a list of polygons formed by the polygonization.
315
316 \param g Input Polygon.
317 \param pols Output Polygon Vector.
318 */
319 TEGEOMEXPORT void Polygonizer(te::gm::Geometry* g, std::vector<te::gm::Polygon*>& pols);
320
321 /*!
322 \brief It will get a list of polygons formed by the polygonization.
323
324 \param g Input Polygon.
325 \param pols Output Polygon Vector.
326 */
328
329 /*!
330 \brief Add all line strings from the polygon given to the vector given.
331
332 \param polygon polygon from which to extract line strings
333 \param pAdd A reference to a vector of geometries.
334 */
336
337 /*!
338 \brief Add the linestring given to the vector.
339
340 \param linestring line string
341 \param pAdd A reference to a vector of geometries.
342 */
344
345 /*!
346 \brief Prepares the geometry A with intersection points in geometry B.
347
348 \param geom_A Geometry used to be inserted new points of intersection.
349 \param geomB The geometry to be used to intersect with Geometry B.
350 \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
351 \param tolerance Tolerance value to be used in geometric operations
352
353 \return A new geometry based on geometry A with intersection points in geometry B.
354 */
356 bool& wasChanged, double tolerance = 0.000000001);
357
359 bool checkValidityAndFix, bool& wasChanged, double tolerance = 0.000000001);
360
361 /*!
362 \brief Prepares the geometry A with intersection points in geometry B.
363
364 \param geom_A Geometry used to be inserted new points of intersection.
365 \param vecGeomB The list of Geometries used to intersects with Geometry A.
366 \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
367 \param tolerance Tolerance value to be used in geometric operations
368
369 \return A new geometry based on geometry A with intersection points in geometry B.
370 */
372 bool& wasChanged, double tolerance = 0.000000001);
373
375 bool checkValidityAndFix, bool& wasChanged, double tolerance = 0.000000001);
376
377 /*!
378 \brief Prepares the geometries vector to be used in overlay operations.
379 \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;
380 2 - It breaks crossing segments in the intersection coordinates, sometimes gerating new coordinates in both segments
381
382 \param vecGeometries The vector to be prepared.
383 \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
384 \param tolerance Tolerance value to be used in geometric operations
385
386 \return A new geometry vector prepared to overlay operations.
387 */
389 bool& wasChanged, double tolerance = 0.000000001);
390
391 /*!
392 \brief Prepares the MultiLineString A with intersection points in MultiLineString B.
393
394 \param mline_A MultiLineString used to be inserted new points of intersection.
395 \param rtree Rtree indexing all the segments that must be used in the prepare algorithm.
396 \param vecRtreeSegments All the segments indexed in the rtree
397 \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
398 \param tolerance Tolerance value to be used in geometric operations
399
400 \return A new MultiLineString based on MultiLineString A with intersection points in MultiLineString B.
401 */
403 std::vector<te::gm::LineString>& vecRtreeSegments, bool& wasChanged, double tolerance = 0.000000001);
404
405 /*!
406 \brief Prepares the LineString A with intersection points in LineString B.
407
408 \param ls_A LineString used to be inserted new points of intersection.
409 \param rtree Rtree indexing all the segments that must be used in the prepare algorithm.
410 \param vecRtreeSegments All the segments indexed in the rtree
411 \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
412 \param tolerance Tolerance value to be used in geometric operations
413
414 \return A new LineString based on LineString A with intersection points in LineString B.
415 */
417 std::vector<te::gm::LineString>& vecRtreeSegments, bool& wasChanged, double tolerance = 0.000000001);
418
419 /*!
420 \brief Snaps a LinearRing based on a set of LineString.
421
422 \param rtree The R-tree contains the candidates envelopes as reference to snap.
423 \param referenceSegments A vector of LineString that is used as reference to snap.
424 \param setIndexesIgnored A set of indexes of candidates that had must be ignored in the processing. This set is used for optimization purposes
425 \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
426 \param linearRingToSnap A LinearRing that will be snapped.
427 \param tolerance Tolerance value to be used in geometric operations
428
429 \return A new snapped LinearRing.
430 */
432 const std::vector<te::gm::LineString>& referenceSegments,
433 const std::set<std::size_t>& setIndexesIgnored,
434 const te::gm::LineString& linearRingToSnap, bool& wasChanged,
435 double tolerance = 0.000000001);
436
437 /*!
438 \brief Add intersection points in a LinearRing based on a Vector of LineString as reference.
439
440 \param rtree The R-tree contains the candidates envelopes as reference to snap.
441 \param candidateSegments A vector of LineString that is used as reference to snap.
442 \param setIndexesIgnored A set of indexes of candidates that had must be ignored in the processing. This set is used for optimization purposes
443 \param wasChanged This is an output value to inform if the geometry has been changed or not during the prepare
444 \param lr_Reference A LinearRing that will be added new points of intersection.
445 \param usePerpendicularDistance True if the new points are added by perpendicular distance algorithm.
446 \param tolerance Tolerance value to be used in geometric operations
447
448 \return
449 */
451 const std::vector<te::gm::LineString>& candidateSegments,
452 const std::set<std::size_t>& setIndexesIgnored,
453 const te::gm::LineString& lr_Reference,
454 const bool& usePerpendicularDistance = false,
455 double tolerance = 0.000000001);
456
457 /*!
458 \brief Gets a vector of LineString reference points including intersection points using GEOS operators.
459
460 \param lsReference LineString used as reference.
461 \param candidates A Vector of LineString used to intersects the lsReference.
462 \param tolerance Tolerance value to be used in geometric operations
463
464 \return A vector of LineString reference points including intersection points using GEOS operators.
465 */
466 TEGEOMEXPORT std::vector<te::gm::Coord2D> GetIntersectionPointsByOperators(const te::gm::LineString& lsReference, const std::vector<te::gm::LineString>& candidates, double tolerance = 0.000000001);
467
468 /*!
469 \brief Gets a vector of LineString reference points including intersection points using perpendicular distance.
470
471 \param lsReference LineString used as reference.
472 \param candidates A Vector of LineString used to intersects the lsReference.
473 \param tolerance Tolerance value to be used in geometric operations
474
475 \return A vector of LineString reference points including intersection points using perpendicular distance.
476 */
477 TEGEOMEXPORT std::vector<te::gm::Coord2D> GetIntersectionPointsByPerpendicularDistance(const te::gm::LineString& lsReference, const std::vector<te::gm::LineString>& candidates, double tolerance = 0.000000001);
478
479 /*!
480 \brief Get the vector of MultLineStrings that compose the Geometry
481
482 \param geometry Used to get lineStrings.
483
484 return A vector of MultiLineString based on geometry parameter.
485 */
486 TEGEOMEXPORT std::vector<MultiLineString *> GetAsMultiLineStringVector(const te::gm::Geometry& geometry);
487
488
489 /*!
490 \brief A geometry is built based on a Vector of MultiLineString and the origin geometry type.
491
492 \param multiLineStringVector A vector of multiLineString that have all lines of a Geometry.
493
494 return A geometry built based on a Vector of MultiLineString and the origin geometry type.
495 */
496 TEGEOMEXPORT te::gm::Geometry* MultiLineToDefinedType(const std::vector<te::gm::MultiLineString*>& multiLineStringVector,
497 te::gm::GeomType geometryType);
498
499 /*!
500 \brief Get the LineStrings that compose the Geometry
501
502 \param geometry Used to get lineStrings.
503
504 return A LineString based on parameter geometry.
505 */
507
508 /*!
509 \brief Verifies if the geomType is a collection type.
510
511 \param geomType enum te::gm::GeomType.
512
513 return True if the geomType is a collection type.
514 */
516
517 /*!
518 \brief Get the simple type of GeomType.
519
520 \param geomType enum te::gm::GeomType.
521
522 return A simple type of GeomType.
523 */
525
526 /*!
527 \brief Get the collection type of GeomType.
528
529 \param geomType enum te::gm::GeomType.
530
531 return A collection type of GeomType.
532 */
534
535 /*!
536 \brief Creates a LineString between the given startCoord and endCoord with the given number of intermediate coordinates.
537
538 \param startCoord The first coordinate of the line
539 \param endCoord The last coordinate of the line
540 \param srid The srid of the line
541 \param numberOfIntermediateCoords The number of intermediate coordinates of the line
542
543 \return A LineString between startCoord and endCoord with the given number of intermediate coordinates
544 */
545 TEGEOMEXPORT te::gm::LineString CreateLine(const te::gm::Coord2D& startCoord, const te::gm::Coord2D& endCoord, const int& srid, const int& numberOfIntermediateCoords);
546
547 /*!
548 \brief Creates a Polygon from the given envelope and with the given number of intermediate coordinates in each of its four borders lines.
549
550 \param box The envelope from which the polygon will be created
551 \param srid The srid of the polygon
552 \param numberOfIntermediateCoords The number of intermediate coordinates of each border line
553
554 \return A LineString between startCoord and endCoord with the given number of intermediate coordinates in each border line
555 */
556 TEGEOMEXPORT te::gm::Polygon CreatePolygon(const te::gm::Envelope& box, const int& srid, const int& numberOfIntermediateCoords);
557
558 /*!
559 \brief Creates a parallel line from the given line. Here will use the distance for offset between the original line and the parallel.
560
561 \param line Original line
562 \param distance for offset between the original line and the parallel. Left will be positive and right will be negative
563
564 \return A LineString between startCoord and endCoord with the given number of intermediate coordinates in each border line
565 */
567
568 /*!
569 \brief Checks if the given point in within the given polygon or multipolygon geometry
570
571 \param coord The coord to be checked
572 \param geometry The Polygon or Multipolygon to be used as reference
573
574 \return TRUE if the point is within the polygon. FALSE otherwise
575 */
577
578 /*!
579 \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.
580 Otherwise, the point may lie on the boundary of the geometry.
581
582 \param geometry The input geometry
583
584 \return An interior point inside the given Geometry, if possible.
585 */
587
588
589 /*!
590 \brief Normalizes and filters the given geometry based on the given simple type.
591 \description If the given geometry if already from the given simple type, it will clone the geometry and return it.
592 If the geometry is from the multi type related to the single, it will clone the geometry and return it.
593 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.
594
595 \param geometry The geometry to be analysed
596 \param singleGeometryType The base single type to be used as filter
597
598 \return The normalized geometry based onthe given singleGeometryType. Null if this given type could not be found in the given geometry.
599 */
601
602 /*!
603 \brief Returns the appropriate precision to be used by spatial operations that adjust geometric data from other geometric systems
604
605 \param srid The id of the SRS (Spatial Reference System)
606
607 \return The precision appropriate to the given srid
608 */
610
611 /*!
612 \brief Clips the given geometry to the given clipArea
613
614 \param geometry The geometry to be clipped
615 \param clipArea The clipping area
616
617 \return The clipped geometry
618 */
620
621 /*!
622 \brief Checks if the geometry is null or empty
623
624 \param geometry The geometry to be checked
625
626 \return The result of the check. TRUE if the geometry is null or empty. FALSE otherwise
627 */
629
630 /*!
631 \brief Checks if the geometry is null or empty
632
633 \param geometry The geometry to be checked
634
635 \return The result of the check. TRUE if the geometry is null or empty. FALSE otherwise
636 */
638
639 /*!
640 \brief Creates a polygon from the given curve
641
642 \param curve The curve to be used to create a polygon
643
644 \return The created polygon
645 */
647
648
649 /*!
650 \brief Checks if a LinearRing is in Counter-clockwise orientation
651
652 \param curve The LinearRing to be checked
653
654 \return TRUE if the given LinearRing is in Counter-clockwise orientation. FALSE otherwise
655 */
657
658 /*!
659 \brief Calculates the area of the given geometry. If the geometry is from dimension 0 or 1, it returns 0
660
661 \param geometry The geometry to be analysed
662
663 \return The area of the geometry or 0 if the dimension of the geometry is 0 or 1
664 */
665 TEGEOMEXPORT double GetArea(const te::gm::Geometry* geometry);
666
667 /*!
668 \brief Creates a geometry collection based on the given geometryVector
669
670 \param geometryVector The input geometry vector
671
672 \return A geometry collection containing all the grometries from the geometry vector
673 */
675
676 //!< Adapts a non const geometry vector to a const geometry vector. No geometry copy is made
678
679 /*!
680 \brief Splits the given 'inputGeometry' (must be an area) using the given 'bladeLineGeometry' (must be a line)
681
682 \param inputGeometry The input geometry to be splitted
683 \param inputGeometry The line to be used to split the input geoemtry
684
685 \return The splitted geometry. Throws an exception if an error occur
686 */
687 TEGEOMEXPORT std::vector<te::gm::Geometry*> SplitGeometry(const te::gm::Geometry* inputGeometry, const te::gm::Geometry* bladeLineGeometry);
688
689 /*!
690 \brief Returns true if the given type has M dimension.
691
692 \param geomType enum te::gm::GeomType.
693
694 \return Returns true if the given type has M dimension.
695 */
697
698 /*!
699 \brief Returns true if the given type has Z dimension.
700
701 \param geomType enum te::gm::GeomType.
702
703 \return Returns true if the given type has Z dimension.
704 */
706
707 /*!
708 \brief Converts the given geometry to the given geometry type.
709 \param inGeomPtr Input geometry pointer.
710 \param targetGeomType Target geometry type.
711 \param outputGeomsPtrsVec A vector of converted geometries or, if the conversion is not possible, an empty vector is returned.
712 \note The caller must take the ownership of the returned objects.
713 */
715 te::gm::Geometry const * const inGeomPtr,
716 const te::gm::GeomType targetGeomType,
717 te::gm::GeometryVector& outputGeomsPtrsVec );
718
719 /*!
720 \brief Converts the given geometries set to the given geometry type.
721 \param vecGeometries Input geometries vector.
722 \param targetGeomType Target geometry type.
723 \param outputGeomsPtrsVec A vector of converted geometries or, if the conversion is not possible, an empty vector is returned.
724 \note The caller must take the ownership of the returned objects.
725 */
726 template< typename GeometryTypeT >
728 const std::vector< GeometryTypeT* >& vecGeometries,
729 te::gm::GeomType geomType,
730 te::gm::GeometryVector& outputGeomsPtrsVec )
731 {
732 outputGeomsPtrsVec.clear();
733 const std::size_t vecGeometriesSize = vecGeometries.size();
734
735 for (std::size_t vecGeometriesIdx = 0; vecGeometriesIdx <
736 vecGeometriesSize; ++vecGeometriesIdx )
737 {
738 te::gm::GeometryVector currentResult;
740 vecGeometries.at( vecGeometriesIdx ), geomType,
741 currentResult );
742
743 outputGeomsPtrsVec.insert(outputGeomsPtrsVec.end(),
744 currentResult.begin(), currentResult.end());
745 }
746 }
747
748 } // end namespace gm
749} // end namespace te
750
751#endif // __TERRALIB_GEOMETRY_INTERNAL_GEOMUTILS_H
752
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
A class that represents an R-tree.
Definition Index.h:57
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 * UnaryUnion(te::gm::Geometry *geom)
It will get the union of the input geometries.
TEGEOMEXPORT te::gm::Geometry * ClipGeometry(const te::gm::Geometry *geometry, const te::gm::Envelope &clipArea)
Clips the given geometry to the given clipArea.
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 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 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::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 te::gm::GeomType GetMultiType(te::gm::GeomType geomType)
Get the collection type of GeomType.
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 te::gm::Line * GetIntersectionLine(te::gm::Geometry *geom, te::gm::Coord2D coord)
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::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 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 void Polygonizer(te::gm::Geometry *g, std::vector< te::gm::Polygon * > &pols)
It will get a list of polygons formed by the polygonization.
TEGEOMEXPORT Geometry * GetGeomFromEnvelope(const Envelope *const e, int srid)
It creates a Geometry (a polygon) from the given envelope.
TEGEOMEXPORT te::gm::Geometry * Single2Multi(const te::gm::Geometry *g)
It will get geometry and return the related GeometryCollection type.
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 bool HasZDim(te::gm::GeomType geomType)
Returns true if the given type has Z dimension.
TEGEOMEXPORT const std::string Get2DGeometryType(const te::gm::GeomType &type)
It returns the name of 2D geometry subclass.
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::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 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 Coord2D * locateAlong(const LineString *line, double initial, double final, double target)
Make the line interpolation to find a target.
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 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 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 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 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 bool isCCW(const te::gm::LinearRing *ring)
Checks if a LinearRing is in Counter-clockwise orientation.
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 * 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 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 bool HasMDim(te::gm::GeomType geomType)
Returns true if the given type has M dimension.
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 GeomType Get2DGeomTypeId(const te::gm::GeomType &type)
It returns the 2D geometry subclass type identifier.
std::vector< te::gm::Geometry * > GeometryVector
TEGEOMEXPORT std::vector< MultiLineString * > GetAsMultiLineStringVector(const te::gm::Geometry &geometry)
Get the vector of MultLineStrings that compose the Geometry.
std::vector< const te::gm::Geometry * > GeometryVectorConst
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 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 void ConvertGeometryType(te::gm::Geometry const *const inGeomPtr, const te::gm::GeomType targetGeomType, te::gm::GeometryVector &outputGeomsPtrsVec)
Converts the given geometry to the given geometry type.
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.