166 Q_PROPERTY(
bool isNull READ isNull )
321 static QgsGeometry collectGeometry(
const QVector<QgsGeometry> &geometries );
338 static QgsGeometry createWedgeBuffer(
const QgsPoint ¢er,
double azimuth,
double angularWidth,
339 double outerRadius,
double innerRadius = 0 );
346 void fromWkb(
unsigned char *wkb,
int length )
SIP_SKIP;
352 void fromWkb(
const QByteArray &wkb );
372 bool isEmpty() const;
418 bool isGeosValid(
Qgis::GeometryValidityFlags flags =
Qgis::GeometryValidityFlags() ) const;
428 bool isSimple() const;
443 bool isAxisParallelRectangle(
double maximumDeviation,
bool simpleRectanglesOnly = false ) const;
473 double length() const;
660 double hausdorffDistance(
const QgsGeometry &geom )
const;
680 double hausdorffDistanceDensify(
const QgsGeometry &geom,
double densifyFraction )
const;
744 double distanceToVertex(
int vertex )
const;
753 double angleAtVertex(
int vertex )
const;
767 void adjacentVertices(
int atVertex,
int &beforeVertex
SIP_OUT,
int &afterVertex
SIP_OUT )
const;
781 bool insertVertex(
double x,
double y,
int beforeVertex );
795 bool insertVertex(
const QgsPoint &point,
int beforeVertex );
804 bool moveVertex(
double x,
double y,
int atVertex );
813 bool moveVertex(
const QgsPoint &p,
int atVertex );
826 bool deleteVertex(
int atVertex );
835 bool toggleCircularAtVertex(
int atVertex );
842 QgsPoint vertexAt(
int atVertex )
const;
876 double closestVertexWithContext(
const QgsPointXY &point,
int &atVertex
SIP_OUT )
const;
942 QgsGeometry removeInteriorRings(
double minimumAllowedArea = -1 )
const;
974 Qgis::GeometryOperationResult transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 );
982 Qgis::GeometryOperationResult rotate(
double rotation, const
QgsPointXY ¢er );
1037 Qgis::GeometryOperationResult reshapeGeometry( const
QgsLineString &reshapeLineString );
1110 QgsGeometry orthogonalize(
double tolerance = 1.0E-8,
int maxIterations = 1000,
double angleThreshold = 15.0 ) const;
1124 QgsGeometry triangularWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1144 QgsGeometry triangularWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1158 QgsGeometry squareWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1178 QgsGeometry squareWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1192 QgsGeometry roundWaves(
double wavelength,
double amplitude,
bool strictWavelength = false ) const;
1212 QgsGeometry roundWavesRandomized(
double minimumWavelength,
double maximumWavelength,
double minimumAmplitude,
double maximumAmplitude,
unsigned long seed = 0 ) const;
1227 QgsGeometry applyDashPattern( const QVector<
double > &pattern,
1228 Qgis::DashPatternLineEndingRule startRule =
Qgis::DashPatternLineEndingRule::NoRule,
1229 Qgis::DashPatternLineEndingRule endRule =
Qgis::DashPatternLineEndingRule::NoRule,
1230 Qgis::DashPatternSizeAdjustment adjustment =
Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap,
1231 double patternOffset = 0 ) const;
1245 QgsGeometry snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const;
1267 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false );
1278 bool intersects( const
QgsRectangle &rectangle ) const;
1294 bool intersects( const
QgsGeometry &geometry ) const;
1305 bool boundingBoxIntersects( const
QgsRectangle &rectangle ) const;
1316 bool boundingBoxIntersects( const
QgsGeometry &geometry ) const;
1333 bool contains( const
QgsGeometry &geometry ) const;
1345 bool disjoint( const
QgsGeometry &geometry ) const;
1357 bool touches( const
QgsGeometry &geometry ) const;
1369 bool overlaps( const
QgsGeometry &geometry ) const;
1393 bool crosses( const
QgsGeometry &geometry ) const;
1402 QgsGeometry buffer(
double distance,
int segments ) const;
1416 QgsGeometry buffer(
double distance,
int segments,
Qgis::EndCapStyle endCapStyle,
Qgis::JoinStyle joinStyle,
double miterLimit ) const;
1426 QgsGeometry offsetCurve(
double distance,
int segments,
Qgis::JoinStyle joinStyle,
double miterLimit ) const;
1443 QgsGeometry singleSidedBuffer(
double distance,
int segments,
Qgis::BufferSide side,
1444 Qgis::JoinStyle joinStyle =
Qgis::JoinStyle::Round,
1445 double miterLimit = 2.0 ) const;
1464 QgsGeometry taperedBuffer(
double startWidth,
double endWidth,
int segments ) const;
1480 QgsGeometry variableWidthBufferByM(
int segments ) const;
1488 QgsGeometry extendLine(
double startDistance,
double endDistance ) const;
1502 QgsGeometry densifyByCount(
int extraNodesPerSegment ) const;
1518 QgsGeometry densifyByDistance(
double distance ) const;
1535 QgsGeometry convertToCurves(
double distanceTolerance = 1e-8,
double angleTolerance = 1e-8 ) const;
1709 QgsGeometry delaunayTriangulation(
double tolerance = 0.0,
bool edgesOnly = false ) const;
1791 double lineLocatePoint( const
QgsGeometry &point ) const;
1802 double interpolateAngle(
double distance ) const;
1938 const
QgsWkbTypes::GeometryType type = sipCpp->type();
1939 if ( sipCpp->isNull() )
1941 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Cannot generate points inside a null geometry." ).toUtf8().constData() );
1946 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"Cannot generate points inside a %1 geometry. Only Polygon types are permitted." ).arg(
QgsWkbTypes::displayString( sipCpp->wkbType() ) ).toUtf8().constData() );
1951 const sipTypeDef *qvector_type = sipFindType(
"QVector<QgsPointXY>" );
1952 sipRes = sipConvertFromNewType(
new QVector< QgsPointXY >( sipCpp->randomPointsInPolygon( a0, a1 ) ), qvector_type, Py_None );
1967 int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() )
const;
1976 QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() )
const;
1983 QString asWkt(
int precision = 17 )
const;
1986 SIP_PYOBJECT __repr__();
1989 if ( sipCpp->isNull() )
1990 str = QStringLiteral(
"<QgsGeometry: null>" );
1993 QString wkt = sipCpp->asWkt();
1994 if ( wkt.length() > 1000 )
1995 wkt = wkt.left( 1000 ) + QStringLiteral(
"..." );
1996 str = QStringLiteral(
"<QgsGeometry: %1>" ).arg( wkt );
1998 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
2005 QString asJson(
int precision = 17 )
const;
2040 QVector<
QgsGeometry > coerceToType(
QgsWkbTypes::Type type,
double defaultZ = 0,
double defaultM = 0 ) const;
2083 if ( sipCpp->isNull() )
2085 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a point." ).toUtf8().constData() );
2093 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() );
2098 sipRes = sipConvertFromNewType(
new QgsPointXY( sipCpp->asPoint() ), sipType_QgsPointXY, Py_None );
2131 if ( sipCpp->isNull() )
2133 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polyline." ).toUtf8().constData() );
2138 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() );
2143 const sipTypeDef *qvector_type = sipFindType(
"QVector< QgsPointXY >" );
2144 sipRes = sipConvertFromNewType(
new QgsPolylineXY( sipCpp->asPolyline() ), qvector_type, Py_None );
2176 if ( sipCpp->isNull() )
2178 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polygon." ).toUtf8().constData() );
2183 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() );
2188 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QgsPointXY>>" );
2189 sipRes = sipConvertFromNewType(
new QgsPolygonXY( sipCpp->asPolygon() ), qvector_type, Py_None );
2219 if ( sipCpp->isNull() )
2221 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multipoint." ).toUtf8().constData() );
2226 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"%1 geometry cannot be converted to a multipoint. Only multipoint types are permitted." ).arg(
QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
2231 const sipTypeDef *qvector_type = sipFindType(
"QVector< QgsPointXY >" );
2232 sipRes = sipConvertFromNewType(
new QgsPolylineXY( sipCpp->asMultiPoint() ), qvector_type, Py_None );
2264 if ( sipCpp->isNull() )
2266 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multilinestring." ).toUtf8().constData() );
2271 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() );
2276 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QgsPointXY>>" );
2277 sipRes = sipConvertFromNewType(
new QgsMultiPolylineXY( sipCpp->asMultiPolyline() ), qvector_type, Py_None );
2309 if ( sipCpp->isNull() )
2311 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a multipolygon." ).toUtf8().constData() );
2316 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() );
2321 const sipTypeDef *qvector_type = sipFindType(
"QVector<QVector<QVector<QgsPointXY>>>" );
2322 sipRes = sipConvertFromNewType(
new QgsMultiPolygonXY( sipCpp->asMultiPolygon() ), qvector_type, Py_None );
2331 QVector<QgsGeometry> asGeometryCollection()
const;
2360 bool deleteRing(
int ringNum,
int partNum = 0 );
2367 bool deletePart(
int partNum );
2377 bool convertToMultiType();
2388 bool convertToSingleType();
2399 bool convertGeometryCollectionToSubclass(
QgsWkbTypes::GeometryType geomType );
2412 int avoidIntersections( const QList<
QgsVectorLayer *> &avoidIntersectionsLayers,
2480 : mMessage( QStringLiteral(
"none" ) )
2490 , mHasLocation( true ) {}
2495 QString what()
const;
2505 bool hasWhere()
const;
2508 SIP_PYOBJECT __repr__();
2510 QString
str = QStringLiteral(
"<QgsGeometry.Error: %1>" ).arg( sipCpp->what() );
2511 sipRes = PyUnicode_FromString(
str.toUtf8().data() );
2518 return other.mMessage == mMessage && other.mHasLocation == mHasLocation && other.mLocation == mLocation;
2524 bool mHasLocation =
false;
2566 static QgsGeometry polygonize(
const QVector<QgsGeometry> &geometries );
2583 bool requiresConversionToStraightSegments()
const;
2597 void draw( QPainter &p )
const;
2642 void filterVertices( const std::function<
bool( const
QgsPoint & ) > &filter )
SIP_SKIP;
2674 static
QgsGeometry fromQPolygonF( const QPolygonF &polygon );
2706 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2718 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2731 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2753 static bool compare( PyObject *obj1, PyObject *obj2,
double epsilon = 4 * std::numeric_limits<double>::epsilon() );
2761 if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
2762 PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
2764 PyObject *o0 = PyList_GetItem( a0, 0 );
2765 PyObject *o1 = PyList_GetItem( a1, 0 );
2769 if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2770 sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2771 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2772 sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2776 p0 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2777 p1 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2780 sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
2781 sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
2788 else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
2789 PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
2791 PyObject *oo0 = PyList_GetItem( o0, 0 );
2792 PyObject *oo1 = PyList_GetItem( o1, 0 );
2796 if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2797 sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2798 sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2799 sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2803 p0 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2804 p1 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2807 sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
2808 sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
2815 else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
2816 PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
2818 PyObject *ooo0 = PyList_GetItem( oo0, 0 );
2819 PyObject *ooo1 = PyList_GetItem( oo1, 0 );
2823 if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2824 sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2825 sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2826 sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2830 p0 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2831 p1 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2834 sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
2835 sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
2868 QgsGeometry smooth(
unsigned int iterations = 1,
double offset = 0.25,
2869 double minimumDistance = -1.0,
double maxAngle = 180.0 )
const;
2915 static void convertPointList(
const QVector<QgsPointXY> &input,
QgsPointSequence &output );
2922 static void convertPointList(
const QgsPointSequence &input, QVector<QgsPointXY> &output );
2925 operator QVariant()
const
2927 return QVariant::fromValue( *
this );
2935 mutable QString mLastError;
2947 void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
2952 QgsGeometry convertToPoint(
bool destMultipart )
const;
2954 QgsGeometry convertToLine(
bool destMultipart )
const;
2956 QgsGeometry convertToPolygon(
bool destMultipart )
const;
2969 std::unique_ptr< QgsLineString > smoothLine(
const QgsLineString &line,
unsigned int iterations = 1,
double offset = 0.25,
2970 double minimumDistance = -1,
double maxAngle = 180.0 )
const;
2983 std::unique_ptr< QgsPolygon > smoothPolygon(
const QgsPolygon &polygon,
unsigned int iterations = 1,
double offset = 0.25,
2984 double minimumDistance = -1,
double maxAngle = 180.0 )
const;