16#ifndef QGSABSTRACTGEOMETRYV2
17#define QGSABSTRACTGEOMETRYV2
30#include <nlohmann/json_fwd.hpp>
31using namespace nlohmann;
84 if ( qgsgeometry_cast<QgsPoint *>( sipCpp ) !=
nullptr )
85 sipType = sipType_QgsPoint;
86 else if ( qgsgeometry_cast<QgsLineString *>( sipCpp ) !=
nullptr )
87 sipType = sipType_QgsLineString;
88 else if ( qgsgeometry_cast<QgsCircularString *>( sipCpp ) !=
nullptr )
89 sipType = sipType_QgsCircularString;
90 else if ( qgsgeometry_cast<QgsCompoundCurve *>( sipCpp ) !=
nullptr )
91 sipType = sipType_QgsCompoundCurve;
92 else if ( qgsgeometry_cast<QgsTriangle *>( sipCpp ) !=
nullptr )
93 sipType = sipType_QgsTriangle;
94 else if ( qgsgeometry_cast<QgsPolygon *>( sipCpp ) !=
nullptr )
95 sipType = sipType_QgsPolygon;
96 else if ( qgsgeometry_cast<QgsCurvePolygon *>( sipCpp ) !=
nullptr )
97 sipType = sipType_QgsCurvePolygon;
98 else if ( qgsgeometry_cast<QgsTriangulatedSurface *>( sipCpp ) !=
nullptr )
99 sipType = sipType_QgsTriangulatedSurface;
100 else if ( qgsgeometry_cast<QgsPolyhedralSurface *>( sipCpp ) !=
nullptr )
101 sipType = sipType_QgsPolyhedralSurface;
102 else if ( qgsgeometry_cast<QgsSurface *>( sipCpp ) !=
nullptr )
103 sipType = sipType_QgsSurface;
104 else if ( qgsgeometry_cast<QgsMultiPoint *>( sipCpp ) !=
nullptr )
105 sipType = sipType_QgsMultiPoint;
106 else if ( qgsgeometry_cast<QgsMultiLineString *>( sipCpp ) !=
nullptr )
107 sipType = sipType_QgsMultiLineString;
108 else if ( qgsgeometry_cast<QgsMultiPolygon *>( sipCpp ) !=
nullptr )
109 sipType = sipType_QgsMultiPolygon;
110 else if ( qgsgeometry_cast<QgsMultiSurface *>( sipCpp ) !=
nullptr )
111 sipType = sipType_QgsMultiSurface;
112 else if ( qgsgeometry_cast<QgsMultiCurve *>( sipCpp ) !=
nullptr )
113 sipType = sipType_QgsMultiCurve;
114 else if ( qgsgeometry_cast<QgsGeometryCollection *>( sipCpp ) !=
nullptr )
115 sipType = sipType_QgsGeometryCollection;
141 Q_ENUM( SegmentationToleranceType )
209 virtual
void clear() = 0;
229 virtual
int dimension() const = 0;
236 virtual QString geometryType() const = 0;
250 QString wktTypeStr()
const;
301 virtual bool fromWkt(
const QString &wkt ) = 0;
311 FlagExportTrianglesAsPolygons = 1 << 0,
312 FlagExportNanAsDoubleMin = 1 << 1,
423 virtual
void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
424 double mTranslate = 0.0,
double mScale = 1.0 ) = 0;
430 virtual
void draw( QPainter &p ) const = 0;
440 virtual QPainterPath asQPainterPath() const = 0;
476 virtual
int nCoordinates() const;
497 int *leftOf
SIP_OUT =
nullptr,
double epsilon = 4 * std::numeric_limits<
double>::epsilon() ) const = 0;
542 virtual
double length() const;
556 virtual
double perimeter() const;
570 virtual
double area() const;
579 virtual
double segmentLength(
QgsVertexId startVertex ) const = 0;
587 virtual
bool isEmpty() const;
592 virtual
bool hasCurvedSegments() const;
652 virtual
QgsAbstractGeometry *snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0,
bool removeRedundantPoints = false ) const = 0
SIP_FACTORY;
687 virtual
bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) = 0;
701 virtual
int vertexCount(
int part = 0,
int ring = 0 ) const = 0;
706 virtual
int ringCount(
int part = 0 ) const = 0;
713 virtual
int partCount() const = 0;
722 virtual
bool addZValue(
double zValue = 0 ) = 0;
731 virtual
bool addMValue(
double mValue = 0 ) = 0;
739 virtual
bool dropZValue() = 0;
747 virtual
bool dropMValue() = 0;
755 virtual
void swapXy() = 0;
761 virtual
bool convertTo(
Qgis::WkbType type );
794 virtual
bool isValid( QString &error
SIP_OUT,
Qgis::GeometryValidityFlags flags =
Qgis::GeometryValidityFlags() ) const = 0;
822 virtual void filterVertices(
const std::function<
bool(
const QgsPoint & ) > &filter );
838 virtual void transformVertices(
const std::function<
QgsPoint(
const QgsPoint & ) > &transform );
872 int partNumber()
const;
899 part_iterator parts_end();
942 int partNumber()
const;
967 const_part_iterator const_parts_end()
const;
991 std::array<Level, 3> levels;
1122 int sortIndex()
const;
1140 virtual bool hasChildGeometries()
const;
1158 virtual QgsPoint childPoint(
int index )
const;
1180 virtual QgsBox3D calculateBoundingBox3D()
const;
1185 virtual void clearCache()
const;
1187 friend class TestQgsGeometry;
1196 return std::remove_pointer<T>::type::cast( geom );
1202 return std::remove_pointer<T>::type::cast( geom );
1222 , i( g->vertices_begin() )
1223 , n( g->vertices_end() )
1230 return g && g->vertices_end() != i;
1244 if ( sipCpp->hasNext() )
1245 sipRes = sipConvertFromType( new
QgsPoint( sipCpp->next() ), sipType_QgsPoint, Py_None );
1247 PyErr_SetString( PyExc_StopIteration, "" );
1271 , i( g->parts_begin() )
1272 , n( g->parts_end() )
1279 return g && g->parts_end() != i;
1293 if ( sipCpp->hasNext() )
1294 sipRes = sipConvertFromType( sipCpp->next(), sipType_QgsAbstractGeometry, NULL );
1296 PyErr_SetString( PyExc_StopIteration, "" );
1321 , i( g->const_parts_begin() )
1322 , n( g->const_parts_end() )
1329 return g && g->const_parts_end() != i;
1343 if ( sipCpp->hasNext() )
1344 sipRes = sipConvertFromType( const_cast<
QgsAbstractGeometry * >( sipCpp->next() ), sipType_QgsAbstractGeometry, NULL );
1346 PyErr_SetString( PyExc_StopIteration, "" );
The Qgis class provides global constants for use throughout the application.
WkbType
The WKB type describes the number of dimensions a geometry has.
The part_iterator class provides STL-style iterator for const references to geometry parts.
bool operator!=(const_part_iterator other) const
const_part_iterator()=default
Create invalid iterator.
The part_iterator class provides STL-style iterator for geometry parts.
part_iterator()=default
Create invalid iterator.
bool operator!=(part_iterator other) const
The vertex_iterator class provides STL-style iterator for vertices.
vertex_iterator()=default
Create invalid iterator.
bool operator!=(const vertex_iterator &other) const
Abstract base class for all geometries.
virtual bool fromWkb(QgsConstWkbPtr &wkb)=0
Sets the geometry from a WKB string.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
bool isMeasure() const
Returns true if the geometry contains m values.
QFlags< WkbFlag > WkbFlags
virtual int childCount() const
Returns number of child geometries (for geometries with child geometries) or child points (for geomet...
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
AxisOrder
Axis order for GML generation.
virtual QgsAbstractGeometry * createEmptyWithSameType() const =0
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
virtual bool fromWkt(const QString &wkt)=0
Sets the geometry from a WKT string.
virtual void normalize()=0
Reorganizes the geometry into a normalized form (or "canonical" form).
vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
virtual QgsAbstractGeometry * childGeometry(int index) const
Returns pointer to child geometry (for geometries with child geometries - i.e.
const_part_iterator const_parts_begin() const
Returns STL-style iterator pointing to the const first part of the geometry.
virtual int compareToSameClass(const QgsAbstractGeometry *other) const =0
Compares to an other geometry of the same class, and returns a integer for sorting of the two geometr...
part_iterator parts_begin()
Returns STL-style iterator pointing to the first part of the geometry.
A 3-dimensional box composed of x, y, z coordinates.
Custom exception class for Coordinate Reference System related exceptions.
Abstract base class for curved geometry type.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Java-style iterator for const traversal of parts of a geometry.
QgsGeometryConstPartIterator(const QgsAbstractGeometry *geometry)
Constructs iterator for the given geometry.
bool hasNext() const
Find out whether there are more parts.
QgsGeometryConstPartIterator()=default
Java-style iterator for traversal of parts of a geometry.
QgsGeometryPartIterator()=default
bool hasNext() const
Find out whether there are more parts.
QgsGeometryPartIterator(QgsAbstractGeometry *geometry)
Constructs iterator for the given geometry.
Perform transforms between map coordinates and device coordinates.
Multi curve geometry collection.
Multi point geometry collection.
Point geometry type, with support for z-dimension and m-values.
A rectangle specified with double values.
Java-style iterator for traversal of vertices of a geometry.
bool hasNext() const
Find out whether there are more vertices.
QgsVertexIterator()=default
QgsVertexIterator(const QgsAbstractGeometry *geometry)
Constructs iterator for the given geometry.
static bool hasZ(Qgis::WkbType type)
Tests whether a WKB type contains the z-dimension.
static bool hasM(Qgis::WkbType type)
Tests whether a WKB type contains m values.
#define SIP_TYPEHINT(type)
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
#define SIP_ENUM_BASETYPE(type)
#define SIP_THROW(name,...)
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QVector< QgsRingSequence > QgsCoordinateSequence
QVector< QgsPointSequence > QgsRingSequence
QVector< QgsPoint > QgsPointSequence
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QgsMargins operator*(const QgsMargins &margins, double factor)
Returns a QgsMargins object that is formed by multiplying each component of the given margins by fact...
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsTextRendererUtils::CurvedTextFlags)
double closestSegment(const QgsPolylineXY &pl, const QgsPointXY &pt, int &vertexAfter, double epsilon)
Utility class for identifying a unique vertex within a geometry.