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 ) );
1112 PyObject *o0 = sipConvertFromEnum(
static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1113 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1114 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPointXY, Py_None );
1116 sipRes = PyTuple_New( 3 );
1117 PyTuple_SET_ITEM( sipRes, 0, o0 );
1118 PyTuple_SET_ITEM( sipRes, 1, o1 );
1119 PyTuple_SET_ITEM( sipRes, 2, o2 );
1121 sipReleaseType( splitLine, sipType_QVector_0100QgsPointXY, state );
1124 else if ( sipCanConvertToType( p0, sipType_QgsPoint, SIP_NOT_NONE ) &&
1125 sipCanConvertToType( a0, sipType_QVector_0100QgsPoint, SIP_NOT_NONE ) )
1127 QVector<QgsGeometry> newGeometries;
1128 QVector<QgsPoint> topologyTestPoints;
1130 QVector<QgsPoint> *splitLine =
reinterpret_cast<QVector<QgsPoint> *
>( sipConvertToType( a0, sipType_QVector_0100QgsPoint, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
1135 PyObject *o0 = sipConvertFromEnum(
static_cast<int>( result ), sipType_Qgis_GeometryOperationResult );
1136 PyObject *o1 = sipConvertFromType( &newGeometries, sipType_QVector_0100QgsGeometry, Py_None );
1137 PyObject *o2 = sipConvertFromType( &topologyTestPoints, sipType_QVector_0100QgsPoint, Py_None );
1139 sipRes = PyTuple_New( 3 );
1140 PyTuple_SET_ITEM( sipRes, 0, o0 );
1141 PyTuple_SET_ITEM( sipRes, 1, o1 );
1142 PyTuple_SET_ITEM( sipRes, 2, o2 );
1144 sipReleaseType( splitLine, sipType_QVector_0100QgsPoint, state );
1149 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"Could not convert first argument to a list of QgsPoint or QgsPointXY." ).toUtf8().constData() );
1155 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"First argument is not a list of points or is empty." ).toUtf8().constData() );
1255 QgsGeometry orthogonalize(
double tolerance = 1.0E-8,
int maxIterations = 1000,
double angleThreshold = 15.0 ) const;
1269 QgsGeometry triangularWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1289 QgsGeometry triangularWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1303 QgsGeometry squareWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1323 QgsGeometry squareWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1337 QgsGeometry roundWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1357 QgsGeometry roundWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1372 QgsGeometry applyDashPattern( const QVector<
double > &pattern,
1373 Qgis::DashPatternLineEndingRule startRule =
Qgis::DashPatternLineEndingRule::NoRule,
1374 Qgis::DashPatternLineEndingRule endRule =
Qgis::DashPatternLineEndingRule::NoRule,
1375 Qgis::DashPatternSizeAdjustment adjustment =
Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap,
1376 double patternOffset = 0 ) const;
1389 QgsGeometry snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const;
1410 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false );
1421 bool intersects( const
QgsRectangle &rectangle ) const;
1437 bool intersects( const
QgsGeometry &geometry ) const;
1447 bool boundingBoxIntersects( const
QgsRectangle &rectangle ) const;
1457 bool boundingBoxIntersects( const
QgsGeometry &geometry ) const;
1469 bool contains(
double x,
double y ) const;
1480 bool contains( const
QgsGeometry &geometry ) const;
1491 bool disjoint( const
QgsGeometry &geometry ) const;
1502 bool touches( const
QgsGeometry &geometry ) const;
1513 bool overlaps( const
QgsGeometry &geometry ) const;
1535 bool crosses( const
QgsGeometry &geometry ) const;
1544 QgsGeometry buffer(
double distance,
int segments ) const;
1557 QgsGeometry buffer(
double distance,
int segments,
Qgis::EndCapStyle endCapStyle,
Qgis::JoinStyle joinStyle,
double miterLimit ) const;
1566 QgsGeometry offsetCurve(
double distance,
int segments,
Qgis::JoinStyle joinStyle,
double miterLimit ) const;
1582 QgsGeometry singleSidedBuffer(
double distance,
int segments,
Qgis::BufferSide side,
1583 Qgis::JoinStyle joinStyle =
Qgis::JoinStyle::Round,
1584 double miterLimit = 2.0 ) const;
1603 QgsGeometry taperedBuffer(
double startWidth,
double endWidth,
int segments ) const;
1619 QgsGeometry variableWidthBufferByM(
int segments ) const;
1626 QgsGeometry extendLine(
double startDistance,
double endDistance ) const;
1639 QgsGeometry densifyByCount(
int extraNodesPerSegment ) const;
1654 QgsGeometry densifyByDistance(
double distance ) const;
1671 QgsGeometry convertToCurves(
double distanceTolerance = 1e-8,
double angleTolerance = 1e-8 ) const;
1844 QgsGeometry delaunayTriangulation(
double tolerance = 0.0,
bool edgesOnly = false ) const;
1991 double lineLocatePoint( const
QgsGeometry &point ) const;
2001 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;
2243 QVector<
QgsGeometry > coerceToType(
Qgis::WkbType type,
double defaultZ = 0,
double defaultM = 0,
bool avoidDuplicates = true ) const;
2256 QgsGeometry convertToType(
Qgis::GeometryType destType,
bool destMultipart = false ) const;
2285 if ( sipCpp->isNull() )
2287 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a point." ).toUtf8().constData() );
2295 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() );
2300 sipRes = sipConvertFromNewType(
new QgsPointXY( sipCpp->asPoint() ), sipType_QgsPointXY, Py_None );
2332 const
Qgis::WkbType type = sipCpp->wkbType();
2333 if ( sipCpp->isNull() )
2335 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polyline." ).toUtf8().constData() );
2340 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() );
2345 const sipTypeDef *qvector_type = sipFindType(
"QVector< QgsPointXY >" );
2346 sipRes = sipConvertFromNewType(
new QgsPolylineXY( sipCpp->asPolyline() ), qvector_type, Py_None );
2377 const
Qgis::WkbType type = sipCpp->wkbType();
2378 if ( sipCpp->isNull() )
2380 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polygon." ).toUtf8().constData() );
2385 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() );
2390 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QgsPointXY>>" );
2391 sipRes = sipConvertFromNewType(
new QgsPolygonXY( sipCpp->asPolygon() ), qvector_type, Py_None );
2420 const
Qgis::WkbType type = sipCpp->wkbType();
2421 if ( sipCpp->isNull() )
2423 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multipoint." ).toUtf8().constData() );
2428 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"%1 geometry cannot be converted to a multipoint. Only multipoint types are permitted." ).arg(
QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2433 const sipTypeDef *qvector_type = sipFindType(
"QVector< QgsPointXY >" );
2434 sipRes = sipConvertFromNewType(
new QgsPolylineXY( sipCpp->asMultiPoint() ), qvector_type, Py_None );
2465 const
Qgis::WkbType type = sipCpp->wkbType();
2466 if ( sipCpp->isNull() )
2468 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multilinestring." ).toUtf8().constData() );
2473 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() );
2478 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QgsPointXY>>" );
2479 sipRes = sipConvertFromNewType(
new QgsMultiPolylineXY( sipCpp->asMultiPolyline() ), qvector_type, Py_None );
2510 const
Qgis::WkbType type = sipCpp->wkbType();
2511 if ( sipCpp->isNull() )
2513 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multipolygon." ).toUtf8().constData() );
2518 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() );
2523 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QVector<QgsPointXY>>>" );
2524 sipRes = sipConvertFromNewType(
new QgsMultiPolygonXY( sipCpp->asMultiPolygon() ), qvector_type, Py_None );
2532 QVector<QgsGeometry> asGeometryCollection()
const;
2558 bool deleteRing(
int ringNum,
int partNum = 0 );
2564 bool deletePart(
int partNum );
2574 bool convertToMultiType();
2591 bool convertToCurvedMultiType();
2602 bool convertToSingleType();
2613 bool convertGeometryCollectionToSubclass(
Qgis::GeometryType geomType );
2626 Q_DECL_DEPRECATED
int avoidIntersections( const QList<
QgsVectorLayer *> &avoidIntersectionsLayers,
2640 Qgis::GeometryOperationResult avoidIntersectionsV2( const QList<
QgsVectorLayer *> &avoidIntersectionsLayers,
2674 Qgis::AngularDirection polygonOrientation() const;
2755 : mMessage( QStringLiteral(
"none" ) )
2765 , mHasLocation( true ) {}
2770 QString what()
const;
2780 bool hasWhere()
const;
2783 SIP_PYOBJECT __repr__();
2785 QString str = QStringLiteral(
"<QgsGeometry.Error: %1>" ).arg( sipCpp->what() );
2786 sipRes = PyUnicode_FromString( str.toUtf8().data() );
2793 return other.mMessage == mMessage && other.mHasLocation == mHasLocation && other.mLocation == mLocation;
2799 bool mHasLocation =
false;
2839 static QgsGeometry polygonize(
const QVector<QgsGeometry> &geometries );
2854 bool requiresConversionToStraightSegments()
const;
2866 void draw( QPainter &p )
const;
2908 void filterVertices( const std::function<
bool( const
QgsPoint & ) > &filter )
SIP_SKIP;
2938 static
QgsGeometry fromQPolygonF( const QPolygonF &polygon );
2969 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2980 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2992 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
3013 static bool compare( PyObject *obj1, PyObject *obj2,
double epsilon = 4 * std::numeric_limits<double>::epsilon() );
3021 if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
3022 PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
3024 PyObject *o0 = PyList_GetItem( a0, 0 );
3025 PyObject *o1 = PyList_GetItem( a1, 0 );
3029 if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3030 sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3031 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3032 sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3036 p0 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3037 p1 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3042 sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
3043 sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
3045 else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
3046 PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
3048 PyObject *oo0 = PyList_GetItem( o0, 0 );
3049 PyObject *oo1 = PyList_GetItem( o1, 0 );
3053 if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3054 sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3055 sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3056 sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3060 p0 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3061 p1 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3066 sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
3067 sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
3069 else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
3070 PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
3072 PyObject *ooo0 = PyList_GetItem( oo0, 0 );
3073 PyObject *ooo1 = PyList_GetItem( oo1, 0 );
3077 if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3078 sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3079 sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3080 sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3084 p0 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3085 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 );
3118 QgsGeometry smooth(
unsigned int iterations = 1,
double offset = 0.25,
3119 double minimumDistance = -1.0,
double maxAngle = 180.0 )
const;
3167 static void convertPointList(
const QVector<QgsPointXY> &input,
QgsPointSequence &output );
3174 static void convertPointList(
const QgsPointSequence &input, QVector<QgsPointXY> &output );
3177 operator QVariant()
const
3179 return QVariant::fromValue( *
this );
3177 operator QVariant()
const {
…}
3187 mutable QString mLastError;
3199 void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
3204 QgsGeometry convertToPoint(
bool destMultipart )
const;
3206 QgsGeometry convertToLine(
bool destMultipart )
const;
3208 QgsGeometry convertToPolygon(
bool destMultipart )
const;
3221 std::unique_ptr< QgsLineString > smoothLine(
const QgsLineString &line,
unsigned int iterations = 1,
double offset = 0.25,
3222 double minimumDistance = -1,
double maxAngle = 180.0 )
const;
3235 std::unique_ptr< QgsPolygon > smoothPolygon(
const QgsPolygon &polygon,
unsigned int iterations = 1,
double offset = 0.25,
3236 double minimumDistance = -1,
double maxAngle = 180.0 )
const;