164 Q_PROPERTY(
bool isNull READ isNull )
165 Q_PROPERTY(
Qgis::GeometryType type READ type )
243 Q_INVOKABLE static
QgsGeometry fromWkt( const QString &wkt );
330 static QgsGeometry collectGeometry(
const QVector<QgsGeometry> &geometries );
347 static QgsGeometry createWedgeBuffer(
const QgsPoint ¢er,
double azimuth,
double angularWidth,
348 double outerRadius,
double innerRadius = 0 );
363 static QgsGeometry createWedgeBufferFromAngles(
const QgsPoint ¢er,
double startAngle,
double endAngle,
364 double outerRadius,
double innerRadius = 0 );
371 void fromWkb(
unsigned char *wkb,
int length )
SIP_SKIP;
376 void fromWkb(
const QByteArray &wkb );
439 bool isGeosValid(
Qgis::GeometryValidityFlags flags =
Qgis::GeometryValidityFlags() ) const;
448 bool isSimple() const;
463 bool isAxisParallelRectangle(
double maximumDeviation,
bool simpleRectanglesOnly = false ) const;
491 double length() const;
674 double hausdorffDistance(
const QgsGeometry &geom )
const;
693 double hausdorffDistanceDensify(
const QgsGeometry &geom,
double densifyFraction )
const;
756 double distanceToVertex(
int vertex )
const;
764 double angleAtVertex(
int vertex )
const;
778 void adjacentVertices(
int atVertex,
int &beforeVertex
SIP_OUT,
int &afterVertex
SIP_OUT )
const;
792 bool insertVertex(
double x,
double y,
int beforeVertex );
806 bool insertVertex(
const QgsPoint &point,
int beforeVertex );
815 bool addTopologicalPoint(
const QgsPoint &point,
double snappingTolerance = 1e-8,
double segmentSearchEpsilon = 1e-12 );
824 bool moveVertex(
double x,
double y,
int atVertex );
833 bool moveVertex(
const QgsPoint &p,
int atVertex );
846 bool deleteVertex(
int atVertex );
855 bool toggleCircularAtVertex(
int atVertex );
862 QgsPoint vertexAt(
int atVertex )
const;
894 double closestVertexWithContext(
const QgsPointXY &point,
int &atVertex
SIP_OUT )
const;
989 QgsGeometry removeInteriorRings(
double minimumAllowedArea = -1 )
const;
1021 Qgis::GeometryOperationResult transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 );
1029 Qgis::GeometryOperationResult rotate(
double rotation, const
QgsPointXY ¢er );
1041 Q_DECL_DEPRECATED
Qgis::GeometryOperationResult splitGeometry( const QVector<
QgsPointXY> &splitLine, QVector<
QgsGeometry> &newGeometries,
bool topological, QVector<
QgsPointXY> &topologyTestPoints,
bool splitFeature = true )
SIP_SKIP;
1098 if ( PyList_Check( a0 ) && PyList_GET_SIZE( a0 ) )
1100 PyObject *p0 = PyList_GetItem( a0, 0 );
1101 if ( sipCanConvertToType( p0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1102 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1104 QVector<QgsGeometry> newGeometries;
1105 QVector<QgsPointXY> topologyTestPoints;
1107 QVector<QgsPointXY> *splitLine =
reinterpret_cast<QVector<QgsPointXY> *
>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1110 sipReleaseType( splitLine, sipType_QVector_0100QgsPointXY, state );
1116 PyObject *o0 = sipConvertFromEnum(
static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1117 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1118 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPointXY, Py_None );
1120 sipRes = PyTuple_New( 3 );
1121 PyTuple_SET_ITEM( sipRes, 0, o0 );
1122 PyTuple_SET_ITEM( sipRes, 1, o1 );
1123 PyTuple_SET_ITEM( sipRes, 2, o2 );
1127 else if ( sipCanConvertToType( p0, sipType_QgsPoint, SIP_NOT_NONE ) &&
1128 sipCanConvertToType( a0, sipType_QVector_0100QgsPoint, SIP_NOT_NONE ) )
1130 QVector<QgsGeometry> newGeometries;
1131 QVector<QgsPoint> topologyTestPoints;
1133 QVector<QgsPoint> *splitLine =
reinterpret_cast<QVector<QgsPoint> *
>( sipConvertToType( a0, sipType_QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1136 sipReleaseType( splitLine, sipType_QVector_0100QgsPoint, state );
1142 PyObject *o0 = sipConvertFromEnum(
static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1143 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1144 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPoint, Py_None );
1146 sipRes = PyTuple_New( 3 );
1147 PyTuple_SET_ITEM( sipRes, 0, o0 );
1148 PyTuple_SET_ITEM( sipRes, 1, o1 );
1149 PyTuple_SET_ITEM( sipRes, 2, o2 );
1155 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"Could not convert first argument to a list of QgsPoint or QgsPointXY." ).toUtf8().constData() );
1161 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"First argument is not a list of points or is empty." ).toUtf8().constData() );
1258 QgsGeometry orthogonalize(
double tolerance = 1.0E-8,
int maxIterations = 1000,
double angleThreshold = 15.0 ) const;
1272 QgsGeometry triangularWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1292 QgsGeometry triangularWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1306 QgsGeometry squareWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1326 QgsGeometry squareWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1340 QgsGeometry roundWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1360 QgsGeometry roundWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1375 QgsGeometry applyDashPattern( const QVector<
double > &pattern,
1376 Qgis::DashPatternLineEndingRule startRule =
Qgis::DashPatternLineEndingRule::NoRule,
1377 Qgis::DashPatternLineEndingRule endRule =
Qgis::DashPatternLineEndingRule::NoRule,
1378 Qgis::DashPatternSizeAdjustment adjustment =
Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap,
1379 double patternOffset = 0 ) const;
1392 QgsGeometry snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const;
1413 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false );
1424 bool intersects( const
QgsRectangle &rectangle ) const;
1440 bool intersects( const
QgsGeometry &geometry ) const;
1450 bool boundingBoxIntersects( const
QgsRectangle &rectangle ) const;
1460 bool boundingBoxIntersects( const
QgsGeometry &geometry ) const;
1472 bool contains(
double x,
double y ) const;
1483 bool contains( const
QgsGeometry &geometry ) const;
1494 bool disjoint( const
QgsGeometry &geometry ) const;
1505 bool touches( const
QgsGeometry &geometry ) const;
1516 bool overlaps( const
QgsGeometry &geometry ) const;
1538 bool crosses( const
QgsGeometry &geometry ) const;
1547 QgsGeometry buffer(
double distance,
int segments ) const;
1560 QgsGeometry buffer(
double distance,
int segments,
Qgis::EndCapStyle endCapStyle,
Qgis::JoinStyle joinStyle,
double miterLimit ) const;
1569 QgsGeometry offsetCurve(
double distance,
int segments,
Qgis::JoinStyle joinStyle,
double miterLimit ) const;
1585 QgsGeometry singleSidedBuffer(
double distance,
int segments,
Qgis::BufferSide side,
1586 Qgis::JoinStyle joinStyle =
Qgis::JoinStyle::Round,
1587 double miterLimit = 2.0 ) const;
1606 QgsGeometry taperedBuffer(
double startWidth,
double endWidth,
int segments ) const;
1622 QgsGeometry variableWidthBufferByM(
int segments ) const;
1629 QgsGeometry extendLine(
double startDistance,
double endDistance ) const;
1642 QgsGeometry densifyByCount(
int extraNodesPerSegment ) const;
1657 QgsGeometry densifyByDistance(
double distance ) const;
1674 QgsGeometry convertToCurves(
double distanceTolerance = 1e-8,
double angleTolerance = 1e-8 ) const;
1847 QgsGeometry delaunayTriangulation(
double tolerance = 0.0,
bool edgesOnly = false ) const;
1994 double lineLocatePoint( const
QgsGeometry &point ) const;
2004 double interpolateAngle(
double distance ) const;
2138 const
Qgis::GeometryType type = sipCpp->type();
2139 if ( sipCpp->isNull() )
2141 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Cannot generate points inside a null geometry." ).toUtf8().constData() );
2146 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"Cannot generate points inside a %1 geometry. Only Polygon types are permitted." ).arg(
QgsWkbTypes::displayString( sipCpp->wkbType() ) ).toUtf8().constData() );
2151 const sipTypeDef *qvector_type = sipFindType(
"QVector<QgsPointXY>" );
2152 sipRes = sipConvertFromNewType(
new QVector< QgsPointXY >( sipCpp->randomPointsInPolygon( a0, a1 ) ), qvector_type, Py_None );
2182 Q_INVOKABLE QString asWkt(
int precision = 17 )
const;
2185 SIP_PYOBJECT __repr__();
2188 if ( sipCpp->isNull() )
2189 str = QStringLiteral(
"<QgsGeometry: null>" );
2192 QString wkt = sipCpp->asWkt();
2193 if ( wkt.length() > 1000 )
2194 wkt = wkt.left( 1000 ) + QStringLiteral(
"..." );
2195 str = QStringLiteral(
"<QgsGeometry: %1>" ).arg( wkt );
2197 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
2204 QString asJson(
int precision = 17 )
const;
2239 QVector<
QgsGeometry > coerceToType(
Qgis::WkbType type,
double defaultZ = 0,
double defaultM = 0 ) const;
2252 QgsGeometry convertToType(
Qgis::GeometryType destType,
bool destMultipart = false ) const;
2281 if ( sipCpp->isNull() )
2283 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a point." ).toUtf8().constData() );
2291 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() );
2296 sipRes = sipConvertFromNewType(
new QgsPointXY( sipCpp->asPoint() ), sipType_QgsPointXY, Py_None );
2328 const
Qgis::WkbType type = sipCpp->wkbType();
2329 if ( sipCpp->isNull() )
2331 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polyline." ).toUtf8().constData() );
2336 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() );
2341 const sipTypeDef *qvector_type = sipFindType(
"QVector< QgsPointXY >" );
2342 sipRes = sipConvertFromNewType(
new QgsPolylineXY( sipCpp->asPolyline() ), qvector_type, Py_None );
2373 const
Qgis::WkbType type = sipCpp->wkbType();
2374 if ( sipCpp->isNull() )
2376 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polygon." ).toUtf8().constData() );
2381 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() );
2386 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QgsPointXY>>" );
2387 sipRes = sipConvertFromNewType(
new QgsPolygonXY( sipCpp->asPolygon() ), qvector_type, Py_None );
2416 const
Qgis::WkbType type = sipCpp->wkbType();
2417 if ( sipCpp->isNull() )
2419 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multipoint." ).toUtf8().constData() );
2424 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"%1 geometry cannot be converted to a multipoint. Only multipoint types are permitted." ).arg(
QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2429 const sipTypeDef *qvector_type = sipFindType(
"QVector< QgsPointXY >" );
2430 sipRes = sipConvertFromNewType(
new QgsPolylineXY( sipCpp->asMultiPoint() ), qvector_type, Py_None );
2461 const
Qgis::WkbType type = sipCpp->wkbType();
2462 if ( sipCpp->isNull() )
2464 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multilinestring." ).toUtf8().constData() );
2469 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() );
2474 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QgsPointXY>>" );
2475 sipRes = sipConvertFromNewType(
new QgsMultiPolylineXY( sipCpp->asMultiPolyline() ), qvector_type, Py_None );
2506 const
Qgis::WkbType type = sipCpp->wkbType();
2507 if ( sipCpp->isNull() )
2509 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multipolygon." ).toUtf8().constData() );
2514 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() );
2519 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QVector<QgsPointXY>>>" );
2520 sipRes = sipConvertFromNewType(
new QgsMultiPolygonXY( sipCpp->asMultiPolygon() ), qvector_type, Py_None );
2528 QVector<QgsGeometry> asGeometryCollection()
const;
2554 bool deleteRing(
int ringNum,
int partNum = 0 );
2560 bool deletePart(
int partNum );
2570 bool convertToMultiType();
2587 bool convertToCurvedMultiType();
2598 bool convertToSingleType();
2609 bool convertGeometryCollectionToSubclass(
Qgis::GeometryType geomType );
2622 Q_DECL_DEPRECATED
int avoidIntersections( const QList<
QgsVectorLayer *> &avoidIntersectionsLayers,
2636 Qgis::GeometryOperationResult avoidIntersectionsV2( const QList<
QgsVectorLayer *> &avoidIntersectionsLayers,
2670 Qgis::AngularDirection polygonOrientation() const;
2751 : mMessage( QStringLiteral(
"none" ) )
2761 , mHasLocation( true ) {}
2766 QString what()
const;
2776 bool hasWhere()
const;
2779 SIP_PYOBJECT __repr__();
2781 QString str = QStringLiteral(
"<QgsGeometry.Error: %1>" ).arg( sipCpp->what() );
2782 sipRes = PyUnicode_FromString( str.toUtf8().data() );
2789 return other.mMessage == mMessage && other.mHasLocation == mHasLocation && other.mLocation == mLocation;
2795 bool mHasLocation =
false;
2835 static QgsGeometry polygonize(
const QVector<QgsGeometry> &geometries );
2850 bool requiresConversionToStraightSegments()
const;
2862 void draw( QPainter &p )
const;
2904 void filterVertices( const std::function<
bool( const
QgsPoint & ) > &filter )
SIP_SKIP;
2934 static
QgsGeometry fromQPolygonF( const QPolygonF &polygon );
2965 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2976 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2988 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
3009 static bool compare( PyObject *obj1, PyObject *obj2,
double epsilon = 4 * std::numeric_limits<double>::epsilon() );
3017 if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
3018 PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
3020 PyObject *o0 = PyList_GetItem( a0, 0 );
3021 PyObject *o1 = PyList_GetItem( a1, 0 );
3025 if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3026 sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3027 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3028 sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3032 p0 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3033 p1 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3036 sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
3037 sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
3044 else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
3045 PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
3047 PyObject *oo0 = PyList_GetItem( o0, 0 );
3048 PyObject *oo1 = PyList_GetItem( o1, 0 );
3052 if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3053 sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3054 sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3055 sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3059 p0 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3060 p1 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3063 sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
3064 sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
3071 else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
3072 PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
3074 PyObject *ooo0 = PyList_GetItem( oo0, 0 );
3075 PyObject *ooo1 = PyList_GetItem( oo1, 0 );
3079 if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3080 sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3081 sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3082 sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3086 p0 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3087 p1 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3090 sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
3091 sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
3123 QgsGeometry smooth(
unsigned int iterations = 1,
double offset = 0.25,
3124 double minimumDistance = -1.0,
double maxAngle = 180.0 )
const;
3172 static void convertPointList(
const QVector<QgsPointXY> &input,
QgsPointSequence &output );
3179 static void convertPointList(
const QgsPointSequence &input, QVector<QgsPointXY> &output );
3182 operator QVariant()
const
3184 return QVariant::fromValue( *
this );
3192 mutable QString mLastError;
3204 void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
3209 QgsGeometry convertToPoint(
bool destMultipart )
const;
3211 QgsGeometry convertToLine(
bool destMultipart )
const;
3213 QgsGeometry convertToPolygon(
bool destMultipart )
const;
3226 std::unique_ptr< QgsLineString > smoothLine(
const QgsLineString &line,
unsigned int iterations = 1,
double offset = 0.25,
3227 double minimumDistance = -1,
double maxAngle = 180.0 )
const;
3240 std::unique_ptr< QgsPolygon > smoothPolygon(
const QgsPolygon &polygon,
unsigned int iterations = 1,
double offset = 0.25,
3241 double minimumDistance = -1,
double maxAngle = 180.0 )
const;