23#include <nlohmann/json.hpp>
62#include "moc_qgsgeometry.cpp"
64using namespace Qt::StringLiterals;
76 std::unique_ptr< QgsAbstractGeometry >
geometry;
85 if ( !d->ref.deref() )
92 d->geometry.reset( geom );
102 mLastError = other.mLastError;
108 if (
this != &other )
110 if ( !d->ref.deref() )
115 mLastError = other.mLastError;
122void QgsGeometry::detach()
127 std::unique_ptr< QgsAbstractGeometry > cGeom;
129 cGeom.reset( d->
geometry->clone() );
131 reset( std::move( cGeom ) );
134void QgsGeometry::reset( std::unique_ptr<QgsAbstractGeometry> newGeometry )
138 ( void ) d->ref.deref();
139 d =
new QgsGeometryPrivate();
141 d->geometry = std::move( newGeometry );
146 return d->geometry.get();
152 return d->geometry.get();
157 if ( d->geometry.get() == geometry )
162 reset( std::unique_ptr< QgsAbstractGeometry >( geometry ) );
176 QMutexLocker lock( sWktMutex() );
177 if (
const QgsGeometry *cached = sWktCache()->
object( wkt ) )
180 sWktCache()->insert( wkt,
new QgsGeometry( result ), 1 );
211 return QgsGeometry( std::make_unique< QgsLineString >( polyline ) );
259 auto ext = std::make_unique< QgsLineString >(
263 auto polygon = std::make_unique< QgsPolygon >();
264 polygon->setExteriorRing( ext.release() );
275 auto polyhedralSurface = std::make_unique< QgsPolyhedralSurface >();
277 auto ext1 = std::make_unique< QgsLineString >(
282 auto polygon1 = std::make_unique< QgsPolygon >( ext1.release() );
283 polyhedralSurface->addPatch( polygon1.release() );
285 auto ext2 = std::make_unique< QgsLineString >(
290 auto polygon2 = std::make_unique< QgsPolygon >( ext2.release() );
291 polyhedralSurface->addPatch( polygon2.release() );
293 auto ext3 = std::make_unique< QgsLineString >(
298 auto polygon3 = std::make_unique< QgsPolygon >( ext3.release() );
299 polyhedralSurface->addPatch( polygon3.release() );
301 auto ext4 = std::make_unique< QgsLineString >(
306 auto polygon4 = std::make_unique< QgsPolygon >( ext4.release() );
307 polyhedralSurface->addPatch( polygon4.release() );
309 auto ext5 = std::make_unique< QgsLineString >(
314 auto polygon5 = std::make_unique< QgsPolygon >( ext5.release() );
315 polyhedralSurface->addPatch( polygon5.release() );
317 auto ext6 = std::make_unique< QgsLineString >(
322 auto polygon6 = std::make_unique< QgsPolygon >( ext6.release() );
323 polyhedralSurface->addPatch( polygon6.release() );
325 return QgsGeometry( std::move( polyhedralSurface ) );
341 if ( g.isMultipart() )
343 for (
auto p = g.const_parts_begin(); p != g.const_parts_end(); ++p )
359 auto resultTin = std::make_unique<QgsTriangulatedSurface>();
375 resultTin->addZValue( 0 );
376 if ( tin->isMeasure() )
377 resultTin->addMValue( 0 );
382 for (
int j = 0; j < tin->numPatches(); ++j )
384 if (
const QgsPolygon *patch = tin->patchN( j ) )
386 resultTin->addPatch( patch->clone() );
395 if ( triangle->is3D() )
396 resultTin->addZValue( 0 );
397 if ( triangle->isMeasure() )
398 resultTin->addMValue( 0 );
402 resultTin->addPatch( triangle->clone() );
406 if ( resultTin->numPatches() == 0 )
414 const double startAngle = azimuth - angularWidth * 0.5;
415 const double endAngle = azimuth + angularWidth * 0.5;
422 auto wedge = std::make_unique< QgsCompoundCurve >();
424 const double DEG_TO_RAD = M_PI / 180.0;
425 const double RAD_TO_DEG = 180.0 / M_PI;
427 const double angularWidth = endAngle - startAngle;
430 if ( std::abs( angularWidth ) >= 360.0 )
432 auto outerCc = std::make_unique< QgsCompoundCurve >();
437 auto cp = std::make_unique< QgsCurvePolygon >();
438 cp->setExteriorRing( outerCc.release() );
442 auto innerCc = std::make_unique< QgsCompoundCurve >();
447 cp->setInteriorRings( { innerCc.release() } );
472 auto cp = std::make_unique< QgsCurvePolygon >();
473 cp->setExteriorRing( wedge.release() );
498 return d->geometry->wkbType();
518 return d->geometry->isEmpty();
550 d->geometry->adjacentVertices(
id, prevVertex, nextVertex );
586 return d->geometry->vertexAngle( v2 );
605 d->geometry->adjacentVertices(
id, beforeVertexId, afterVertexId );
625 return d->geometry->moveVertex(
id,
QgsPoint( x, y ) );
643 return d->geometry->moveVertex(
id, p );
676 return d->geometry->deleteVertex(
id );
689 if ( atVertices.size() != 1 && !atVertices.contains( 0 ) )
696 QSet<QgsVertexId> vertexIds;
697 for (
int vertex : atVertices )
703 vertexIds.insert(
id );
707 std::unique_ptr< QgsAbstractGeometry > originalGeometry( d->geometry->clone() );
711 if ( !d->geometry->deleteVertices( vertexIds ) )
713 reset( std::move( originalGeometry ) );
736 if ( owningCollection )
737 part = owningCollection->
geometryN(
id.part );
754 bool success =
false;
765 auto cpdCurve = std::make_unique<QgsCompoundCurve>();
772 if ( !owningPolygon && !owningCollection )
775 reset( std::make_unique<QgsCompoundCurve>( *cpdCurve ) );
777 else if ( owningPolygon )
790 else if ( owningCollection )
825 return d->geometry->insertVertex(
id,
QgsPoint( x, y ) );
851 return d->geometry->insertVertex(
id, point );
861 const double sqrSnappingTolerance = snappingTolerance * snappingTolerance;
862 int segmentAfterVertex;
864 const double sqrDistSegmentSnap =
closestSegmentWithContext( point, snappedPoint, segmentAfterVertex,
nullptr, segmentSearchEpsilon );
866 if ( sqrDistSegmentSnap > sqrSnappingTolerance )
869 int atVertex, beforeVertex, afterVertex;
870 double sqrDistVertexSnap;
871 closestVertex( point, atVertex, beforeVertex, afterVertex, sqrDistVertexSnap );
873 if ( sqrDistVertexSnap < sqrSnappingTolerance )
880 QgsPoint interpolatedPoint( point );
881 if ( d->geometry.get()->is3D() || d->geometry.get()->isMeasure() )
888 if ( !
insertVertex( interpolatedPoint, segmentAfterVertex ) )
910 return d->geometry->vertexAt( vId );
930 result.mLastError = mLastError;
945 result.mLastError = mLastError;
975 double sqrDist = d->geometry->closestSegment(
QgsPoint( point ), segmentPt, vertexAfter, leftOrRightOfSegment, epsilon );
979 minDistPoint.
setX( segmentPt.
x() );
980 minDistPoint.
setY( segmentPt.
y() );
987 auto ringLine = std::make_unique< QgsLineString >( ring );
988 return addRing( ringLine.release() );
993 std::unique_ptr< QgsCurve > r( ring );
1009 return addPart( l, geomType );
1022 std::unique_ptr< QgsAbstractGeometry > partGeom;
1023 if ( points.size() == 1 )
1025 partGeom = std::make_unique< QgsPoint >( points[0] );
1027 else if ( points.size() > 1 )
1029 auto ringLine = std::make_unique< QgsLineString >();
1030 ringLine->setPoints( points );
1031 partGeom = std::move( ringLine );
1034 return addPart( partGeom.release(), geomType );
1040 std::unique_ptr< QgsAbstractGeometry > partGeom;
1041 if ( points.size() == 1 )
1043 partGeom = std::make_unique< QgsPoint >( points[0] );
1045 else if ( points.size() > 1 )
1047 auto ringLine = std::make_unique< QgsLineString >();
1048 ringLine->setPoints( points );
1049 partGeom = std::move( ringLine );
1056 std::unique_ptr< QgsAbstractGeometry > p( part );
1062 reset( std::make_unique< QgsMultiPoint >() );
1065 reset( std::make_unique< QgsMultiLineString >() );
1068 reset( std::make_unique< QgsMultiPolygon >() );
1086 std::unique_ptr< QgsAbstractGeometry > p( part );
1092 reset( std::make_unique< QgsMultiPoint >() );
1095 reset( std::make_unique< QgsMultiLineString >() );
1099 reset( std::make_unique< QgsMultiPolygon >() );
1102 reset( std::make_unique< QgsMultiSurface >() );
1106 reset( std::make_unique< QgsMultiCurve >() );
1109 reset( std::make_unique< QgsPolyhedralSurface >() );
1112 reset( std::make_unique< QgsTriangulatedSurface >() );
1157 QVector<QgsGeometry> results;
1158 results.reserve(
parts.count() );
1161 QgsGeometry result = part.removeInteriorRings( minimumRingArea );
1165 if ( results.isEmpty() )
1169 for (
const QgsGeometry &result : std::as_const( results ) )
1177 std::unique_ptr< QgsCurvePolygon > newPoly(
static_cast< QgsCurvePolygon *
>( d->geometry->clone() ) );
1178 newPoly->removeInteriorRings( minimumRingArea );
1192 d->geometry->transform( QTransform::fromTranslate( dx, dy ), dz, 1.0, dm );
1205 QTransform t = QTransform::fromTranslate( center.
x(), center.
y() );
1206 t.rotate( -rotation );
1207 t.translate( -center.
x(), -center.
y() );
1208 d->geometry->transform( t );
1218 if ( !geom->
is3D() )
1224 for (
const QgsPoint &pt : points )
1235 if (
const QgsPoint v = geom->
vertexAt( prevVertexId ); v.
x() == pt.x() && v.y() == pt.y() )
1237 else if (
const QgsPoint v = geom->
vertexAt( nextVertexId ); v.
x() == pt.x() && v.y() == pt.y() )
1244 const QVector<QgsPointXY> &splitLine, QVector<QgsGeometry> &newGeometries,
bool topological, QVector<QgsPointXY> &topologyTestPoints,
bool splitFeature
1255 const QgsPointSequence &splitLine, QVector<QgsGeometry> &newGeometries,
bool topological,
QgsPointSequence &topologyTestPoints,
bool splitFeature,
bool skipIntersectionTest
1258#if GEOS_VERSION_NUM >= GEOS_COMPUTE_VERSION( 3, 15, 0 )
1259 Q_UNUSED( skipIntersectionTest )
1265 if ( splitLine.isEmpty() )
1273 QVector<QgsGeometry > newGeomsTemp;
1275#if GEOS_VERSION_NUM >= GEOS_COMPUTE_VERSION( 3, 15, 0 )
1276 for (
const QgsPoint &v : splitLine )
1281 std::unique_ptr< QgsAbstractGeometry > splitGeom;
1282 if ( splitLine.size() > 1 )
1284 splitGeom = std::make_unique< QgsLineString >( splitLine );
1285 splitGeom->dropZValue();
1286 splitGeom->dropMValue();
1288 else if ( splitLine.size() == 1 )
1290 splitGeom = std::make_unique< QgsPoint >( splitLine[0].x(), splitLine[0].y() );
1300 newGeometries = collectSplitGeometries( newGeomsTemp, splitFeature );
1303 for (
const QgsPoint &v : splitLine )
1321 addedTopologicalPoints.append( topoPoint );
1338 if ( !addedTopologicalPoints.isEmpty() )
1340 for (
int i = 0; i < newGeomsTemp.size(); ++i )
1343 removeDuplicateAdjacentPointsAt( geom, addedTopologicalPoints );
1346 if ( splitFeature && !newGeomsTemp.isEmpty() )
1347 *
this = newGeomsTemp.takeAt( 0 );
1349 newGeometries = newGeomsTemp;
1374 const QgsCurve *curve, QVector<QgsGeometry> &newGeometries,
bool preserveCircular,
bool topological,
QgsPointSequence &topologyTestPoints,
bool splitFeature
1377#if GEOS_VERSION_NUM >= GEOS_COMPUTE_VERSION( 3, 15, 0 )
1378 Q_UNUSED( preserveCircular );
1393 curve->
points( curvePoints );
1395 for (
const QgsPoint &v : std::as_const( curvePoints ) )
1400 QVector< QgsGeometry> newGeomsTemp;
1410 newGeometries = collectSplitGeometries( newGeomsTemp, splitFeature );
1430 std::unique_ptr<QgsLineString> segmentizedLine( curve->
curveToLine() );
1432 segmentizedLine->points( points );
1437 if ( preserveCircular )
1439 for (
int i = 0; i < newGeometries.count(); ++i )
1458 reshapeLineString.
points( reshapePoints );
1461 for (
const QgsPoint &v : std::as_const( reshapePoints ) )
1475 addedTopologicalPoints.append( topoPoint );
1483 std::unique_ptr< QgsAbstractGeometry > geom(
geos.reshapeGeometry( reshapeLineString, &errorCode, &mLastError ) );
1488 if ( !addedTopologicalPoints.isEmpty() )
1490 removeDuplicateAdjacentPointsAt( geom.get(), addedTopologicalPoints );
1492 reset( std::move( geom ) );
1496 switch ( errorCode )
1520 if ( !d->geometry || !other.d->
geometry )
1534 reset( std::move( diffGeom ) );
1547 return d->geometry->boundingBox();
1556 return d->geometry->boundingBox3D();
1587 double area, angle, width, height;
1593 auto l_boundary = boundary.length();
1595 if ( ( points.length() == 0 ) || ( l_boundary == 3 ) )
1597 switch ( l_boundary )
1604 boundary.pop_back();
1609 boundary.pop_back();
1611 boundary.pop_back();
1616 QgsPoint p1( boundary.at( 0 ) );
1617 QgsPoint p2( boundary.at( 1 ) );
1618 QgsPoint p3( boundary.at( 2 ) );
1626 QgsPointXY pxy = points.last();
1628 circ_mec = __recMinimalEnclosingCircle( points, boundary );
1632 boundary.append( pxy );
1633 circ_mec = __recMinimalEnclosingCircle( points, boundary );
1657 QgsCircle circ = __recMinimalEnclosingCircle( P, R );
1676 return engine.
orthogonalize( tolerance, maxIterations, angleThreshold );
1682 return engine.
triangularWaves( wavelength, amplitude, strictWavelength );
1688 return engine.
triangularWavesRandomized( minimumWavelength, maximumWavelength, minimumAmplitude, maximumAmplitude, seed );
1694 return engine.
squareWaves( wavelength, amplitude, strictWavelength );
1700 return engine.
squareWavesRandomized( minimumWavelength, maximumWavelength, minimumAmplitude, maximumAmplitude, seed );
1706 return engine.
roundWaves( wavelength, amplitude, strictWavelength );
1712 return engine.
roundWavesRandomized( minimumWavelength, maximumWavelength, minimumAmplitude, maximumAmplitude, seed );
1720 return engine.
applyDashPattern( pattern, startRule, endRule, adjustment, patternOffset );
1729 return QgsGeometry( d->geometry->snappedToGrid( hSpacing, vSpacing, dSpacing, mSpacing ) );
1738 return d->geometry->removeDuplicateNodes( epsilon, useZValues );
1754#if GEOS_VERSION_NUM < GEOS_COMPUTE_VERSION( 3, 12, 0 )
1770 if ( !d->geometry || geometry.
isNull() )
1777 return geos.intersects( geometry.d->
geometry.get(), &mLastError );
1787 return d->geometry->boundingBoxIntersects( rectangle );
1792 if ( !d->geometry || geometry.
isNull() )
1802 if ( !d->geometry || !p )
1809 return geos.contains( p->
x(), p->
y(), &mLastError );
1821 return geos.contains( x, y, &mLastError );
1826 if ( !d->geometry || geometry.
isNull() )
1833 return geos.contains( geometry.d->
geometry.get(), &mLastError );
1838 if ( !d->geometry || geometry.
isNull() )
1845 return geos.disjoint( geometry.d->
geometry.get(), &mLastError );
1855 if ( !d->geometry || geometry.
isNull() )
1862 return geos.touches( geometry.d->
geometry.get(), &mLastError );
1867 if ( !d->geometry || geometry.
isNull() )
1874 return geos.overlaps( geometry.d->
geometry.get(), &mLastError );
1879 if ( !d->geometry || geometry.
isNull() )
1886 return geos.within( geometry.d->
geometry.get(), &mLastError );
1891 if ( !d->geometry || geometry.
isNull() )
1898 return geos.crosses( geometry.d->
geometry.get(), &mLastError );
1907 return d->geometry->asWkt( precision );
1917 return QString::fromStdString(
asJsonObject( precision, profile ).dump() );
1926 return d->geometry->asJsonObject( precision, profile );
1932 QVector< QgsGeometry > res;
1952 newGeom =
QgsGeometry( d->geometry.get()->segmentize() );
1960 bool hasNurbs =
false;
1967 for (
int i = 0; i < collection->numGeometries(); ++i )
1980 for (
int i = 0; !hasNurbs && i < cp->numInteriorRings(); ++i )
1988 for (
int i = 0; i < cc->nCurves(); ++i )
2018 std::unique_ptr< QgsAbstractGeometry > exterior( ( *part )->clone() );
2023 auto cp = std::make_unique< QgsCurvePolygon >();
2024 cp->setExteriorRing( curve );
2025 ( void ) exterior.release();
2026 gc->addGeometry( cp.release() );
2030 auto p = std::make_unique< QgsPolygon >();
2032 ( void ) exterior.release();
2033 gc->addGeometry( p.release() );
2044 auto mp = std::make_unique< QgsMultiPoint >();
2046 QSet< QgsPoint > added;
2049 if ( avoidDuplicates && added.contains( *vertex ) )
2051 mp->addGeometry( ( *vertex ).clone() );
2052 added.insert( *vertex );
2060 auto polySurface = std::make_unique< QgsPolyhedralSurface >();
2066 polySurface->addPatch( polygon->clone() );
2069 newGeom =
QgsGeometry( std::move( polySurface ) );
2076 auto tin = std::make_unique< QgsTriangulatedSurface >();
2082 tin->addPatch( triangle->clone() );
2087 if ( polygon->exteriorRing() )
2089 const int numPoints = polygon->exteriorRing()->numPoints();
2090 if ( numPoints != 4 )
2092 mLastError = QObject::tr(
"Cannot convert polygon with %1 vertices to a triangle. A triangle requires exactly 3 vertices." ).arg( numPoints > 0 ? numPoints - 1 : 0 );
2095 auto triangle = std::make_unique< QgsTriangle >();
2096 triangle->setExteriorRing( polygon->exteriorRing()->clone() );
2097 tin->addPatch( triangle.release() );
2108 auto multiPolygon = std::make_unique< QgsMultiPolygon >();
2111 for (
int i = 0; i < polySurface->numPatches(); ++i )
2113 const QgsPolygon *patch = polySurface->patchN( i );
2114 auto polygon = std::make_unique< QgsPolygon >();
2120 multiPolygon->addGeometry( polygon.release() );
2123 newGeom =
QgsGeometry( std::move( multiPolygon ) );
2132 if ( polygon->exteriorRing() )
2134 const int numPoints = polygon->exteriorRing()->numPoints();
2135 if ( numPoints != 4 )
2137 mLastError = QObject::tr(
"Cannot convert polygon with %1 vertices to a triangle. A triangle requires exactly 3 vertices." ).arg( numPoints > 0 ? numPoints - 1 : 0 );
2140 auto triangle = std::make_unique< QgsTriangle >();
2141 triangle->setExteriorRing( polygon->exteriorRing()->clone() );
2182 res.reserve(
parts->partCount() );
2183 for (
int i = 0; i <
parts->partCount(); i++ )
2198 bool allExpectedType =
true;
2203 allExpectedType =
false;
2207 if ( allExpectedType )
2209 std::unique_ptr< QgsGeometryCollection > newGeomCol;
2212 newGeomCol = std::make_unique< QgsMultiPoint >();
2216 newGeomCol = std::make_unique< QgsMultiLineString >();
2220 newGeomCol = std::make_unique< QgsMultiPolygon >();
2246 return convertToPoint( destMultipart );
2249 return convertToLine( destMultipart );
2252 return convertToPolygon( destMultipart );
2287 d->geometry = std::move( geom );
2319 if ( sourceMultiGeom )
2321 for (
int i = 0; i < sourceMultiGeom->
numGeometries(); ++i )
2329 if ( !multiGeom->
addGeometry( d->geometry->clone() ) )
2333 reset( std::move( geom ) );
2350 if ( !multiGeom || multiGeom->
partCount() < 1 )
2353 std::unique_ptr< QgsAbstractGeometry > firstPart( multiGeom->
geometryN( 0 )->
clone() );
2354 reset( std::move( firstPart ) );
2365 std::unique_ptr<QgsGeometryCollection> resGeom;
2369 resGeom = std::make_unique<QgsMultiPoint>();
2372 resGeom = std::make_unique<QgsMultiLineString>();
2375 resGeom = std::make_unique<QgsMultiPolygon>();
2388 resGeom->addGeometry( g->
clone() );
2391 set( resGeom.release() );
2421 std::unique_ptr< QgsLineString > segmentizedLine;
2423 if ( doSegmentation )
2431 line = segmentizedLine.get();
2443 polyLine.resize( nVertices );
2445 const double *xData = line->
xData();
2446 const double *yData = line->
yData();
2447 for (
int i = 0; i < nVertices; ++i )
2449 data->
setX( *xData++ );
2450 data->
setY( *yData++ );
2465 std::unique_ptr< QgsPolygon > segmentized;
2466 if ( doSegmentation )
2473 segmentized.reset( curvePoly->
toPolygon() );
2474 p = segmentized.get();
2487 convertPolygon( *p, polygon );
2507 for (
int i = 0; i < nPoints; ++i )
2510 multiPoint[i].setX( pt->
x() );
2511 multiPoint[i].setY( pt->
y() );
2524 if ( !geomCollection )
2536 mpl.reserve( nLines );
2537 for (
int i = 0; i < nLines; ++i )
2540 std::unique_ptr< QgsLineString > segmentized;
2549 line = segmentized.get();
2554 polyLine.resize( nVertices );
2556 const double *xData = line->
xData();
2557 const double *yData = line->
yData();
2558 for (
int i = 0; i < nVertices; ++i )
2560 data->
setX( *xData++ );
2561 data->
setY( *yData++ );
2564 mpl.append( polyLine );
2577 if ( !geomCollection )
2583 if ( nPolygons < 1 )
2589 mp.reserve( nPolygons );
2590 for (
int i = 0; i < nPolygons; ++i )
2607 convertPolygon( *polygon, poly );
2608 mp.push_back( poly );
2620 return d->geometry->area();
2630 return d->geometry->area3D();
2646 return d->geometry->length();
2649 return d->geometry->perimeter();
2653 return d->geometry->length();
2660 if ( !d->geometry || !geom.d->
geometry )
2671 QgsGeos g( d->geometry.get() );
2678 if ( !d->geometry || !geom.d->
geometry )
2683 QgsGeos g( d->geometry.get() );
2690 if ( !d->geometry || !geom.d->
geometry )
2695 QgsGeos g( d->geometry.get() );
2703 if ( !d->geometry || !geom.d->
geometry )
2708 QgsGeos g( d->geometry.get() );
2715 if ( !d->geometry || !geom.d->
geometry )
2720 QgsGeos g( d->geometry.get() );
2727 if ( !d->geometry || d->geometry.get()->isEmpty() )
2729 return d->geometry->vertices_begin();
2734 if ( !d->geometry || d->geometry.get()->isEmpty() )
2736 return d->geometry->vertices_end();
2741 if ( !d->geometry || d->geometry.get()->isEmpty() )
2752 return d->geometry->parts_begin();
2759 return d->geometry->parts_end();
2766 return d->geometry->const_parts_begin();
2773 return d->geometry->const_parts_end();
2800 QgsGeos g( d->geometry.get() );
2802 std::unique_ptr<QgsAbstractGeometry> geom( g.
buffer(
distance, segments, &mLastError, feedback ) );
2806 result.mLastError = mLastError;
2819 QgsGeos g( d->geometry.get() );
2825 result.mLastError = mLastError;
2841 QVector<QgsGeometry> results;
2842 results.reserve(
parts.count() );
2849 if ( results.isEmpty() )
2853 for (
const QgsGeometry &result : std::as_const( results ) )
2867 std::unique_ptr< QgsAbstractGeometry > offsetGeom(
geos.offsetCurve(
distance, segments, joinStyle, miterLimit, &mLastError ) );
2871 result.mLastError = mLastError;
2878 if ( newOrientation != prevOrientation )
2881 std::unique_ptr< QgsAbstractGeometry > flipped(
offsetCurve->reversed() );
2882 offsetGeom = std::move( flipped );
2899 QVector<QgsGeometry> results;
2900 results.reserve(
parts.count() );
2903 QgsGeometry result = part.singleSidedBuffer(
distance, segments, side, joinStyle, miterLimit );
2907 if ( results.isEmpty() )
2911 for (
const QgsGeometry &result : std::as_const( results ) )
2921 std::unique_ptr< QgsAbstractGeometry > bufferGeom =
geos.singleSidedBuffer(
distance, segments, side, joinStyle, miterLimit, &mLastError );
2925 result.mLastError = mLastError;
2936 return engine.
taperedBuffer( startWidth, endWidth, segments );
2956 QVector<QgsGeometry> results;
2957 results.reserve(
parts.count() );
2960 QgsGeometry result = part.extendLine( startDistance, endDistance, startDeflection, endDeflection );
2964 if ( results.isEmpty() )
2968 for (
const QgsGeometry &result : std::as_const( results ) )
2980 std::unique_ptr< QgsLineString > newLine( line->
clone() );
2981 newLine->extend( startDistance, endDistance, startDeflection, endDeflection );
2995 std::unique_ptr< QgsAbstractGeometry > simplifiedGeom(
geos.simplify( tolerance, &mLastError, feedback ) );
2996 if ( !simplifiedGeom )
2999 result.mLastError = mLastError;
3002 return QgsGeometry( std::move( simplifiedGeom ) );
3037 c.get()->dropZValue();
3038 c.get()->dropMValue();
3046 result.mLastError = mLastError;
3061 result.mLastError = mLastError;
3083 result.mLastError = mLastError;
3098 result.mLastError = mLastError;
3106 return std::numeric_limits< double >::quiet_NaN();
3112 return geos.minimumClearance( &mLastError );
3126 result.mLastError = mLastError;
3138 std::unique_ptr< QgsAbstractGeometry > cHull(
geos.convexHull( &mLastError ) );
3142 geom.mLastError = mLastError;
3156 std::unique_ptr< QgsAbstractGeometry >
concaveHull(
geos.concaveHull( targetPercent, allowHoles, &mLastError, feedback ) );
3160 geom.mLastError = mLastError;
3176 geom.mLastError = u
"Only Polygon or MultiPolygon geometries are supported"_s;
3182 std::unique_ptr< QgsAbstractGeometry >
concaveHull(
geos.concaveHullOfPolygons( lengthRatio, allowHoles, isTight, &mLastError, feedback ) );
3186 geom.mLastError = mLastError;
3202 result.mLastError = mLastError;
3216 result.mLastError = mLastError;
3230 result.mLastError = mLastError;
3249 result.mLastError = mLastError;
3262 std::unique_ptr< QgsAbstractGeometry > invalidEdgesGeom;
3266 if ( invalidEdges && invalidEdgesGeom )
3267 *invalidEdges =
QgsGeometry( std::move( invalidEdgesGeom ) );
3281 QgsGeometry result(
geos.simplifyCoverageVW( tolerance, preserveBoundary, &mLastError ) );
3282 result.mLastError = mLastError;
3300 const QgsGeometry result(
geos.cleanCoverage( parameters, &mLastError, feedback ) );
3301 result.mLastError = mLastError;
3315 result.mLastError = mLastError;
3329 result.mLastError = mLastError;
3341 std::unique_ptr< QgsAbstractGeometry > segmentizedCopy;
3344 segmentizedCopy.reset( d->geometry->segmentize() );
3345 geom = segmentizedCopy.get();
3350 std::unique_ptr< QgsAbstractGeometry > result(
geos.subdivide( maxNodes, &mLastError, parameters, feedback ) );
3354 geom.mLastError = mLastError;
3379 for (
int part = 0; part < collection->numGeometries(); ++part )
3384 const double candidateLength = candidate->
length();
3425 return geos.lineLocatePoint( *(
static_cast< QgsPoint *
>( point.d->
geometry.get() ) ), &mLastError );
3430 if ( !d->geometry || d->geometry->isEmpty() )
3449 if ( previous == next )
3488 if ( !d->geometry || geometry.
isNull() )
3496 std::unique_ptr< QgsAbstractGeometry > resultGeom(
geos.intersection( geometry.d->
geometry.get(), &mLastError, parameters, feedback ) );
3501 geom.mLastError = mLastError;
3510 if ( !d->geometry || geometry.
isNull() )
3517 std::unique_ptr< QgsAbstractGeometry > resultGeom(
geos.combine( geometry.d->
geometry.get(), &mLastError, parameters, feedback ) );
3521 geom.mLastError = mLastError;
3543 result.mLastError = mLastError;
3549 if ( !d->geometry || geometry.
isNull() )
3557 std::unique_ptr< QgsAbstractGeometry > resultGeom(
geos.difference( geometry.d->
geometry.get(), &mLastError, parameters, feedback ) );
3561 geom.mLastError = mLastError;
3569 if ( !d->geometry || geometry.
isNull() )
3577 std::unique_ptr< QgsAbstractGeometry > resultGeom(
geos.symDifference( geometry.d->
geometry.get(), &mLastError, parameters, feedback ) );
3581 geom.mLastError = mLastError;
3591 return engine.
extrude( x, y );
3599 return QVector< QgsPointXY >();
3602 const QVector<QgsPointXY> res = engine.randomPointsInPolygon( count, acceptPoint, seed, feedback, maxTriesPerPoint );
3603 mLastError = engine.lastError();
3610 return QVector< QgsPointXY >();
3613 const QVector<QgsPointXY> res = engine.randomPointsInPolygon( count, [](
const QgsPointXY & ) {
return true; }, seed, feedback, 0 );
3614 mLastError = engine.lastError();
3621 return d->geometry ? d->geometry->wkbSize( flags ) : 0;
3626 return d->geometry ? d->geometry->asWkb( flags ) : QByteArray();
3631 QVector<QgsGeometry> geometryList;
3634 return geometryList;
3641 geometryList.reserve( numGeom );
3642 for (
int i = 0; i < numGeom; ++i )
3649 geometryList.append( *
this );
3652 return geometryList;
3668 if ( collection->numGeometries() > 0 )
3669 part = collection->geometryN( 0 );
3675 return curve->asQPolygonF();
3677 return polygon->exteriorRing() ? polygon->exteriorRing()->asQPolygonF() : QPolygonF();
3720 bool haveInvalidGeometry =
false;
3721 bool geomModified =
false;
3726 reset( std::move( diffGeom ) );
3727 geomModified =
true;
3730 if ( geomTypeBeforeModification !=
wkbType() )
3732 if ( haveInvalidGeometry )
3734 if ( !geomModified )
3779 std::unique_ptr< QgsAbstractGeometry > g(
geos.makeValid( method, keepCollapsed, &mLastError, feedback ) );
3782 result.mLastError = mLastError;
3833 std::unique_ptr< QgsCurvePolygon > corrected( cp->clone() );
3834 corrected->forceClockwise();
3835 newCollection->addGeometry( corrected.release() );
3839 newCollection->addGeometry( g->
clone() );
3848 std::unique_ptr< QgsCurvePolygon > corrected( cp->clone() );
3849 corrected->forceClockwise();
3875 std::unique_ptr< QgsCurvePolygon > corrected( cp->clone() );
3876 corrected->forceCounterClockwise();
3877 newCollection->addGeometry( corrected.release() );
3881 newCollection->addGeometry( g->
clone() );
3890 std::unique_ptr< QgsCurvePolygon > corrected( cp->clone() );
3891 corrected->forceCounterClockwise();
3946 const QgsSfcgalGeometry sfcgalGeom( d->geometry.get() );
3947 if ( !QgsSfcgalEngine::isValid( sfcgalGeom.sfcgalGeometry().get(),
nullptr, &errorMsg, &errorLoc ) )
3961 throw QgsNotSupportedException( u
"This operation requires a QGIS installation with SFCGAL support enabled. Please use a version of QGIS that includes SFCGAL."_s );
3975 d->geometry->normalize();
3985 return d->geometry->isValid( mLastError, flags );
3995 return geos.isSimple( &mLastError );
4017 if ( !d->geometry || g.
isNull() )
4037 return *d->geometry == *g.d->
geometry;
4040 if ( d->geometry->boundingBox() != g.d->
geometry->boundingBox() )
4045 return geos.isFuzzyEqual( g.d->
geometry.get(), 1e-8, &mLastError );
4051 if ( ( !d->geometry->is3D() && d->geometry->boundingBox() != g.d->
geometry->boundingBox() ) || ( d->geometry->is3D() && d->geometry->boundingBox3D() != g.d->
geometry->boundingBox3D() ) )
4055 return *d->geometry == *g.d->
geometry;
4063 if ( !d->geometry || !g.d->
geometry )
4082 if ( d->geometry->boundingBox() != g.d->
geometry->boundingBox() )
4086 return geos.isEqual( g.d->
geometry.get(), &mLastError );
4097 if ( !d->geometry || g.
isNull() )
4116 return geos.isFuzzyEqual( g.d->
geometry.get(), epsilon, &mLastError );
4122 return d->geometry->fuzzyEqual( *g.d->
geometry, epsilon );
4133 std::unique_ptr< QgsAbstractGeometry > geom(
geos.combine( geometries, &error, parameters, feedback ) );
4135 result.mLastError = error;
4141 QVector<const QgsAbstractGeometry *> geomV2List;
4144 if ( !( g.isNull() ) )
4146 geomV2List.append( g.constGet() );
4152 result.mLastError = error;
4163 std::unique_ptr< QgsAbstractGeometry > straightGeom( d->geometry->segmentize( tolerance, toleranceType ) );
4164 reset( std::move( straightGeom ) );
4174 return d->geometry->hasCurvedSegments();
4185 d->geometry->transform( ct, direction, transformZ );
4197 d->geometry->transform( ct, zTranslate, zScale, mTranslate, mScale );
4206 d->geometry->transform( mtp.
transform() );
4212 if ( !d->geometry || rectangle.
isNull() || rectangle.
isEmpty() )
4219 std::unique_ptr< QgsAbstractGeometry > resultGeom =
geos.clip( rectangle, &mLastError, feedback );
4223 result.mLastError = mLastError;
4233 d->geometry->draw( p );
4237static bool vertexIndexInfo(
const QgsAbstractGeometry *g,
int vertexIndex,
int &partIndex,
int &ringIndex,
int &vertex )
4239 if ( vertexIndex < 0 )
4245 for (
int i = 0; i < geomCollection->numGeometries(); ++i )
4251 for (
int k = 0; k < part->
ringCount(); ++k )
4254 if ( vertexIndex < numPoints )
4257 return vertexIndexInfo( part, vertexIndex, nothing, ringIndex, vertex );
4259 vertexIndex -= numPoints;
4267 for (
int i = 0; i < polySurface->numPatches(); ++i )
4269 const QgsPolygon *patch = polySurface->patchN( i );
4272 for (
int k = 0; k < patch->
ringCount(); ++k )
4275 if ( vertexIndex < numPoints )
4278 return vertexIndexInfo( patch, vertexIndex, nothing, ringIndex, vertex );
4280 vertexIndex -= numPoints;
4286 const QgsCurve *ring = curvePolygon->exteriorRing();
4287 if ( vertexIndex < ring->numPoints() )
4291 vertex = vertexIndex;
4296 for (
int i = 0; i < curvePolygon->numInteriorRings(); ++i )
4298 const QgsCurve *ring = curvePolygon->interiorRing( i );
4299 if ( vertexIndex < ring->numPoints() )
4302 vertex = vertexIndex;
4311 if ( vertexIndex < curve->numPoints() )
4315 vertex = vertexIndex;
4321 if ( vertexIndex == 0 )
4342 bool res = vertexIndexInfo( d->geometry.get(), nr,
id.part,
id.ring,
id.vertex );
4350 g = geomCollection->geometryN(
id.part );
4354 g = polySurface->patchN(
id.part );
4359 g =
id.ring == 0 ? curvePolygon->exteriorRing() : curvePolygon->interiorRing(
id.ring - 1 );
4365 res = curve->pointAt(
id.vertex, p,
id.
type );
4394 d->geometry->filterVertices( filter );
4404 d->geometry->transformVertices(
transform );
4432 std::unique_ptr< QgsLineString > segmentizedLine;
4434 if ( doSegmentation )
4437 line = segmentizedLine.get();
4449 res.resize( nVertices );
4450 QgsPointXY *data = res.data();
4451 const double *xData = line->
xData();
4452 const double *yData = line->
yData();
4453 for (
int i = 0; i < nVertices; ++i )
4455 data->
setX( *xData++ );
4456 data->
setY( *yData++ );
4464 output.push_back( convertRing( exterior ) );
4468 output.reserve( output.size() + interiorRingCount );
4469 for (
int n = 0; n < interiorRingCount; ++n )
4471 output.push_back( convertRing( input.
interiorRing( n ) ) );
4477 return QgsGeometry( std::make_unique< QgsPoint >( point.x(), point.y() ) );
4484 if ( polygon.isClosed() )
4486 auto poly = std::make_unique< QgsPolygon >();
4487 poly->setExteriorRing( ring.release() );
4508 result.reserve( polygon.count() );
4509 for (
const QPointF &p : polygon )
4518 if ( p1.count() != p2.count() )
4521 for (
int i = 0; i < p1.count(); ++i )
4523 if ( !p1.at( i ).compare( p2.at( i ), epsilon ) )
4531 if ( p1.count() != p2.count() )
4534 for (
int i = 0; i < p1.count(); ++i )
4545 if ( p1.count() != p2.count() )
4548 for (
int i = 0; i < p1.count(); ++i )
4558 if ( !d->geometry || d->geometry->isEmpty() )
4575 return QgsGeometry( smoothLine( *lineString, iterations, offset, minimumDistance, maxAngle ) );
4582 auto resultMultiline = std::make_unique< QgsMultiLineString>();
4583 resultMultiline->reserve( inputMultiLine->
numGeometries() );
4586 resultMultiline->addGeometry( smoothLine( *( inputMultiLine->
lineStringN( i ) ), iterations, offset, minimumDistance, maxAngle ).release() );
4588 return QgsGeometry( std::move( resultMultiline ) );
4594 return QgsGeometry( smoothPolygon( *poly, iterations, offset, minimumDistance, maxAngle ) );
4601 auto resultMultiPoly = std::make_unique< QgsMultiPolygon >();
4602 resultMultiPoly->reserve( inputMultiPoly->
numGeometries() );
4605 resultMultiPoly->addGeometry( smoothPolygon( *( inputMultiPoly->
polygonN( i ) ), iterations, offset, minimumDistance, maxAngle ).release() );
4607 return QgsGeometry( std::move( resultMultiPoly ) );
4616std::unique_ptr< QgsLineString >
smoothCurve(
const QgsLineString &line,
const unsigned int iterations,
const double offset,
double squareDistThreshold,
double maxAngleRads,
bool isRing )
4618 auto result = std::make_unique< QgsLineString >( line );
4620 for (
unsigned int iteration = 0; iteration < iterations; ++iteration )
4622 outputLine.resize( 0 );
4623 outputLine.reserve( 2 * ( result->numPoints() - 1 ) );
4624 bool skipFirst =
false;
4625 bool skipLast =
false;
4628 QgsPoint p1 = result->pointN( result->numPoints() - 2 );
4632 angle = std::fabs( M_PI - angle );
4633 skipFirst = angle > maxAngleRads;
4635 for (
int i = 0; i < result->numPoints() - 1; i++ )
4638 QgsPoint p2 = result->pointN( i + 1 );
4640 double angle = M_PI;
4641 if ( i == 0 && isRing )
4643 QgsPoint p3 = result->pointN( result->numPoints() - 2 );
4646 else if ( i < result->numPoints() - 2 )
4648 QgsPoint p3 = result->pointN( i + 2 );
4651 else if ( i == result->numPoints() - 2 && isRing )
4657 skipLast = angle < M_PI - maxAngleRads || angle > M_PI + maxAngleRads;
4684 skipFirst = skipLast;
4687 if ( isRing && outputLine.at( 0 ) != outputLine.at( outputLine.count() - 1 ) )
4688 outputLine << outputLine.at( 0 );
4690 result->setPoints( outputLine );
4695std::unique_ptr<QgsLineString> QgsGeometry::smoothLine(
const QgsLineString &line,
const unsigned int iterations,
const double offset,
double minimumDistance,
double maxAngle )
const
4697 double maxAngleRads = maxAngle * M_PI / 180.0;
4698 double squareDistThreshold = minimumDistance > 0 ? minimumDistance * minimumDistance : -1;
4699 return smoothCurve( line, iterations, offset, squareDistThreshold, maxAngleRads,
false );
4702std::unique_ptr<QgsPolygon> QgsGeometry::smoothPolygon(
const QgsPolygon &polygon,
const unsigned int iterations,
const double offset,
double minimumDistance,
double maxAngle )
const
4704 double maxAngleRads = maxAngle * M_PI / 180.0;
4705 double squareDistThreshold = minimumDistance > 0 ? minimumDistance * minimumDistance : -1;
4706 auto resultPoly = std::make_unique< QgsPolygon >();
4708 resultPoly->setExteriorRing(
smoothCurve( *(
static_cast< const QgsLineString *
>( polygon.
exteriorRing() ) ), iterations, offset, squareDistThreshold, maxAngleRads,
true ).release() );
4712 resultPoly->addInteriorRing(
smoothCurve( *(
static_cast< const QgsLineString *
>( polygon.
interiorRing( i ) ) ), iterations, offset, squareDistThreshold, maxAngleRads,
true ).release() );
4717QgsGeometry QgsGeometry::convertToPoint(
bool destMultipart )
const
4725 if ( ( destMultipart && srcIsMultipart ) || ( !destMultipart && !srcIsMultipart ) )
4730 if ( destMultipart )
4739 if ( multiPoint.count() == 1 )
4750 if ( !destMultipart )
4759 for (
const QgsPointXY &p : l )
4767 if ( !line.isEmpty() )
4776 if ( !destMultipart )
4786 for (
const QgsPointXY &pt : line )
4796 for (
const QgsPointXY &pt : line )
4807QgsGeometry QgsGeometry::convertToLine(
bool destMultipart )
const
4817 if ( multiPoint.count() < 2 )
4820 if ( destMultipart )
4830 if ( ( destMultipart && srcIsMultipart ) || ( !destMultipart && !srcIsMultipart ) )
4835 if ( destMultipart )
4839 if ( !line.isEmpty() )
4846 if ( inputMultiLine.count() == 1 )
4861 inputMultiLine << line;
4863 if ( destMultipart )
4868 else if ( inputMultiLine.count() == 1 )
4879 if ( polygon.count() > 1 )
4883 if ( destMultipart )
4887 inputMultiLine.reserve( polygon.count() );
4889 inputMultiLine << line;
4894 else if ( polygon.count() == 1 )
4896 if ( destMultipart )
4914QgsGeometry QgsGeometry::convertToPolygon(
bool destMultipart )
const
4924 if ( multiPoint.count() < 3 )
4927 if ( multiPoint.last() != multiPoint.first() )
4928 multiPoint << multiPoint.first();
4931 if ( destMultipart )
4944 for ( QgsMultiPolylineXY::iterator multiLineIt = inputMultiLine.begin(); multiLineIt != inputMultiLine.end(); ++multiLineIt )
4947 if ( ( *multiLineIt ).count() < 3 )
4949 if ( ( *multiLineIt ).count() == 3 && ( *multiLineIt ).first() == ( *multiLineIt ).last() )
4953 if ( ( *multiLineIt ).first() != ( *multiLineIt ).last() )
4954 *multiLineIt << ( *multiLineIt ).first();
4958 if ( !multiPolygon.isEmpty() )
4960 if ( destMultipart )
4964 else if ( multiPolygon.count() == 1 )
4977 if ( line.count() < 3 )
4979 if ( line.count() == 3 && line.first() == line.last() )
4983 if ( line.first() != line.last() )
4984 line << line.first();
4987 if ( destMultipart )
5003 if ( ( destMultipart && srcIsMultipart ) || ( !destMultipart && !srcIsMultipart ) )
5008 if ( destMultipart )
5012 if ( !polygon.isEmpty() )
5018 if ( multiPolygon.count() == 1 )
5034 return new QgsGeos( geometry, precision, flags );
5039 out << geometry.
asWkb();
5045 QByteArray byteArray;
5047 if ( byteArray.isEmpty() )
5049 geometry.
set(
nullptr );
5053 geometry.
fromWkb( byteArray );
5070 return mHasLocation;
5078 mLastError = u
"Operation '%1' needs non-null geometry."_s.arg(
qgsEnumValueToKey( op ) );
5084 int modifiedPart = -1;
5085 int modifiedRing = -1;
5089 mLastError = u
"Invalid vertex index"_s;
5092 int resolvedVertexIndex = vertexId.
vertex;
5093 QgsMultiCurve *inputMultiCurve =
nullptr;
5094 QgsMultiSurface *inputMultiSurface =
nullptr;
5101 modifiedPart = vertexId.
part;
5104 curve =
dynamic_cast<QgsCurve *
>( inputMultiCurve->
curveN( modifiedPart ) );
5108 curve =
dynamic_cast<QgsCurve *
>( d->geometry.get() );
5113 QgsCurvePolygon *poly =
nullptr;
5116 modifiedPart = vertexId.
part;
5119 poly =
dynamic_cast<QgsCurvePolygon *
>( inputMultiSurface->
surfaceN( modifiedPart ) );
5127 mLastError = u
"Could not get polygon geometry."_s;
5132 modifiedRing = vertexId.
ring;
5133 if ( modifiedRing == 0 )
5143 mLastError = u
"Operation '%1' needs curve geometry."_s.arg(
qgsEnumValueToKey( op ) );
5147 std::unique_ptr<QgsAbstractGeometry> result;
5155 catch ( QgsInvalidArgumentException &e )
5157 mLastError = u
"%1 Requested vertex: %2 was resolved as: [part: %3, ring: %4, vertex: %5]"_s
5160 .arg( modifiedPart )
5161 .arg( modifiedRing )
5162 .arg( resolvedVertexIndex );
5168 mLastError = u
"Operation '%1' generates a null geometry."_s.arg(
qgsEnumValueToKey( op ) );
5172 if ( result->isEmpty() )
5176 auto updatePolygon = [](
const QgsCurvePolygon *inputPoly, QgsAbstractGeometry *result,
int modifiedRing ) -> std::unique_ptr<QgsCurvePolygon> {
5177 auto newPoly = std::make_unique<QgsCurvePolygon>();
5179 newPoly = std::make_unique<QgsPolygon>();
5181 for (
int ringIndex = 0; ringIndex < inputPoly->
numInteriorRings() + 1; ++ringIndex )
5183 if ( ringIndex == modifiedRing )
5185 for ( QgsAbstractGeometry::part_iterator resPartIte = result->parts_begin(); resPartIte != result->parts_end(); ++resPartIte )
5187 if ( ringIndex == 0 && resPartIte == result->parts_begin() )
5195 if ( ringIndex == 0 )
5204 std::unique_ptr<QgsAbstractGeometry> finalGeom;
5207 if ( modifiedPart >= 0 )
5209 auto newMultiCurve = std::make_unique<QgsMultiCurve>();
5211 newMultiCurve = std::make_unique<QgsMultiLineString>();
5214 for ( QgsMultiCurve::part_iterator partIte = inputMultiCurve->
parts_begin(); partIte != inputMultiCurve->
parts_end(); ++partIte )
5216 if ( partIndex == modifiedPart )
5218 for ( QgsAbstractGeometry::part_iterator resPartIte = result->parts_begin(); resPartIte != result->parts_end(); ++resPartIte )
5220 newMultiCurve->addGeometry( ( *resPartIte )->clone() );
5225 newMultiCurve->addGeometry( ( *partIte )->clone() );
5229 finalGeom = std::move( newMultiCurve );
5234 finalGeom = std::move( result );
5240 if ( modifiedPart >= 0 )
5242 auto newMultiSurface = std::make_unique<QgsMultiSurface>();
5244 newMultiSurface = std::make_unique<QgsMultiPolygon>();
5247 for ( QgsAbstractGeometry::part_iterator partIte = inputMultiSurface->
parts_begin(); partIte != inputMultiSurface->
parts_end(); ++partIte )
5249 if ( partIndex == modifiedPart )
5252 newMultiSurface->addGeometry( newCurvePoly.release() );
5256 newMultiSurface->addGeometry( ( *partIte )->clone() );
5260 finalGeom = std::move( newMultiSurface );
5265 finalGeom = std::move( newCurvePoly );
5269 QgsGeometry finalResult( std::move( finalGeom ) );
5271 QgsDebugMsgLevel( u
"Final result Wkt: %1"_s.arg( finalResult.asWkt( 2 ) ), 3 );
5311QVector< QgsGeometry > QgsGeometry::collectSplitFeatures(
const QVector< QgsGeometry> newGeoms )
const
5313 QVector< QgsGeometry> collectedNewGeoms;
5314 QVector< QgsGeometry> unchangedParts;
5318 bool inOriginalCollection =
false;
5322 if ( newGeom.isExactlyEqual( originalPart ) )
5324 inOriginalCollection =
true;
5328 if ( inOriginalCollection )
5330 unchangedParts.append( newGeom );
5335 newGeom.convertToMultiType();
5336 collectedNewGeoms.append( newGeom );
5341 if ( !unchangedParts.empty() )
5345 return collectedNewGeoms;
5348QVector< QgsGeometry > QgsGeometry::collectSplitParts(
const QVector< QgsGeometry> newGeoms )
const
5350 QVector< QgsGeometry> collectedNewGeoms;
5355 return collectedNewGeoms;
5358QVector< QgsGeometry > QgsGeometry::collectSplitGeometries(
const QVector< QgsGeometry> newGeomsTemp,
const bool splitFeature )
5360 QVector< QgsGeometry> newGeoms;
5361 if ( !newGeomsTemp.isEmpty() )
5365 newGeoms = splitFeature ? collectSplitFeatures( newGeomsTemp ) : collectSplitParts( newGeomsTemp );
5369 newGeoms = newGeomsTemp;
5372 if ( splitFeature && !newGeoms.isEmpty() )
5374 *
this = newGeoms.takeAt( 0 );
GeometryBackend
Geometry backend for QgsGeometry.
@ GEOS
Use GEOS implementation.
@ QGIS
Use internal implementation.
@ AllowSelfTouchingHoles
Indicates that self-touching holes are permitted. OGC validity states that self-touching holes are NO...
BufferSide
Side of line to buffer.
DashPatternSizeAdjustment
Dash pattern size adjustment options.
AngularDirection
Angular directions.
@ NoOrientation
Unknown orientation or sentinel value.
GeometryOperationResult
Success or failure of a geometry operation.
@ AddPartSelectedGeometryNotFound
The selected geometry cannot be found.
@ InvalidInputGeometryType
The input geometry (ring, part, split line, etc.) has not the correct geometry type.
@ Success
Operation succeeded.
@ SelectionIsEmpty
No features were selected.
@ GeometryTypeHasChanged
Operation has changed geometry type.
@ AddRingNotInExistingFeature
The input ring doesn't have any existing ring to fit into.
@ AddRingCrossesExistingRings
The input ring crosses existing rings (it is not disjoint).
@ AddPartNotMultiGeometry
The source geometry is not multi.
@ AddRingNotClosed
The input ring is not closed.
@ SelectionIsGreaterThanOne
More than one features were selected.
@ SplitCannotSplitPoint
Cannot split points.
@ GeometryEngineError
Geometry engine misses a method implemented or an error occurred in the geometry engine.
@ NothingHappened
Nothing happened, without any error.
@ InvalidBaseGeometry
The base geometry on which the operation is done is invalid or empty.
@ LayerNotEditable
Cannot edit layer.
@ AddRingNotValid
The input ring is not valid.
QFlags< GeometryValidityFlag > GeometryValidityFlags
Geometry validity flags.
@ Segment
The actual start or end point of a segment.
GeometryValidationEngine
Available engines for validating geometries.
@ QgisInternal
Use internal QgsGeometryValidator method.
@ Sfcgal
Use SFCGAL validation methods. Only available for QGIS builds with SFCGAL support enabled.
@ Geos
Use GEOS validation methods.
QFlags< GeosCreationFlag > GeosCreationFlags
Geos geometry creation behavior flags.
GeoJsonProfile
GeoJson export Profile according to OGC Features and Geometries JSON - Part 1: Core https://docs....
@ Rfc7946
GeoJson profile compliant with RFC7946 standard "http://www.opengis.net/def/profile/OGC/0/rfc7946".
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
JoinStyle
Join styles for buffers.
EndCapStyle
End cap styles for buffers.
CoverageValidityResult
Coverage validity results.
@ Error
An exception occurred while determining validity.
DashPatternLineEndingRule
Dash pattern line ending rules.
MakeValidMethod
Algorithms to use when repairing invalid geometries.
WkbType
The WKB type describes the number of dimensions a geometry has.
@ CompoundCurve
CompoundCurve.
@ MultiPolygon
MultiPolygon.
@ MultiLineString
MultiLineString.
@ CircularString
CircularString.
@ GeometryCollection
GeometryCollection.
@ CurvePolygon
CurvePolygon.
@ PolyhedralSurface
PolyhedralSurface.
@ MultiSurface
MultiSurface.
TransformDirection
Indicates the direction (forward or inverse) of a transform.
The part_iterator class provides an STL-style iterator for const references to geometry parts.
The part_iterator class provides an STL-style iterator for geometry parts.
The vertex_iterator class provides an STL-style iterator for vertices.
Abstract base class for all geometries.
virtual int ringCount(int part=0) const =0
Returns the number of rings of which this geometry is built.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
virtual bool moveVertex(QgsVertexId position, const QgsPoint &newPos)=0
Moves a vertex within the geometry.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
virtual int vertexNumberFromVertexId(QgsVertexId id) const =0
Returns the vertex number corresponding to a vertex id.
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
virtual const QgsAbstractGeometry * simplifiedTypeRef() const
Returns a reference to the simplest lossless representation of this geometry, e.g.
virtual QgsAbstractGeometry * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves.
virtual int vertexCount(int part=0, int ring=0) const =0
Returns the number of vertices of which this geometry is built.
bool isMeasure() const
Returns true if the geometry contains m values.
QFlags< WkbFlag > WkbFlags
virtual QgsRectangle boundingBox() const
Returns the minimal bounding box for the geometry.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
virtual QgsAbstractGeometry * toCurveType() const =0
Returns the geometry converted to the more generic curve type.
virtual void adjacentVertices(QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex) const =0
Returns the vertices adjacent to a specified vertex within a geometry.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
virtual bool deleteVertex(QgsVertexId position)
Deletes a vertex within the geometry.
part_iterator parts_end()
Returns STL-style iterator pointing to the imaginary part after the last part of the geometry.
virtual double length() const
Returns the planar, 2-dimensional length of the geometry.
virtual bool isEmpty() const
Returns true if the geometry is empty.
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
virtual int dimension() const =0
Returns the inherent dimension of the geometry.
part_iterator parts_begin()
Returns STL-style iterator pointing to the first part of the geometry.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
A 3-dimensional box composed of x, y, z coordinates.
double yMaximum() const
Returns the maximum y value.
double xMinimum() const
Returns the minimum x value.
double zMaximum() const
Returns the maximum z value.
double xMaximum() const
Returns the maximum x value.
QgsRectangle toRectangle() const
Converts the box to a 2D rectangle.
bool is2d() const
Returns true if the box can be considered a 2-dimensional box, i.e.
double zMinimum() const
Returns the minimum z value.
double yMinimum() const
Returns the minimum y value.
static QgsCircle from2Points(const QgsPoint &pt1, const QgsPoint &pt2)
Constructs a circle by 2 points on the circle.
double radius() const
Returns the radius of the circle.
std::unique_ptr< QgsCircularString > toCircularString(bool oriented=false) const
Returns a circular string from the circle.
bool contains(const QgsPoint &point, double epsilon=1E-8) const
Returns true if the circle contains the point.
static QgsCircle minimalCircleFrom3Points(const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double epsilon=1E-8)
Constructs the smallest circle from 3 points.
Circular string geometry type.
static QgsCircularString fromTwoPointsAndCenter(const QgsPoint &p1, const QgsPoint &p2, const QgsPoint ¢er, bool useShortestArc=true)
Creates a circular string with a single arc representing the curve from p1 to p2 with the specified c...
Compound curve geometry type.
bool toggleCircularAtVertex(QgsVertexId position)
Converts the vertex at the given position from/to circular.
void addCurve(QgsCurve *c, bool extendPrevious=false)
Adds a curve to the geometry (takes ownership).
Encapsulates parameters for a coverage cleaning operation.
Curve polygon geometry type.
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
int vertexCount(int part=0, int ring=0) const override
Returns the number of vertices of which this geometry is built.
virtual QgsPolygon * toPolygon(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a new polygon geometry corresponding to a segmentized approximation of the curve.
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
virtual void setExteriorRing(QgsCurve *ring)
Sets the exterior ring of the polygon.
virtual void addInteriorRing(QgsCurve *ring)
Adds an interior ring to the geometry (takes ownership).
int ringCount(int part=0) const override
Returns the number of rings of which this geometry is built.
bool removeInteriorRing(int ringIndex)
Removes an interior ring from the polygon.
Abstract base class for curved geometry type.
virtual int numPoints() const =0
Returns the number of points in the curve.
QgsCurve * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
virtual QgsPoint * interpolatePoint(double distance) const =0
Returns an interpolated point on the curve at the specified distance.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
virtual void points(QgsPointSequence &pt) const =0
Returns a list of points within the curve.
virtual QgsLineString * curveToLine(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const =0
Returns a new line string geometry corresponding to a segmentized approximation of the curve.
virtual QgsPolygon * toPolygon(unsigned int segments=36) const
Returns a segmented polygon.
QgsPoint center() const
Returns the center point.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
virtual bool insertGeometry(QgsAbstractGeometry *g, int index)
Inserts a geometry before a specified index and takes ownership.
virtual bool removeGeometry(int nr)
Removes a geometry from the collection.
QgsGeometryCollection * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
int partCount() const override
Returns count of parts contained in the geometry.
int numGeometries() const
Returns the number of geometries within the collection.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
Java-style iterator for const traversal of parts of a geometry.
static Qgis::GeometryOperationResult addRing(QgsAbstractGeometry *geometry, std::unique_ptr< QgsCurve > ring)
Add an interior ring to a geometry.
static std::unique_ptr< QgsAbstractGeometry > avoidIntersections(const QgsAbstractGeometry &geom, const QList< QgsVectorLayer * > &avoidIntersectionsLayers, bool &haveInvalidGeometry, const QHash< QgsVectorLayer *, QSet< QgsFeatureId > > &ignoreFeatures=(QHash< QgsVectorLayer *, QSet< QgsFeatureId > >()))
Alters a geometry so that it avoids intersections with features from all open vector layers.
static bool deletePart(QgsAbstractGeometry *geom, int partNum)
Deletes a part from a geometry.
static bool deleteRing(QgsAbstractGeometry *geom, int ringNum, int partNum=0)
Deletes a ring from a geometry.
static Qgis::GeometryOperationResult addPart(QgsAbstractGeometry *geometry, std::unique_ptr< QgsAbstractGeometry > part)
Add a part to multi type geometry.
A geometry engine is a low-level representation of a QgsAbstractGeometry object, optimised for use wi...
EngineOperationResult
Success or failure of a geometry operation.
@ NothingHappened
Nothing happened, without any error.
@ InvalidBaseGeometry
The geometry on which the operation occurs is not valid.
@ InvalidInput
The input is not valid.
@ NodedGeometryError
Error occurred while creating a noded geometry.
@ EngineError
Error occurred in the geometry engine.
@ SplitCannotSplitPoint
Points cannot be split.
@ Success
Operation succeeded.
@ MethodNotImplemented
Method not implemented in geometry engine.
static std::unique_ptr< QgsMultiPolygon > fromMultiPolygonXY(const QgsMultiPolygonXY &multipoly)
Construct geometry from a multipolygon.
static std::unique_ptr< QgsAbstractGeometry > geomFromWkb(QgsConstWkbPtr &wkb)
Construct geometry from a WKB string.
static std::unique_ptr< QgsGeometryCollection > createCollectionOfType(Qgis::WkbType type)
Returns a new geometry collection matching a specified WKB type.
static std::unique_ptr< QgsAbstractGeometry > fromPolylineXY(const QgsPolylineXY &polyline)
Construct geometry from a polyline.
static std::unique_ptr< QgsMultiPoint > fromMultiPointXY(const QgsMultiPointXY &multipoint)
Construct geometry from a multipoint.
static std::unique_ptr< QgsAbstractGeometry > geomFromWkt(const QString &text)
Construct geometry from a WKT string.
static std::unique_ptr< QgsMultiLineString > fromMultiPolylineXY(const QgsMultiPolylineXY &multiline)
Construct geometry from a multipolyline.
static std::unique_ptr< QgsAbstractGeometry > fromPointXY(const QgsPointXY &point)
Construct geometry from a point.
static std::unique_ptr< QgsPolygon > fromPolygonXY(const QgsPolygonXY &polygon)
Construct geometry from a polygon.
static std::unique_ptr< QgsAbstractGeometry > geomFromWkbType(Qgis::WkbType t)
Returns empty geometry from wkb type.
Encapsulates parameters under which a geometry operation is performed.
Java-style iterator for traversal of parts of a geometry.
static double angleBetweenThreePoints(double x1, double y1, double x2, double y2, double x3, double y3)
Calculates the angle between the lines AB and BC, where AB and BC described by points a,...
static double lineAngle(double x1, double y1, double x2, double y2)
Calculates the direction of line joining two points in radians, clockwise from the north direction.
static double averageAngle(double x1, double y1, double x2, double y2, double x3, double y3)
Calculates the average angle (in radians) between the two linear segments from (x1,...
static double normalizedAngle(double angle)
Ensures that an angle is in the range 0 <= angle < 2 pi.
static std::unique_ptr< QgsLineString > createChamferGeometry(const QgsPoint &segment1Start, const QgsPoint &segment1End, const QgsPoint &segment2Start, const QgsPoint &segment2End, double distance1, double distance2)
Creates a complete chamfer geometry connecting two segments.
static QgsPointXY interpolatePointOnLine(double x1, double y1, double x2, double y2, double fraction)
Interpolates the position of a point a fraction of the way along the line from (x1,...
static std::unique_ptr< QgsAbstractGeometry > createFilletGeometry(const QgsPoint &segment1Start, const QgsPoint &segment1End, const QgsPoint &segment2Start, const QgsPoint &segment2End, double radius, int segments)
Creates a complete fillet geometry connecting two segments.
static QgsPoint interpolatePointOnSegment(double x, double y, const QgsPoint &segmentStart, const QgsPoint &segmentEnd)
Interpolates a point on a segment with proper Z and M value interpolation.
static bool verticesAtDistance(const QgsAbstractGeometry &geometry, double distance, QgsVertexId &previousVertex, QgsVertexId &nextVertex)
Retrieves the vertices which are before and after the interpolated point at a specified distance alon...
static double distanceToVertex(const QgsAbstractGeometry &geom, QgsVertexId id)
Returns the distance along a geometry from its first vertex to the specified vertex.
static QgsPoint closestVertex(const QgsAbstractGeometry &geom, const QgsPoint &pt, QgsVertexId &id)
Returns the closest vertex to a geometry for a specified point.
static Q_DECL_DEPRECATED double sqrDistance2D(double x1, double y1, double x2, double y2)
Returns the squared 2D distance between (x1, y1) and (x2, y2).
static std::unique_ptr< QgsAbstractGeometry > chamferVertex(const QgsCurve *curve, int vertexIndex, double distance1, double distance2)
Applies chamfer to a vertex in a curve geometry.
static std::unique_ptr< QgsAbstractGeometry > filletVertex(const QgsCurve *curve, int vertexIndex, double radius, int segments)
Applies fillet to a vertex in a curve geometry.
static void validateGeometry(const QgsGeometry &geometry, QVector< QgsGeometry::Error > &errors, Qgis::GeometryValidationEngine method=Qgis::GeometryValidationEngine::QgisInternal)
Validate geometry and produce a list of geometry errors.
bool hasWhere() const
true if the location available from
QgsPointXY where() const
The coordinates at which the error is located and should be visualized.
QString what() const
A human readable error message containing details about the error.
A geometry is the spatial representation of a feature.
Q_DECL_DEPRECATED QgsGeometry makeDifference(const QgsGeometry &other, QgsFeedback *feedback=nullptr) const
Returns the geometry formed by modifying this geometry such that it does not intersect the other geom...
QPolygonF asQPolygonF() const
Returns contents of the geometry as a QPolygonF.
double closestSegmentWithContext(const QgsPointXY &point, QgsPointXY &minDistPoint, int &nextVertexIndex, int *leftOrRightOfSegment=nullptr, double epsilon=Qgis::DEFAULT_SEGMENT_EPSILON) const
Searches for the closest segment of geometry to the given point.
bool deleteRing(int ringNum, int partNum=0)
Deletes a ring in polygon or multipolygon.
QVector< QgsPointXY > randomPointsInPolygon(int count, const std::function< bool(const QgsPointXY &) > &acceptPoint, unsigned long seed=0, QgsFeedback *feedback=nullptr, int maxTriesPerPoint=0) const
Returns a list of count random points generated inside a (multi)polygon geometry (if acceptPoint is s...
double hausdorffDistanceDensify(const QgsGeometry &geom, double densifyFraction) const
Returns the Hausdorff distance between this geometry and geom.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
double area3D() const
Returns the 3-dimensional surface area of the geometry.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
double lineLocatePoint(const QgsGeometry &point) const
Returns a distance representing the location along this linestring of the closest point on this lines...
QgsGeometry intersection(const QgsGeometry &geometry, const QgsGeometryParameters ¶meters=QgsGeometryParameters(), QgsFeedback *feedback=nullptr) const
Returns a geometry representing the points shared by this geometry and other.
void adjacentVertices(int atVertex, int &beforeVertex, int &afterVertex) const
Returns the indexes of the vertices before and after the given vertex index.
QgsMultiPolygonXY asMultiPolygon() const
Returns the contents of the geometry as a multi-polygon.
QgsGeometry concaveHullOfPolygons(double lengthRatio, bool allowHoles=false, bool isTight=false, QgsFeedback *feedback=nullptr) const
Constructs a concave hull of a set of polygons, respecting the polygons as constraints.
QgsGeometry chamfer(int vertexIndex, double distance1, double distance2=-1.0) const
Creates a chamfer (angled corner) at the specified vertex.
bool deleteVertex(int atVertex)
Deletes the vertex at the given position number and item (first number is index 0).
double length() const
Returns the planar, 2-dimensional length of geometry.
QgsGeometry offsetCurve(double distance, int segments, Qgis::JoinStyle joinStyle, double miterLimit) const
Returns an offset line at a given distance and side from an input line.
static bool compare(const QgsPolylineXY &p1, const QgsPolylineXY &p2, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compares two polylines for equality within a specified tolerance.
QgsVertexIterator vertices() const
Returns a read-only, Java-style iterator for traversal of vertices of all the geometry,...
QgsGeometry densifyByDistance(double distance) const
Densifies the geometry by adding regularly placed extra nodes inside each segment so that the maximum...
ChamferFilletOperationType
Privatly used in chamfer/fillet functions.
QgsGeometry poleOfInaccessibility(double precision, double *distanceToBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
QgsAbstractGeometry::const_part_iterator const_parts_begin() const
Returns STL-style const iterator pointing to the first part of the geometry.
QgsGeometry squareWaves(double wavelength, double amplitude, bool strictWavelength=false) const
Constructs square waves along the boundary of the geometry, with the specified wavelength and amplitu...
QgsGeometry concaveHull(double targetPercent, bool allowHoles=false, QgsFeedback *feedback=nullptr) const
Returns a possibly concave polygon that contains all the points in the geometry.
static QgsGeometry fromQPointF(QPointF point)
Construct geometry from a QPointF.
static QgsGeometry collectTinPatches(const QVector< QgsGeometry > &geometries)
Collects all patches from a list of TIN or Triangle geometries into a single TIN geometry.
static QgsGeometry polygonize(const QVector< QgsGeometry > &geometries)
Creates a GeometryCollection geometry containing possible polygons formed from the constituent linewo...
bool addTopologicalPoint(const QgsPoint &point, double snappingTolerance=1e-8, double segmentSearchEpsilon=1e-12)
Adds a vertex to the segment which intersect point but don't already have a vertex there.
QgsGeometry triangularWaves(double wavelength, double amplitude, bool strictWavelength=false) const
Constructs triangular waves along the boundary of the geometry, with the specified wavelength and amp...
Q_INVOKABLE bool boundingBoxIntersects(const QgsRectangle &rectangle) const
Returns true if the bounding box of this geometry intersects with a rectangle.
bool vertexIdFromVertexNr(int number, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
QgsGeometry pointOnSurface() const
Returns a point guaranteed to lie on the surface of a geometry.
Q_INVOKABLE bool touches(const QgsGeometry &geometry) const
Returns true if the geometry touches another geometry.
Q_DECL_DEPRECATED int makeDifferenceInPlace(const QgsGeometry &other, QgsFeedback *feedback=nullptr)
Changes this geometry such that it does not intersect the other geometry.
void transformVertices(const std::function< QgsPoint(const QgsPoint &) > &transform)
Transforms the vertices from the geometry in place, applying the transform function to every vertex.
bool isExactlyEqual(const QgsGeometry &geometry, Qgis::GeometryBackend backend=Qgis::GeometryBackend::QGIS) const
Compares the geometry with another geometry using the specified backend.
QgsGeometry minimumWidth() const
Returns a linestring geometry which represents the minimum diameter of the geometry.
QgsGeometry applyDashPattern(const QVector< double > &pattern, Qgis::DashPatternLineEndingRule startRule=Qgis::DashPatternLineEndingRule::NoRule, Qgis::DashPatternLineEndingRule endRule=Qgis::DashPatternLineEndingRule::NoRule, Qgis::DashPatternSizeAdjustment adjustment=Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap, double patternOffset=0) const
Applies a dash pattern to a geometry, returning a MultiLineString geometry which is the input geometr...
Qgis::CoverageValidityResult validateCoverage(double gapWidth, QgsGeometry *invalidEdges=nullptr) const
Analyze a coverage (represented as a collection of polygonal geometry with exactly matching edge geom...
QgsGeometry roundWaves(double wavelength, double amplitude, bool strictWavelength=false) const
Constructs rounded (sine-like) waves along the boundary of the geometry, with the specified wavelengt...
QgsGeometry nearestPoint(const QgsGeometry &other) const
Returns the nearest (closest) point on this geometry to another geometry.
QgsGeometry simplifyCoverageVW(double tolerance, bool preserveBoundary) const
Operates on a coverage (represented as a list of polygonal geometry with exactly matching edge geomet...
static QgsGeometry collectGeometry(const QVector< QgsGeometry > &geometries)
Creates a new multipart geometry from a list of QgsGeometry objects.
QgsGeometry fillet(int vertexIndex, double radius, int segments=8) const
Creates a fillet (rounded corner) at the specified vertex.
QgsGeometry mergeLines(const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const
Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line ...
static QgsGeometry fromMultiPolylineXY(const QgsMultiPolylineXY &multiline)
Creates a new geometry from a QgsMultiPolylineXY object.
double frechetDistance(const QgsGeometry &geom) const
Returns the Fréchet distance between this geometry and geom, restricted to discrete points for both g...
QString lastError() const
Returns an error string referring to the last error encountered either when this geometry was created...
QgsGeometry convertToType(Qgis::GeometryType destType, bool destMultipart=false) const
Try to convert the geometry to the requested type.
QgsGeometry clipped(const QgsRectangle &rectangle, QgsFeedback *feedback=nullptr)
Clips the geometry using the specified rectangle.
bool isAxisParallelRectangle(double maximumDeviation, bool simpleRectanglesOnly=false) const
Returns true if the geometry is a polygon that is almost an axis-parallel rectangle.
static QgsGeometry fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer for a (multi)linestring geometry, where the width at each node is ...
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
static QgsGeometry fromPolylineXY(const QgsPolylineXY &polyline)
Creates a new LineString geometry from a list of QgsPointXY points.
QgsMultiPointXY asMultiPoint() const
Returns the contents of the geometry as a multi-point.
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
QgsPointXY closestVertex(const QgsPointXY &point, int &closestVertexIndex, int &previousVertexIndex, int &nextVertexIndex, double &sqrDist) const
Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap ...
void normalize()
Reorganizes the geometry into a normalized form (or "canonical" form).
int wkbSize(QgsAbstractGeometry::WkbFlags flags=QgsAbstractGeometry::WkbFlags()) const
Returns the length of the QByteArray returned by asWkb().
QgsPolygonXY asPolygon() const
Returns the contents of the geometry as a polygon.
Q_INVOKABLE bool disjoint(const QgsGeometry &geometry) const
Returns true if the geometry is disjoint of another geometry.
QVector< QgsGeometry > asGeometryCollection() const
Returns contents of the geometry as a list of geometries.
QgsGeometry roundWavesRandomized(double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed=0) const
Constructs randomized rounded (sine-like) waves along the boundary of the geometry,...
double distance(const QgsGeometry &geom) const
Returns the minimum distance between this geometry and another geometry.
QgsGeometry interpolate(double distance) const
Returns an interpolated point on the geometry at the specified distance.
QgsGeometry extrude(double x, double y)
Returns an extruded version of this geometry.
static Q_DECL_DEPRECATED QgsPolylineXY createPolylineFromQPolygonF(const QPolygonF &polygon)
Creates a QgsPolylineXY from a QPolygonF.
void mapToPixel(const QgsMapToPixel &mtp)
Transforms the geometry from map units to pixels in place.
static QgsGeometry fromMultiPointXY(const QgsMultiPointXY &multipoint)
Creates a new geometry from a QgsMultiPointXY object.
virtual json asJsonObject(int precision=17, Qgis::GeoJsonProfile profile=Qgis::GeoJsonProfile::Legacy) const
Exports the geometry to a json object with the give precision and following the specified GeoJSON pro...
QgsGeometry symDifference(const QgsGeometry &geometry, const QgsGeometryParameters ¶meters=QgsGeometryParameters(), QgsFeedback *feedback=nullptr) const
Returns a geometry representing the points making up this geometry that do not make up other.
QgsGeometry singleSidedBuffer(double distance, int segments, Qgis::BufferSide side, Qgis::JoinStyle joinStyle=Qgis::JoinStyle::Round, double miterLimit=2.0) const
Returns a single sided buffer for a (multi)line geometry.
QgsAbstractGeometry * get()
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
QgsBox3D boundingBox3D() const
Returns the 3D bounding box of the geometry.
friend class QgsInternalGeometryEngine
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
static Q_INVOKABLE QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
bool contains(const QgsPointXY *p) const
Returns true if the geometry contains the point p.
QgsPolylineXY asPolyline() const
Returns the contents of the geometry as a polyline.
QgsAbstractGeometry::part_iterator parts_begin()
Returns STL-style iterator pointing to the first part of the geometry.
QgsGeometry forceRHR() const
Forces geometries to respect the Right-Hand-Rule, in which the area that is bounded by a polygon is t...
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
QgsGeometry snappedToGrid(double hSpacing, double vSpacing, double dSpacing=0, double mSpacing=0) const
Returns a new geometry with all points or vertices snapped to the closest point of the grid.
void filterVertices(const std::function< bool(const QgsPoint &) > &filter)
Filters the vertices from the geometry in place, removing any which do not return true for the filter...
Q_DECL_DEPRECATED bool equals(const QgsGeometry &geometry) const
Test if this geometry is exactly equal to another geometry.
bool isGeosValid(Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const
Checks validity of the geometry using GEOS.
bool insertVertex(double x, double y, int beforeVertex)
Insert a new vertex before the given vertex index, ring and item (first number is index 0) If the req...
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
QgsGeometry subdivide(int maxNodes=256, const QgsGeometryParameters ¶meters=QgsGeometryParameters(), QgsFeedback *feedback=nullptr) const
Subdivides the geometry.
static Q_DECL_DEPRECATED QgsPolygonXY createPolygonFromQPolygonF(const QPolygonF &polygon)
Creates a QgsPolygonXYfrom a QPolygonF.
bool convertToSingleType()
Converts multi type geometry into single type geometry e.g.
Qgis::GeometryOperationResult addRing(const QVector< QgsPointXY > &ring)
Adds a new ring to this geometry.
QgsGeometry extendLine(double startDistance, double endDistance, double startDeflection=0, double endDeflection=0) const
Extends a (multi)line geometry by extrapolating out the start or end of the line by a specified dista...
bool requiresConversionToStraightSegments() const
Returns true if the geometry is a curved geometry type which requires conversion to display as straig...
bool isSimple() const
Determines whether the geometry is simple (according to OGC definition), i.e.
static QgsGeometry fromPolyline(const QgsPolyline &polyline)
Creates a new LineString geometry from a list of QgsPoint points.
void validateGeometry(QVector< QgsGeometry::Error > &errors, Qgis::GeometryValidationEngine method=Qgis::GeometryValidationEngine::QgisInternal, Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const
Validates geometry and produces a list of geometry errors.
QgsMultiPolylineXY asMultiPolyline() const
Returns the contents of the geometry as a multi-linestring.
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a variable width buffer ("tapered buffer") for a (multi)curve geometry.
Qgis::GeometryOperationResult avoidIntersectionsV2(const QList< QgsVectorLayer * > &avoidIntersectionsLayers, const QHash< QgsVectorLayer *, QSet< QgsFeatureId > > &ignoreFeatures=(QHash< QgsVectorLayer *, QSet< QgsFeatureId > >()))
Modifies geometry to avoid intersections with the layers specified in project properties.
Q_INVOKABLE bool within(const QgsGeometry &geometry) const
Returns true if the geometry is completely within another geometry.
QPointF asQPointF() const
Returns contents of the geometry as a QPointF if wkbType is WKBPoint, otherwise returns a null QPoint...
QString asGeoJson(int precision=17, Qgis::GeoJsonProfile profile=Qgis::GeoJsonProfile::Legacy) const
Export the geometry to a GeoJSON string, with the given precision and following the specified GeoJSON...
void convertToStraightSegment(double tolerance=M_PI/180., QgsAbstractGeometry::SegmentationToleranceType toleranceType=QgsAbstractGeometry::MaximumAngle)
Converts the geometry to straight line segments, if it is a curved geometry type.
double area() const
Returns the planar, 2-dimensional area of the geometry.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
Q_INVOKABLE bool crosses(const QgsGeometry &geometry) const
Returns true if the geometry crosses another geometry.
QgsGeometry & operator=(QgsGeometry const &rhs)
Creates a shallow copy of the geometry.
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...
Qgis::AngularDirection polygonOrientation() const
Returns the orientation of the polygon.
double hausdorffDistance(const QgsGeometry &geom) const
Returns the Hausdorff distance between this geometry and geom.
QgsGeometry combine(const QgsGeometry &geometry, const QgsGeometryParameters ¶meters=QgsGeometryParameters(), QgsFeedback *feedback=nullptr) const
Returns a geometry representing all the points in this geometry and other (a union geometry operation...
bool deleteVertices(const QSet< int > &atVertices)
Deletes vertices at the given positions (first number is index 0).
QgsGeometry makeValid(Qgis::MakeValidMethod method=Qgis::MakeValidMethod::Linework, bool keepCollapsed=false, QgsFeedback *feedback=nullptr) const
Attempts to make an invalid geometry valid without losing vertices.
QgsGeometry largestEmptyCircle(double tolerance, const QgsGeometry &boundary=QgsGeometry()) const
Constructs the Largest Empty Circle for a set of obstacle geometries, up to a specified tolerance.
Q_DECL_DEPRECATED Qgis::GeometryOperationResult addPart(const QVector< QgsPointXY > &points, Qgis::GeometryType geomType=Qgis::GeometryType::Unknown)
Adds a new part to a the geometry.
static QgsGeometry unaryUnion(const QVector< QgsGeometry > &geometries, const QgsGeometryParameters ¶meters=QgsGeometryParameters(), QgsFeedback *feedback=nullptr)
Compute the unary union on a list of geometries.
QgsGeometryPartIterator parts()
Returns Java-style iterator for traversal of parts of the geometry.
QgsGeometry convertToCurves(double distanceTolerance=1e-8, double angleTolerance=1e-8) const
Attempts to convert a non-curved geometry into a curved geometry type (e.g.
QgsGeometry voronoiDiagram(const QgsGeometry &extent=QgsGeometry(), double tolerance=0.0, bool edgesOnly=false) const
Creates a Voronoi diagram for the nodes contained within the geometry.
void set(QgsAbstractGeometry *geometry)
Sets the underlying geometry store.
QgsGeometry convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry.
QgsGeometry minimumClearanceLine() const
Returns a LineString whose endpoints define the minimum clearance of a geometry.
QgsGeometry sharedPaths(const QgsGeometry &other) const
Find paths shared between the two given lineal geometries (this and other).
static QgsGeometry fromPolygonXY(const QgsPolygonXY &polygon)
Creates a new geometry from a QgsPolygonXY.
double sqrDistToVertexAt(QgsPointXY &point, int atVertex) const
Returns the squared Cartesian distance between the given point to the given vertex index (vertex at t...
void fromWkb(unsigned char *wkb, int length)
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
QgsGeometry minimalEnclosingCircle(QgsPointXY ¢er, double &radius, unsigned int segments=36) const
Returns the minimal enclosing circle for the geometry.
static QgsGeometry fromMultiPolygonXY(const QgsMultiPolygonXY &multipoly)
Creates a new geometry from a QgsMultiPolygonXY.
QgsGeometry buffer(double distance, int segments, QgsFeedback *feedback=nullptr) const
Returns a buffer region around this geometry having the given width and with a specified number of se...
QVector< QgsGeometry > coerceToType(Qgis::WkbType type, double defaultZ=0, double defaultM=0, bool avoidDuplicates=true) const
Attempts to coerce this geometry into the specified destination type.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QgsGeometry node() const
Returns a (Multi)LineString representing the fully noded version of a collection of linestrings.
double distanceToVertex(int vertex) const
Returns the distance along this geometry from its first vertex to the specified vertex.
int vertexNrFromVertexId(QgsVertexId id) const
Returns the vertex number corresponding to a vertex id.
QgsAbstractGeometry::const_part_iterator const_parts_end() const
Returns STL-style iterator pointing to the imaginary part after the last part of the geometry.
bool removeDuplicateNodes(double epsilon=4 *std::numeric_limits< double >::epsilon(), bool useZValues=false)
Removes duplicate nodes from the geometry, wherever removing the nodes does not result in a degenerat...
bool convertGeometryCollectionToSubclass(Qgis::GeometryType geomType)
Converts geometry collection to a the desired geometry type subclass (multi-point,...
QgsAbstractGeometry::part_iterator parts_end()
Returns STL-style iterator pointing to the imaginary part after the last part of the geometry.
QgsAbstractGeometry::vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
bool isFuzzyEqual(const QgsGeometry &geometry, double epsilon=1e-4, Qgis::GeometryBackend backend=Qgis::GeometryBackend::QGIS) const
Compares the geometry with another geometry within the tolerance epsilon using the specified backend.
QgsGeometry forcePolygonClockwise() const
Forces geometries to respect the exterior ring is clockwise, interior rings are counter-clockwise con...
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
QString asJson(int precision=17) const
Exports the geometry to a GeoJSON RFC7946 string.
static QgsGeometry createWedgeBuffer(const QgsPoint ¢er, double azimuth, double angularWidth, double outerRadius, double innerRadius=0)
Creates a wedge shaped buffer from a center point.
double frechetDistanceDensify(const QgsGeometry &geom, double densifyFraction) const
Returns the Fréchet distance between this geometry and geom, restricted to discrete points for both g...
QByteArray asWkb(QgsAbstractGeometry::WkbFlags flags=QgsAbstractGeometry::WkbFlags()) const
Export the geometry to WKB.
QgsGeometry unionCoverage() const
Optimized union algorithm for polygonal inputs that are correctly noded and do not overlap.
bool convertToCurvedMultiType()
Converts a geometry into a multitype geometry of curve kind (when there is a corresponding curve type...
static void convertPointList(const QVector< QgsPointXY > &input, QgsPointSequence &output)
Upgrades a point list from QgsPointXY to QgsPoint.
QgsGeometry orientedMinimumBoundingBox() const
Returns the oriented minimum bounding box for the geometry, which is the smallest (by area) rotated r...
QgsGeometry triangularWavesRandomized(double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed=0) const
Constructs randomized triangular waves along the boundary of the geometry, with the specified wavelen...
QgsGeometry squareWavesRandomized(double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed=0) const
Constructs randomized square waves along the boundary of the geometry, with the specified wavelength ...
bool isTopologicallyEqual(const QgsGeometry &geometry, Qgis::GeometryBackend backend=Qgis::GeometryBackend::GEOS) const
Compares the geometry with another geometry using the specified backend.
QgsGeometryConstPartIterator constParts() const
Returns Java-style iterator for traversal of parts of the geometry.
QgsGeometry simplify(double tolerance, QgsFeedback *feedback=nullptr) const
Returns a simplified version of this geometry using a specified tolerance value.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
Qgis::GeometryOperationResult addPartV2(const QVector< QgsPointXY > &points, Qgis::WkbType wkbType=Qgis::WkbType::Unknown)
Adds a new part to a the geometry.
double minimumClearance() const
Computes the minimum clearance of a geometry.
Qgis::GeometryOperationResult rotate(double rotation, const QgsPointXY ¢er)
Rotate this geometry around the Z axis.
Qgis::GeometryOperationResult translate(double dx, double dy, double dz=0.0, double dm=0.0)
Translates this geometry by dx, dy, dz and dm.
double interpolateAngle(double distance) const
Returns the angle parallel to the linestring or polygon boundary at the specified distance along the ...
double angleAtVertex(int vertex) const
Returns the bisector angle for this geometry at the specified vertex.
Qgis::GeometryOperationResult reshapeGeometry(const QgsLineString &reshapeLineString)
Replaces a part of this geometry with another line.
double closestVertexWithContext(const QgsPointXY &point, int &atVertex) const
Searches for the closest vertex in this geometry to the given point.
QgsGeometry delaunayTriangulation(double tolerance=0.0, bool edgesOnly=false) const
Returns the Delaunay triangulation for the vertices of the geometry.
void draw(QPainter &p) const
Draws the geometry onto a QPainter.
QgsGeometry smooth(unsigned int iterations=1, double offset=0.25, double minimumDistance=-1.0, double maxAngle=180.0) const
Smooths a geometry by rounding off corners using the Chaikin algorithm.
QgsGeometry forcePolygonCounterClockwise() const
Forces geometries to respect the exterior ring is counter-clockwise, interior rings are clockwise con...
Q_INVOKABLE QString asWkt(int precision=17) const
Exports the geometry to WKT.
QgsGeometry cleanCoverage(const QgsCoverageCleanParameters ¶meters, QgsFeedback *feedback=nullptr) const
Operates on a coverage (represented as a list of polygonal geometry), to fix cases where the geometry...
Q_DECL_DEPRECATED Qgis::GeometryOperationResult splitGeometry(const QVector< QgsPointXY > &splitLine, QVector< QgsGeometry > &newGeometries, bool topological, QVector< QgsPointXY > &topologyTestPoints, bool splitFeature=true)
Splits this geometry according to a given line.
bool toggleCircularAtVertex(int atVertex)
Converts the vertex at the given position from/to circular.
Qgis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.).
bool moveVertex(double x, double y, int atVertex)
Moves the vertex at the given position number and item (first number is index 0) to the given coordin...
QgsGeometry constrainedDelaunayTriangulation() const
Returns a constrained Delaunay triangulation for the vertices of the geometry.
Q_DECL_DEPRECATED bool isGeosEqual(const QgsGeometry &) const
Compares the geometry with another geometry using GEOS.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry, double precision=0.0, Qgis::GeosCreationFlags flags=Qgis::GeosCreationFlag::SkipEmptyInteriorRings)
Creates and returns a new geometry engine representing the specified geometry using precision on a gr...
Q_INVOKABLE bool intersects(const QgsRectangle &rectangle) const
Returns true if this geometry exactly intersects with a rectangle.
static QgsGeometry fromBox3D(const QgsBox3D &box)
Creates a new geometry from a QgsBox3D object Returns a 2D polygon geometry if the box is purely 2d,...
QgsAbstractGeometry::vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
static QgsGeometry createWedgeBufferFromAngles(const QgsPoint ¢er, double startAngle, double endAngle, double outerRadius, double innerRadius=0)
Creates a wedge shaped buffer from a center point.
bool deletePart(int partNum)
Deletes part identified by the part number.
QgsGeometry removeInteriorRings(double minimumAllowedArea=-1) const
Removes the interior rings from a (multi)polygon geometry.
static QgsGeometry fromPoint(const QgsPoint &point)
Creates a new geometry from a QgsPoint object.
QgsGeometry difference(const QgsGeometry &geometry, const QgsGeometryParameters ¶meters=QgsGeometryParameters(), QgsFeedback *feedback=nullptr) const
Returns a geometry representing the points making up this geometry that do not make up other.
Q_INVOKABLE bool overlaps(const QgsGeometry &geometry) const
Returns true if the geometry overlaps another geometry.
Q_DECL_DEPRECATED int avoidIntersections(const QList< QgsVectorLayer * > &avoidIntersectionsLayers, const QHash< QgsVectorLayer *, QSet< QgsFeatureId > > &ignoreFeatures=(QHash< QgsVectorLayer *, QSet< QgsFeatureId > >()))
Modifies geometry to avoid intersections with the layers specified in project properties.
QgsGeometry shortestLine(const QgsGeometry &other) const
Returns the shortest line joining this geometry to another geometry.
Does vector analysis using the GEOS library and handles import, export, and exception handling.
double distance(const QgsAbstractGeometry *geom, QString *errorMsg=nullptr, QgsFeedback *feedback=nullptr) const override
Calculates the distance between this and geom.
QgsAbstractGeometry * buffer(double distance, int segments, QString *errorMsg=nullptr, QgsFeedback *feedback=nullptr) const override
Buffers the geometry.
double hausdorffDistanceDensify(const QgsAbstractGeometry *geometry, double densifyFraction, QString *errorMsg=nullptr, QgsFeedback *feedback=nullptr) const
Returns the Hausdorff distance between this geometry and another geometry.
double frechetDistanceDensify(const QgsAbstractGeometry *geometry, double densifyFraction, QString *errorMsg=nullptr, QgsFeedback *feedback=nullptr) const
Returns the Fréchet distance between this geometry and another geometry, restricted to discrete point...
double hausdorffDistance(const QgsAbstractGeometry *geometry, QString *errorMsg=nullptr, QgsFeedback *feedback=nullptr) const
Returns the Hausdorff distance between this geometry and another geometry.
double frechetDistance(const QgsAbstractGeometry *geometry, QString *errorMsg=nullptr, QgsFeedback *feedback=nullptr) const
Returns the Fréchet distance between this geometry and another geometry, restricted to discrete point...
static QgsGeometry polygonize(const QVector< const QgsAbstractGeometry * > &geometries, QString *errorMsg=nullptr, QgsFeedback *feedback=nullptr)
Creates a GeometryCollection geometry containing possible polygons formed from the constituent linewo...
Offers geometry processing methods.
QgsGeometry triangularWavesRandomized(double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed=0) const
Constructs randomized triangular waves along the boundary of the geometry, with the specified wavelen...
QgsGeometry triangularWaves(double wavelength, double amplitude, bool strictWavelength=false) const
Constructs triangular waves along the boundary of the geometry, with the specified wavelength and amp...
QgsGeometry roundWaves(double wavelength, double amplitude, bool strictWavelength=false) const
Constructs rounded (sine-like) waves along the boundary of the geometry, with the specified wavelengt...
QgsGeometry poleOfInaccessibility(double precision, double *distanceFromBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
QgsGeometry squareWaves(double wavelength, double amplitude, bool strictWavelength=false) const
Constructs square waves along the boundary of the geometry, with the specified wavelength and amplitu...
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer using the m-values from a (multi)line geometry.
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...
QgsGeometry roundWavesRandomized(double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed=0) const
Constructs randomized rounded (sine-like) waves along the boundary of the geometry,...
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...
QString lastError() const
Returns an error string referring to the last error encountered.
QgsGeometry orientedMinimumBoundingBox(double &area, double &angle, double &width, double &height) const
Returns the oriented minimum bounding box for the geometry, which is the smallest (by area) rotated r...
QgsGeometry densifyByDistance(double distance) const
Densifies the geometry by adding regularly placed extra nodes inside each segment so that the maximum...
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a tapered width buffer for a (multi)curve geometry.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Densifies the geometry by adding the specified number of extra nodes within each segment of the geome...
QgsGeometry applyDashPattern(const QVector< double > &pattern, Qgis::DashPatternLineEndingRule startRule=Qgis::DashPatternLineEndingRule::NoRule, Qgis::DashPatternLineEndingRule endRule=Qgis::DashPatternLineEndingRule::NoRule, Qgis::DashPatternSizeAdjustment adjustment=Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap, double patternOffset=0) const
Applies a dash pattern to a geometry, returning a MultiLineString geometry which is the input geometr...
QgsGeometry squareWavesRandomized(double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed=0) const
Constructs randomized square waves along the boundary of the geometry, with the specified wavelength ...
QgsGeometry convertToCurves(double distanceTolerance, double angleTolerance) const
Attempts to convert a non-curved geometry into a curved geometry type (e.g.
bool isAxisParallelRectangle(double maximumDeviation, bool simpleRectanglesOnly=false) const
Returns true if the geometry is a polygon that is almost an axis-parallel rectangle.
Custom exception class when argument are invalid.
Line string geometry type, with support for z-dimension and m-values.
static std::unique_ptr< QgsLineString > fromQPolygonF(const QPolygonF &polygon)
Returns a new linestring from a QPolygonF polygon input.
QgsLineString * clone() const override
Clones the geometry by performing a deep copy.
Perform transforms between map coordinates and device coordinates.
QgsPointXY transform(const QgsPointXY &p) const
Transforms a point p from map (world) coordinates to device coordinates.
QgsCurve * curveN(int index)
Returns the curve with the specified index.
Multi line string geometry collection.
QgsLineString * lineStringN(int index)
Returns the line string with the specified index.
Multi point geometry collection.
QgsPoint * pointN(int index)
Returns the point with the specified index.
Multi polygon geometry collection.
QgsPolygon * polygonN(int index)
Returns the polygon with the specified index.
QgsSurface * surfaceN(int index)
Returns the surface with the specified index.
Custom exception class which is raised when an operation is not supported.
void setY(double y)
Sets the y value of the point.
void setX(double x)
Sets the x value of the point.
QPointF toQPointF() const
Converts a point to a QPointF.
Point geometry type, with support for z-dimension and m-values.
QgsPoint * clone() const override
Clones the geometry by performing a deep copy.
QgsPoint project(double distance, double azimuth, double inclination=90.0) const
Returns a new point which corresponds to this point projected by a specified distance with specified ...
Polyhedral surface geometry type.
A rectangle specified with double values.
bool dropZValue() override
Drops any z-dimensions which exist in the geometry.
bool dropMValue() override
Drops any measure values which exist in the geometry.
int numPoints() const override
Returns the number of points in the curve.
void points(QgsPointSequence &pts) const override
Returns a list of points within the curve.
const double * yData() const
Returns a const pointer to the y vertex data.
const double * xData() const
Returns a const pointer to the x vertex data.
Triangulated surface geometry type.
Represents a vector layer which manages a vector based dataset.
Java-style iterator for traversal of vertices of a geometry.
static Qgis::GeometryType geometryType(Qgis::WkbType type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
static Q_INVOKABLE bool hasZ(Qgis::WkbType type)
Tests whether a WKB type contains the z-dimension.
static Qgis::WkbType singleType(Qgis::WkbType type)
Returns the single type for a WKB type.
static Q_INVOKABLE bool hasM(Qgis::WkbType type)
Tests whether a WKB type contains m values.
static Q_INVOKABLE bool isNurbsType(Qgis::WkbType type)
Returns true if the WKB type is a NURBS curve type.
static Q_INVOKABLE bool isCurvedType(Qgis::WkbType type)
Returns true if the WKB type is a curved type or can contain curved geometries.
static Qgis::WkbType multiType(Qgis::WkbType type)
Returns the multi type for a WKB type.
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
static Q_INVOKABLE bool isMultiType(Qgis::WkbType type)
Returns true if the WKB type is a multi type.
static Qgis::WkbType curveType(Qgis::WkbType type)
Returns the curve type for a WKB type.
Contains geos related utilities and functions.
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
#define Q_NOWARN_DEPRECATED_POP
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
#define BUILTIN_UNREACHABLE
#define Q_NOWARN_DEPRECATED_PUSH
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QVector< QgsPoint > QgsPointSequence
Q_GLOBAL_STATIC_WITH_ARGS(PalPropertyList, palHiddenProperties,({ static_cast< int >(QgsPalLayerSettings::Property::PositionX), static_cast< int >(QgsPalLayerSettings::Property::PositionY), static_cast< int >(QgsPalLayerSettings::Property::Show), static_cast< int >(QgsPalLayerSettings::Property::LabelRotation), static_cast< int >(QgsPalLayerSettings::Property::Family), static_cast< int >(QgsPalLayerSettings::Property::FontStyle), static_cast< int >(QgsPalLayerSettings::Property::Size), static_cast< int >(QgsPalLayerSettings::Property::Bold), static_cast< int >(QgsPalLayerSettings::Property::Italic), static_cast< int >(QgsPalLayerSettings::Property::Underline), static_cast< int >(QgsPalLayerSettings::Property::Color), static_cast< int >(QgsPalLayerSettings::Property::Strikeout), static_cast< int >(QgsPalLayerSettings::Property::MultiLineAlignment), static_cast< int >(QgsPalLayerSettings::Property::BufferSize), static_cast< int >(QgsPalLayerSettings::Property::BufferDraw), static_cast< int >(QgsPalLayerSettings::Property::BufferColor), static_cast< int >(QgsPalLayerSettings::Property::LabelDistance), static_cast< int >(QgsPalLayerSettings::Property::Hali), static_cast< int >(QgsPalLayerSettings::Property::Vali), static_cast< int >(QgsPalLayerSettings::Property::ScaleVisibility), static_cast< int >(QgsPalLayerSettings::Property::MinScale), static_cast< int >(QgsPalLayerSettings::Property::MaxScale), static_cast< int >(QgsPalLayerSettings::Property::AlwaysShow), static_cast< int >(QgsPalLayerSettings::Property::CalloutDraw), static_cast< int >(QgsPalLayerSettings::Property::LabelAllParts) })) Q_GLOBAL_STATIC_WITH_ARGS(SymbolPropertyList
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
std::unique_ptr< QgsLineString > smoothCurve(const QgsLineString &line, const unsigned int iterations, const double offset, double squareDistThreshold, double maxAngleRads, bool isRing)
QCache< QString, QgsGeometry > WktCache
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item.
CORE_EXPORT QDataStream & operator>>(QDataStream &in, QgsGeometry &geometry)
Reads a geometry from stream in into geometry. QGIS version compatibility is not guaranteed.
CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QgsGeometry &geometry)
Writes the geometry to stream out. QGIS version compatibility is not guaranteed.
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
QgsPointSequence QgsPolyline
Polyline as represented as a vector of points.
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
std::unique_ptr< QgsAbstractGeometry > geometry
QgsGeometryPrivate(std::unique_ptr< QgsAbstractGeometry > geometry)
Utility class for identifying a unique vertex within a geometry.
bool isValid() const
Returns true if the vertex id is valid.