53 std::unique_ptr< QgsAbstractGeometry >
geometry;
63 if ( !d->
ref.deref() )
71 d->
ref = QAtomicInt( 1 );
78 d->
ref = QAtomicInt( 1 );
84 mLastError = other.mLastError;
90 if ( !d->
ref.deref() )
95 mLastError = other.mLastError;
101 void QgsGeometry::detach()
106 std::unique_ptr< QgsAbstractGeometry > cGeom;
108 cGeom.reset( d->
geometry->clone() );
110 reset( std::move( cGeom ) );
113 void QgsGeometry::reset( std::unique_ptr<QgsAbstractGeometry> newGeometry )
117 ( void )d->
ref.deref();
120 d->
geometry = std::move( newGeometry );
136 if ( d->
geometry.get() == geometry )
141 reset( std::unique_ptr< QgsAbstractGeometry >( geometry ) );
181 return QgsGeometry( qgis::make_unique< QgsLineString >( polyline ) );
226 std::unique_ptr< QgsLineString > ext = qgis::make_unique< QgsLineString >(
227 QVector< double >() << rect.
xMinimum()
232 QVector< double >() << rect.
yMinimum()
237 std::unique_ptr< QgsPolygon > polygon = qgis::make_unique< QgsPolygon >();
238 polygon->setExteriorRing( ext.release() );
353 d->
geometry->adjacentVertices(
id, prevVertex, nextVertex );
389 return d->
geometry->vertexAngle( v2 );
408 d->
geometry->adjacentVertices(
id, beforeVertexId, afterVertexId );
446 return d->
geometry->moveVertex(
id, p );
479 return d->
geometry->deleteVertex(
id );
531 return d->
geometry->insertVertex(
id, point );
547 return d->
geometry->vertexAt( vId );
561 result.mLastError = mLastError;
570 result.mLastError = mLastError;
594 double epsilon )
const 604 double sqrDist = d->
geometry->closestSegment(
QgsPoint( point.
x(), point.
y() ), segmentPt, vertexAfter, leftOf, epsilon );
608 minDistPoint.
setX( segmentPt.
x() );
609 minDistPoint.
setY( segmentPt.
y() );
616 std::unique_ptr< QgsLineString > ringLine = qgis::make_unique< QgsLineString >( ring );
617 return addRing( ringLine.release() );
622 std::unique_ptr< QgsCurve > r( ring );
642 std::unique_ptr< QgsAbstractGeometry > partGeom;
643 if ( points.size() == 1 )
645 partGeom = qgis::make_unique< QgsPoint >( points[0] );
647 else if ( points.size() > 1 )
649 std::unique_ptr< QgsLineString > ringLine = qgis::make_unique< QgsLineString >();
650 ringLine->setPoints( points );
651 partGeom = std::move( ringLine );
653 return addPart( partGeom.release(), geomType );
658 std::unique_ptr< QgsAbstractGeometry > p( part );
664 reset( qgis::make_unique< QgsMultiPoint >() );
667 reset( qgis::make_unique< QgsMultiLineString >() );
670 reset( qgis::make_unique< QgsMultiPolygon >() );
674 return QgsGeometry::OperationResult::AddPartNotMultiGeometry;
692 if ( !newPart || !newPart.d->
geometry )
710 QVector<QgsGeometry> results;
717 if ( results.isEmpty() )
721 for (
const QgsGeometry &result : qgis::as_const( results ) )
729 std::unique_ptr< QgsCurvePolygon > newPoly( static_cast< QgsCurvePolygon * >( d->
geometry->clone() ) );
730 newPoly->removeInteriorRings( minimumRingArea );
761 d->
geometry->transform( QTransform::fromTranslate( dx, dy ), dz, 1.0, dm );
774 QTransform t = QTransform::fromTranslate( center.
x(), center.
y() );
775 t.rotate( -rotation );
776 t.translate( -center.
x(), -center.
y() );
785 return QgsGeometry::OperationResult::InvalidBaseGeometry;
788 QVector<QgsGeometry > newGeoms;
798 *
this = newGeoms.takeAt( 0 );
800 newGeometries = newGeoms;
808 return QgsGeometry::OperationResult::Success;
812 return QgsGeometry::OperationResult::GeometryEngineError;
814 return QgsGeometry::OperationResult::InvalidBaseGeometry;
816 return QgsGeometry::OperationResult::InvalidInputGeometryType;
818 return QgsGeometry::OperationResult::SplitCannotSplitPoint;
820 return QgsGeometry::OperationResult::NothingHappened;
839 std::unique_ptr< QgsAbstractGeometry > geom(
geos.reshapeGeometry( reshapeLineString, &errorCode, &mLastError ) );
842 reset( std::move( geom ) );
878 std::unique_ptr< QgsAbstractGeometry > diffGeom(
geos.intersection( other.
constGet(), &mLastError ) );
884 reset( std::move( diffGeom ) );
898 std::unique_ptr< QgsAbstractGeometry > diffGeom(
geos.intersection( other.
constGet(), &mLastError ) );
902 result.mLastError = mLastError;
940 double prevAngle = 0.0;
944 double rotateAngle = 180.0 / M_PI * ( currentAngle - prevAngle );
945 prevAngle = currentAngle;
947 QTransform t = QTransform::fromTranslate( pt0.
x(), pt0.
y() );
948 t.rotate( rotateAngle );
949 t.translate( -pt0.
x(), -pt0.
y() );
954 double currentArea = bounds.
width() * bounds.
height();
955 if ( currentArea < area )
959 angle = 180.0 / M_PI * currentAngle;
960 width = bounds.
width();
972 angle = std::fmod( angle, 180.0 );
985 auto l_boundary = boundary.length();
987 if ( ( points.length() == 0 ) || ( l_boundary == 3 ) )
989 switch ( l_boundary )
1001 boundary.pop_back();
1003 boundary.pop_back();
1020 circ_mec = __recMinimalEnclosingCircle( points, boundary );
1024 boundary.append( pxy );
1025 circ_mec = __recMinimalEnclosingCircle( points, boundary );
1049 QgsCircle circ = __recMinimalEnclosingCircle( P, R );
1070 return engine.
orthogonalize( tolerance, maxIterations, angleThreshold );
1079 return QgsGeometry( d->
geometry->snappedToGrid( hSpacing, vSpacing, dSpacing, mSpacing ) );
1088 return d->
geometry->removeDuplicateNodes( epsilon, useZValues );
1106 return geos.intersects( geometry.d->
geometry.get(), &mLastError );
1116 return d->
geometry->boundingBox().intersects( rectangle );
1139 return geos.contains( &pt, &mLastError );
1151 return geos.contains( geometry.d->
geometry.get(), &mLastError );
1163 return geos.disjoint( geometry.d->
geometry.get(), &mLastError );
1174 if ( d == geometry.d )
1190 return geos.touches( geometry.d->
geometry.get(), &mLastError );
1202 return geos.overlaps( geometry.d->
geometry.get(), &mLastError );
1214 return geos.within( geometry.d->
geometry.get(), &mLastError );
1226 return geos.crosses( geometry.d->
geometry.get(), &mLastError );
1235 return d->
geometry->asWkt( precision );
1242 return QStringLiteral(
"null" );
1244 return d->
geometry->asJson( precision );
1252 return convertToPoint( destMultipart );
1255 return convertToLine( destMultipart );
1258 return convertToPolygon( destMultipart );
1310 if ( !multiGeom || multiGeom->
partCount() < 1 )
1313 std::unique_ptr< QgsAbstractGeometry > firstPart( multiGeom->
geometryN( 0 )->
clone() );
1314 reset( std::move( firstPart ) );
1343 std::unique_ptr< QgsLineString > segmentizedLine;
1345 if ( doSegmentation )
1353 line = segmentizedLine.get();
1365 polyLine.resize( nVertices );
1366 for (
int i = 0; i < nVertices; ++i )
1368 polyLine[i].setX( line->
xAt( i ) );
1369 polyLine[i].setY( line->
yAt( i ) );
1383 std::unique_ptr< QgsPolygon > segmentized;
1384 if ( doSegmentation )
1391 segmentized.reset( curvePoly->
toPolygon() );
1392 p = segmentized.get();
1405 convertPolygon( *p, polygon );
1425 for (
int i = 0; i < nPoints; ++i )
1428 multiPoint[i].
setX( pt->
x() );
1429 multiPoint[i].setY( pt->
y() );
1442 if ( !geomCollection )
1454 for (
int i = 0; i < nLines; ++i )
1457 std::unique_ptr< QgsLineString > segmentized;
1466 line = segmentized.get();
1470 line->
points( lineCoords );
1472 convertToPolyline( lineCoords, polyLine );
1473 mpl.append( polyLine );
1486 if ( !geomCollection )
1492 if ( nPolygons < 1 )
1498 for (
int i = 0; i < nPolygons; ++i )
1515 convertPolygon( *polygon, poly );
1531 double geosArea = g.
area();
1532 double qgisArea = 0;
1536 qgisArea = surface->
area();
1541 return g.area( &mLastError );
1552 return g.length( &mLastError );
1564 return g.distance( geom.d->
geometry.get(), &mLastError );
1576 return g.hausdorffDistance( geom.d->
geometry.get(), &mLastError );
1588 return g.hausdorffDistanceDensify( geom.d->
geometry.get(), densifyFraction, &mLastError );
1595 return d->
geometry->vertices_begin();
1602 return d->
geometry->vertices_end();
1621 std::unique_ptr<QgsAbstractGeometry> geom( g.buffer( distance, segments, &mLastError ) );
1625 result.mLastError = mLastError;
1640 QgsAbstractGeometry *geom = g.buffer( distance, segments, endCapStyle, joinStyle, miterLimit, &mLastError );
1644 result.mLastError = mLastError;
1660 QVector<QgsGeometry> results;
1661 results.reserve( parts.count() );
1668 if ( results.isEmpty() )
1672 for (
const QgsGeometry &result : qgis::as_const( results ) )
1686 result.mLastError = mLastError;
1703 QVector<QgsGeometry> results;
1704 results.reserve( parts.count() );
1711 if ( results.isEmpty() )
1715 for (
const QgsGeometry &result : qgis::as_const( results ) )
1725 std::unique_ptr< QgsAbstractGeometry > bufferGeom =
geos.singleSidedBuffer( distance, segments, side,
1726 joinStyle, miterLimit, &mLastError );
1730 result.mLastError = mLastError;
1747 QVector<QgsGeometry> results;
1748 results.reserve( parts.count() );
1755 if ( results.isEmpty() )
1759 for (
const QgsGeometry &result : qgis::as_const( results ) )
1771 std::unique_ptr< QgsLineString > newLine( line->
clone() );
1772 newLine->extend( startDistance, endDistance );
1786 std::unique_ptr< QgsAbstractGeometry > simplifiedGeom(
geos.simplify( tolerance, &mLastError ) );
1787 if ( !simplifiedGeom )
1790 result.mLastError = mLastError;
1793 return QgsGeometry( std::move( simplifiedGeom ) );
1821 result.mLastError = mLastError;
1836 result.mLastError = mLastError;
1855 std::unique_ptr< QgsAbstractGeometry > cHull(
geos.convexHull( &mLastError ) );
1859 geom.mLastError = mLastError;
1875 result.mLastError = mLastError;
1888 QgsGeometry result =
geos.delaunayTriangulation( tolerance, edgesOnly );
1889 result.mLastError = mLastError;
1901 std::unique_ptr< QgsAbstractGeometry > segmentizedCopy;
1904 segmentizedCopy.reset( d->
geometry->segmentize() );
1905 geom = segmentizedCopy.get();
1910 std::unique_ptr< QgsAbstractGeometry > result( geos.
subdivide( maxNodes, &mLastError ) );
1914 geom.mLastError = mLastError;
1933 std::unique_ptr< QgsAbstractGeometry > result(
geos.interpolate( distance, &mLastError ) );
1937 geom.mLastError = mLastError;
1954 segmentized =
QgsGeometry( static_cast< QgsCurve * >( d->
geometry.get() )->segmentize() );
1959 return geos.lineLocatePoint( *( static_cast< QgsPoint * >( point.d->
geometry.get() ) ), &mLastError );
1971 segmentized =
QgsGeometry( static_cast< QgsCurve * >( d->
geometry.get() )->segmentize() );
1979 if ( previous == next )
2026 std::unique_ptr< QgsAbstractGeometry > resultGeom(
geos.intersection( geometry.d->
geometry.get(), &mLastError ) );
2031 geom.mLastError = mLastError;
2047 std::unique_ptr< QgsAbstractGeometry > resultGeom(
geos.combine( geometry.d->
geometry.get(), &mLastError ) );
2051 geom.mLastError = mLastError;
2073 result.mLastError = mLastError;
2087 std::unique_ptr< QgsAbstractGeometry > resultGeom(
geos.difference( geometry.d->
geometry.get(), &mLastError ) );
2091 geom.mLastError = mLastError;
2107 std::unique_ptr< QgsAbstractGeometry > resultGeom(
geos.symDifference( geometry.d->
geometry.get(), &mLastError ) );
2111 geom.mLastError = mLastError;
2121 return engine.
extrude( x, y );
2131 QVector<QgsGeometry> geometryList;
2134 return geometryList;
2141 geometryList.reserve( numGeom );
2142 for (
int i = 0; i < numGeom; ++i )
2152 return geometryList;
2173 if ( polygon.empty() )
2175 polyline = polygon.at( 0 );
2182 result.reserve( polyline.count() );
2183 for (
const QgsPointXY &p : qgis::as_const( polyline ) )
2185 result << p.toQPointF();
2230 reset( std::move( diffGeom ) );
2245 result.mLastError = mLastError;
2264 return geos.isValid( &mLastError );
2274 return geos.isSimple( &mLastError );
2286 return geos.isEqual( g.d->
geometry.get(), &mLastError );
2294 std::unique_ptr< QgsAbstractGeometry > geom( geos.
combine( geometries, &error ) );
2296 result.mLastError = error;
2304 QVector<const QgsAbstractGeometry *> geomV2List;
2307 if ( !( g.isNull() ) )
2309 geomV2List.append( g.constGet() );
2315 result.mLastError = error;
2326 std::unique_ptr< QgsAbstractGeometry > straightGeom( d->
geometry->segmentize() );
2327 reset( std::move( straightGeom ) );
2337 return d->
geometry->hasCurvedSegments();
2348 d->
geometry->transform( ct, direction, transformZ );
2360 d->
geometry->transform( ct, zTranslate, zScale, mTranslate, mScale );
2382 std::unique_ptr< QgsAbstractGeometry > resultGeom =
geos.clip( rectangle, &mLastError );
2386 result.mLastError = mLastError;
2400 static bool vertexIndexInfo(
const QgsAbstractGeometry *g,
int vertexIndex,
int &partIndex,
int &ringIndex,
int &vertex )
2402 if ( vertexIndex < 0 )
2405 if (
const QgsGeometryCollection *geomCollection = qgsgeometry_cast<const QgsGeometryCollection *>( g ) )
2409 for (
int i = 0; i < geomCollection->numGeometries(); ++i )
2415 for (
int k = 0; k < part->
ringCount(); ++k )
2418 if ( vertexIndex < numPoints )
2421 return vertexIndexInfo( part, vertexIndex, nothing, ringIndex, vertex );
2423 vertexIndex -= numPoints;
2424 offset += numPoints;
2428 else if (
const QgsCurvePolygon *curvePolygon = qgsgeometry_cast<const QgsCurvePolygon *>( g ) )
2430 const QgsCurve *ring = curvePolygon->exteriorRing();
2431 if ( vertexIndex < ring->numPoints() )
2435 vertex = vertexIndex;
2440 for (
int i = 0; i < curvePolygon->numInteriorRings(); ++i )
2442 const QgsCurve *ring = curvePolygon->interiorRing( i );
2443 if ( vertexIndex < ring->numPoints() )
2446 vertex = vertexIndex;
2453 else if (
const QgsCurve *curve = qgsgeometry_cast<const QgsCurve *>( g ) )
2455 if ( vertexIndex < curve->numPoints() )
2459 vertex = vertexIndex;
2463 else if ( qgsgeometry_cast<const QgsPoint *>( g ) )
2465 if ( vertexIndex == 0 )
2486 bool res = vertexIndexInfo( d->
geometry.get(), nr,
id.part,
id.ring,
id.vertex );
2492 if (
const QgsGeometryCollection *geomCollection = qgsgeometry_cast<const QgsGeometryCollection *>( g ) )
2494 g = geomCollection->geometryN(
id.part );
2497 if (
const QgsCurvePolygon *curvePolygon = qgsgeometry_cast<const QgsCurvePolygon *>( g ) )
2499 g =
id.ring == 0 ? curvePolygon->exteriorRing() : curvePolygon->interiorRing(
id.ring - 1 );
2502 if (
const QgsCurve *curve = qgsgeometry_cast<const QgsCurve *>( g ) )
2505 res = curve->pointAt(
id.vertex, p,
id.
type );
2519 return d->
geometry->vertexNumberFromVertexId(
id );
2545 QgsGeometry::operator bool()
const 2553 output.resize( input.size() );
2555 for (
int i = 0; i < input.size(); ++i )
2557 const QgsPoint &pt = input.at( i );
2558 output[i].
setX( pt.
x() );
2559 output[i].setY( pt.
y() );
2567 if ( coords.empty() )
2572 output.resize( rings.size() );
2573 for (
int i = 0; i < rings.size(); ++i )
2575 convertToPolyline( rings[i], output[i] );
2586 return QgsGeometry( qgis::make_unique< QgsPoint >( point.x(), point.y() ) );
2591 if ( polygon.isClosed() )
2611 result.reserve( polygon.count() );
2612 for (
const QPointF &p : polygon )
2621 if ( p1.count() != p2.count() )
2624 for (
int i = 0; i < p1.count(); ++i )
2626 if ( !p1.at( i ).compare( p2.at( i ), epsilon ) )
2634 if ( p1.count() != p2.count() )
2637 for (
int i = 0; i < p1.count(); ++i )
2648 if ( p1.count() != p2.count() )
2651 for (
int i = 0; i < p1.count(); ++i )
2678 return QgsGeometry( smoothLine( *lineString, iterations, offset, minimumDistance, maxAngle ) );
2685 std::unique_ptr< QgsMultiLineString > resultMultiline = qgis::make_unique< QgsMultiLineString> ();
2688 resultMultiline->
addGeometry( smoothLine( *( static_cast< QgsLineString * >( multiLine->
geometryN( i ) ) ), iterations, offset, minimumDistance, maxAngle ).release() );
2690 return QgsGeometry( std::move( resultMultiline ) );
2696 return QgsGeometry( smoothPolygon( *poly, iterations, offset, minimumDistance, maxAngle ) );
2703 std::unique_ptr< QgsMultiPolygon > resultMultiPoly = qgis::make_unique< QgsMultiPolygon >();
2706 resultMultiPoly->
addGeometry( smoothPolygon( *( static_cast< QgsPolygon * >( multiPoly->
geometryN( i ) ) ), iterations, offset, minimumDistance, maxAngle ).release() );
2708 return QgsGeometry( std::move( resultMultiPoly ) );
2718 const double offset,
double squareDistThreshold,
double maxAngleRads,
2721 std::unique_ptr< QgsLineString > result = qgis::make_unique< QgsLineString >( line );
2723 for (
unsigned int iteration = 0; iteration < iterations; ++iteration )
2725 outputLine.resize( 0 );
2726 outputLine.reserve( 2 * ( result->numPoints() - 1 ) );
2727 bool skipFirst =
false;
2728 bool skipLast =
false;
2731 QgsPoint p1 = result->pointN( result->numPoints() - 2 );
2736 angle = std::fabs( M_PI - angle );
2737 skipFirst = angle > maxAngleRads;
2739 for (
int i = 0; i < result->numPoints() - 1; i++ )
2742 QgsPoint p2 = result->pointN( i + 1 );
2744 double angle = M_PI;
2745 if ( i == 0 && isRing )
2747 QgsPoint p3 = result->pointN( result->numPoints() - 2 );
2751 else if ( i < result->numPoints() - 2 )
2753 QgsPoint p3 = result->pointN( i + 2 );
2757 else if ( i == result->numPoints() - 2 && isRing )
2764 skipLast = angle < M_PI - maxAngleRads || angle > M_PI + maxAngleRads;
2767 if ( i == 0 || i >= result->numPoints() - 2
2792 skipFirst = skipLast;
2795 if ( isRing && outputLine.at( 0 ) != outputLine.at( outputLine.count() - 1 ) )
2796 outputLine << outputLine.at( 0 );
2798 result->setPoints( outputLine );
2803 std::unique_ptr<QgsLineString> QgsGeometry::smoothLine(
const QgsLineString &line,
const unsigned int iterations,
const double offset,
double minimumDistance,
double maxAngle )
const 2805 double maxAngleRads = maxAngle * M_PI / 180.0;
2806 double squareDistThreshold = minimumDistance > 0 ? minimumDistance * minimumDistance : -1;
2807 return smoothCurve( line, iterations, offset, squareDistThreshold, maxAngleRads,
false );
2810 std::unique_ptr<QgsPolygon> QgsGeometry::smoothPolygon(
const QgsPolygon &polygon,
const unsigned int iterations,
const double offset,
double minimumDistance,
double maxAngle )
const 2812 double maxAngleRads = maxAngle * M_PI / 180.0;
2813 double squareDistThreshold = minimumDistance > 0 ? minimumDistance * minimumDistance : -1;
2814 std::unique_ptr< QgsPolygon > resultPoly = qgis::make_unique< QgsPolygon >();
2816 resultPoly->setExteriorRing(
smoothCurve( *( static_cast< const QgsLineString *>( polygon.
exteriorRing() ) ), iterations, offset,
2817 squareDistThreshold, maxAngleRads, true ).release() );
2821 resultPoly->addInteriorRing(
smoothCurve( *( static_cast< const QgsLineString *>( polygon.
interiorRing( i ) ) ), iterations, offset,
2822 squareDistThreshold, maxAngleRads, true ).release() );
2827 QgsGeometry QgsGeometry::convertToPoint(
bool destMultipart )
const 2835 if ( ( destMultipart && srcIsMultipart ) ||
2836 ( !destMultipart && !srcIsMultipart ) )
2841 if ( destMultipart )
2850 if ( multiPoint.count() == 1 )
2861 if ( !destMultipart )
2878 if ( !line.isEmpty() )
2887 if ( !destMultipart )
2918 QgsGeometry QgsGeometry::convertToLine(
bool destMultipart )
const 2928 if ( multiPoint.count() < 2 )
2931 if ( destMultipart )
2941 if ( ( destMultipart && srcIsMultipart ) ||
2942 ( !destMultipart && ! srcIsMultipart ) )
2947 if ( destMultipart )
2951 if ( !line.isEmpty() )
2958 if ( multiLine.count() == 1 )
2975 if ( destMultipart )
2980 else if ( multiLine.count() == 1 )
2991 if ( polygon.count() > 1 )
2995 if ( destMultipart )
2999 multiLine.reserve( polygon.count() );
3006 else if ( polygon.count() == 1 )
3008 if ( destMultipart )
3026 QgsGeometry QgsGeometry::convertToPolygon(
bool destMultipart )
const 3036 if ( multiPoint.count() < 3 )
3039 if ( multiPoint.last() != multiPoint.first() )
3040 multiPoint << multiPoint.first();
3043 if ( destMultipart )
3056 for ( QgsMultiPolylineXY::iterator multiLineIt = multiLine.begin(); multiLineIt != multiLine.end(); ++multiLineIt )
3059 if ( ( *multiLineIt ).count() < 3 )
3061 if ( ( *multiLineIt ).count() == 3 && ( *multiLineIt ).first() == ( *multiLineIt ).last() )
3065 if ( ( *multiLineIt ).first() != ( *multiLineIt ).last() )
3066 *multiLineIt << ( *multiLineIt ).first();
3070 if ( !multiPolygon.isEmpty() )
3072 if ( destMultipart )
3076 else if ( multiPolygon.count() == 1 )
3089 if ( line.count() < 3 )
3091 if ( line.count() == 3 && line.first() == line.last() )
3095 if ( line.first() != line.last() )
3096 line << line.first();
3099 if ( destMultipart )
3115 if ( ( destMultipart && srcIsMultipart ) ||
3116 ( !destMultipart && ! srcIsMultipart ) )
3121 if ( destMultipart )
3125 if ( !polygon.isEmpty() )
3131 if ( multiPolygon.count() == 1 )
3147 return new QgsGeos( geometry );
3152 out << geometry.
asWkb();
3158 QByteArray byteArray;
3160 if ( byteArray.isEmpty() )
3162 geometry.
set(
nullptr );
3166 geometry.
fromWkb( byteArray );
Geometry engine misses a method implemented or an error occurred in the geometry engine.
static std::unique_ptr< QgsAbstractGeometry > geomFromWkb(QgsConstWkbPtr &wkb)
Construct geometry from a WKB string.
bool boundingBoxIntersects(const QgsRectangle &rectangle) const
Returns true if the bounding box of this geometry intersects with a rectangle.
const QgsCurve * interiorRing(int i) const
static QgsPolygonXY createPolygonFromQPolygonF(const QPolygonF &polygon)
Creates a QgsPolygonXYfrom a QPolygonF.
static QgsGeometry fromMultiPolygonXY(const QgsMultiPolygonXY &multipoly)
Creates a new geometry from a QgsMultiPolygon.
static void validateGeometry(const QgsGeometry &geometry, QVector< QgsGeometry::Error > &errors, QgsGeometry::ValidationMethod method=QgsGeometry::ValidatorQgisInternal)
Validate geometry and produce a list of geometry errors.
QgsGeometry orientedMinimumBoundingBox() const
Returns the oriented minimum bounding box for the geometry, which is the smallest (by area) rotated r...
double closestSegmentWithContext(const QgsPointXY &point, QgsPointXY &minDistPoint, int &afterVertex, int *leftOf=nullptr, double epsilon=DEFAULT_SEGMENT_EPSILON) const
Searches for the closest segment of geometry to the given point.
A rectangle specified with double values.
QgsGeometry combine(const QgsGeometry &geometry) const
Returns a geometry representing all the points in this geometry and other (a union geometry operation...
static QgsGeometry fromPolylineXY(const QgsPolylineXY &polyline)
Creates a new LineString geometry from a list of QgsPointXY points.
static std::unique_ptr< QgsAbstractGeometry > geomFromWkbType(QgsWkbTypes::Type t)
Return empty geometry from wkb type.
void points(QgsPointSequence &pt) const override
Returns a list of points within the curve.
double hausdorffDistanceDensify(const QgsGeometry &geom, double densifyFraction) const
Returns the Hausdorff distance between this geometry and geom.
static Type multiType(Type type)
Returns the multi type for a WKB type.
int makeDifferenceInPlace(const QgsGeometry &other)
Changes this geometry such that it does not intersect the other geometry.
static QgsGeometry fromPolyline(const QgsPolyline &polyline)
Creates a new LineString geometry from a list of QgsPoint points.
QDataStream & operator<<(QDataStream &out, const QgsGeometry &geometry)
Writes the geometry to stream out. QGIS version compatibility is not guaranteed.
QgsGeometry removeInteriorRings(double minimumAllowedArea=-1) const
Removes the interior rings from a (multi)polygon geometry.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
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...
OperationResult addPart(const QVector< QgsPointXY > &points, QgsWkbTypes::GeometryType geomType=QgsWkbTypes::UnknownGeometry)
Adds a new part to a the geometry.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
double distance(const QgsGeometry &geom) const
Returns the minimum distance between this geometry and another geometry, using GEOS.
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...
Java-style iterator for traversal of vertices of a geometry.
Multi point geometry collection.
bool isValid() const
Returns true if the vertex id is valid.
bool within(const QgsGeometry &geometry) const
Test for if geometry is within another (uses GEOS)
static bool isMultiType(Type type)
Returns true if the WKB type is a multi type.
The source geometry is not multi.
Nothing happened, without any error.
void fromWkb(unsigned char *wkb, int length)
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length...
double angleAtVertex(int vertex) const
Returns the bisector angle for this geometry at the specified vertex.
static double averageAngle(double x1, double y1, double x2, double y2, double x3, double y3)
Angle between two linear segments.
QVector< QgsRingSequence > QgsCoordinateSequence
QgsGeometry poleOfInaccessibility(double precision, double *distanceFromBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
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 std::unique_ptr< QgsAbstractGeometry > fromPointXY(const QgsPointXY &point)
Construct geometry from a point.
QgsWkbTypes::Type wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
QgsGeometry subdivide(int maxNodes=256) const
Subdivides the geometry.
static std::unique_ptr< QgsAbstractGeometry > fromPolylineXY(const QgsPolylineXY &polyline)
Construct geometry from a polyline.
double area(QString *errorMsg=nullptr) const override
A class to represent a 2D point.
QVector< QgsPoint > QgsPolyline
Polyline as represented as a vector of points.
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 asJson(int precision=17) const
Exports the geometry to a GeoJSON string.
OperationResult rotate(double rotation, const QgsPointXY ¢er)
Rotate this geometry around the Z axis.
static QgsGeometry fromMultiPolylineXY(const QgsMultiPolylineXY &multiline)
Creates a new geometry from a QgsMultiPolylineXY object.
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
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...
Multi line string geometry collection.
QgsGeometry interpolate(double distance) const
Returns interpolated point on line at distance.
Curve polygon geometry type.
bool overlaps(const QgsGeometry &geometry) const
Test for if geometry overlaps another (uses GEOS)
A geometry is the spatial representation of a feature.
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...
QgsGeometry centroid() const
Returns the center of mass of a geometry.
QgsGeometry()
Constructor.
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
OperationResult addRing(const QVector< QgsPointXY > &ring)
Adds a new ring to this geometry.
OperationResult reshapeGeometry(const QgsLineString &reshapeLineString)
Replaces a part of this geometry with another line.
double radius() const
Returns the radius of the circle.
QgsGeometry intersection(const QgsGeometry &geometry) const
Returns a geometry representing the points shared by this geometry and other.
QgsPoint center() const
Returns the center point.
static QgsPoint closestVertex(const QgsAbstractGeometry &geom, const QgsPoint &pt, QgsVertexId &id)
Returns the closest vertex to a geometry for a specified point.
double distanceToVertex(int vertex) const
Returns the distance along this geometry from its first vertex to the specified vertex.
EndCapStyle
End cap styles for buffers.
virtual bool nextVertex(QgsVertexId &id, QgsPoint &vertex) const =0
Returns next vertex id and coordinates.
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...
virtual QgsRectangle boundingBox() const =0
Returns the minimal bounding box for the geometry.
QgsGeometry minimalEnclosingCircle(QgsPointXY ¢er, double &radius, unsigned int segments=36) const
Returns the minimal enclosing circle for the geometry.
QgsGeometry nearestPoint(const QgsGeometry &other) const
Returns the nearest point on this geometry to another geometry.
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform, bool transformZ=false)=0
Transforms the geometry using a coordinate transform.
QgsGeometry & operator=(QgsGeometry const &rhs)
Creates a deep copy of the object.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
static std::unique_ptr< QgsPolygon > fromPolygonXY(const QgsPolygonXY &polygon)
Construct geometry from a polygon.
OperationResult
Success or failure of a geometry operation.
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)
bool isGeosEqual(const QgsGeometry &) const
Compares the geometry with another geometry using GEOS.
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
bool deleteRing(int ringNum, int partNum=0)
Deletes a ring in polygon or multipolygon.
bool isGeosValid() const
Checks validity of the geometry using GEOS.
static GEOSContextHandle_t getGEOSHandler()
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
int numPoints() const override
Returns the number of points in the curve.
QgsPointXY closestVertex(const QgsPointXY &point, int &atVertex, int &beforeVertex, int &afterVertex, double &sqrDist) const
Returns the vertex closest to the given point, the corresponding vertex index, squared distance snap ...
QgsGeometry poleOfInaccessibility(double precision, double *distanceToBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
static std::unique_ptr< QgsMultiPoint > fromMultiPointXY(const QgsMultiPointXY &multipoint)
Construct geometry from a multipoint.
bool deletePart(int partNum)
Deletes part identified by the part number.
bool intersects(const QgsRectangle &rectangle) const
Returns true if this geometry exactly intersects with a rectangle.
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
QgsMultiPolylineXY asMultiPolyline() const
Returns contents of the geometry as a multi linestring if wkbType is WKBMultiLineString, otherwise an empty list.
QVector< QgsGeometry > asGeometryCollection() const
Return contents of the geometry as a list of geometries.
QgsGeometry mergeLines() const
Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line ...
Perform transforms between map coordinates and device coordinates.
QgsPointXY transform(const QgsPointXY &p) const
Transform the point from map (world) coordinates to device coordinates.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
int numInteriorRings() const
void validateGeometry(QVector< QgsGeometry::Error > &errors, ValidationMethod method=ValidatorQgisInternal) const
Validates geometry and produces a list of geometry errors.
Nothing happened, without any error.
Type
The WKB type describes the number of dimensions a geometry has.
QPointF toQPointF() const
Converts a point to a QPointF.
static QgsPolylineXY createPolylineFromQPolygonF(const QPolygonF &polygon)
Creates a QgsPolylineXY from a QPolygonF.
static bool deleteRing(QgsAbstractGeometry *geom, int ringNum, int partNum=0)
Deletes a ring from a geometry.
static std::unique_ptr< QgsAbstractGeometry > fromGeos(const GEOSGeometry *geos)
Create a geometry from a GEOSGeometry.
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.
Utility class for identifying a unique vertex within a geometry.
bool isEmpty() const
Returns true if the rectangle is empty.
QgsPolygonXY asPolygon() const
Returns contents of the geometry as a polygon if wkbType is WKBPolygon, otherwise an empty list...
static QgsGeometry fromQPointF(QPointF point)
Construct geometry from a QPointF.
virtual QgsPolygon * toPolygon(unsigned int segments=36) const
Returns a segmented polygon.
QgsGeometry convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry. ...
double width() const
Returns the width of the rectangle.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
bool deleteVertex(int atVertex)
Deletes the vertex at the given position number and item (first number is index 0) ...
double yAt(int index) const override
Returns the y-coordinate of the specified node in the line string.
void setY(double y)
Sets the y value of the point.
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
static std::unique_ptr< QgsAbstractGeometry > avoidIntersections(const QgsAbstractGeometry &geom, const QList< QgsVectorLayer *> &avoidIntersectionsLayers, 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 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...
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...
T qgsgeometry_cast(const QgsAbstractGeometry *geom)
QgsGeometry offsetCurve(double distance, int segments, JoinStyle joinStyle, double miterLimit) const
Returns an offset line at a given distance and side from an input line.
void fromGeos(GEOSGeometry *geos)
Set the geometry, feeding in a geometry in GEOS format.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
static geos::unique_ptr asGeos(const QgsAbstractGeometry *geom, double precision=0)
bool contains(const QgsPoint &point, double epsilon=1E-8) const
Returns true if the circle contains the point.
bool crosses(const QgsGeometry &geometry) const
Test for if geometry crosses another (uses GEOS)
QgsGeometry clipped(const QgsRectangle &rectangle)
Clips the geometry using the specified rectangle.
static QgsGeometry polygonize(const QVector< const QgsAbstractGeometry *> &geometries, QString *errorMsg=nullptr)
Creates a GeometryCollection geometry containing possible polygons formed from the constituent linewo...
QgsGeometry densifyByDistance(double distance) const
Densifies the geometry by adding regularly placed extra nodes inside each segment so that the maximum...
Method not implemented in geometry engine.
virtual double area() const
Returns the area of the geometry.
virtual int ringCount(int part=0) const =0
Returns the number of rings of which this geometry is built.
Abstract base class for curved geometry type.
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...
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, y1) to (x2, y2).
QgsGeometry pointOnSurface() const
Returns a point guaranteed to lie on the surface of a geometry.
bool touches(const QgsGeometry &geometry) const
Test for if geometry touch another (uses GEOS)
Abstract base class for all geometries.
QgsCoordinateSequence coordinateSequence() const override
Retrieves the sequence of geometries, rings and nodes.
The vertex_iterator class provides STL-style iterator for vertices.
void convertToStraightSegment()
Converts the geometry to straight line segments, if it is a curved geometry type. ...
const QgsCurve * exteriorRing() const
Does vector analysis using the geos library and handles import, export, exception handling*...
static std::unique_ptr< QgsMultiLineString > fromMultiPolylineXY(const QgsMultiPolylineXY &multiline)
Construct geometry from a multipolyline.
Point geometry type, with support for z-dimension and m-values.
QgsGeometry densifyByDistance(double distance) const
Densifies the geometry by adding regularly placed extra nodes inside each segment so that the maximum...
QgsWkbTypes::GeometryType type() const
Returns type of the geometry as a QgsWkbTypes::GeometryType.
double length() const
Returns the length of geometry using GEOS.
This class offers geometry processing methods.
void setX(double x)
Sets the x value of the point.
QByteArray asWkb() const
Export the geometry to WKB.
Error occurred while creating a noded geometry.
QgsLineString * clone() const override
Clones the geometry by performing a deep copy.
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
QgsGeometry extrude(double x, double y)
Returns an extruded version of this geometry.
Error occurred in the geometry engine.
void draw(QPainter &p) const
Draws the geometry onto a QPainter.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
int numGeometries() const
Returns the number of geometries within the collection.
Contains geos related utilities and functions.
void setX(double x)
Sets the point's x-coordinate.
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.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
QgsAbstractGeometry * combine(const QgsAbstractGeometry *geom, QString *errorMsg=nullptr) const override
Calculate the combination of this and geom.
QString asWkt(int precision=17) const
Exports the geometry to WKT.
QPolygonF asQPolygonF() const
Returns contents of the geometry as a QPolygonF.
double interpolateAngle(double distance) const
Returns the angle parallel to the linestring or polygon boundary at the specified distance along the ...
static QgsGeometry fromPolygonXY(const QgsPolygonXY &polygon)
Creates a new geometry from a QgsPolygon.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
BufferSide
Side of line to buffer.
QVector< QgsPoint > QgsPointSequence
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.
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
static QgsGeometry::OperationResult addPart(QgsAbstractGeometry *geometry, std::unique_ptr< QgsAbstractGeometry > part)
Add a part to multi type geometry.
virtual void adjacentVertices(QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex) const =0
Returns the vertices adjacent to a specified vertex within a geometry.
int partCount() const override
Returns count of parts contained in the geometry.
QVector< QgsPointSequence > QgsRingSequence
QString lastError() const
Returns an error string referring to the last error encountered either when this geometry was created...
QgsGeometry simplify(double tolerance) const
Returns a simplified version of this geometry using a specified tolerance value.
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
static double sqrDistance2D(const QgsPoint &pt1, const QgsPoint &pt2)
Returns the squared 2D distance between two points.
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
static std::unique_ptr< QgsAbstractGeometry > geomFromWkt(const QString &text)
Construct geometry from a WKT string.
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
double hausdorffDistance(const QgsGeometry &geom) const
Returns the Hausdorff distance between this geometry and geom.
QgsPointXY asPoint() const
Returns contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
The base geometry on which the operation is done is invalid or empty.
Multi polygon geometry collection.
static GEOSContextHandle_t getGEOSHandler()
Return GEOS context handle.
int vertexNrFromVertexId(QgsVertexId id) const
Returns the vertex number corresponding to a vertex id.
The input geometry (ring, part, split line, etc.) has not the correct geometry type.
OperationResult splitGeometry(const QVector< QgsPointXY > &splitLine, QVector< QgsGeometry > &newGeometries, bool topological, QVector< QgsPointXY > &topologyTestPoints)
Splits this geometry according to a given line.
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...
void mapToPixel(const QgsMapToPixel &mtp)
Transforms the geometry from map units to pixels in place.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
static bool isCurvedType(Type type)
Returns true if the WKB type is a curved type or can contain curved geometries.
GEOSGeometry * exportToGeos(double precision=0) const
Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destr...
QgsGeometry makeValid() const
Attempts to make an invalid geometry valid without losing vertices.
bool isSimple() const
Determines whether the geometry is simple (according to OGC definition), i.e.
std::unique_ptr< QgsAbstractGeometry > subdivide(int maxNodes, QString *errorMsg=nullptr) const
Subdivides the geometry.
Line string geometry type, with support for z-dimension and m-values.
QPointF asQPointF() const
Returns contents of the geometry as a QPointF if wkbType is WKBPoint, otherwise returns a null QPoint...
ValidationMethod
Available methods for validating geometries.
virtual int vertexCount(int part=0, int ring=0) const =0
Returns the number of vertices 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...
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
QgsGeometry shortestLine(const QgsGeometry &other) const
Returns the shortest line joining this geometry to another geometry.
std::unique_ptr< QgsAbstractGeometry > _qgis_lwgeom_make_valid(const QgsAbstractGeometry *lwgeom_in, QString &errorMessage)
Implementation of QgsGeometry::makeValid(). Not a public API.
static QgsCircle minimalCircleFrom3Points(const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double epsilon=1E-8)
Constructs the smallest circle from 3 points.
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
static QgsGeometry fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
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...
QgsGeometry singleSidedBuffer(double distance, int segments, BufferSide side, JoinStyle joinStyle=JoinStyleRound, double miterLimit=2.0) const
Returns a single sided buffer for a (multi)line geometry.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
double xAt(int index) const override
Returns the x-coordinate of the specified node in the line string.
OperationResult translate(double dx, double dy, double dz=0.0, double dm=0.0)
Translates this geometry by dx, dy, dz and dm.
void adjacentVertices(int atVertex, int &beforeVertex, int &afterVertex) const
Returns the indexes of the vertices before and after the given vertex index.
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.
Contains geometry relation and modification algorithms.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QgsGeometry makeDifference(const QgsGeometry &other) const
Returns the geometry formed by modifying this geometry such that it does not intersect the other geom...
QgsPolylineXY asPolyline() const
Returns contents of the geometry as a polyline if wkbType is WKBLineString, otherwise an empty list...
QgsVertexIterator vertices() const
Returns Java-style iterator for traversal of vertices of the geometry.
static QgsCircle from2Points(const QgsPoint &pt1, const QgsPoint &pt2)
Constructs a circle by 2 points on the circle.
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.
static bool deletePart(QgsAbstractGeometry *geom, int partNum)
Deletes a part from a geometry.
QgsMultiPointXY asMultiPoint() const
Returns contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty lis...
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...
double area() const
Returns the area of the geometry using GEOS.
EngineOperationResult
Success or failure of a geometry operation.
bool vertexIdFromVertexNr(int number, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
JoinStyle
Join styles for buffers.
void set(QgsAbstractGeometry *geometry)
Sets the underlying geometry store.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Densifies the geometry by adding the specified number of extra nodes within each segment of the geome...
bool contains(const QgsPointXY *p) const
Tests for containment of a point (uses GEOS)
QgsGeometry symDifference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
Represents a vector layer which manages a vector based data sets.
QgsAbstractGeometry::vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry...
static Type flatType(Type type)
Returns the flat type for a WKB type.
QgsGeometry delaunayTriangulation(double tolerance=0.0, bool edgesOnly=false) const
Returns the Delaunay triangulation for the vertices of the geometry.
QgsGeometry smooth(const unsigned int iterations=1, const double offset=0.25, double minimumDistance=-1.0, double maxAngle=180.0) const
Smooths a geometry by rounding off corners using the Chaikin algorithm.
static QgsGeometry unaryUnion(const QVector< QgsGeometry > &geometries)
Compute the unary union on a list of geometries.
QgsMultiPolygonXY asMultiPolygon() const
Returns contents of the geometry as a multi polygon if wkbType is WKBMultiPolygon, otherwise an empty list.
static QgsGeometry collectGeometry(const QVector< QgsGeometry > &geometries)
Creates a new multipart geometry from a list of QgsGeometry objects.
The geometry on which the operation occurs is not valid.
virtual int numPoints() const =0
Returns the number of points in the curve.
static double distanceToVertex(const QgsAbstractGeometry &geom, QgsVertexId id)
Returns the distance along a geometry from its first vertex to the specified vertex.
QgsAbstractGeometry::vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
bool removeDuplicateNodes(double epsilon=4 *DBL_EPSILON, bool useZValues=false)
Removes duplicate nodes from the geometry, wherever removing the nodes does not result in a degenerat...
double lineLocatePoint(const QgsGeometry &point) const
Returns a distance representing the location along this linestring of the closest point on this lines...
double ANALYSIS_EXPORT leftOf(const QgsPoint &thepoint, const QgsPoint *p1, const QgsPoint *p2)
Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'. Negativ values mean left a...
bool disjoint(const QgsGeometry &geometry) const
Tests for if geometry is disjoint of another (uses GEOS)
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
static QgsGeometry::OperationResult addRing(QgsAbstractGeometry *geometry, std::unique_ptr< QgsCurve > ring)
Add an interior ring to a 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...
std::unique_ptr< QgsAbstractGeometry > 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 addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
double height() const
Returns the height of the rectangle.
static std::unique_ptr< QgsMultiPolygon > fromMultiPolygonXY(const QgsMultiPolygonXY &multipoly)
Construct geometry from a multipolygon.
std::unique_ptr< QgsLineString > smoothCurve(const QgsLineString &line, const unsigned int iterations, const double offset, double squareDistThreshold, double maxAngleRads, bool isRing)
QDataStream & operator>>(QDataStream &in, QgsGeometry &geometry)
Reads a geometry from stream in into geometry. QGIS version compatibility is not guaranteed.
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 difference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...