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() );
1252 QgsGeometry orthogonalize(
double tolerance = 1.0E-8,
int maxIterations = 1000,
double angleThreshold = 15.0 ) const;
1266 QgsGeometry triangularWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1286 QgsGeometry triangularWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1300 QgsGeometry squareWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1320 QgsGeometry squareWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1334 QgsGeometry roundWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1354 QgsGeometry roundWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1369 QgsGeometry applyDashPattern( const QVector<
double > &pattern,
1370 Qgis::DashPatternLineEndingRule startRule =
Qgis::DashPatternLineEndingRule::NoRule,
1371 Qgis::DashPatternLineEndingRule endRule =
Qgis::DashPatternLineEndingRule::NoRule,
1372 Qgis::DashPatternSizeAdjustment adjustment =
Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap,
1373 double patternOffset = 0 ) const;
1386 QgsGeometry snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const;
1407 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false );
1418 bool intersects( const
QgsRectangle &rectangle ) const;
1434 bool intersects( const
QgsGeometry &geometry ) const;
1444 bool boundingBoxIntersects( const
QgsRectangle &rectangle ) const;
1454 bool boundingBoxIntersects( const
QgsGeometry &geometry ) const;
1466 bool contains(
double x,
double y ) const;
1477 bool contains( const
QgsGeometry &geometry ) const;
1488 bool disjoint( const
QgsGeometry &geometry ) const;
1499 bool touches( const
QgsGeometry &geometry ) const;
1510 bool overlaps( const
QgsGeometry &geometry ) const;
1532 bool crosses( const
QgsGeometry &geometry ) const;
1541 QgsGeometry buffer(
double distance,
int segments ) const;
1554 QgsGeometry buffer(
double distance,
int segments,
Qgis::EndCapStyle endCapStyle,
Qgis::JoinStyle joinStyle,
double miterLimit ) const;
1563 QgsGeometry offsetCurve(
double distance,
int segments,
Qgis::JoinStyle joinStyle,
double miterLimit ) const;
1579 QgsGeometry singleSidedBuffer(
double distance,
int segments,
Qgis::BufferSide side,
1580 Qgis::JoinStyle joinStyle =
Qgis::JoinStyle::Round,
1581 double miterLimit = 2.0 ) const;
1600 QgsGeometry taperedBuffer(
double startWidth,
double endWidth,
int segments ) const;
1616 QgsGeometry variableWidthBufferByM(
int segments ) const;
1623 QgsGeometry extendLine(
double startDistance,
double endDistance ) const;
1636 QgsGeometry densifyByCount(
int extraNodesPerSegment ) const;
1651 QgsGeometry densifyByDistance(
double distance ) const;
1668 QgsGeometry convertToCurves(
double distanceTolerance = 1e-8,
double angleTolerance = 1e-8 ) const;
1841 QgsGeometry delaunayTriangulation(
double tolerance = 0.0,
bool edgesOnly = false ) const;
1988 double lineLocatePoint( const
QgsGeometry &point ) const;
1998 double interpolateAngle(
double distance ) const;
2132 const
Qgis::GeometryType type = sipCpp->type();
2133 if ( sipCpp->isNull() )
2135 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Cannot generate points inside a null geometry." ).toUtf8().constData() );
2140 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"Cannot generate points inside a %1 geometry. Only Polygon types are permitted." ).arg(
QgsWkbTypes::displayString( sipCpp->wkbType() ) ).toUtf8().constData() );
2145 const sipTypeDef *qvector_type = sipFindType(
"QVector<QgsPointXY>" );
2146 sipRes = sipConvertFromNewType(
new QVector< QgsPointXY >( sipCpp->randomPointsInPolygon( a0, a1 ) ), qvector_type, Py_None );
2176 Q_INVOKABLE QString asWkt(
int precision = 17 )
const;
2179 SIP_PYOBJECT __repr__();
2182 if ( sipCpp->isNull() )
2183 str = QStringLiteral(
"<QgsGeometry: null>" );
2186 QString wkt = sipCpp->asWkt();
2187 if ( wkt.length() > 1000 )
2188 wkt = wkt.left( 1000 ) + QStringLiteral(
"..." );
2189 str = QStringLiteral(
"<QgsGeometry: %1>" ).arg( wkt );
2191 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
2198 QString asJson(
int precision = 17 )
const;
2233 QVector<
QgsGeometry > coerceToType(
Qgis::WkbType type,
double defaultZ = 0,
double defaultM = 0 ) const;
2246 QgsGeometry convertToType(
Qgis::GeometryType destType,
bool destMultipart = false ) const;
2275 if ( sipCpp->isNull() )
2277 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a point." ).toUtf8().constData() );
2285 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() );
2290 sipRes = sipConvertFromNewType(
new QgsPointXY( sipCpp->asPoint() ), sipType_QgsPointXY, Py_None );
2322 const
Qgis::WkbType type = sipCpp->wkbType();
2323 if ( sipCpp->isNull() )
2325 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polyline." ).toUtf8().constData() );
2330 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() );
2335 const sipTypeDef *qvector_type = sipFindType(
"QVector< QgsPointXY >" );
2336 sipRes = sipConvertFromNewType(
new QgsPolylineXY( sipCpp->asPolyline() ), qvector_type, Py_None );
2367 const
Qgis::WkbType type = sipCpp->wkbType();
2368 if ( sipCpp->isNull() )
2370 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polygon." ).toUtf8().constData() );
2375 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() );
2380 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QgsPointXY>>" );
2381 sipRes = sipConvertFromNewType(
new QgsPolygonXY( sipCpp->asPolygon() ), qvector_type, Py_None );
2410 const
Qgis::WkbType type = sipCpp->wkbType();
2411 if ( sipCpp->isNull() )
2413 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multipoint." ).toUtf8().constData() );
2418 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"%1 geometry cannot be converted to a multipoint. Only multipoint types are permitted." ).arg(
QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2423 const sipTypeDef *qvector_type = sipFindType(
"QVector< QgsPointXY >" );
2424 sipRes = sipConvertFromNewType(
new QgsPolylineXY( sipCpp->asMultiPoint() ), qvector_type, Py_None );
2455 const
Qgis::WkbType type = sipCpp->wkbType();
2456 if ( sipCpp->isNull() )
2458 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multilinestring." ).toUtf8().constData() );
2463 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() );
2468 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QgsPointXY>>" );
2469 sipRes = sipConvertFromNewType(
new QgsMultiPolylineXY( sipCpp->asMultiPolyline() ), qvector_type, Py_None );
2500 const
Qgis::WkbType type = sipCpp->wkbType();
2501 if ( sipCpp->isNull() )
2503 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multipolygon." ).toUtf8().constData() );
2508 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() );
2513 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QVector<QgsPointXY>>>" );
2514 sipRes = sipConvertFromNewType(
new QgsMultiPolygonXY( sipCpp->asMultiPolygon() ), qvector_type, Py_None );
2522 QVector<QgsGeometry> asGeometryCollection()
const;
2548 bool deleteRing(
int ringNum,
int partNum = 0 );
2554 bool deletePart(
int partNum );
2564 bool convertToMultiType();
2581 bool convertToCurvedMultiType();
2592 bool convertToSingleType();
2603 bool convertGeometryCollectionToSubclass(
Qgis::GeometryType geomType );
2616 Q_DECL_DEPRECATED
int avoidIntersections( const QList<
QgsVectorLayer *> &avoidIntersectionsLayers,
2630 Qgis::GeometryOperationResult avoidIntersectionsV2( const QList<
QgsVectorLayer *> &avoidIntersectionsLayers,
2664 Qgis::AngularDirection polygonOrientation() const;
2745 : mMessage( QStringLiteral(
"none" ) )
2755 , mHasLocation( true ) {}
2760 QString what()
const;
2770 bool hasWhere()
const;
2773 SIP_PYOBJECT __repr__();
2775 QString str = QStringLiteral(
"<QgsGeometry.Error: %1>" ).arg( sipCpp->what() );
2776 sipRes = PyUnicode_FromString( str.toUtf8().data() );
2783 return other.mMessage == mMessage && other.mHasLocation == mHasLocation && other.mLocation == mLocation;
2789 bool mHasLocation =
false;
2829 static QgsGeometry polygonize(
const QVector<QgsGeometry> &geometries );
2844 bool requiresConversionToStraightSegments()
const;
2856 void draw( QPainter &p )
const;
2898 void filterVertices( const std::function<
bool( const
QgsPoint & ) > &filter )
SIP_SKIP;
2928 static
QgsGeometry fromQPolygonF( const QPolygonF &polygon );
2959 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2970 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2982 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
3003 static bool compare( PyObject *obj1, PyObject *obj2,
double epsilon = 4 * std::numeric_limits<double>::epsilon() );
3011 if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
3012 PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
3014 PyObject *o0 = PyList_GetItem( a0, 0 );
3015 PyObject *o1 = PyList_GetItem( a1, 0 );
3019 if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3020 sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3021 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3022 sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3026 p0 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3027 p1 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3032 sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
3033 sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
3035 else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
3036 PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
3038 PyObject *oo0 = PyList_GetItem( o0, 0 );
3039 PyObject *oo1 = PyList_GetItem( o1, 0 );
3043 if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3044 sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3045 sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3046 sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3050 p0 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3051 p1 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3056 sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
3057 sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
3059 else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
3060 PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
3062 PyObject *ooo0 = PyList_GetItem( oo0, 0 );
3063 PyObject *ooo1 = PyList_GetItem( oo1, 0 );
3067 if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3068 sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
3069 sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
3070 sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
3074 p0 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
3075 p1 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
3080 sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
3081 sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
3108 QgsGeometry smooth(
unsigned int iterations = 1,
double offset = 0.25,
3109 double minimumDistance = -1.0,
double maxAngle = 180.0 )
const;
3157 static void convertPointList(
const QVector<QgsPointXY> &input,
QgsPointSequence &output );
3164 static void convertPointList(
const QgsPointSequence &input, QVector<QgsPointXY> &output );
3167 operator QVariant()
const
3169 return QVariant::fromValue( *
this );
3167 operator QVariant()
const {
…}
3177 mutable QString mLastError;
3189 void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
3194 QgsGeometry convertToPoint(
bool destMultipart )
const;
3196 QgsGeometry convertToLine(
bool destMultipart )
const;
3198 QgsGeometry convertToPolygon(
bool destMultipart )
const;
3211 std::unique_ptr< QgsLineString > smoothLine(
const QgsLineString &line,
unsigned int iterations = 1,
double offset = 0.25,
3212 double minimumDistance = -1,
double maxAngle = 180.0 )
const;
3225 std::unique_ptr< QgsPolygon > smoothPolygon(
const QgsPolygon &polygon,
unsigned int iterations = 1,
double offset = 0.25,
3226 double minimumDistance = -1,
double maxAngle = 180.0 )
const;