QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
20 #include <nlohmann/json.hpp>
30 #if ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR<8 )
63 std::unique_ptr< QgsAbstractGeometry >
geometry;
73 if ( !d->
ref.deref() )
81 d->
ref = QAtomicInt( 1 );
88 d->
ref = QAtomicInt( 1 );
94 mLastError = other.mLastError;
100 if (
this != &other )
102 if ( !d->
ref.deref() )
107 mLastError = other.mLastError;
114 void QgsGeometry::detach()
119 std::unique_ptr< QgsAbstractGeometry > cGeom;
121 cGeom.reset( d->
geometry->clone() );
123 reset( std::move( cGeom ) );
126 void QgsGeometry::reset( std::unique_ptr<QgsAbstractGeometry> newGeometry )
130 ( void )d->
ref.deref();
133 d->
geometry = std::move( newGeometry );
149 if ( d->
geometry.get() == geometry )
154 reset( std::unique_ptr< QgsAbstractGeometry >( geometry ) );
168 QMutexLocker lock( sWktMutex() );
169 if (
const QgsGeometry *cached = sWktCache()->
object( wkt ) )
172 sWktCache()->insert( wkt,
new QgsGeometry( result ), 1 );
198 return QgsGeometry( std::make_unique< QgsLineString >( polyline ) );
243 std::unique_ptr< QgsLineString > ext = std::make_unique< QgsLineString >(
244 QVector< double >() << rect.
xMinimum()
249 QVector< double >() << rect.
yMinimum()
254 std::unique_ptr< QgsPolygon > polygon = std::make_unique< QgsPolygon >();
255 polygon->setExteriorRing( ext.release() );
272 if ( g.isMultipart() )
274 for (
auto p = g.const_parts_begin(); p != g.const_parts_end(); ++p )
276 collected.
addPart( ( *p )->clone() );
290 if ( std::abs( angularWidth ) >= 360.0 )
292 std::unique_ptr< QgsCompoundCurve > outerCc = std::make_unique< QgsCompoundCurve >();
297 std::unique_ptr< QgsCurvePolygon > cp = std::make_unique< QgsCurvePolygon >();
298 cp->setExteriorRing( outerCc.release() );
302 std::unique_ptr< QgsCompoundCurve > innerCc = std::make_unique< QgsCompoundCurve >();
307 cp->setInteriorRings( { innerCc.release() } );
313 std::unique_ptr< QgsCompoundCurve > wedge = std::make_unique< QgsCompoundCurve >();
315 const double startAngle = azimuth - angularWidth * 0.5;
316 const double endAngle = azimuth + angularWidth * 0.5;
321 const bool useShortestArc = angularWidth <= 180.0;
339 std::unique_ptr< QgsCurvePolygon > cp = std::make_unique< QgsCurvePolygon >();
340 cp->setExteriorRing( wedge.release() );
418 d->
geometry->adjacentVertices(
id, prevVertex, nextVertex );
454 return d->
geometry->vertexAngle( v2 );
473 d->
geometry->adjacentVertices(
id, beforeVertexId, afterVertexId );
511 return d->
geometry->moveVertex(
id, p );
544 return d->
geometry->deleteVertex(
id );
564 if ( owningCollection !=
nullptr )
565 part = owningCollection->
geometryN(
id.part );
571 QgsCurvePolygon *owningPolygon = qgsgeometry_cast<QgsCurvePolygon *>( part );
572 if ( owningPolygon !=
nullptr )
578 QgsCurve *curve = qgsgeometry_cast<QgsCurve *>( ring );
579 if ( curve ==
nullptr )
582 bool success =
false;
584 if ( cpdCurve !=
nullptr )
593 std::unique_ptr<QgsCompoundCurve> cpdCurve = std::make_unique<QgsCompoundCurve>();
594 cpdCurve->addCurve( curve->
clone() );
595 success = cpdCurve->toggleCircularAtVertex(
QgsVertexId( -1, -1,
id.vertex ) );
601 if ( owningPolygon ==
nullptr && owningCollection ==
nullptr )
604 reset( std::make_unique<QgsCompoundCurve>( *cpdCurve ) );
606 else if ( owningPolygon !=
nullptr )
619 else if ( owningCollection !=
nullptr )
680 return d->
geometry->insertVertex(
id, point );
696 return d->
geometry->vertexAt( vId );
716 result.mLastError = mLastError;
725 return QgsGeometry( std::make_unique< QgsLineString >( *qgsgeometry_cast< const QgsPoint * >( d->
geometry.get() ), *qgsgeometry_cast< const QgsPoint * >( other.
constGet() ) ) );
731 result.mLastError = mLastError;
753 int &nextVertexIndex,
754 int *leftOrRightOfSegment,
755 double epsilon )
const
765 double sqrDist = d->
geometry->closestSegment(
QgsPoint( point ), segmentPt, vertexAfter, leftOrRightOfSegment, epsilon );
769 minDistPoint.
setX( segmentPt.
x() );
770 minDistPoint.
setY( segmentPt.
y() );
777 std::unique_ptr< QgsLineString > ringLine = std::make_unique< QgsLineString >( ring );
778 return addRing( ringLine.release() );
783 std::unique_ptr< QgsCurve > r( ring );
803 std::unique_ptr< QgsAbstractGeometry > partGeom;
804 if ( points.size() == 1 )
806 partGeom = std::make_unique< QgsPoint >( points[0] );
808 else if ( points.size() > 1 )
810 std::unique_ptr< QgsLineString > ringLine = std::make_unique< QgsLineString >();
811 ringLine->setPoints( points );
812 partGeom = std::move( ringLine );
814 return addPart( partGeom.release(), geomType );
819 std::unique_ptr< QgsAbstractGeometry > p( part );
825 reset( std::make_unique< QgsMultiPoint >() );
828 reset( std::make_unique< QgsMultiLineString >() );
831 reset( std::make_unique< QgsMultiPolygon >() );
871 QVector<QgsGeometry> results;
872 results.reserve(
parts.count() );
879 if ( results.isEmpty() )
883 for (
const QgsGeometry &result : std::as_const( results ) )
892 newPoly->removeInteriorRings( minimumRingArea );
906 d->
geometry->transform( QTransform::fromTranslate( dx, dy ), dz, 1.0, dm );
919 QTransform t = QTransform::fromTranslate( center.
x(), center.
y() );
920 t.rotate( -rotation );
921 t.translate( -center.
x(), -center.
y() );
942 QVector<QgsGeometry > newGeoms;
952 *
this = newGeoms.takeAt( 0 );
953 newGeometries = newGeoms;
982 std::unique_ptr<QgsLineString> segmentizedLine( curve->
curveToLine() );
984 segmentizedLine->points( points );
989 if ( preserveCircular )
991 for (
int i = 0; i < newGeometries.count(); ++i )
1010 std::unique_ptr< QgsAbstractGeometry > geom(
geos.reshapeGeometry( reshapeLineString, &errorCode, &mLastError ) );
1013 reset( std::move( geom ) );
1017 switch ( errorCode )
1049 std::unique_ptr< QgsAbstractGeometry > diffGeom(
geos.intersection( other.
constGet(), &mLastError ) );
1055 reset( std::move( diffGeom ) );
1069 std::unique_ptr< QgsAbstractGeometry > diffGeom(
geos.intersection( other.
constGet(), &mLastError ) );
1073 result.mLastError = mLastError;
1107 auto l_boundary = boundary.length();
1109 if ( ( points.length() == 0 ) || ( l_boundary == 3 ) )
1111 switch ( l_boundary )
1118 boundary.pop_back();
1123 boundary.pop_back();
1125 boundary.pop_back();
1142 circ_mec = __recMinimalEnclosingCircle( points, boundary );
1146 boundary.append( pxy );
1147 circ_mec = __recMinimalEnclosingCircle( points, boundary );
1171 QgsCircle circ = __recMinimalEnclosingCircle( P, R );
1192 return engine.
orthogonalize( tolerance, maxIterations, angleThreshold );
1198 return engine.
triangularWaves( wavelength, amplitude, strictWavelength );
1204 return engine.
triangularWavesRandomized( minimumWavelength, maximumWavelength, minimumAmplitude, maximumAmplitude, seed );
1210 return engine.
squareWaves( wavelength, amplitude, strictWavelength );
1216 return engine.
squareWavesRandomized( minimumWavelength, maximumWavelength, minimumAmplitude, maximumAmplitude, seed );
1222 return engine.
roundWaves( wavelength, amplitude, strictWavelength );
1228 return engine.
roundWavesRandomized( minimumWavelength, maximumWavelength, minimumAmplitude, maximumAmplitude, seed );
1234 return engine.
applyDashPattern( pattern, startRule, endRule, adjustment, patternOffset );
1243 return QgsGeometry( d->
geometry->snappedToGrid( hSpacing, vSpacing, dSpacing, mSpacing ) );
1252 return d->
geometry->removeDuplicateNodes( epsilon, useZValues );
1280 return geos.intersects( geometry.d->
geometry.get(), &mLastError );
1290 return d->
geometry->boundingBoxIntersects( rectangle );
1313 return geos.contains( &pt, &mLastError );
1325 return geos.contains( geometry.d->
geometry.get(), &mLastError );
1337 return geos.disjoint( geometry.d->
geometry.get(), &mLastError );
1348 if ( d == geometry.d )
1368 return geos.touches( geometry.d->
geometry.get(), &mLastError );
1380 return geos.overlaps( geometry.d->
geometry.get(), &mLastError );
1392 return geos.within( geometry.d->
geometry.get(), &mLastError );
1404 return geos.crosses( geometry.d->
geometry.get(), &mLastError );
1433 QVector< QgsGeometry > res;
1471 std::unique_ptr< QgsAbstractGeometry > exterior( ( *part )->clone() );
1472 if (
QgsCurve *curve = qgsgeometry_cast< QgsCurve * >( exterior.get() ) )
1476 std::unique_ptr< QgsCurvePolygon > cp = std::make_unique< QgsCurvePolygon >();
1477 cp->setExteriorRing( curve );
1479 gc->addGeometry( cp.release() );
1483 std::unique_ptr< QgsPolygon > p = std::make_unique< QgsPolygon >();
1484 p->setExteriorRing( qgsgeometry_cast< QgsLineString * >( curve ) );
1486 gc->addGeometry( p.release() );
1499 std::unique_ptr< QgsMultiPoint > mp = std::make_unique< QgsMultiPoint >();
1501 QSet< QgsPoint > added;
1504 if ( added.contains( *vertex ) )
1506 mp->addGeometry( ( *vertex ).clone() );
1507 added.insert( *vertex );
1540 res.reserve(
parts->partCount() );
1541 for (
int i = 0; i <
parts->partCount( ); i++ )
1558 return convertToPoint( destMultipart );
1561 return convertToLine( destMultipart );
1564 return convertToPolygon( destMultipart );
1616 if ( !multiGeom || multiGeom->
partCount() < 1 )
1619 std::unique_ptr< QgsAbstractGeometry > firstPart( multiGeom->
geometryN( 0 )->
clone() );
1620 reset( std::move( firstPart ) );
1631 std::unique_ptr<QgsGeometryCollection> resGeom;
1635 resGeom = std::make_unique<QgsMultiPoint>();
1638 resGeom = std::make_unique<QgsMultiLineString>();
1641 resGeom = std::make_unique<QgsMultiPolygon>();
1654 resGeom->addGeometry( g->
clone() );
1657 set( resGeom.release() );
1668 if (
QgsPoint *pt = qgsgeometry_cast<QgsPoint *>( d->
geometry->simplifiedTypeRef() ) )
1688 std::unique_ptr< QgsLineString > segmentizedLine;
1690 if ( doSegmentation )
1698 line = segmentizedLine.get();
1702 line = qgsgeometry_cast<QgsLineString *>( d->
geometry.get() );
1710 polyLine.resize( nVertices );
1712 const double *xData = line->
xData();
1713 const double *yData = line->
yData();
1714 for (
int i = 0; i < nVertices; ++i )
1716 data->
setX( *xData++ );
1717 data->
setY( *yData++ );
1732 std::unique_ptr< QgsPolygon > segmentized;
1733 if ( doSegmentation )
1740 segmentized.reset( curvePoly->
toPolygon() );
1741 p = segmentized.get();
1745 p = qgsgeometry_cast<QgsPolygon *>( d->
geometry.get() );
1754 convertPolygon( *p, polygon );
1774 for (
int i = 0; i < nPoints; ++i )
1777 multiPoint[i].
setX( pt->
x() );
1778 multiPoint[i].setY( pt->
y() );
1791 if ( !geomCollection )
1803 mpl.reserve( nLines );
1804 for (
int i = 0; i < nLines; ++i )
1807 std::unique_ptr< QgsLineString > segmentized;
1810 const QgsCurve *curve = qgsgeometry_cast<const QgsCurve *>( geomCollection->
geometryN( i ) );
1816 line = segmentized.get();
1821 polyLine.resize( nVertices );
1823 const double *xData = line->
xData();
1824 const double *yData = line->
yData();
1825 for (
int i = 0; i < nVertices; ++i )
1827 data->
setX( *xData++ );
1828 data->
setY( *yData++ );
1831 mpl.append( polyLine );
1844 if ( !geomCollection )
1850 if ( nPolygons < 1 )
1856 mp.reserve( nPolygons );
1857 for (
int i = 0; i < nPolygons; ++i )
1859 const QgsPolygon *polygon = qgsgeometry_cast<const QgsPolygon *>( geomCollection->
geometryN( i ) );
1874 convertPolygon( *polygon, poly );
1875 mp.push_back( poly );
1925 return qgsgeometry_cast< const QgsPoint * >( d->
geometry.get() )->distance( *qgsgeometry_cast< const QgsPoint * >( geom.
constGet() ) );
1986 return d->
geometry->vertices_begin();
1993 return d->
geometry->vertices_end();
2023 return d->
geometry->const_parts_begin();
2030 return d->
geometry->const_parts_end();
2059 std::unique_ptr<QgsAbstractGeometry> geom( g.
buffer(
distance, segments, &mLastError ) );
2063 result.mLastError = mLastError;
2082 result.mLastError = mLastError;
2098 QVector<QgsGeometry> results;
2099 results.reserve(
parts.count() );
2106 if ( results.isEmpty() )
2110 for (
const QgsGeometry &result : std::as_const( results ) )
2124 std::unique_ptr< QgsAbstractGeometry > offsetGeom(
geos.offsetCurve(
distance, segments, joinStyle, miterLimit, &mLastError ) );
2128 result.mLastError = mLastError;
2132 if (
const QgsCurve *
offsetCurve = qgsgeometry_cast< const QgsCurve * >( offsetGeom.get() ) )
2135 if ( newOrientation != prevOrientation )
2138 std::unique_ptr< QgsAbstractGeometry > flipped(
offsetCurve->reversed() );
2139 offsetGeom = std::move( flipped );
2156 QVector<QgsGeometry> results;
2157 results.reserve(
parts.count() );
2164 if ( results.isEmpty() )
2168 for (
const QgsGeometry &result : std::as_const( results ) )
2178 std::unique_ptr< QgsAbstractGeometry > bufferGeom =
geos.singleSidedBuffer(
distance, segments, side,
2179 joinStyle, miterLimit, &mLastError );
2183 result.mLastError = mLastError;
2194 return engine.
taperedBuffer( startWidth, endWidth, segments );
2214 QVector<QgsGeometry> results;
2215 results.reserve(
parts.count() );
2222 if ( results.isEmpty() )
2226 for (
const QgsGeometry &result : std::as_const( results ) )
2238 std::unique_ptr< QgsLineString > newLine( line->
clone() );
2239 newLine->extend( startDistance, endDistance );
2253 std::unique_ptr< QgsAbstractGeometry > simplifiedGeom(
geos.simplify( tolerance, &mLastError ) );
2254 if ( !simplifiedGeom )
2257 result.mLastError = mLastError;
2260 return QgsGeometry( std::move( simplifiedGeom ) );
2295 c.get()->dropZValue();
2296 c.get()->dropMValue();
2304 result.mLastError = mLastError;
2319 result.mLastError = mLastError;
2341 result.mLastError = mLastError;
2356 result.mLastError = mLastError;
2364 return std::numeric_limits< double >::quiet_NaN();
2370 return geos.minimumClearance( &mLastError );
2384 result.mLastError = mLastError;
2396 std::unique_ptr< QgsAbstractGeometry > cHull(
geos.convexHull( &mLastError ) );
2400 geom.mLastError = mLastError;
2416 result.mLastError = mLastError;
2429 QgsGeometry result =
geos.delaunayTriangulation( tolerance, edgesOnly );
2430 result.mLastError = mLastError;
2444 result.mLastError = mLastError;
2458 result.mLastError = mLastError;
2470 std::unique_ptr< QgsAbstractGeometry > segmentizedCopy;
2473 segmentizedCopy.reset( d->
geometry->segmentize() );
2474 geom = segmentizedCopy.get();
2479 std::unique_ptr< QgsAbstractGeometry > result(
geos.subdivide( maxNodes, &mLastError ) );
2483 geom.mLastError = mLastError;
2509 for (
int part = 0; part < collection->
numGeometries(); ++part )
2511 const QgsCurve *candidate = qgsgeometry_cast< const QgsCurve * >( collection->
geometryN( part ) );
2514 const double candidateLength = candidate->
length();
2526 curve = qgsgeometry_cast< const QgsCurve * >( line.
constGet() );
2555 return geos.lineLocatePoint( *(
static_cast< QgsPoint *
>( point.d->
geometry.get() ) ), &mLastError );
2579 if ( previous == next )
2626 std::unique_ptr< QgsAbstractGeometry > resultGeom(
geos.intersection( geometry.d->
geometry.get(), &mLastError ) );
2631 geom.mLastError = mLastError;
2647 std::unique_ptr< QgsAbstractGeometry > resultGeom(
geos.combine( geometry.d->
geometry.get(), &mLastError ) );
2651 geom.mLastError = mLastError;
2673 result.mLastError = mLastError;
2687 std::unique_ptr< QgsAbstractGeometry > resultGeom(
geos.difference( geometry.d->
geometry.get(), &mLastError ) );
2691 geom.mLastError = mLastError;
2707 std::unique_ptr< QgsAbstractGeometry > resultGeom(
geos.symDifference( geometry.d->
geometry.get(), &mLastError ) );
2711 geom.mLastError = mLastError;
2721 return engine.
extrude( x, y );
2729 return QVector< QgsPointXY >();
2737 return QVector< QgsPointXY >();
2755 QVector<QgsGeometry> geometryList;
2758 return geometryList;
2765 geometryList.reserve( numGeom );
2766 for (
int i = 0; i < numGeom; ++i )
2773 geometryList.append( *
this );
2776 return geometryList;
2790 if (
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection *>( part ) )
2792 if ( collection->numGeometries() > 0 )
2793 part = collection->geometryN( 0 );
2798 if (
const QgsCurve *curve = qgsgeometry_cast< const QgsCurve * >( part ) )
2799 return curve->asQPolygonF();
2800 else if (
const QgsCurvePolygon *polygon = qgsgeometry_cast< const QgsCurvePolygon * >( part ) )
2801 return polygon->exteriorRing() ? polygon->exteriorRing()->asQPolygonF() : QPolygonF();
2844 bool haveInvalidGeometry =
false;
2848 reset( std::move( diffGeom ) );
2851 if ( geomTypeBeforeModification !=
wkbType() )
2853 if ( haveInvalidGeometry )
2866 #if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=8 )
2868 std::unique_ptr< QgsAbstractGeometry > g(
geos.makeValid( &mLastError ) );
2870 std::unique_ptr< QgsAbstractGeometry > g( _qgis_lwgeom_make_valid( d->
geometry.get(), mLastError ) );
2874 result.mLastError = mLastError;
2896 if (
const QgsCurvePolygon *cp = qgsgeometry_cast< const QgsCurvePolygon * >( g ) )
2898 std::unique_ptr< QgsCurvePolygon > corrected( cp->clone() );
2899 corrected->forceClockwise();
2900 newCollection->addGeometry( corrected.release() );
2904 newCollection->addGeometry( g->
clone() );
2913 std::unique_ptr< QgsCurvePolygon > corrected( cp->clone() );
2914 corrected->forceClockwise();
2938 if (
const QgsCurvePolygon *cp = qgsgeometry_cast< const QgsCurvePolygon * >( g ) )
2940 std::unique_ptr< QgsCurvePolygon > corrected( cp->clone() );
2941 corrected->forceCounterClockwise();
2942 newCollection->addGeometry( corrected.release() );
2946 newCollection->addGeometry( g->
clone() );
2955 std::unique_ptr< QgsCurvePolygon > corrected( cp->clone() );
2956 corrected->forceCounterClockwise();
2982 case Qgis::GeometryValidationEngine::QgisInternal:
2986 case Qgis::GeometryValidationEngine::Geos:
2991 if ( !
geos.isValid( &error, flags & Qgis::GeometryValidityFlag::AllowSelfTouchingHoles, &errorLoc ) )
3026 return d->
geometry->isValid( mLastError, flags );
3036 return geos.isSimple( &mLastError );
3076 return geos.isEqual( g.d->
geometry.get(), &mLastError );
3084 std::unique_ptr< QgsAbstractGeometry > geom(
geos.combine( geometries, &error ) );
3086 result.mLastError = error;
3092 QVector<const QgsAbstractGeometry *> geomV2List;
3095 if ( !( g.isNull() ) )
3097 geomV2List.append( g.constGet() );
3103 result.mLastError = error;
3114 std::unique_ptr< QgsAbstractGeometry > straightGeom( d->
geometry->segmentize( tolerance, toleranceType ) );
3115 reset( std::move( straightGeom ) );
3125 return d->
geometry->hasCurvedSegments();
3136 d->
geometry->transform( ct, direction, transformZ );
3148 d->
geometry->transform( ct, zTranslate, zScale, mTranslate, mScale );
3170 std::unique_ptr< QgsAbstractGeometry > resultGeom =
geos.clip( rectangle, &mLastError );
3174 result.mLastError = mLastError;
3188 static bool vertexIndexInfo(
const QgsAbstractGeometry *g,
int vertexIndex,
int &partIndex,
int &ringIndex,
int &vertex )
3190 if ( vertexIndex < 0 )
3193 if (
const QgsGeometryCollection *geomCollection = qgsgeometry_cast<const QgsGeometryCollection *>( g ) )
3196 for (
int i = 0; i < geomCollection->numGeometries(); ++i )
3202 for (
int k = 0; k < part->
ringCount(); ++k )
3205 if ( vertexIndex < numPoints )
3208 return vertexIndexInfo( part, vertexIndex, nothing, ringIndex, vertex );
3210 vertexIndex -= numPoints;
3214 else if (
const QgsCurvePolygon *curvePolygon = qgsgeometry_cast<const QgsCurvePolygon *>( g ) )
3216 const QgsCurve *ring = curvePolygon->exteriorRing();
3217 if ( vertexIndex < ring->numPoints() )
3221 vertex = vertexIndex;
3226 for (
int i = 0; i < curvePolygon->numInteriorRings(); ++i )
3228 const QgsCurve *ring = curvePolygon->interiorRing( i );
3229 if ( vertexIndex < ring->numPoints() )
3232 vertex = vertexIndex;
3239 else if (
const QgsCurve *curve = qgsgeometry_cast<const QgsCurve *>( g ) )
3241 if ( vertexIndex < curve->numPoints() )
3245 vertex = vertexIndex;
3249 else if ( qgsgeometry_cast<const QgsPoint *>( g ) )
3251 if ( vertexIndex == 0 )
3270 id.type = Qgis::VertexType::Segment;
3272 bool res = vertexIndexInfo( d->
geometry.get(), nr,
id.part,
id.ring,
id.vertex );
3278 if (
const QgsGeometryCollection *geomCollection = qgsgeometry_cast<const QgsGeometryCollection *>( g ) )
3280 g = geomCollection->geometryN(
id.part );
3283 if (
const QgsCurvePolygon *curvePolygon = qgsgeometry_cast<const QgsCurvePolygon *>( g ) )
3285 g =
id.ring == 0 ? curvePolygon->exteriorRing() : curvePolygon->interiorRing(
id.ring - 1 );
3288 if (
const QgsCurve *curve = qgsgeometry_cast<const QgsCurve *>( g ) )
3291 res = curve->pointAt(
id.vertex, p,
id.
type );
3305 return d->
geometry->vertexNumberFromVertexId(
id );
3320 d->
geometry->filterVertices( filter );
3360 std::unique_ptr< QgsLineString > segmentizedLine;
3362 if ( doSegmentation )
3365 line = segmentizedLine.get();
3369 line = qgsgeometry_cast<const QgsLineString *>( ring );
3377 res.resize( nVertices );
3379 const double *xData = line->
xData();
3380 const double *yData = line->
yData();
3381 for (
int i = 0; i < nVertices; ++i )
3383 data->
setX( *xData++ );
3384 data->
setY( *yData++ );
3392 output.push_back( convertRing( exterior ) );
3396 output.reserve( output.size() + interiorRingCount );
3397 for (
int n = 0; n < interiorRingCount; ++n )
3399 output.push_back( convertRing( input.
interiorRing( n ) ) );
3405 return QgsGeometry( std::make_unique< QgsPoint >( point.x(), point.y() ) );
3412 if ( polygon.isClosed() )
3414 std::unique_ptr< QgsPolygon > poly = std::make_unique< QgsPolygon >();
3415 poly->setExteriorRing( ring.release() );
3436 result.reserve( polygon.count() );
3437 for (
const QPointF &p : polygon )
3446 if ( p1.count() != p2.count() )
3449 for (
int i = 0; i < p1.count(); ++i )
3451 if ( !p1.at( i ).compare( p2.at( i ), epsilon ) )
3459 if ( p1.count() != p2.count() )
3462 for (
int i = 0; i < p1.count(); ++i )
3473 if ( p1.count() != p2.count() )
3476 for (
int i = 0; i < p1.count(); ++i )
3503 return QgsGeometry( smoothLine( *lineString, iterations, offset, minimumDistance, maxAngle ) );
3510 std::unique_ptr< QgsMultiLineString > resultMultiline = std::make_unique< QgsMultiLineString> ();
3514 resultMultiline->addGeometry( smoothLine( *( multiLine->
lineStringN( i ) ), iterations, offset, minimumDistance, maxAngle ).release() );
3516 return QgsGeometry( std::move( resultMultiline ) );
3522 return QgsGeometry( smoothPolygon( *poly, iterations, offset, minimumDistance, maxAngle ) );
3529 std::unique_ptr< QgsMultiPolygon > resultMultiPoly = std::make_unique< QgsMultiPolygon >();
3533 resultMultiPoly->addGeometry( smoothPolygon( *( multiPoly->
polygonN( i ) ), iterations, offset, minimumDistance, maxAngle ).release() );
3535 return QgsGeometry( std::move( resultMultiPoly ) );
3545 const double offset,
double squareDistThreshold,
double maxAngleRads,
3548 std::unique_ptr< QgsLineString > result = std::make_unique< QgsLineString >( line );
3550 for (
unsigned int iteration = 0; iteration < iterations; ++iteration )
3552 outputLine.resize( 0 );
3553 outputLine.reserve( 2 * ( result->numPoints() - 1 ) );
3554 bool skipFirst =
false;
3555 bool skipLast =
false;
3558 QgsPoint p1 = result->pointN( result->numPoints() - 2 );
3564 skipFirst =
angle > maxAngleRads;
3566 for (
int i = 0; i < result->numPoints() - 1; i++ )
3569 QgsPoint p2 = result->pointN( i + 1 );
3571 double angle = M_PI;
3572 if ( i == 0 && isRing )
3574 QgsPoint p3 = result->pointN( result->numPoints() - 2 );
3578 else if ( i < result->numPoints() - 2 )
3580 QgsPoint p3 = result->pointN( i + 2 );
3584 else if ( i == result->numPoints() - 2 && isRing )
3591 skipLast =
angle < M_PI - maxAngleRads ||
angle > M_PI + maxAngleRads;
3594 if ( i == 0 || i >= result->numPoints() - 2
3619 skipFirst = skipLast;
3622 if ( isRing && outputLine.at( 0 ) != outputLine.at( outputLine.count() - 1 ) )
3623 outputLine << outputLine.at( 0 );
3625 result->setPoints( outputLine );
3630 std::unique_ptr<QgsLineString> QgsGeometry::smoothLine(
const QgsLineString &line,
const unsigned int iterations,
const double offset,
double minimumDistance,
double maxAngle )
const
3632 double maxAngleRads = maxAngle * M_PI / 180.0;
3633 double squareDistThreshold = minimumDistance > 0 ? minimumDistance * minimumDistance : -1;
3634 return smoothCurve( line, iterations, offset, squareDistThreshold, maxAngleRads,
false );
3637 std::unique_ptr<QgsPolygon> QgsGeometry::smoothPolygon(
const QgsPolygon &polygon,
const unsigned int iterations,
const double offset,
double minimumDistance,
double maxAngle )
const
3639 double maxAngleRads = maxAngle * M_PI / 180.0;
3640 double squareDistThreshold = minimumDistance > 0 ? minimumDistance * minimumDistance : -1;
3641 std::unique_ptr< QgsPolygon > resultPoly = std::make_unique< QgsPolygon >();
3644 squareDistThreshold, maxAngleRads,
true ).release() );
3649 squareDistThreshold, maxAngleRads,
true ).release() );
3654 QgsGeometry QgsGeometry::convertToPoint(
bool destMultipart )
const
3662 if ( ( destMultipart && srcIsMultipart ) ||
3663 ( !destMultipart && !srcIsMultipart ) )
3668 if ( destMultipart )
3677 if ( multiPoint.count() == 1 )
3688 if ( !destMultipart )
3705 if ( !line.isEmpty() )
3714 if ( !destMultipart )
3745 QgsGeometry QgsGeometry::convertToLine(
bool destMultipart )
const
3755 if ( multiPoint.count() < 2 )
3758 if ( destMultipart )
3768 if ( ( destMultipart && srcIsMultipart ) ||
3769 ( !destMultipart && ! srcIsMultipart ) )
3774 if ( destMultipart )
3778 if ( !line.isEmpty() )
3785 if ( multiLine.count() == 1 )
3802 if ( destMultipart )
3807 else if ( multiLine.count() == 1 )
3818 if ( polygon.count() > 1 )
3822 if ( destMultipart )
3826 multiLine.reserve( polygon.count() );
3833 else if ( polygon.count() == 1 )
3835 if ( destMultipart )
3853 QgsGeometry QgsGeometry::convertToPolygon(
bool destMultipart )
const
3863 if ( multiPoint.count() < 3 )
3866 if ( multiPoint.last() != multiPoint.first() )
3867 multiPoint << multiPoint.first();
3870 if ( destMultipart )
3883 for ( QgsMultiPolylineXY::iterator multiLineIt = multiLine.begin(); multiLineIt != multiLine.end(); ++multiLineIt )
3886 if ( ( *multiLineIt ).count() < 3 )
3888 if ( ( *multiLineIt ).count() == 3 && ( *multiLineIt ).first() == ( *multiLineIt ).last() )
3892 if ( ( *multiLineIt ).first() != ( *multiLineIt ).last() )
3893 *multiLineIt << ( *multiLineIt ).first();
3897 if ( !multiPolygon.isEmpty() )
3899 if ( destMultipart )
3903 else if ( multiPolygon.count() == 1 )
3916 if ( line.count() < 3 )
3918 if ( line.count() == 3 && line.first() == line.last() )
3922 if ( line.first() != line.last() )
3923 line << line.first();
3926 if ( destMultipart )
3942 if ( ( destMultipart && srcIsMultipart ) ||
3943 ( !destMultipart && ! srcIsMultipart ) )
3948 if ( destMultipart )
3952 if ( !polygon.isEmpty() )
3958 if ( multiPolygon.count() == 1 )
3974 return new QgsGeos( geometry );
3979 out << geometry.
asWkb();
3985 QByteArray byteArray;
3987 if ( byteArray.isEmpty() )
3989 geometry.
set(
nullptr );
3993 geometry.
fromWkb( byteArray );
4010 return mHasLocation;
Abstract base class for curved geometry type.
bool toggleCircularAtVertex(QgsVertexId position)
Converts the vertex at the given position from/to circular.
QgsGeometry combine(const QgsGeometry &geometry) const
Returns a geometry representing all the points in this geometry and other (a union geometry operation...
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...
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...
bool contains(const QgsPoint &point, double epsilon=1E-8) const
Returns true if the circle contains the point.
QString lastError() const SIP_HOLDGIL
Returns an error string referring to the last error encountered either when this geometry was created...
double hausdorffDistanceDensify(const QgsAbstractGeometry *geom, double densifyFraction, QString *errorMsg=nullptr) const
Returns the Hausdorff distance between this geometry and geom.
double hausdorffDistanceDensify(const QgsGeometry &geom, double densifyFraction) const
Returns the Hausdorff distance between this geometry and geom.
std::unique_ptr< QgsLineString > smoothCurve(const QgsLineString &line, const unsigned int iterations, const double offset, double squareDistThreshold, double maxAngleRads, bool isRing)
void normalize()
Reorganizes the geometry into a normalized form (or "canonical" form).
QDataStream & operator>>(QDataStream &in, QgsGeometry &geometry)
Reads a geometry from stream in into geometry. QGIS version compatibility is not guaranteed.
int makeDifferenceInPlace(const QgsGeometry &other)
Changes this geometry such that it does not intersect the other geometry.
QgsGeometry sharedPaths(const QgsGeometry &other) const
Find paths shared between the two given lineal geometries (this and other).
double distance(const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
Calculates the distance between this and geom.
@ AddPartNotMultiGeometry
The source geometry is not multi.
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.
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
virtual bool insertGeometry(QgsAbstractGeometry *g, int index)
Inserts a geometry before a specified index and takes ownership.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Densifies the geometry by adding the specified number of extra nodes within each segment of the geome...
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.
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...
QByteArray asWkb(QgsAbstractGeometry::WkbFlags flags=QgsAbstractGeometry::WkbFlags()) const
Export the geometry to WKB.
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.
@ InvalidInput
The input is not valid.
virtual void adjacentVertices(QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex) const =0
Returns the vertices adjacent to a specified vertex within a geometry.
double distance(const QgsGeometry &geom) const
Returns the minimum distance between this geometry and another geometry.
bool convertGeometryCollectionToSubclass(QgsWkbTypes::GeometryType geomType)
Converts geometry collection to a the desired geometry type subclass (multi-point,...
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
Qgis::GeometryOperationResult addPart(const QVector< QgsPointXY > &points, QgsWkbTypes::GeometryType geomType=QgsWkbTypes::UnknownGeometry)
Adds a new part to a the geometry.
bool within(const QgsGeometry &geometry) const
Returns true if the geometry is completely within another geometry.
static Q_DECL_DEPRECATED QgsPolygonXY createPolygonFromQPolygonF(const QPolygonF &polygon)
Creates a QgsPolygonXYfrom a QPolygonF.
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...
bool isAxisParallelRectangle(double maximumDeviation, bool simpleRectanglesOnly=false) const
Returns true if the geometry is a polygon that is almost an axis-parallel rectangle.
static QgsCircle minimalCircleFrom3Points(const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double epsilon=1E-8) SIP_HOLDGIL
Constructs the smallest circle from 3 points.
bool isAxisParallelRectangle(double maximumDeviation, bool simpleRectanglesOnly=false) const
Returns true if the geometry is a polygon that is almost an axis-parallel rectangle.
double angleAtVertex(int vertex) const
Returns the bisector angle for this geometry at the specified vertex.
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...
virtual QgsPoint * interpolatePoint(double distance) const =0
Returns an interpolated point on the curve at the specified distance.
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
QgsGeometry subdivide(int maxNodes=256) const
Subdivides the geometry.
static QgsGeometry fromPolylineXY(const QgsPolylineXY &polyline)
Creates a new LineString geometry from a list of QgsPointXY points.
Point geometry type, with support for z-dimension and m-values.
QgsAbstractGeometry::const_part_iterator const_parts_end() const
Returns STL-style iterator pointing to the imaginary part after the last part of the geometry.
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
QString asJson(int precision=17) const
Exports the geometry to a GeoJSON string.
static QgsGeometry fromMultiPolylineXY(const QgsMultiPolylineXY &multiline)
Creates a new geometry from a QgsMultiPolylineXY object.
static QgsGeometry fromPolyline(const QgsPolyline &polyline)
Creates a new LineString geometry from a list of QgsPoint points.
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer using the m-values from a (multi)line geometry.
QgsGeometry removeInteriorRings(double minimumAllowedArea=-1) const
Removes the interior rings from a (multi)polygon geometry.
static std::unique_ptr< QgsPolygon > fromPolygonXY(const QgsPolygonXY &polygon)
Construct geometry from a polygon.
QgsGeometryPartIterator parts()
Returns Java-style iterator for traversal of parts of the geometry.
const QgsCurve * exteriorRing() const SIP_HOLDGIL
Returns the curve polygon's exterior ring.
QDataStream & operator<<(QDataStream &out, const QgsGeometry &geometry)
Writes the geometry to stream out. QGIS version compatibility is not guaranteed.
virtual void setExteriorRing(QgsCurve *ring)
Sets the exterior ring of the polygon.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
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...
static Type flatType(Type type) SIP_HOLDGIL
Returns the flat type for a WKB type.
static std::unique_ptr< QgsAbstractGeometry > geomFromWkb(QgsConstWkbPtr &wkb)
Construct geometry from a WKB string.
EndCapStyle
End cap styles for buffers.
Curve polygon geometry type.
QgsGeometry interpolate(double distance) const
Returns an interpolated point on the geometry at the specified distance.
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
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 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...
Contains geos related utilities and functions.
static QgsGeometry fromPointXY(const QgsPointXY &point) SIP_HOLDGIL
Creates a new geometry from a QgsPointXY object.
@ EngineError
Error occurred in the geometry engine.
Multi line string geometry collection.
QgsGeometry poleOfInaccessibility(double precision, double *distanceFromBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
static std::unique_ptr< QgsMultiPolygon > fromMultiPolygonXY(const QgsMultiPolygonXY &multipoly)
Construct geometry from a multipolygon.
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 centroid() const
Returns the center of mass of a geometry.
double frechetDistance(const QgsGeometry &geom) const SIP_THROW(QgsNotSupportedException)
Returns the Fréchet distance between this geometry and geom, restricted to discrete points for both g...
static QVector< QgsPointXY > randomPointsInPolygon(const QgsGeometry &polygon, int count, const std::function< bool(const QgsPointXY &) > &acceptPoint, unsigned long seed=0, QgsFeedback *feedback=nullptr, int maxTriesPerPoint=0)
Returns a list of count random points generated inside a polygon geometry (if acceptPoint is specifie...
Java-style iterator for const traversal of parts of a geometry.
static QgsGeometry fromQPointF(QPointF point) SIP_HOLDGIL
Construct geometry from a QPointF.
QgsGeometry minimumClearanceLine() const SIP_THROW(QgsNotSupportedException)
Returns a LineString whose endpoints define the minimum clearance of a geometry.
void setY(double y) SIP_HOLDGIL
Sets the y value of the point.
@ MethodNotImplemented
Method not implemented in geometry engine.
static double lineAngle(double x1, double y1, double x2, double y2) SIP_HOLDGIL
Calculates the direction of line joining two points in radians, clockwise from the north direction.
const double * yData() const
Returns a const pointer to the y vertex data.
virtual double length() const
Returns the planar, 2-dimensional length of the geometry.
QPointF toQPointF() const
Converts a point to a QPointF.
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
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...
QgsGeometry minimalEnclosingCircle(QgsPointXY ¢er, double &radius, unsigned int segments=36) const
Returns the minimal enclosing circle for the geometry.
QgsAbstractGeometry::const_part_iterator const_parts_begin() const
Returns STL-style const iterator pointing to the first part of the geometry.
Type
The WKB type describes the number of dimensions a geometry has.
QgsGeometry & operator=(QgsGeometry const &rhs)
Creates a deep copy of the object.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
QgsAbstractGeometry * buffer(double distance, int segments, QString *errorMsg=nullptr) const override
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...
QString lastError() const
Returns an error string referring to the last error encountered.
static Type multiType(Type type) SIP_HOLDGIL
Returns the multi type for a WKB type.
static double sqrDistance2D(const QgsPoint &pt1, const QgsPoint &pt2) SIP_HOLDGIL
Returns the squared 2D distance between two points.
Line string geometry type, with support for z-dimension and m-values.
bool overlaps(const QgsGeometry &geometry) const
Returns true if the geometry overlaps another geometry.
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 roundWaves(double wavelength, double amplitude, bool strictWavelength=false) const
Constructs rounded (sine-like) waves along the boundary of the geometry, with the specified wavelengt...
void setX(double x) SIP_HOLDGIL
Sets the x value of the point.
QgsGeometry buffer(double distance, int segments) const
Returns a buffer region around this geometry having the given width and with a specified number of se...
double frechetDistanceDensify(const QgsGeometry &geom, double densifyFraction) const SIP_THROW(QgsNotSupportedException)
Returns the Fréchet distance between this geometry and geom, restricted to discrete points for both g...
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
bool deletePart(int partNum)
Deletes part identified by the part number.
A rectangle specified with double values.
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.
QgsMultiPolylineXY asMultiPolyline() const
Returns the contents of the geometry as a multi-linestring.
GeometryValidationEngine
Available engines for validating geometries.
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
QVector< QgsGeometry > asGeometryCollection() const
Returns contents of the geometry as a list of geometries.
double hausdorffDistance(const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const
Returns the Hausdorff distance between this geometry and geom.
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 ...
QgsPoint project(double distance, double azimuth, double inclination=90.0) const SIP_HOLDGIL
Returns a new point which corresponds to this point projected by a specified distance with specified ...
const double * xData() const
Returns a const pointer to the x vertex data.
QgsGeometry mergeLines() const
Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line ...
int numGeometries() const SIP_HOLDGIL
Returns the number of geometries within the collection.
double distanceToVertex(int vertex) const
Returns the distance along this geometry from its first vertex to the specified vertex.
QgsGeometry intersection(const QgsGeometry &geometry) const
Returns a geometry representing the points shared by this geometry and other.
virtual int vertexCount(int part=0, int ring=0) const =0
Returns the number of vertices of which this geometry is built.
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 bool deleteRing(QgsAbstractGeometry *geom, int ringNum, int partNum=0)
Deletes a ring from a geometry.
QgsGeometry forcePolygonClockwise() const
Forces geometries to respect the exterior ring is clockwise, interior rings are counter-clockwise con...
bool isMultipart() const SIP_HOLDGIL
Returns true if WKB of the geometry is of WKBMulti* type.
QgsGeometry nearestPoint(const QgsGeometry &other) const
Returns the nearest (closest) point on this geometry to another geometry.
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
bool isMeasure() const SIP_HOLDGIL
Returns true if the geometry contains m values.
static Q_DECL_DEPRECATED QgsPolylineXY createPolylineFromQPolygonF(const QPolygonF &polygon)
Creates a QgsPolylineXY from a QPolygonF.
static QgsCircle from2Points(const QgsPoint &pt1, const QgsPoint &pt2) SIP_HOLDGIL
Constructs a circle by 2 points on the circle.
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.
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.
bool isGeosEqual(const QgsGeometry &) const
Compares the geometry with another geometry using GEOS.
bool deleteRing(int ringNum, int partNum=0)
Deletes a ring in polygon or multipolygon.
int numInteriorRings() const SIP_HOLDGIL
Returns the number of interior rings contained with the curve polygon.
The part_iterator class provides STL-style iterator for geometry parts.
#define Q_NOWARN_DEPRECATED_POP
QgsGeometryCollection * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
bool hasWhere() const
true if the location available from
Qgis::GeometryOperationResult addRing(const QVector< QgsPointXY > &ring)
Adds a new ring to this geometry.
QPolygonF asQPolygonF() const SIP_HOLDGIL
Returns contents of the geometry as a QPolygonF.
QgsGeometry poleOfInaccessibility(double precision, double *distanceToBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
QgsPolygonXY asPolygon() const
Returns the contents of the geometry as a polygon.
bool intersects(const QgsRectangle &rectangle) const
Returns true if this geometry exactly intersects with a rectangle.
bool removeInteriorRing(int ringIndex)
Removes an interior ring from the polygon.
QgsLineString * clone() const override
Clones the geometry by performing a deep copy.
Qgis::GeometryOperationResult reshapeGeometry(const QgsLineString &reshapeLineString)
Replaces a part of this geometry with another line.
double minimumClearance() const SIP_THROW(QgsNotSupportedException)
Computes the minimum clearance of a geometry.
int partCount() const override
Returns count of parts contained in the geometry.
@ NodedGeometryError
Error occurred while creating a noded geometry.
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,...
Circular string geometry type.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
@ InvalidBaseGeometry
The geometry on which the operation occurs is not valid.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
static std::unique_ptr< QgsMultiLineString > fromMultiPolylineXY(const QgsMultiPolylineXY &multiline)
Construct geometry from a multipolyline.
static std::unique_ptr< QgsGeometryCollection > createCollectionOfType(QgsWkbTypes::Type type)
Returns a new geometry collection matching a specified WKB type.
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...
int wkbSize(QgsAbstractGeometry::WkbFlags flags=QgsAbstractGeometry::WkbFlags()) const
Returns the length of the QByteArray returned by asWkb()
static QgsGeometry fromMultiPointXY(const QgsMultiPointXY &multipoint)
Creates a new geometry from a QgsMultiPointXY object.
QgsGeometry extendLine(double startDistance, double endDistance) const
Extends a (multi)line geometry by extrapolating out the start or end of the line by a specified dista...
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...
QgsGeometry convertToCurves(double distanceTolerance, double angleTolerance) const
Attempts to convert a non-curved geometry into a curved geometry type (e.g.
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...
QString what() const
A human readable error message containing details about the error.
double sqrDistToVertexAt(QgsPointXY &point SIP_IN, int atVertex) const
Returns the squared Cartesian distance between the given point to the given vertex index (vertex at t...
@ GeometryEngineError
Geometry engine misses a method implemented or an error occurred in the geometry engine.
virtual void addInteriorRing(QgsCurve *ring)
Adds an interior ring to the geometry (takes ownership)
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.
This class offers geometry processing methods.
DashPatternSizeAdjustment
Dash pattern size adjustment options.
The part_iterator class provides STL-style iterator for const references to geometry parts.
QgsGeometry minimumWidth() const SIP_THROW(QgsNotSupportedException)
Returns a linestring geometry which represents the minimum diameter of the geometry.
QgsPointXY where() const
The coordinates at which the error is located and should be visualized.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Base class for feedback objects to be used for cancellation of something running in a worker thread.
bool convertToSingleType()
Converts multi type geometry into single type geometry e.g.
bool equals(const QgsGeometry &geometry) const
Test if this geometry is exactly equal to another geometry.
BufferSide
Side of line to buffer.
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 ...
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer for a (multi)linestring geometry, where the width at each node is ...
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a variable width buffer ("tapered buffer") for a (multi)curve geometry.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
Does vector analysis using the geos library and handles import, export, exception handling*.
static QgsGeometry polygonize(const QVector< const QgsAbstractGeometry * > &geometries, QString *errorMsg=nullptr)
Creates a GeometryCollection geometry containing possible polygons formed from the constituent linewo...
static double averageAngle(double x1, double y1, double x2, double y2, double x3, double y3) SIP_HOLDGIL
Calculates the average angle (in radians) between the two linear segments from (x1,...
static std::unique_ptr< QgsMultiPoint > fromMultiPointXY(const QgsMultiPointXY &multipoint)
Construct geometry from a multipoint.
static QgsLineString * fromQPolygonF(const QPolygonF &polygon)
Returns a new linestring from a QPolygonF polygon input.
double radius() const SIP_HOLDGIL
Returns the radius of the circle.
GeometryOperationResult
Success or failure of a geometry operation.
QgsGeometry convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry.
Qgis::GeometryOperationResult rotate(double rotation, const QgsPointXY ¢er)
Rotate this geometry around the Z axis.
bool deleteVertex(int atVertex)
Deletes the vertex at the given position number and item (first number is index 0)
void setX(double x) SIP_HOLDGIL
Sets the point's x-coordinate.
QgsGeometry node() const
Returns a (Multi)LineString representing the fully noded version of a collection of linestrings.
static bool hasM(Type type) SIP_HOLDGIL
Tests whether a WKB type contains m values.
QgsGeometry densifyByDistance(double distance) const
Densifies the geometry by adding regularly placed extra nodes inside each segment so that the maximum...
QgsCircularString * toCircularString(bool oriented=false) const
Returns a circular string from the circle.
static std::unique_ptr< QgsAbstractGeometry > geomFromWkt(const QString &text)
Construct geometry from a WKT string.
double length() const
Returns the planar, 2-dimensional length of geometry.
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
QCache< QString, QgsGeometry > WktCache
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QgsGeometry extrude(double x, double y)
Returns an extruded version of this geometry.
bool crosses(const QgsGeometry &geometry) const
Returns true if the geometry crosses another geometry.
Multi polygon geometry collection.
void draw(QPainter &p) const
Draws the geometry onto a QPainter.
void transformVertices(const std::function< QgsPoint(const QgsPoint &) > &transform)
Transforms the vertices from the geometry in place, applying the transform function to every vertex.
QPointF asQPointF() const SIP_HOLDGIL
Returns contents of the geometry as a QPointF if wkbType is WKBPoint, otherwise returns a null QPoint...
QgsGeometry clipped(const QgsRectangle &rectangle)
Clips the geometry using the specified rectangle.
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...
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
std::unique_ptr< QgsAbstractGeometry > geometry
double closestSegmentWithContext(const QgsPointXY &point, QgsPointXY &minDistPoint, int &nextVertexIndex, int *leftOrRightOfSegment=nullptr, double epsilon=DEFAULT_SEGMENT_EPSILON) const
Searches for the closest segment of geometry to the given point.
JoinStyle
Join styles for buffers.
const QgsCurve * interiorRing(int i) const SIP_HOLDGIL
Retrieves an interior ring from the curve polygon.
QgsPoint center() const SIP_HOLDGIL
Returns the center point.
QgsGeometry pointOnSurface() const
Returns a point guaranteed to lie on the surface of a geometry.
static Qgis::GeometryOperationResult addPart(QgsAbstractGeometry *geometry, std::unique_ptr< QgsAbstractGeometry > part)
Add a part to multi type geometry.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Qgis::GeometryOperationResult translate(double dx, double dy, double dz=0.0, double dm=0.0)
Translates this geometry by dx, dy, dz and dm.
bool touches(const QgsGeometry &geometry) const
Returns true if the geometry touches another geometry.
Multi point geometry collection.
QgsPointXY transform(const QgsPointXY &p) const
Transforms a point p from map (world) coordinates to device coordinates.
static QgsPoint closestVertex(const QgsAbstractGeometry &geom, const QgsPoint &pt, QgsVertexId &id)
Returns the closest vertex to a geometry for a specified point.
Abstract base class for all geometries.
QgsGeometry simplify(double tolerance) const
Returns a simplified version of this geometry using a specified tolerance value.
static Qgis::GeometryOperationResult addRing(QgsAbstractGeometry *geometry, std::unique_ptr< QgsCurve > ring)
Add an interior ring to a geometry.
static bool deletePart(QgsAbstractGeometry *geom, int partNum)
Deletes a part from a geometry.
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
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.
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
QgsPoint * pointN(int index)
Returns the point with the specified index.
double frechetDistanceDensify(const QgsAbstractGeometry *geom, double densifyFraction, QString *errorMsg=nullptr) const
Returns the Fréchet distance between this geometry and geom, restricted to discrete points for both g...
QgsPointSequence QgsPolyline
Polyline as represented as a vector of points.
A class to represent a 2D point.
QgsGeometry() SIP_HOLDGIL
Constructor.
double hausdorffDistance(const QgsGeometry &geom) const
Returns the Hausdorff distance between this geometry and geom.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
virtual QgsRectangle boundingBox() const =0
Returns the minimal bounding box for the geometry.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
QgsGeometry densifyByDistance(double distance) const
Densifies the geometry by adding regularly placed extra nodes inside each segment so that the maximum...
DashPatternLineEndingRule
Dash pattern line ending rules.
static double distanceToVertex(const QgsAbstractGeometry &geom, QgsVertexId id)
Returns the distance along a geometry from its first vertex to the specified vertex.
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.
virtual json asJsonObject(int precision=17) const
Exports the geometry to a json object.
bool isValid() const SIP_HOLDGIL
Returns true if the vertex id is valid.
static QgsGeometry polygonize(const QVector< QgsGeometry > &geometries)
Creates a GeometryCollection geometry containing possible polygons formed from the constituent linewo...
bool requiresConversionToStraightSegments() const
Returns true if the geometry is a curved geometry type which requires conversion to display as straig...
@ NothingHappened
Nothing happened, without any error.
QgsAbstractGeometry * get()
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine representing the specified geometry.
static bool isCurvedType(Type type) SIP_HOLDGIL
Returns true if the WKB type is a curved type or can contain curved geometries.
QString asWkt(int precision=17) const
Exports the geometry to WKT.
double interpolateAngle(double distance) const
Returns the angle parallel to the linestring or polygon boundary at the specified distance along the ...
QVector< QgsGeometry > coerceToType(QgsWkbTypes::Type type, double defaultZ=0, double defaultM=0) const
Attempts to coerce this geometry into the specified destination type.
@ SplitCannotSplitPoint
Points cannot be split.
static QgsGeometry fromPolygonXY(const QgsPolygonXY &polygon)
Creates a new geometry from a QgsPolygonXY.
@ InvalidBaseGeometry
The base geometry on which the operation is done is invalid or empty.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
QgsGeometry makeValid() const
Attempts to make an invalid geometry valid without losing vertices.
static void convertPointList(const QVector< QgsPointXY > &input, QgsPointSequence &output)
Upgrades a point list from QgsPointXY to QgsPoint.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
The vertex_iterator class provides STL-style iterator for vertices.
QgsGeometry shortestLine(const QgsGeometry &other) const
Returns the shortest line joining this geometry to another geometry.
QVector< QgsPoint > QgsPointSequence
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
A geometry is the spatial representation of a feature.
Perform transforms between map coordinates and device coordinates.
Java-style iterator for traversal of parts of a geometry.
Represents a vector layer which manages a vector based data sets.
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.
QgsLineString * lineStringN(int index)
Returns the line string with the specified index.
@ Success
Operation succeeded.
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
@ Success
Operation succeeded.
bool toggleCircularAtVertex(int atVertex)
Converts the vertex at the given position from/to circular.
static QgsGeometry fromRect(const QgsRectangle &rect) SIP_HOLDGIL
Creates a new geometry from a QgsRectangle.
Utility class for identifying a unique vertex within a geometry.
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...
QgsGeometry forceRHR() const
Forces geometries to respect the Right-Hand-Rule, in which the area that is bounded by a polygon is t...
QgsGeometry convertToType(QgsWkbTypes::GeometryType destType, bool destMultipart=false) const
Try to convert the geometry to the requested type.
double closestVertexWithContext(const QgsPointXY &point, int &atVertex) const
Searches for the closest vertex in this geometry to the given point.
int vertexNrFromVertexId(QgsVertexId id) const
Returns the vertex number corresponding to a vertex id.
void mapToPixel(const QgsMapToPixel &mtp)
Transforms the geometry from map units to pixels in place.
QgsGeometry makeDifference(const QgsGeometry &other) const
Returns the geometry formed by modifying this geometry such that it does not intersect the other geom...
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...
QgsPolylineXY asPolyline() const
Returns the contents of the geometry as a polyline.
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.
QgsVertexIterator vertices() const
Returns a read-only, Java-style iterator for traversal of vertices of all the geometry,...
static GeometryType geometryType(Type type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
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.
QgsMultiPointXY asMultiPoint() const
Returns the contents of the geometry as a multi-point.
bool isSimple() const
Determines whether the geometry is simple (according to OGC definition), i.e.
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
static QgsGeometry createWedgeBuffer(const QgsPoint ¢er, double azimuth, double angularWidth, double outerRadius, double innerRadius=0)
Creates a wedge shaped buffer from a center point.
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 forcePolygonCounterClockwise() const
Forces geometries to respect the exterior ring is counter-clockwise, interior rings are clockwise con...
EngineOperationResult
Success or failure of a geometry operation.
Java-style iterator for traversal of vertices of a geometry.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
static bool hasZ(Type type) SIP_HOLDGIL
Tests whether a WKB type contains the z-dimension.
virtual QgsPolygon * toPolygon(unsigned int segments=36) const
Returns a segmented polygon.
bool vertexIdFromVertexNr(int number, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
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.
static QgsGeometry fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
QgsGeometry symDifference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other.
bool contains(const QgsPointXY *p) const
Returns true if the geometry contains the point p.
virtual int numPoints() const =0
Returns the number of points in the curve.
TransformDirection
Indicates the direction (forward or inverse) of a transform.
QgsAbstractGeometry::vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
QgsAbstractGeometry::part_iterator parts_begin()
Returns STL-style iterator pointing to the first part of the geometry.
static double angleBetweenThreePoints(double x1, double y1, double x2, double y2, double x3, double y3) SIP_HOLDGIL
Calculates the angle between the lines AB and BC, where AB and BC described by points a,...
void adjacentVertices(int atVertex, int &beforeVertex, int &afterVertex) const
Returns the indexes of the vertices before and after the given vertex index.
QgsCurve * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
QgsAbstractGeometry::vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
QgsGeometry largestEmptyCircle(double tolerance, const QgsGeometry &boundary=QgsGeometry()) const SIP_THROW(QgsNotSupportedException)
Constructs the Largest Empty Circle for a set of obstacle geometries, up to a specified tolerance.
Q_GLOBAL_STATIC_WITH_ARGS(WktCache, sWktCache,(2000)) QgsGeometry QgsGeometry
double frechetDistance(const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const
Returns the Fréchet distance between this geometry and geom, restricted to discrete points for both g...
int numPoints() const override SIP_HOLDGIL
Returns the number of points in the curve.
static bool isMultiType(Type type) SIP_HOLDGIL
Returns true if the WKB type is a multi type.
QgsWkbTypes::GeometryType type
#define Q_NOWARN_DEPRECATED_PUSH
@ NothingHappened
Nothing happened, without any error.
static std::unique_ptr< QgsAbstractGeometry > geomFromWkbType(QgsWkbTypes::Type t)
Returns empty geometry from wkb type.
A geometry engine is a low-level representation of a QgsAbstractGeometry object, optimised for use wi...
bool isEmpty() const
Returns true if the rectangle is empty.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
double area() const
Returns the planar, 2-dimensional area of the geometry.
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.
virtual bool removeGeometry(int nr)
Removes a geometry from the collection.
virtual int ringCount(int part=0) const =0
Returns the number of rings of which this geometry is built.
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.
@ InvalidInputGeometryType
The input geometry (ring, part, split line, etc.) has not the correct geometry type.
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...
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
void set(QgsAbstractGeometry *geometry)
Sets the underlying geometry store.
QgsGeometry difference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other.
static QgsPointXY interpolatePointOnLine(double x1, double y1, double x2, double y2, double fraction) SIP_HOLDGIL
Interpolates the position of a point a fraction of the way along the line from (x1,...
bool boundingBoxIntersects(const QgsRectangle &rectangle) const
Returns true if the bounding box of this geometry intersects with a rectangle.
QgsPolygon * polygonN(int index)
Returns the polygon with the specified index.
static std::unique_ptr< QgsAbstractGeometry > fromPolylineXY(const QgsPolylineXY &polyline)
Construct geometry from a polyline.
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...
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
QgsGeometry delaunayTriangulation(double tolerance=0.0, bool edgesOnly=false) const
Returns the Delaunay triangulation for the vertices of the geometry.
Compound curve geometry type.
static QgsGeometry fromMultiPolygonXY(const QgsMultiPolygonXY &multipoly)
Creates a new geometry from a QgsMultiPolygonXY.
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a tapered width buffer for a (multi)curve geometry.
AngularDirection
Angular directions.
@ SplitCannotSplitPoint
Cannot split points.
static QgsGeometry unaryUnion(const QVector< QgsGeometry > &geometries)
Compute the unary union on a list of geometries.
QgsGeometryConstPartIterator constParts() const
Returns Java-style iterator for traversal of parts of the geometry.
static QgsGeometry collectGeometry(const QVector< QgsGeometry > &geometries)
Creates a new multipart geometry from a list of QgsGeometry objects.
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 orientedMinimumBoundingBox() const
Returns the oriented minimum bounding box for the geometry, which is the smallest (by area) rotated r...
QgsMultiPolygonXY asMultiPolygon() const
Returns the contents of the geometry as a multi-polygon.
QgsAbstractGeometry::part_iterator parts_end()
Returns STL-style iterator pointing to the imaginary part after the last part of the geometry.
bool isGeosValid(Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const
Checks validity of the geometry using GEOS.
static std::unique_ptr< QgsAbstractGeometry > fromPointXY(const QgsPointXY &point)
Construct geometry from a point.
double lineLocatePoint(const QgsGeometry &point) const
Returns a distance representing the location along this linestring of the closest point on this lines...
bool disjoint(const QgsGeometry &geometry) const
Returns true if the geometry is disjoint of another geometry.