164 Q_PROPERTY(
bool isNull READ isNull )
165 Q_PROPERTY(
Qgis::GeometryType type READ type )
329 static QgsGeometry collectGeometry(
const QVector<QgsGeometry> &geometries );
346 static QgsGeometry createWedgeBuffer(
const QgsPoint ¢er,
double azimuth,
double angularWidth,
347 double outerRadius,
double innerRadius = 0 );
354 void fromWkb(
unsigned char *wkb,
int length )
SIP_SKIP;
359 void fromWkb(
const QByteArray &wkb );
379 bool isEmpty() const;
422 bool isGeosValid(
Qgis::GeometryValidityFlags flags =
Qgis::GeometryValidityFlags() ) const;
431 bool isSimple() const;
446 bool isAxisParallelRectangle(
double maximumDeviation,
bool simpleRectanglesOnly = false ) const;
474 double length() const;
657 double hausdorffDistance(
const QgsGeometry &geom )
const;
676 double hausdorffDistanceDensify(
const QgsGeometry &geom,
double densifyFraction )
const;
739 double distanceToVertex(
int vertex )
const;
747 double angleAtVertex(
int vertex )
const;
761 void adjacentVertices(
int atVertex,
int &beforeVertex
SIP_OUT,
int &afterVertex
SIP_OUT )
const;
775 bool insertVertex(
double x,
double y,
int beforeVertex );
789 bool insertVertex(
const QgsPoint &point,
int beforeVertex );
798 bool moveVertex(
double x,
double y,
int atVertex );
807 bool moveVertex(
const QgsPoint &p,
int atVertex );
820 bool deleteVertex(
int atVertex );
829 bool toggleCircularAtVertex(
int atVertex );
836 QgsPoint vertexAt(
int atVertex )
const;
868 double closestVertexWithContext(
const QgsPointXY &point,
int &atVertex
SIP_OUT )
const;
933 QgsGeometry removeInteriorRings(
double minimumAllowedArea = -1 )
const;
965 Qgis::GeometryOperationResult transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 );
973 Qgis::GeometryOperationResult rotate(
double rotation, const
QgsPointXY ¢er );
985 Q_DECL_DEPRECATED
Qgis::GeometryOperationResult splitGeometry( const QVector<
QgsPointXY> &splitLine, QVector<
QgsGeometry> &newGeometries,
bool topological, QVector<
QgsPointXY> &topologyTestPoints,
bool splitFeature = true )
SIP_SKIP;
1043 if ( PyList_Check( a0 ) && PyList_GET_SIZE( a0 ) )
1045 PyObject *p0 = PyList_GetItem( a0, 0 );
1046 if ( sipCanConvertToType( p0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1047 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1049 QVector<QgsGeometry> newGeometries;
1050 QVector<QgsPointXY> topologyTestPoints;
1052 QVector<QgsPointXY> *splitLine =
reinterpret_cast<QVector<QgsPointXY> *
>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1055 sipReleaseType( splitLine, sipType_QVector_0100QgsPointXY, state );
1061 PyObject *o0 = sipConvertFromEnum(
static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1062 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1063 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPointXY, Py_None );
1065 sipRes = PyTuple_New( 3 );
1066 PyTuple_SET_ITEM( sipRes, 0, o0 );
1067 PyTuple_SET_ITEM( sipRes, 1, o1 );
1068 PyTuple_SET_ITEM( sipRes, 2, o2 );
1072 else if ( sipCanConvertToType( p0, sipType_QgsPoint, SIP_NOT_NONE ) &&
1073 sipCanConvertToType( a0, sipType_QVector_0100QgsPoint, SIP_NOT_NONE ) )
1075 QVector<QgsGeometry> newGeometries;
1076 QVector<QgsPoint> topologyTestPoints;
1078 QVector<QgsPoint> *splitLine =
reinterpret_cast<QVector<QgsPoint> *
>( sipConvertToType( a0, sipType_QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1081 sipReleaseType( splitLine, sipType_QVector_0100QgsPoint, 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_0100QgsPoint, 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 );
1100 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"Could not convert first argument to a list of QgsPoint or QgsPointXY." ).toUtf8().constData() );
1106 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"First argument is not a list of points or is empty." ).toUtf8().constData() );
1203 QgsGeometry orthogonalize(
double tolerance = 1.0E-8,
int maxIterations = 1000,
double angleThreshold = 15.0 ) const;
1217 QgsGeometry triangularWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1237 QgsGeometry triangularWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1251 QgsGeometry squareWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1271 QgsGeometry squareWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1285 QgsGeometry roundWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1305 QgsGeometry roundWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1320 QgsGeometry applyDashPattern( const QVector<
double > &pattern,
1321 Qgis::DashPatternLineEndingRule startRule =
Qgis::DashPatternLineEndingRule::NoRule,
1322 Qgis::DashPatternLineEndingRule endRule =
Qgis::DashPatternLineEndingRule::NoRule,
1323 Qgis::DashPatternSizeAdjustment adjustment =
Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap,
1324 double patternOffset = 0 ) const;
1337 QgsGeometry snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const;
1358 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false );
1369 bool intersects( const
QgsRectangle &rectangle ) const;
1385 bool intersects( const
QgsGeometry &geometry ) const;
1395 bool boundingBoxIntersects( const
QgsRectangle &rectangle ) const;
1405 bool boundingBoxIntersects( const
QgsGeometry &geometry ) const;
1421 bool contains( const
QgsGeometry &geometry ) const;
1432 bool disjoint( const
QgsGeometry &geometry ) const;
1443 bool touches( const
QgsGeometry &geometry ) const;
1454 bool overlaps( const
QgsGeometry &geometry ) const;
1476 bool crosses( const
QgsGeometry &geometry ) const;
1485 QgsGeometry buffer(
double distance,
int segments ) const;
1498 QgsGeometry buffer(
double distance,
int segments,
Qgis::EndCapStyle endCapStyle,
Qgis::JoinStyle joinStyle,
double miterLimit ) const;
1507 QgsGeometry offsetCurve(
double distance,
int segments,
Qgis::JoinStyle joinStyle,
double miterLimit ) const;
1523 QgsGeometry singleSidedBuffer(
double distance,
int segments,
Qgis::BufferSide side,
1524 Qgis::JoinStyle joinStyle =
Qgis::JoinStyle::Round,
1525 double miterLimit = 2.0 ) const;
1544 QgsGeometry taperedBuffer(
double startWidth,
double endWidth,
int segments ) const;
1560 QgsGeometry variableWidthBufferByM(
int segments ) const;
1567 QgsGeometry extendLine(
double startDistance,
double endDistance ) const;
1580 QgsGeometry densifyByCount(
int extraNodesPerSegment ) const;
1595 QgsGeometry densifyByDistance(
double distance ) const;
1612 QgsGeometry convertToCurves(
double distanceTolerance = 1e-8,
double angleTolerance = 1e-8 ) const;
1785 QgsGeometry delaunayTriangulation(
double tolerance = 0.0,
bool edgesOnly = false ) const;
1932 double lineLocatePoint( const
QgsGeometry &point ) const;
1942 double interpolateAngle(
double distance ) const;
2076 const
Qgis::GeometryType type = sipCpp->type();
2077 if ( sipCpp->isNull() )
2079 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Cannot generate points inside a null geometry." ).toUtf8().constData() );
2084 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"Cannot generate points inside a %1 geometry. Only Polygon types are permitted." ).arg(
QgsWkbTypes::displayString( sipCpp->wkbType() ) ).toUtf8().constData() );
2089 const sipTypeDef *qvector_type = sipFindType(
"QVector<QgsPointXY>" );
2090 sipRes = sipConvertFromNewType(
new QVector< QgsPointXY >( sipCpp->randomPointsInPolygon( a0, a1 ) ), qvector_type, Py_None );
2105 int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() )
const;
2113 QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() )
const;
2120 QString asWkt(
int precision = 17 )
const;
2123 SIP_PYOBJECT __repr__();
2126 if ( sipCpp->isNull() )
2127 str = QStringLiteral(
"<QgsGeometry: null>" );
2130 QString wkt = sipCpp->asWkt();
2131 if ( wkt.length() > 1000 )
2132 wkt = wkt.left( 1000 ) + QStringLiteral(
"..." );
2133 str = QStringLiteral(
"<QgsGeometry: %1>" ).arg( wkt );
2135 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
2142 QString asJson(
int precision = 17 )
const;
2177 QVector<
QgsGeometry > coerceToType(
Qgis::WkbType type,
double defaultZ = 0,
double defaultM = 0 ) const;
2190 QgsGeometry convertToType(
Qgis::GeometryType destType,
bool destMultipart = false ) const;
2219 if ( sipCpp->isNull() )
2221 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a point." ).toUtf8().constData() );
2229 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() );
2234 sipRes = sipConvertFromNewType(
new QgsPointXY( sipCpp->asPoint() ), sipType_QgsPointXY, Py_None );
2266 const
Qgis::WkbType type = sipCpp->wkbType();
2267 if ( sipCpp->isNull() )
2269 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polyline." ).toUtf8().constData() );
2274 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() );
2279 const sipTypeDef *qvector_type = sipFindType(
"QVector< QgsPointXY >" );
2280 sipRes = sipConvertFromNewType(
new QgsPolylineXY( sipCpp->asPolyline() ), qvector_type, Py_None );
2311 const
Qgis::WkbType type = sipCpp->wkbType();
2312 if ( sipCpp->isNull() )
2314 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polygon." ).toUtf8().constData() );
2319 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() );
2324 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QgsPointXY>>" );
2325 sipRes = sipConvertFromNewType(
new QgsPolygonXY( sipCpp->asPolygon() ), qvector_type, Py_None );
2354 const
Qgis::WkbType type = sipCpp->wkbType();
2355 if ( sipCpp->isNull() )
2357 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multipoint." ).toUtf8().constData() );
2362 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"%1 geometry cannot be converted to a multipoint. Only multipoint types are permitted." ).arg(
QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2367 const sipTypeDef *qvector_type = sipFindType(
"QVector< QgsPointXY >" );
2368 sipRes = sipConvertFromNewType(
new QgsPolylineXY( sipCpp->asMultiPoint() ), qvector_type, Py_None );
2399 const
Qgis::WkbType type = sipCpp->wkbType();
2400 if ( sipCpp->isNull() )
2402 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multilinestring." ).toUtf8().constData() );
2407 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() );
2412 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QgsPointXY>>" );
2413 sipRes = sipConvertFromNewType(
new QgsMultiPolylineXY( sipCpp->asMultiPolyline() ), qvector_type, Py_None );
2444 const
Qgis::WkbType type = sipCpp->wkbType();
2445 if ( sipCpp->isNull() )
2447 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multipolygon." ).toUtf8().constData() );
2452 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() );
2457 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QVector<QgsPointXY>>>" );
2458 sipRes = sipConvertFromNewType(
new QgsMultiPolygonXY( sipCpp->asMultiPolygon() ), qvector_type, Py_None );
2466 QVector<QgsGeometry> asGeometryCollection()
const;
2492 bool deleteRing(
int ringNum,
int partNum = 0 );
2498 bool deletePart(
int partNum );
2508 bool convertToMultiType();
2525 bool convertToCurvedMultiType();
2536 bool convertToSingleType();
2547 bool convertGeometryCollectionToSubclass(
Qgis::GeometryType geomType );
2560 Q_DECL_DEPRECATED
int avoidIntersections( const QList<
QgsVectorLayer *> &avoidIntersectionsLayers,
2574 Qgis::GeometryOperationResult avoidIntersectionsV2( const QList<
QgsVectorLayer *> &avoidIntersectionsLayers,
2608 Qgis::AngularDirection polygonOrientation() const;
2689 : mMessage( QStringLiteral(
"none" ) )
2699 , mHasLocation( true ) {}
2704 QString what()
const;
2714 bool hasWhere()
const;
2717 SIP_PYOBJECT __repr__();
2719 QString
str = QStringLiteral(
"<QgsGeometry.Error: %1>" ).arg( sipCpp->what() );
2720 sipRes = PyUnicode_FromString(
str.toUtf8().data() );
2727 return other.mMessage == mMessage && other.mHasLocation == mHasLocation && other.mLocation == mLocation;
2733 bool mHasLocation =
false;
2773 static QgsGeometry polygonize(
const QVector<QgsGeometry> &geometries );
2788 bool requiresConversionToStraightSegments()
const;
2800 void draw( QPainter &p )
const;
2842 void filterVertices( const std::function<
bool( const
QgsPoint & ) > &filter )
SIP_SKIP;
2872 static
QgsGeometry fromQPolygonF( const QPolygonF &polygon );
2903 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2914 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2926 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2947 static bool compare( PyObject *obj1, PyObject *obj2,
double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2955 if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
2956 PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
2958 PyObject *o0 = PyList_GetItem( a0, 0 );
2959 PyObject *o1 = PyList_GetItem( a1, 0 );
2963 if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2964 sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2965 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2966 sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2970 p0 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2971 p1 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2974 sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
2975 sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
2982 else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
2983 PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
2985 PyObject *oo0 = PyList_GetItem( o0, 0 );
2986 PyObject *oo1 = PyList_GetItem( o1, 0 );
2990 if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2991 sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2992 sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2993 sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2997 p0 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2998 p1 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3001 sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
3002 sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
3009 else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
3010 PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
3012 PyObject *ooo0 = PyList_GetItem( oo0, 0 );
3013 PyObject *ooo1 = PyList_GetItem( oo1, 0 );
3017 if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3018 sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3019 sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3020 sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3024 p0 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3025 p1 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3028 sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
3029 sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
3061 QgsGeometry smooth(
unsigned int iterations = 1,
double offset = 0.25,
3062 double minimumDistance = -1.0,
double maxAngle = 180.0 )
const;
3118 operator QVariant()
const
3120 return QVariant::fromValue( *
this );
3128 mutable QString mLastError;
3140 void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
3145 QgsGeometry convertToPoint(
bool destMultipart )
const;
3147 QgsGeometry convertToLine(
bool destMultipart )
const;
3149 QgsGeometry convertToPolygon(
bool destMultipart )
const;
3162 std::unique_ptr< QgsLineString > smoothLine(
const QgsLineString &line,
unsigned int iterations = 1,
double offset = 0.25,
3163 double minimumDistance = -1,
double maxAngle = 180.0 )
const;
3176 std::unique_ptr< QgsPolygon > smoothPolygon(
const QgsPolygon &polygon,
unsigned int iterations = 1,
double offset = 0.25,
3177 double minimumDistance = -1,
double maxAngle = 180.0 )
const;