37 : mGeometry( geometry.constGet() )
50 QVector<QgsLineString *> linesToProcess;
56 for (
int i = 0; i < multiCurve->
partCount(); ++i )
58 linesToProcess << static_cast<QgsLineString *>( multiCurve->
geometryN( i )->
clone() );
65 linesToProcess << static_cast<QgsLineString *>( curve->segmentize() );
68 std::unique_ptr<QgsMultiPolygon> multipolygon( linesToProcess.size() > 1 ?
new QgsMultiPolygon() : nullptr );
71 if ( !linesToProcess.empty() )
73 std::unique_ptr< QgsLineString > secondline;
74 for (
QgsLineString *line : qgis::as_const( linesToProcess ) )
76 QTransform transform = QTransform::fromTranslate( x, y );
78 secondline.reset( line->reversed() );
79 secondline->transform( transform );
81 line->append( secondline.get() );
82 line->addVertex( line->pointN( 0 ) );
85 polygon->setExteriorRing( line );
88 multipolygon->addGeometry( polygon );
110 Cell(
double x,
double y,
double h,
const QgsPolygon *polygon )
115 , max( d + h * M_SQRT2 )
130 struct GreaterThanByMax
132 bool operator()(
const Cell *lhs,
const Cell *rhs )
134 return rhs->max > lhs->max;
138 Cell *getCentroidCell(
const QgsPolygon *polygon )
146 for (
int i = 0, j = len - 1; i < len; j = i++ )
148 double aX = exterior->
xAt( i );
149 double aY = exterior->
yAt( i );
150 double bX = exterior->
xAt( j );
151 double bY = exterior->
yAt( j );
152 double f = aX * bY - bX * aY;
153 x += ( aX + bX ) * f;
154 y += ( aY + bY ) * f;
158 return new Cell( exterior->
xAt( 0 ), exterior->
yAt( 0 ), 0, polygon );
160 return new Cell( x / area, y / area, 0.0, polygon );
165 std::unique_ptr< QgsPolygon > segmentizedPoly;
169 segmentizedPoly.reset( static_cast< QgsPolygon *>( surface->
segmentize() ) );
170 polygon = segmentizedPoly.get();
177 double cellSize = std::min( bounds.
width(), bounds.
height() );
182 double h = cellSize / 2.0;
183 std::priority_queue< Cell *, std::vector<Cell *>, GreaterThanByMax > cellQueue;
190 cellQueue.push(
new Cell( x + h, y + h, h, polygon ) );
195 std::unique_ptr< Cell > bestCell( getCentroidCell( polygon ) );
198 std::unique_ptr< Cell > bboxCell(
new Cell( bounds.
xMinimum() + bounds.
width() / 2.0,
201 if ( bboxCell->d > bestCell->d )
203 bestCell = std::move( bboxCell );
206 while ( !cellQueue.empty() )
209 std::unique_ptr< Cell > cell( cellQueue.top() );
211 Cell *currentCell = cell.get();
214 if ( currentCell->d > bestCell->d )
216 bestCell = std::move( cell );
220 if ( currentCell->max - bestCell->d <=
precision )
224 h = currentCell->h / 2.0;
225 cellQueue.push(
new Cell( currentCell->x - h, currentCell->y - h, h, polygon ) );
226 cellQueue.push(
new Cell( currentCell->x + h, currentCell->y - h, h, polygon ) );
227 cellQueue.push(
new Cell( currentCell->x - h, currentCell->y + h, h, polygon ) );
228 cellQueue.push(
new Cell( currentCell->x + h, currentCell->y + h, h, polygon ) );
231 distanceFromBoundary = bestCell->d;
233 return QgsPoint( bestCell->x, bestCell->y );
240 if ( distanceFromBoundary )
241 *distanceFromBoundary = std::numeric_limits<double>::max();
243 if ( !mGeometry || mGeometry->isEmpty() )
246 if ( precision <= 0 )
249 if (
const QgsGeometryCollection *gc = qgsgeometry_cast< const QgsGeometryCollection *>( mGeometry ) )
251 int numGeom = gc->numGeometries();
255 for (
int i = 0; i < numGeom; ++i )
262 double dist = std::numeric_limits<double>::max();
263 QgsPoint p = surfacePoleOfInaccessibility( surface, precision, dist );
264 if ( dist > maxDist )
274 if ( distanceFromBoundary )
275 *distanceFromBoundary = maxDist;
284 double dist = std::numeric_limits<double>::max();
285 QgsPoint p = surfacePoleOfInaccessibility( surface, precision, dist );
286 if ( distanceFromBoundary )
287 *distanceFromBoundary = dist;
298 return lowerThreshold > std::fabs( dotProduct ) || std::fabs( dotProduct ) > upperThreshold;
324 for (
int i = 0; i < numPoints; ++i )
326 if ( !isClosed && i == numPoints - 1 )
328 else if ( !isClosed && i == 0 )
337 a = ring->
pointN( numPoints - 1 );
340 if ( i == numPoints - 1 )
343 c = ring->
pointN( i + 1 );
349 sum += 2.0 * std::min( std::fabs( dotProduct - 1.0 ), std::min( std::fabs( dotProduct ), std::fabs( dotProduct + 1 ) ) );
359 double lowerThreshold,
double upperThreshold )
368 double scale = 2.0 * std::min( p.
length(), q.
length() );
372 double dotProduct = p * q;
381 if ( dotProduct < -M_SQRT1_2 )
386 return new_v.
normalized() * ( 0.1 * dotProduct * scale );
391 double minScore = std::numeric_limits<double>::max();
396 std::unique_ptr< QgsLineString > best( ring->
clone() );
398 QVector< QgsVector > motions;
399 motions.reserve( numPoints );
401 for (
int it = 0; it < iterations; ++it )
409 for (
int i = 0; i < numPoints; ++i )
411 if ( isClosed && i == numPoints - 1 )
412 motions << motions.at( 0 );
413 else if ( !isClosed && ( i == 0 || i == numPoints - 1 ) )
423 a = ring->
pointN( numPoints - 1 );
426 if ( i == numPoints - 1 )
429 c = ring->
pointN( i + 1 );
431 motions <<
calcMotion( a, b, c, lowerThreshold, upperThreshold );
438 for (
int i = 0; i < numPoints; ++i )
440 ring->
setXAt( i, ring->
xAt( i ) + motions.at( i ).x() );
441 ring->
setYAt( i, ring->
yAt( i ) + motions.at( i ).y() );
444 double newScore =
squareness( ring, lowerThreshold, upperThreshold );
445 if ( newScore < minScore )
447 best.reset( ring->
clone() );
451 if ( minScore < tolerance )
457 return best.release();
463 std::unique_ptr< QgsAbstractGeometry > segmentizedCopy;
467 geom = segmentizedCopy.get();
473 maxIterations, tolerance, lowerThreshold, upperThreshold );
482 maxIterations, tolerance, lowerThreshold, upperThreshold ) );
486 maxIterations, tolerance, lowerThreshold, upperThreshold ) );
501 double lowerThreshold = std::cos( ( 90 - angleThreshold ) * M_PI / 180.00 );
502 double upperThreshold = std::cos( angleThreshold * M_PI / 180.0 );
504 if (
const QgsGeometryCollection *gc = qgsgeometry_cast< const QgsGeometryCollection *>( mGeometry ) )
506 int numGeom = gc->numGeometries();
507 QVector< QgsAbstractGeometry * > geometryList;
508 geometryList.reserve( numGeom );
509 for (
int i = 0; i < numGeom; ++i )
511 geometryList <<
orthogonalizeGeom( gc->geometryN( i ), maxIterations, tolerance, lowerThreshold, upperThreshold );
530 QVector< double > outX;
531 QVector< double > outY;
532 QVector< double > outZ;
533 QVector< double > outM;
534 double multiplier = 1.0 / double( extraNodesPerSegment + 1 );
537 outX.reserve( ( extraNodesPerSegment + 1 ) * nPoints );
538 outY.reserve( ( extraNodesPerSegment + 1 ) * nPoints );
539 bool withZ = ring->
is3D();
541 outZ.reserve( ( extraNodesPerSegment + 1 ) * nPoints );
544 outM.reserve( ( extraNodesPerSegment + 1 ) * nPoints );
557 int extraNodesThisSegment = extraNodesPerSegment;
558 for (
int i = 0; i < nPoints - 1; ++i )
561 x2 = ring->
xAt( i + 1 );
563 y2 = ring->
yAt( i + 1 );
567 z2 = ring->
zAt( i + 1 );
572 m2 = ring->
mAt( i + 1 );
582 if ( extraNodesPerSegment < 0 )
585 extraNodesThisSegment = std::floor( std::sqrt( ( x2 - x1 ) * ( x2 - x1 ) + ( y2 - y1 ) * ( y2 - y1 ) ) / distance );
586 if ( extraNodesThisSegment >= 1 )
587 multiplier = 1.0 / ( extraNodesThisSegment + 1 );
590 for (
int j = 0; j < extraNodesThisSegment; ++j )
592 double delta = multiplier * ( j + 1 );
593 xOut = x1 + delta * ( x2 - x1 );
594 yOut = y1 + delta * ( y2 - y1 );
596 zOut = z1 + delta * ( z2 - z1 );
598 mOut = m1 + delta * ( m2 - m1 );
608 outX << ring->
xAt( nPoints - 1 );
609 outY << ring->
yAt( nPoints - 1 );
611 outZ << ring->
zAt( nPoints - 1 );
613 outM << ring->
mAt( nPoints - 1 );
621 std::unique_ptr< QgsAbstractGeometry > segmentizedCopy;
625 geom = segmentizedCopy.get();
630 return doDensify( static_cast< const QgsLineString * >( geom ), extraNodesPerSegment, distance );
639 extraNodesPerSegment, distance ) );
643 extraNodesPerSegment, distance ) );
662 if (
const QgsGeometryCollection *gc = qgsgeometry_cast< const QgsGeometryCollection *>( mGeometry ) )
664 int numGeom = gc->numGeometries();
665 QVector< QgsAbstractGeometry * > geometryList;
666 geometryList.reserve( numGeom );
667 for (
int i = 0; i < numGeom; ++i )
669 geometryList <<
densifyGeometry( gc->geometryN( i ), extraNodesPerSegment );
697 if (
const QgsGeometryCollection *gc = qgsgeometry_cast< const QgsGeometryCollection *>( mGeometry ) )
699 int numGeom = gc->numGeometries();
700 QVector< QgsAbstractGeometry * > geometryList;
701 geometryList.reserve( numGeom );
702 for (
int i = 0; i < numGeom; ++i )
729 "line_segment_dist_comparer",
730 "AB must not be collinear with the origin." );
732 "line_segment_dist_comparer",
733 "CD must not be collinear with the origin." );
747 if ( ab.
end() == cd.
end() || oad != oab )
757 if ( cdb == 0 && cda == 0 )
759 return mOrigin.sqrDist( ab.
start() ) < mOrigin.sqrDist( cd.
start() );
761 else if ( cda == cdb || cda == 0 || cdb == 0 )
764 return cdo == cda || cdo == cdb;
780 const bool aIsLeft = a.
x() < mVertex.x();
781 const bool bIsLeft = b.
x() < mVertex.x();
782 if ( aIsLeft != bIsLeft )
787 if ( a.
y() >= mVertex.y() || b.
y() >= mVertex.y() )
789 return b.
y() < a.
y();
793 return a.
y() < b.
y();
832 const double distA = ao * direction;
833 const double distB = ( origin - segment.
end() ) * direction;
835 if ( distA > 0 && distB > 0 )
841 if ( ( distA > 0 ) != ( distB > 0 ) )
842 intersectPoint = origin;
843 else if ( distA > distB )
844 intersectPoint = segment.
start();
846 intersectPoint = segment.
end();
854 if ( u < 0.0 || 1.0 < u )
861 intersectPoint = origin + direction * t;
870 if ( radius1 > radius2 )
877 QVector<QgsPointXY> points;
898 std::vector< std::unique_ptr<QgsLineString > > linesToProcess;
903 for (
int i = 0; i < multiCurve->
partCount(); ++i )
905 if ( static_cast< const QgsCurve * >( multiCurve->
geometryN( i ) )->nCoordinates() == 0 )
908 linesToProcess.emplace_back( static_cast<QgsLineString *>( multiCurve->
geometryN( i )->
clone() ) );
916 linesToProcess.emplace_back( static_cast<QgsLineString *>( curve->
segmentize() ) );
919 if ( linesToProcess.empty() )
922 g.mLastError = QStringLiteral(
"Input geometry was not a curve type geometry" );
926 QVector<QgsGeometry> bufferedLines;
927 bufferedLines.reserve( linesToProcess.size() );
929 for ( std::unique_ptr< QgsLineString > &line : linesToProcess )
931 QVector<QgsGeometry> parts;
933 double prevRadius = 0;
936 std::unique_ptr< double[] > widths = widthFunction( line.get() ) ;
941 double thisRadius = widths[ i ] / 2.0;
942 if ( thisRadius > 0 )
947 thisCircle =
QgsGeometry( circ.toPolygon( segments * 4 ) );
957 if ( prevRadius > 0 || thisRadius > 0 )
959 QVector< QgsPointXY > points =
generateSegmentCurve( prevPoint, prevRadius, thisPoint, thisRadius );
960 if ( !points.empty() )
965 int beforeVertex = 0;
968 double sqrDistPrev = 0;
969 for (
int j = 0; j < points.count(); ++j )
973 points[j] = sqrDistPrev < sqrDist ? pA : pB;
976 points.append( points.at( 0 ) );
978 std::unique_ptr< QgsPolygon > poly = qgis::make_unique< QgsPolygon >();
980 if ( poly->area() > 0 )
985 prevPoint = thisPoint;
986 prevRadius = thisRadius;
987 prevCircle = thisCircle;
998 start = std::fabs( start );
999 end = std::fabs( end );
1005 std::unique_ptr< double [] > widths(
new double[ line->nCoordinates() ] );
1007 widths[line->nCoordinates() - 1] = end;
1009 double lineLength = line->length();
1010 double currentLength = 0;
1011 QgsPoint prevPoint = line->pointN( 0 );
1012 for (
int i = 1; i < line->nCoordinates() - 1; ++i )
1014 QgsPoint point = line->pointN( i );
1015 double segmentLength = point.
distance( prevPoint );
1016 currentLength += segmentLength;
1017 double lengthFraction = lineLength > 0 ? currentLength / lineLength : 1;
1018 double delta = lengthFraction * ( end - start );
1019 widths[i] = start + delta;
1032 std::unique_ptr< double [] > widths(
new double[ line->nCoordinates() ] );
1033 for (
int i = 0; i < line->nCoordinates(); ++i )
1035 widths[ i ] = line->mAt( i );
1044 const std::function<
bool(
const QgsPointXY & ) > &acceptPoint,
unsigned long seed,
QgsFeedback *feedback )
1047 return QVector< QgsPointXY >();
1059 return QVector< QgsPointXY >();
1067 std::unique_ptr< QgsPolygon > p( qgsgeometry_cast< QgsPolygon * >( ms->
geometryN( i )->
segmentize() ) );
1074 if (
const QgsPolygon *poly = qgsgeometry_cast< const QgsPolygon * >( polygon.
constGet() ) )
1080 std::unique_ptr< QgsPolygon > p( qgsgeometry_cast< QgsPolygon * >( polygon.
constGet()->
segmentize() ) );
1086 return QVector< QgsPointXY >();
1088 const QVector<float> triangleData = t.
data();
1089 if ( triangleData.empty() )
1090 return QVector< QgsPointXY >();
1093 std::vector< double > cumulativeAreas;
1095 double totalArea = 0;
1096 for (
auto it = triangleData.constBegin(); it != triangleData.constEnd(); )
1099 return QVector< QgsPointXY >();
1101 const float aX = *it++;
1103 const float aY = -( *it++ );
1104 const float bX = *it++;
1106 const float bY = -( *it++ );
1107 const float cX = *it++;
1109 const float cY = -( *it++ );
1113 cumulativeAreas.emplace_back( totalArea );
1116 std::random_device rd;
1117 std::mt19937 mt( seed == 0 ? rd() : seed );
1118 std::uniform_real_distribution<> uniformDist( 0, 1 );
1121 auto selectRandomTriangle = [&cumulativeAreas, totalArea](
double random )->
int 1124 const double target = random * totalArea;
1125 for (
auto it = cumulativeAreas.begin(); it != cumulativeAreas.end(); ++it, triangle++ )
1130 Q_ASSERT_X(
false,
"QgsInternalGeometryEngine::randomPointsInPolygon",
"Invalid random triangle index" );
1135 QVector<QgsPointXY> result;
1136 result.reserve( count );
1137 for (
int i = 0; i < count; )
1140 return QVector< QgsPointXY >();
1142 const double triangleIndexRnd = uniformDist( mt );
1144 const int triangleIndex = selectRandomTriangle( triangleIndexRnd );
1147 const double weightB = uniformDist( mt );
1148 const double weightC = uniformDist( mt );
1153 const double aX = triangleData.at( triangleIndex * 9 ) + bounds.
xMinimum();
1154 const double aY = -triangleData.at( triangleIndex * 9 + 2 ) + bounds.
yMinimum();
1155 const double bX = triangleData.at( triangleIndex * 9 + 3 ) + bounds.
xMinimum();
1156 const double bY = -triangleData.at( triangleIndex * 9 + 5 ) + bounds.
yMinimum();
1157 const double cX = triangleData.at( triangleIndex * 9 + 6 ) + bounds.
xMinimum();
1158 const double cY = -triangleData.at( triangleIndex * 9 + 8 ) + bounds.
yMinimum();
1162 if ( acceptPoint( candidate ) )
bool isMeasure() const
Returns true if the geometry contains m values.
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a tapered width buffer for a (multi)curve geometry.
QVector< float > data() const
Returns array of triangle vertex data.
QgsAbstractGeometry * orthogonalizeGeom(const QgsAbstractGeometry *geom, int maxIterations, double tolerance, double lowerThreshold, double upperThreshold)
QgsLineString * doDensify(const QgsLineString *ring, int extraNodesPerSegment=-1, double distance=1)
QgsVector calcMotion(const QgsPoint &a, const QgsPoint &b, const QgsPoint &c, double lowerThreshold, double upperThreshold)
A rectangle specified with double values.
QgsInternalGeometryEngine(const QgsGeometry &geometry)
The caller is responsible that the geometry is available and unchanged for the whole lifetime of this...
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer using the m-values from a (multi)line geometry.
double zAt(int index) const
Returns the z-coordinate of the specified node in the line string.
OperationResult addPart(const QVector< QgsPointXY > &points, QgsWkbTypes::GeometryType geomType=QgsWkbTypes::UnknownGeometry)
Adds a new part to a the geometry.
QgsGeometry variableWidthBuffer(int segments, const std::function< std::unique_ptr< double[] >(const QgsLineString *line) > &widthFunction) const
Calculates a variable width buffer for a (multi)curve geometry.
double normalizedDotProduct(const QgsPoint &a, const QgsPoint &b, const QgsPoint &c)
QVector< QgsPointXY > generateSegmentCurve(const QgsPoint ¢er1, const double radius1, const QgsPoint ¢er2, const double radius2)
QgsGeometry poleOfInaccessibility(double precision, double *distanceFromBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
double distance(double x, double y) const
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
A class to represent a 2D point.
double endY() const
Returns the segment's end y-coordinate.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
bool intersects(const QgsLineSegment2D &segment, QgsPointXY &intersectPoint) const
Finds the closest intersection point of the ray and a line segment.
A geometry is the spatial representation of a feature.
double crossProduct(QgsVector v) const
Returns the 2D cross product of this vector and another vector v.
void setYAt(int index, double y)
Sets the y-coordinate of the specified node in the line string.
double squareness(QgsLineString *ring, double lowerThreshold, double upperThreshold)
int dataVerticesCount() const
Returns the number of vertices stored in the output data array.
double pointDistanceToBoundary(double x, double y) const
Returns the distance from a point to the boundary of the polygon (either the exterior ring or any clo...
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
static int circleCircleOuterTangents(const QgsPointXY ¢er1, double radius1, const QgsPointXY ¢er2, double radius2, QgsPointXY &line1P1, QgsPointXY &line1P2, QgsPointXY &line2P1, QgsPointXY &line2P2)
Calculates the outer tangent points for two circles, centered at center1 and center2 and with radii o...
Multi surface geometry collection.
void setXAt(int index, double x)
Sets the x-coordinate of the specified node in the line string.
void reverse()
Reverses the line segment, so that the start and end points are flipped.
int numPoints() const override
Returns the number of points in the curve.
QgsPointXY closestVertex(const QgsPointXY &point, int &atVertex, int &beforeVertex, int &afterVertex, double &sqrDist) const
Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap ...
Base class for feedback objects to be used for cancellation of something running in a worker thread...
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QgsPointXY end() const
Returns the segment's end point.
Class that takes care of tessellation of polygons into triangles.
void addInteriorRing(QgsCurve *ring) override
Adds an interior ring to the geometry (takes ownership)
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
static double triangleArea(double aX, double aY, double bX, double bY, double cX, double cY)
Returns the area of the triangle denoted by the points (aX, aY), (bX, bY) and (cX, cY).
double startX() const
Returns the segment's start x-coordinate.
static int leftOfLine(const double x, const double y, const double x1, const double y1, const double x2, const double y2)
Returns a value < 0 if the point (x, y) is left of the line from (x1, y1) -> ( x2, y2).
void addPolygon(const QgsPolygon &polygon, float extrusionHeight)
Tessellates a triangle and adds its vertex entries to the output data array.
double width() const
Returns the width of the rectangle.
double mAt(int index) const
Returns the m value of the specified node in the line string.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
double yAt(int index) const override
Returns the y-coordinate of the specified node in the line string.
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
T qgsgeometry_cast(const QgsAbstractGeometry *geom)
static QVector< QgsPointXY > randomPointsInPolygon(const QgsGeometry &polygon, int count, const std::function< bool(const QgsPointXY &) > &acceptPoint, unsigned long seed=0, QgsFeedback *feedback=nullptr)
Returns a list of count random points generated inside a polygon geometry.
Multi curve geometry collection.
QgsRectangle boundingBox() const override
Returns the minimal bounding box for the geometry.
int pointLeftOfLine(const QgsPointXY &point) const
Tests if a point is to the left of the line segment.
QgsPoint * clone() const override
Clones the geometry by performing a deep copy.
QgsGeometry densifyByDistance(double distance) const
Densifies the geometry by adding regularly placed extra nodes inside each segment so that the maximum...
Abstract base class for curved geometry type.
Abstract base class for all geometries.
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
Point geometry type, with support for z-dimension and m-values.
double length() const
Returns the length of the vector.
QgsAbstractGeometry * densifyGeometry(const QgsAbstractGeometry *geom, int extraNodesPerSegment=1, double distance=1)
Represents a single 2D line segment, consisting of a 2D start and end vertex only.
QgsLineString * clone() const override
Clones the geometry by performing a deep copy.
A class to represent a vector.
int numGeometries() const
Returns the number of geometries within the collection.
virtual bool isClosed() const
Returns true if the curve is closed.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QgsCurve * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
bool dotProductWithinAngleTolerance(double dotProduct, double lowerThreshold, double upperThreshold)
int partCount() const override
Returns count of parts contained in the geometry.
double endX() const
Returns the segment's end x-coordinate.
void reserve(int size)
Attempts to allocate memory for at least size geometries.
void setExteriorRing(QgsCurve *ring) override
Sets the exterior ring of the polygon.
bool isCanceled() const
Tells whether the operation has been canceled already.
Multi polygon geometry collection.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
static bool isCurvedType(Type type)
Returns true if the WKB type is a curved type or can contain curved geometries.
Line string geometry type, with support for z-dimension and m-values.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
QgsPoint pointN(int i) const
Returns the specified point from inside the line string.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
double xAt(int index) const override
Returns the x-coordinate of the specified node in the line string.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QgsWkbTypes::GeometryType type
QgsGeometry orthogonalize(double tolerance=1.0E-8, int maxIterations=1000, double angleThreshold=15.0) const
Attempts to orthogonalize a line or polygon geometry by shifting vertices to make the geometries angl...
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Densifies the geometry by adding the specified number of extra nodes within each segment of the geome...
double startY() const
Returns the segment's start y-coordinate.
int nCoordinates() const override
Returns the number of nodes contained in the geometry.
double lengthSquared() const
Returns the length of the vector.
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
static void weightedPointInTriangle(double aX, double aY, double bX, double bY, double cX, double cY, double weightB, double weightC, double &pointX, double &pointY)
Returns a weighted point inside the triangle denoted by the points (aX, aY), (bX, bY) and (cX...
virtual QgsAbstractGeometry * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves.
static QgsGeometry unaryUnion(const QVector< QgsGeometry > &geometries)
Compute the unary union on a list of geometries.
static QgsGeometry collectGeometry(const QVector< QgsGeometry > &geometries)
Creates a new multipart geometry from a list of QgsGeometry objects.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
QgsGeometry extrude(double x, double y) const
Will extrude a line or (segmentized) curve by a given offset and return a polygon representation of i...
QgsPointXY start() const
Returns the segment's start point.
QgsVector normalized() const
Returns the vector's normalized (or "unit") vector (ie same angle but length of 1.0).
double height() const
Returns the height of the rectangle.
QgsLineString * doOrthogonalize(QgsLineString *ring, int iterations, double tolerance, double lowerThreshold, double upperThreshold)