166 Q_PROPERTY(
bool isNull READ isNull )
167 Q_PROPERTY(
Qgis::GeometryType type READ type )
338 static QgsGeometry collectGeometry(
const QVector<QgsGeometry> &geometries );
355 static QgsGeometry createWedgeBuffer(
const QgsPoint ¢er,
double azimuth,
double angularWidth,
356 double outerRadius,
double innerRadius = 0 );
363 void fromWkb(
unsigned char *wkb,
int length )
SIP_SKIP;
369 void fromWkb(
const QByteArray &wkb );
389 bool isEmpty() const;
435 bool isGeosValid(
Qgis::GeometryValidityFlags flags =
Qgis::GeometryValidityFlags() ) const;
445 bool isSimple() const;
460 bool isAxisParallelRectangle(
double maximumDeviation,
bool simpleRectanglesOnly = false ) const;
490 double length() const;
677 double hausdorffDistance(
const QgsGeometry &geom )
const;
697 double hausdorffDistanceDensify(
const QgsGeometry &geom,
double densifyFraction )
const;
761 double distanceToVertex(
int vertex )
const;
770 double angleAtVertex(
int vertex )
const;
784 void adjacentVertices(
int atVertex,
int &beforeVertex
SIP_OUT,
int &afterVertex
SIP_OUT )
const;
798 bool insertVertex(
double x,
double y,
int beforeVertex );
812 bool insertVertex(
const QgsPoint &point,
int beforeVertex );
821 bool moveVertex(
double x,
double y,
int atVertex );
830 bool moveVertex(
const QgsPoint &p,
int atVertex );
843 bool deleteVertex(
int atVertex );
852 bool toggleCircularAtVertex(
int atVertex );
859 QgsPoint vertexAt(
int atVertex )
const;
893 double closestVertexWithContext(
const QgsPointXY &point,
int &atVertex
SIP_OUT )
const;
959 QgsGeometry removeInteriorRings(
double minimumAllowedArea = -1 )
const;
991 Qgis::GeometryOperationResult transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 );
999 Qgis::GeometryOperationResult rotate(
double rotation, const
QgsPointXY ¢er );
1011 Q_DECL_DEPRECATED
Qgis::GeometryOperationResult splitGeometry( const QVector<
QgsPointXY> &splitLine, QVector<
QgsGeometry> &newGeometries,
bool topological, QVector<
QgsPointXY> &topologyTestPoints,
bool splitFeature = true )
SIP_SKIP;
1069 if ( PyList_Check( a0 ) && PyList_GET_SIZE( a0 ) )
1071 PyObject *p0 = PyList_GetItem( a0, 0 );
1072 if ( sipCanConvertToType( p0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1073 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1075 QVector<QgsGeometry> newGeometries;
1076 QVector<QgsPointXY> topologyTestPoints;
1078 QVector<QgsPointXY> *splitLine =
reinterpret_cast<QVector<QgsPointXY> *
>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1081 sipReleaseType( splitLine, sipType_QVector_0100QgsPointXY, state );
1087 PyObject *o0 = sipConvertFromEnum(
static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1088 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1089 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPointXY, Py_None );
1091 sipRes = PyTuple_New( 3 );
1092 PyTuple_SET_ITEM( sipRes, 0, o0 );
1093 PyTuple_SET_ITEM( sipRes, 1, o1 );
1094 PyTuple_SET_ITEM( sipRes, 2, o2 );
1098 else if ( sipCanConvertToType( p0, sipType_QgsPoint, SIP_NOT_NONE ) &&
1099 sipCanConvertToType( a0, sipType_QVector_0100QgsPoint, SIP_NOT_NONE ) )
1101 QVector<QgsGeometry> newGeometries;
1102 QVector<QgsPoint> topologyTestPoints;
1104 QVector<QgsPoint> *splitLine =
reinterpret_cast<QVector<QgsPoint> *
>( sipConvertToType( a0, sipType_QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1107 sipReleaseType( splitLine, sipType_QVector_0100QgsPoint, state );
1113 PyObject *o0 = sipConvertFromEnum(
static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1114 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1115 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPoint, Py_None );
1117 sipRes = PyTuple_New( 3 );
1118 PyTuple_SET_ITEM( sipRes, 0, o0 );
1119 PyTuple_SET_ITEM( sipRes, 1, o1 );
1120 PyTuple_SET_ITEM( sipRes, 2, o2 );
1126 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"Could not convert first argument to a list of QgsPoint or QgsPointXY." ).toUtf8().constData() );
1132 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"First argument is not a list of points or is empty." ).toUtf8().constData() );
1235 QgsGeometry orthogonalize(
double tolerance = 1.0E-8,
int maxIterations = 1000,
double angleThreshold = 15.0 ) const;
1249 QgsGeometry triangularWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1269 QgsGeometry triangularWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1283 QgsGeometry squareWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1303 QgsGeometry squareWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1317 QgsGeometry roundWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1337 QgsGeometry roundWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1352 QgsGeometry applyDashPattern( const QVector<
double > &pattern,
1353 Qgis::DashPatternLineEndingRule startRule =
Qgis::DashPatternLineEndingRule::NoRule,
1354 Qgis::DashPatternLineEndingRule endRule =
Qgis::DashPatternLineEndingRule::NoRule,
1355 Qgis::DashPatternSizeAdjustment adjustment =
Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap,
1356 double patternOffset = 0 ) const;
1370 QgsGeometry snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const;
1392 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false );
1403 bool intersects( const
QgsRectangle &rectangle ) const;
1419 bool intersects( const
QgsGeometry &geometry ) const;
1430 bool boundingBoxIntersects( const
QgsRectangle &rectangle ) const;
1441 bool boundingBoxIntersects( const
QgsGeometry &geometry ) const;
1458 bool contains( const
QgsGeometry &geometry ) const;
1470 bool disjoint( const
QgsGeometry &geometry ) const;
1482 bool touches( const
QgsGeometry &geometry ) const;
1494 bool overlaps( const
QgsGeometry &geometry ) const;
1518 bool crosses( const
QgsGeometry &geometry ) const;
1527 QgsGeometry buffer(
double distance,
int segments ) const;
1541 QgsGeometry buffer(
double distance,
int segments,
Qgis::EndCapStyle endCapStyle,
Qgis::JoinStyle joinStyle,
double miterLimit ) const;
1551 QgsGeometry offsetCurve(
double distance,
int segments,
Qgis::JoinStyle joinStyle,
double miterLimit ) const;
1568 QgsGeometry singleSidedBuffer(
double distance,
int segments,
Qgis::BufferSide side,
1569 Qgis::JoinStyle joinStyle =
Qgis::JoinStyle::Round,
1570 double miterLimit = 2.0 ) const;
1589 QgsGeometry taperedBuffer(
double startWidth,
double endWidth,
int segments ) const;
1605 QgsGeometry variableWidthBufferByM(
int segments ) const;
1613 QgsGeometry extendLine(
double startDistance,
double endDistance ) const;
1627 QgsGeometry densifyByCount(
int extraNodesPerSegment ) const;
1643 QgsGeometry densifyByDistance(
double distance ) const;
1660 QgsGeometry convertToCurves(
double distanceTolerance = 1e-8,
double angleTolerance = 1e-8 ) const;
1834 QgsGeometry delaunayTriangulation(
double tolerance = 0.0,
bool edgesOnly = false ) const;
1916 double lineLocatePoint( const
QgsGeometry &point ) const;
1927 double interpolateAngle(
double distance ) const;
2063 const
Qgis::GeometryType type = sipCpp->type();
2064 if ( sipCpp->isNull() )
2066 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Cannot generate points inside a null geometry." ).toUtf8().constData() );
2071 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"Cannot generate points inside a %1 geometry. Only Polygon types are permitted." ).arg(
QgsWkbTypes::displayString( sipCpp->wkbType() ) ).toUtf8().constData() );
2076 const sipTypeDef *qvector_type = sipFindType(
"QVector<QgsPointXY>" );
2077 sipRes = sipConvertFromNewType(
new QVector< QgsPointXY >( sipCpp->randomPointsInPolygon( a0, a1 ) ), qvector_type, Py_None );
2092 int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() )
const;
2101 QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() )
const;
2108 QString asWkt(
int precision = 17 )
const;
2111 SIP_PYOBJECT __repr__();
2114 if ( sipCpp->isNull() )
2115 str = QStringLiteral(
"<QgsGeometry: null>" );
2118 QString wkt = sipCpp->asWkt();
2119 if ( wkt.length() > 1000 )
2120 wkt = wkt.left( 1000 ) + QStringLiteral(
"..." );
2121 str = QStringLiteral(
"<QgsGeometry: %1>" ).arg( wkt );
2123 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
2130 QString asJson(
int precision = 17 )
const;
2165 QVector<
QgsGeometry > coerceToType(
Qgis::WkbType type,
double defaultZ = 0,
double defaultM = 0 ) const;
2179 QgsGeometry convertToType(
Qgis::GeometryType destType,
bool destMultipart = false ) const;
2208 if ( sipCpp->isNull() )
2210 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a point." ).toUtf8().constData() );
2218 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"%1 geometry cannot be converted to a point. Only Point types are permitted." ).arg(
QgsWkbTypes::displayString( geom->
wkbType() ) ).toUtf8().constData() );
2223 sipRes = sipConvertFromNewType(
new QgsPointXY( sipCpp->asPoint() ), sipType_QgsPointXY, Py_None );
2255 const
Qgis::WkbType type = sipCpp->wkbType();
2256 if ( sipCpp->isNull() )
2258 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polyline." ).toUtf8().constData() );
2263 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"%1 geometry cannot be converted to a polyline. Only single line or curve types are permitted." ).arg(
QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2268 const sipTypeDef *qvector_type = sipFindType(
"QVector< QgsPointXY >" );
2269 sipRes = sipConvertFromNewType(
new QgsPolylineXY( sipCpp->asPolyline() ), qvector_type, Py_None );
2300 const
Qgis::WkbType type = sipCpp->wkbType();
2301 if ( sipCpp->isNull() )
2303 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polygon." ).toUtf8().constData() );
2308 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"%1 geometry cannot be converted to a polygon. Only single polygon or curve polygon types are permitted." ).arg(
QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2313 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QgsPointXY>>" );
2314 sipRes = sipConvertFromNewType(
new QgsPolygonXY( sipCpp->asPolygon() ), qvector_type, Py_None );
2343 const
Qgis::WkbType type = sipCpp->wkbType();
2344 if ( sipCpp->isNull() )
2346 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multipoint." ).toUtf8().constData() );
2351 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"%1 geometry cannot be converted to a multipoint. Only multipoint types are permitted." ).arg(
QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2356 const sipTypeDef *qvector_type = sipFindType(
"QVector< QgsPointXY >" );
2357 sipRes = sipConvertFromNewType(
new QgsPolylineXY( sipCpp->asMultiPoint() ), qvector_type, Py_None );
2388 const
Qgis::WkbType type = sipCpp->wkbType();
2389 if ( sipCpp->isNull() )
2391 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multilinestring." ).toUtf8().constData() );
2396 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"%1 geometry cannot be converted to a multilinestring. Only multi linestring or curves are permitted." ).arg(
QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2401 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QgsPointXY>>" );
2402 sipRes = sipConvertFromNewType(
new QgsMultiPolylineXY( sipCpp->asMultiPolyline() ), qvector_type, Py_None );
2433 const
Qgis::WkbType type = sipCpp->wkbType();
2434 if ( sipCpp->isNull() )
2436 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multipolygon." ).toUtf8().constData() );
2441 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"%1 geometry cannot be converted to a multipolygon. Only multi polygon or curves are permitted." ).arg(
QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2446 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QVector<QgsPointXY>>>" );
2447 sipRes = sipConvertFromNewType(
new QgsMultiPolygonXY( sipCpp->asMultiPolygon() ), qvector_type, Py_None );
2456 QVector<QgsGeometry> asGeometryCollection()
const;
2485 bool deleteRing(
int ringNum,
int partNum = 0 );
2492 bool deletePart(
int partNum );
2502 bool convertToMultiType();
2519 bool convertToCurvedMultiType();
2530 bool convertToSingleType();
2541 bool convertGeometryCollectionToSubclass(
Qgis::GeometryType geomType );
2555 Q_DECL_DEPRECATED
int avoidIntersections( const QList<
QgsVectorLayer *> &avoidIntersectionsLayers,
2569 Qgis::GeometryOperationResult avoidIntersectionsV2( const QList<
QgsVectorLayer *> &avoidIntersectionsLayers,
2637 : mMessage( QStringLiteral(
"none" ) )
2647 , mHasLocation( true ) {}
2652 QString what()
const;
2662 bool hasWhere()
const;
2665 SIP_PYOBJECT __repr__();
2667 QString
str = QStringLiteral(
"<QgsGeometry.Error: %1>" ).arg( sipCpp->what() );
2668 sipRes = PyUnicode_FromString(
str.toUtf8().data() );
2675 return other.mMessage == mMessage && other.mHasLocation == mHasLocation && other.mLocation == mLocation;
2681 bool mHasLocation =
false;
2723 static QgsGeometry polygonize(
const QVector<QgsGeometry> &geometries );
2740 bool requiresConversionToStraightSegments()
const;
2754 void draw( QPainter &p )
const;
2799 void filterVertices( const std::function<
bool( const
QgsPoint & ) > &filter )
SIP_SKIP;
2831 static
QgsGeometry fromQPolygonF( const QPolygonF &polygon );
2863 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2875 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2888 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2910 static bool compare( PyObject *obj1, PyObject *obj2,
double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2918 if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
2919 PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
2921 PyObject *o0 = PyList_GetItem( a0, 0 );
2922 PyObject *o1 = PyList_GetItem( a1, 0 );
2926 if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2927 sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2928 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2929 sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2933 p0 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2934 p1 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2937 sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
2938 sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
2945 else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
2946 PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
2948 PyObject *oo0 = PyList_GetItem( o0, 0 );
2949 PyObject *oo1 = PyList_GetItem( o1, 0 );
2953 if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2954 sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2955 sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2956 sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2960 p0 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2961 p1 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2964 sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
2965 sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
2972 else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
2973 PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
2975 PyObject *ooo0 = PyList_GetItem( oo0, 0 );
2976 PyObject *ooo1 = PyList_GetItem( oo1, 0 );
2980 if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2981 sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2982 sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2983 sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2987 p0 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2988 p1 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2991 sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
2992 sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
3025 QgsGeometry smooth(
unsigned int iterations = 1,
double offset = 0.25,
3026 double minimumDistance = -1.0,
double maxAngle = 180.0 )
const;
3072 static void convertPointList(
const QVector<QgsPointXY> &input,
QgsPointSequence &output );
3079 static void convertPointList(
const QgsPointSequence &input, QVector<QgsPointXY> &output );
3082 operator QVariant()
const
3084 return QVariant::fromValue( *
this );
3092 mutable QString mLastError;
3104 void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
3109 QgsGeometry convertToPoint(
bool destMultipart )
const;
3111 QgsGeometry convertToLine(
bool destMultipart )
const;
3113 QgsGeometry convertToPolygon(
bool destMultipart )
const;
3126 std::unique_ptr< QgsLineString > smoothLine(
const QgsLineString &line,
unsigned int iterations = 1,
double offset = 0.25,
3127 double minimumDistance = -1,
double maxAngle = 180.0 )
const;
3140 std::unique_ptr< QgsPolygon > smoothPolygon(
const QgsPolygon &polygon,
unsigned int iterations = 1,
double offset = 0.25,
3141 double minimumDistance = -1,
double maxAngle = 180.0 )
const;