21 #include <QDomDocument> 30 #include "qgis_core.h" 118 NothingHappened = 1000,
252 static QgsGeometry collectGeometry(
const QVector<QgsGeometry> &geometries );
269 static QgsGeometry createWedgeBuffer(
const QgsPoint ¢er,
double azimuth,
double angularWidth,
270 double outerRadius,
double innerRadius = 0 );
277 void fromWkb(
unsigned char *wkb,
int length )
SIP_SKIP;
283 void fromWkb(
const QByteArray &wkb );
303 bool isEmpty()
const;
306 bool isMultipart()
const;
345 FlagAllowSelfTouchingHoles = 1 << 0,
356 bool isGeosValid(
QgsGeometry::ValidityFlags flags =
nullptr ) const;
366 bool isSimple() const;
378 double length() const;
561 double hausdorffDistance(
const QgsGeometry &geom )
const;
581 double hausdorffDistanceDensify(
const QgsGeometry &geom,
double densifyFraction )
const;
596 QgsPointXY closestVertex(
const QgsPointXY &point,
int &atVertex
SIP_OUT,
int &beforeVertex SIP_OUT,
int &afterVertex SIP_OUT,
double &sqrDist SIP_OUT )
const;
604 double distanceToVertex(
int vertex )
const;
613 double angleAtVertex(
int vertex )
const;
627 void adjacentVertices(
int atVertex,
int &beforeVertex
SIP_OUT,
int &afterVertex SIP_OUT )
const;
641 bool insertVertex(
double x,
double y,
int beforeVertex );
655 bool insertVertex(
const QgsPoint &point,
int beforeVertex );
664 bool moveVertex(
double x,
double y,
int atVertex );
673 bool moveVertex(
const QgsPoint &p,
int atVertex );
686 bool deleteVertex(
int atVertex );
693 QgsPoint vertexAt(
int atVertex )
const;
722 double closestVertexWithContext(
const QgsPointXY &point,
int &atVertex
SIP_OUT )
const;
788 QgsGeometry removeInteriorRings(
double minimumAllowedArea = -1 ) const;
794 OperationResult translate(
double dx,
double dy,
double dz = 0.0,
double dm = 0.0 );
820 OperationResult transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 );
851 int makeDifferenceInPlace( const
QgsGeometry &other ) SIP_SKIP;
875 QgsGeometry orientedMinimumBoundingBox(
double &area SIP_OUT,
double &
angle SIP_OUT,
double &width SIP_OUT,
double &height SIP_OUT ) const;
882 QgsGeometry orientedMinimumBoundingBox() const SIP_SKIP;
891 QgsGeometry minimalEnclosingCircle(
QgsPointXY ¢er SIP_OUT,
double &radius SIP_OUT,
unsigned int segments = 36 ) const;
898 QgsGeometry minimalEnclosingCircle(
unsigned int segments = 36 ) const SIP_SKIP;
908 QgsGeometry orthogonalize(
double tolerance = 1.0E-8,
int maxIterations = 1000,
double angleThreshold = 15.0 ) const;
922 QgsGeometry snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const;
944 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false );
966 bool intersects( const
QgsGeometry &geometry ) const;
977 bool boundingBoxIntersects( const
QgsRectangle &rectangle ) const;
988 bool boundingBoxIntersects( const
QgsGeometry &geometry ) const;
997 bool contains( const
QgsGeometry &geometry ) const;
1003 bool disjoint( const
QgsGeometry &geometry ) const;
1009 bool touches( const
QgsGeometry &geometry ) const;
1015 bool overlaps( const
QgsGeometry &geometry ) const;
1027 bool crosses( const
QgsGeometry &geometry ) const;
1062 QgsGeometry buffer(
double distance,
int segments ) const;
1086 QgsGeometry offsetCurve(
double distance,
int segments,
JoinStyle joinStyle,
double miterLimit ) const;
1105 double miterLimit = 2.0 ) const;
1124 QgsGeometry taperedBuffer(
double startWidth,
double endWidth,
int segments ) const;
1140 QgsGeometry variableWidthBufferByM(
int segments ) const;
1148 QgsGeometry extendLine(
double startDistance,
double endDistance ) const;
1162 QgsGeometry densifyByCount(
int extraNodesPerSegment ) const;
1178 QgsGeometry densifyByDistance(
double distance ) const;
1260 QgsGeometry delaunayTriangulation(
double tolerance = 0.0,
bool edgesOnly = false ) const;
1281 QgsGeometry subdivide(
int maxNodes = 256 ) const;
1298 QgsGeometry interpolate(
double distance ) const;
1311 double lineLocatePoint( const QgsGeometry &point ) const;
1322 double interpolateAngle(
double distance ) const;
1332 QgsGeometry intersection( const QgsGeometry &geometry ) const;
1354 QgsGeometry combine( const QgsGeometry &geometry ) const;
1364 QgsGeometry mergeLines() const;
1374 QgsGeometry difference( const QgsGeometry &geometry ) const;
1384 QgsGeometry symDifference( const QgsGeometry &geometry ) const;
1387 QgsGeometry extrude(
double x,
double y );
1393 QByteArray asWkb() const;
1400 QString asWkt(
int precision = 17 ) const;
1403 SIP_PYOBJECT __repr__();
1406 if ( sipCpp->isNull() )
1407 str = QStringLiteral(
"<QgsGeometry: null>" );
1410 QString wkt = sipCpp->asWkt();
1411 if ( wkt.length() > 1000 )
1412 wkt = wkt.left( 1000 ) + QStringLiteral(
"..." );
1413 str = QStringLiteral(
"<QgsGeometry: %1>" ).arg( wkt );
1415 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
1422 QString asJson(
int precision = 17 )
const;
1456 SIP_PYOBJECT asPoint()
const;
1459 if ( sipCpp->isNull() )
1461 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a point." ).toUtf8().constData() );
1466 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"%1 geometry cannot be converted to a point. Only Point types are permitted." ).arg(
QgsWkbTypes::displayString( type ) ).toUtf8().constData() );
1471 sipRes = sipConvertFromNewType(
new QgsPointXY( sipCpp->asPoint() ), sipType_QgsPointXY, Py_None );
1499 SIP_PYOBJECT asPolyline()
const;
1502 if ( sipCpp->isNull() )
1504 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polyline." ).toUtf8().constData() );
1509 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() );
1514 const sipMappedType *qvector_type = sipFindMappedType(
"QVector< QgsPointXY >" );
1515 sipRes = sipConvertFromNewType(
new QgsPolylineXY( sipCpp->asPolyline() ), qvector_type, Py_None );
1543 SIP_PYOBJECT asPolygon()
const;
1546 if ( sipCpp->isNull() )
1548 PyErr_SetString( PyExc_ValueError, QStringLiteral(
"Null geometry cannot be converted to a polygon." ).toUtf8().constData() );
1553 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() );
1558 const sipMappedType *qvector_type = sipFindMappedType(
"QVector<QVector<QgsPointXY>>" );
1559 sipRes = sipConvertFromNewType(
new QgsPolygonXY( sipCpp->asPolygon() ), qvector_type, Py_None );
1586 QVector<QgsGeometry> asGeometryCollection()
const;
1593 QPointF asQPointF()
const;
1601 QPolygonF asQPolygonF()
const;
1609 bool deleteRing(
int ringNum,
int partNum = 0 );
1616 bool deletePart(
int partNum );
1626 bool convertToMultiType();
1637 bool convertToSingleType();
1660 int avoidIntersections(
const QList<QgsVectorLayer *> &avoidIntersectionsLayers,
1681 QgsGeometry makeValid()
const;
1690 QgsGeometry forceRHR()
const;
1699 : mMessage( QStringLiteral(
"none" ) )
1709 , mHasLocation( true ) {}
1714 QString what()
const;
1724 bool hasWhere()
const;
1727 SIP_PYOBJECT __repr__();
1729 QString str = QStringLiteral(
"<QgsGeometry.Error: %1>" ).arg( sipCpp->what() );
1730 sipRes = PyUnicode_FromString( str.toUtf8().data() );
1736 return other.mMessage == mMessage && other.mHasLocation == mHasLocation && other.mLocation == mLocation;
1742 bool mHasLocation =
false;
1763 void validateGeometry( QVector<QgsGeometry::Error> &errors
SIP_OUT,
ValidationMethod method = ValidatorQgisInternal, QgsGeometry::ValidityFlags flags =
nullptr )
const;
1770 static QgsGeometry unaryUnion(
const QVector<QgsGeometry> &geometries );
1780 static QgsGeometry polygonize(
const QVector<QgsGeometry> &geometries );
1797 bool requiresConversionToStraightSegments()
const;
1811 void draw( QPainter &p )
const;
1845 QString lastError()
const;
1856 void filterVertices(
const std::function<
bool(
const QgsPoint & ) > &filter ) SIP_SKIP;
1872 void transformVertices( const std::function<
QgsPoint( const
QgsPoint & ) > &transform ) SIP_SKIP;
1879 static QgsGeometry fromQPointF( QPointF point );
1888 static QgsGeometry fromQPolygonF( const QPolygonF &polygon );
1904 static
QgsPolygonXY createPolygonFromQPolygonF( const QPolygonF &polygon ) SIP_FACTORY;
1918 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1930 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1943 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1964 static bool compare( PyObject *obj1, PyObject *obj2,
double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1972 if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
1973 PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
1975 PyObject *o0 = PyList_GetItem( a0, 0 );
1976 PyObject *o1 = PyList_GetItem( a1, 0 );
1980 if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1981 sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1982 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
1983 sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1987 p0 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1988 p1 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1991 sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
1992 sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
1999 else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
2000 PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
2002 PyObject *oo0 = PyList_GetItem( o0, 0 );
2003 PyObject *oo1 = PyList_GetItem( o1, 0 );
2007 if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2008 sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2009 sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2010 sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2014 p0 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2015 p1 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2018 sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
2019 sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
2026 else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
2027 PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
2029 PyObject *ooo0 = PyList_GetItem( oo0, 0 );
2030 PyObject *ooo1 = PyList_GetItem( oo1, 0 );
2034 if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2035 sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
2036 sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
2037 sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
2041 p0 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
2042 p1 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
2045 sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
2046 sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
2079 QgsGeometry smooth(
unsigned int iterations = 1,
double offset = 0.25,
2080 double minimumDistance = -1.0,
double maxAngle = 180.0 )
const;
2092 static void convertPointList(
const QVector<QgsPointXY> &input,
QgsPointSequence &output );
2099 static void convertPointList(
const QgsPointSequence &input, QVector<QgsPointXY> &output );
2102 operator QVariant()
const 2104 return QVariant::fromValue( *
this );
2112 mutable QString mLastError;
2124 void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
2130 QgsGeometry convertToPoint(
bool destMultipart )
const;
2132 QgsGeometry convertToLine(
bool destMultipart )
const;
2134 QgsGeometry convertToPolygon(
bool destMultipart )
const;
2147 std::unique_ptr< QgsLineString > smoothLine(
const QgsLineString &line,
unsigned int iterations = 1,
double offset = 0.25,
2148 double minimumDistance = -1,
double maxAngle = 180.0 )
const;
2161 std::unique_ptr< QgsPolygon > smoothPolygon(
const QgsPolygon &polygon,
unsigned int iterations = 1,
double offset = 0.25,
2162 double minimumDistance = -1,
double maxAngle = 180.0 )
const;
2170 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsGeometry::ValidityFlags )
2173 CORE_EXPORT QDataStream &operator<<( QDataStream &out, const QgsGeometry &geometry );
2175 CORE_EXPORT QDataStream &operator>>( QDataStream &in, QgsGeometry &geometry );
Geometry engine misses a method implemented or an error occurred in the geometry engine.
A rectangle specified with double values.
Java-style iterator for traversal of parts of a geometry.
The input ring doesn't have any existing ring to fit into.
Java-style iterator for traversal of vertices of a geometry.
static bool isMultiType(Type type)
Returns true if the WKB type is a multi type.
The source geometry is not multi.
Maximum angle between generating radii (lines from arc center to output vertices) ...
Use GEOS validation methods.
Java-style iterator for const traversal of parts of a geometry.
Handles storage of information regarding WKB types and their properties.
A class to represent a 2D point.
QVector< QgsPoint > QgsPolyline
Polyline as represented as a vector of points.
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
A geometry is the spatial representation of a feature.
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
The part_iterator class provides STL-style iterator for const references to geometry parts...
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle...
EndCapStyle
End cap styles for buffers.
Q_DECLARE_METATYPE(QModelIndex)
OperationResult
Success or failure of a geometry operation.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
Error(const QString &m, const QgsPointXY &p)
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
Perform transforms between map coordinates and device coordinates.
The selected geometry cannot be found.
No features were selected.
More than one features were selected.
Type
The WKB type describes the number of dimensions a geometry has.
Utility class for identifying a unique vertex within a geometry.
const double DEFAULT_SEGMENT_EPSILON
Default snapping tolerance for segments.
The input ring crosses existing rings (it is not disjoint)
The part_iterator class provides STL-style iterator for geometry parts.
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
Use internal QgsGeometryValidator method.
The input ring is not closed.
Square cap (extends past start/end of line by buffer distance)
Abstract base class for curved geometry type.
Abstract base class for all geometries.
The vertex_iterator class provides STL-style iterator for vertices.
Point geometry type, with support for z-dimension and m-values.
This class offers geometry processing methods.
BufferSide
Side of line to buffer.
QVector< QgsPoint > QgsPointSequence
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
QVector< QgsPointXY > QgsPolylineXY
Polyline as represented as a vector of two-dimensional points.
The base geometry on which the operation is done is invalid or empty.
The input geometry (ring, part, split line, etc.) has not the correct geometry type.
Line string geometry type, with support for z-dimension and m-values.
ValidationMethod
Available methods for validating geometries.
bool operator==(const QgsGeometry::Error &other) const
ValidityFlag
Validity check flags.
static QString displayString(Type type)
Returns a display string type for a WKB type, e.g., the geometry name used in WKT geometry representa...
The input ring is not valid.
Contains geometry relation and modification algorithms.
Custom exception class for Coordinate Reference System related exceptions.
JoinStyle
Join styles for buffers.
Flat cap (in line with start/end of line)
Represents a vector layer which manages a vector based data sets.
static Type flatType(Type type)
Returns the flat type for a WKB type.
double ANALYSIS_EXPORT leftOf(const QgsPoint &thepoint, const QgsPoint *p1, const QgsPoint *p2)
Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'. Negativ values mean left a...
static bool compare(const QgsPolylineXY &p1, const QgsPolylineXY &p2, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compares two polylines for equality within a specified tolerance.