19 #include <QDomDocument> 28 #include "qgis_core.h" 116 NothingHappened = 1000,
250 static QgsGeometry collectGeometry(
const QVector<QgsGeometry> &geometries );
267 static QgsGeometry createWedgeBuffer(
const QgsPoint ¢er,
double azimuth,
double angularWidth,
268 double outerRadius,
double innerRadius = 0 );
275 void fromWkb(
unsigned char *wkb,
int length )
SIP_SKIP;
281 void fromWkb(
const QByteArray &wkb );
301 bool isEmpty()
const;
304 bool isMultipart()
const;
344 bool isGeosValid()
const;
354 bool isSimple()
const;
366 double length()
const;
414 double hausdorffDistance(
const QgsGeometry &geom )
const;
434 double hausdorffDistanceDensify(
const QgsGeometry &geom,
double densifyFraction )
const;
449 QgsPointXY closestVertex(
const QgsPointXY &point,
int &atVertex
SIP_OUT,
int &beforeVertex SIP_OUT,
int &afterVertex SIP_OUT,
double &sqrDist SIP_OUT )
const;
457 double distanceToVertex(
int vertex )
const;
466 double angleAtVertex(
int vertex )
const;
480 void adjacentVertices(
int atVertex,
int &beforeVertex
SIP_OUT,
int &afterVertex SIP_OUT )
const;
494 bool insertVertex(
double x,
double y,
int beforeVertex );
508 bool insertVertex(
const QgsPoint &point,
int beforeVertex );
517 bool moveVertex(
double x,
double y,
int atVertex );
526 bool moveVertex(
const QgsPoint &p,
int atVertex );
539 bool deleteVertex(
int atVertex );
546 QgsPoint vertexAt(
int atVertex )
const;
575 double closestVertexWithContext(
const QgsPointXY &point,
int &atVertex
SIP_OUT )
const;
641 QgsGeometry removeInteriorRings(
double minimumAllowedArea = -1 )
const;
647 OperationResult translate(
double dx,
double dy,
double dz = 0.0,
double dm = 0.0 );
673 OperationResult transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 );
704 int makeDifferenceInPlace( const
QgsGeometry &other ) SIP_SKIP;
728 QgsGeometry orientedMinimumBoundingBox(
double &area SIP_OUT,
double &
angle SIP_OUT,
double &width SIP_OUT,
double &height SIP_OUT ) const;
735 QgsGeometry orientedMinimumBoundingBox() const SIP_SKIP;
744 QgsGeometry minimalEnclosingCircle(
QgsPointXY ¢er SIP_OUT,
double &radius SIP_OUT,
unsigned int segments = 36 ) const;
751 QgsGeometry minimalEnclosingCircle(
unsigned int segments = 36 ) const SIP_SKIP;
761 QgsGeometry orthogonalize(
double tolerance = 1.0E-8,
int maxIterations = 1000,
double angleThreshold = 15.0 ) const;
775 QgsGeometry snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const;
797 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false );
819 bool intersects( const
QgsGeometry &geometry ) const;
830 bool boundingBoxIntersects( const
QgsRectangle &rectangle ) const;
841 bool boundingBoxIntersects( const
QgsGeometry &geometry ) const;
850 bool contains( const
QgsGeometry &geometry ) const;
856 bool disjoint( const
QgsGeometry &geometry ) const;
868 bool overlaps( const
QgsGeometry &geometry ) const;
915 QgsGeometry buffer(
double distance,
int segments )
const;
939 QgsGeometry offsetCurve(
double distance,
int segments,
JoinStyle joinStyle,
double miterLimit )
const;
958 double miterLimit = 2.0 )
const;
977 QgsGeometry taperedBuffer(
double startWidth,
double endWidth,
int segments )
const;
993 QgsGeometry variableWidthBufferByM(
int segments )
const;
1001 QgsGeometry extendLine(
double startDistance,
double endDistance )
const;
1015 QgsGeometry densifyByCount(
int extraNodesPerSegment )
const;
1031 QgsGeometry densifyByDistance(
double distance )
const;
1075 QgsGeometry poleOfInaccessibility(
double precision,
double *distanceToBoundary
SIP_OUT =
nullptr )
const;
1113 QgsGeometry delaunayTriangulation(
double tolerance = 0.0,
bool edgesOnly =
false )
const;
1134 QgsGeometry subdivide(
int maxNodes = 256 )
const;
1160 double lineLocatePoint(
const QgsGeometry &point )
const;
1171 double interpolateAngle(
double distance )
const;
1242 QByteArray asWkb()
const;
1249 QString asWkt(
int precision = 17 )
const;
1252 SIP_PYOBJECT __repr__();
1254 QString str = QStringLiteral(
"<QgsGeometry: %1>" ).arg( sipCpp->asWkt() );
1255 sipRes = PyUnicode_FromString( str.toUtf8().data() );
1262 QString asJson(
int precision = 17 )
const;
1315 QVector<
QgsGeometry> asGeometryCollection() const;
1322 QPointF asQPointF() const;
1330 QPolygonF asQPolygonF() const;
1338 bool deleteRing(
int ringNum,
int partNum = 0 );
1345 bool deletePart(
int partNum );
1355 bool convertToMultiType();
1366 bool convertToSingleType();
1377 bool convertGeometryCollectionToSubclass(
QgsWkbTypes::GeometryType geomType );
1389 int avoidIntersections( const QList<
QgsVectorLayer *> &avoidIntersectionsLayers,
1419 bool hasLocation =
false;
1423 : message( QStringLiteral(
"none" ) )
1433 , hasLocation( true ) {}
1456 void validateGeometry( QVector<QgsGeometry::Error> &errors
SIP_OUT,
ValidationMethod method = ValidatorQgisInternal )
const;
1463 static QgsGeometry unaryUnion(
const QVector<QgsGeometry> &geometries );
1473 static QgsGeometry polygonize(
const QVector<QgsGeometry> &geometries );
1490 bool requiresConversionToStraightSegments()
const;
1504 void draw( QPainter &p )
const;
1538 QString lastError()
const;
1549 void filterVertices(
const std::function<
bool(
const QgsPoint & ) > &filter )
SIP_SKIP;
1565 static QgsGeometry fromQPolygonF(
const QPolygonF &polygon );
1595 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1607 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1620 double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1641 static bool compare( PyObject *obj1, PyObject *obj2,
double epsilon = 4 * std::numeric_limits<double>::epsilon() );
1649 if ( PyList_Check( a0 ) && PyList_Check( a1 ) &&
1650 PyList_GET_SIZE( a0 ) && PyList_GET_SIZE( a1 ) )
1652 PyObject *o0 = PyList_GetItem( a0, 0 );
1653 PyObject *o1 = PyList_GetItem( a1, 0 );
1657 if ( sipCanConvertToType( o0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1658 sipCanConvertToType( o1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1659 sipCanConvertToType( a0, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
1660 sipCanConvertToType( a1, sipType_QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1664 p0 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a0, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1665 p1 =
reinterpret_cast<QgsPolylineXY *
>( sipConvertToType( a1, sipType_QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1668 sipReleaseType( p0, sipType_QVector_0100QgsPointXY, state0 );
1669 sipReleaseType( p1, sipType_QVector_0100QgsPointXY, state1 );
1676 else if ( PyList_Check( o0 ) && PyList_Check( o1 ) &&
1677 PyList_GET_SIZE( o0 ) && PyList_GET_SIZE( o1 ) )
1679 PyObject *oo0 = PyList_GetItem( o0, 0 );
1680 PyObject *oo1 = PyList_GetItem( o1, 0 );
1684 if ( sipCanConvertToType( oo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1685 sipCanConvertToType( oo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1686 sipCanConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
1687 sipCanConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1691 p0 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1692 p1 =
reinterpret_cast<QgsPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1695 sipReleaseType( p0, sipType_QVector_0600QVector_0100QgsPointXY, state0 );
1696 sipReleaseType( p1, sipType_QVector_0600QVector_0100QgsPointXY, state1 );
1703 else if ( PyList_Check( oo0 ) && PyList_Check( oo1 ) &&
1704 PyList_GET_SIZE( oo0 ) && PyList_GET_SIZE( oo1 ) )
1706 PyObject *ooo0 = PyList_GetItem( oo0, 0 );
1707 PyObject *ooo1 = PyList_GetItem( oo1, 0 );
1711 if ( sipCanConvertToType( ooo0, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1712 sipCanConvertToType( ooo1, sipType_QgsPointXY, SIP_NOT_NONE ) &&
1713 sipCanConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) &&
1714 sipCanConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, SIP_NOT_NONE ) )
1718 p0 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state0, &sipIsErr ) );
1719 p1 =
reinterpret_cast<QgsMultiPolygonXY *
>( sipConvertToType( a1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, 0, SIP_NOT_NONE, &state1, &sipIsErr ) );
1722 sipReleaseType( p0, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state0 );
1723 sipReleaseType( p1, sipType_QVector_0600QVector_0600QVector_0100QgsPointXY, state1 );
1756 QgsGeometry smooth(
unsigned int iterations = 1,
double offset = 0.25,
1757 double minimumDistance = -1.0,
double maxAngle = 180.0 )
const;
1769 static void convertPointList(
const QVector<QgsPointXY> &input,
QgsPointSequence &output );
1776 static void convertPointList(
const QgsPointSequence &input, QVector<QgsPointXY> &output );
1779 operator QVariant()
const 1781 return QVariant::fromValue( *
this );
1789 operator bool()
const;
1796 mutable QString mLastError;
1808 void reset( std::unique_ptr< QgsAbstractGeometry > newGeometry );
1814 QgsGeometry convertToPoint(
bool destMultipart )
const;
1816 QgsGeometry convertToLine(
bool destMultipart )
const;
1818 QgsGeometry convertToPolygon(
bool destMultipart )
const;
1831 std::unique_ptr< QgsLineString > smoothLine(
const QgsLineString &line,
unsigned int iterations = 1,
double offset = 0.25,
1832 double minimumDistance = -1,
double maxAngle = 180.0 )
const;
1845 std::unique_ptr< QgsPolygon > smoothPolygon(
const QgsPolygon &polygon,
unsigned int iterations = 1,
double offset = 0.25,
1846 double minimumDistance = -1,
double maxAngle = 180.0 )
const;
Geometry engine misses a method implemented or an error occurred in the geometry engine.
A rectangle specified with double values.
The input ring doesn't have any existing ring to fit into.
Java-style iterator for traversal of vertices of a geometry.
The source geometry is not multi.
Maximum angle between generating radii (lines from arc center to output vertices) ...
Use GEOS validation methods.
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.
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.
CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QgsGeometry &geometry)
Writes the geometry to stream out. QGIS version compatibility is not guaranteed.
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)
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.
CORE_EXPORT QDataStream & operator>>(QDataStream &in, QgsGeometry &geometry)
Reads a geometry from stream in into geometry. QGIS version compatibility is not guaranteed.
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.
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.
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.