QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
16 #ifndef QGSABSTRACTGEOMETRYV2
17 #define QGSABSTRACTGEOMETRYV2
23 #include "qgis_core.h"
29 #include "json_fwd.hpp"
30 using namespace nlohmann;
78 if ( qgsgeometry_cast<QgsPoint *>( sipCpp ) !=
nullptr )
79 sipType = sipType_QgsPoint;
80 else if ( qgsgeometry_cast<QgsLineString *>( sipCpp ) !=
nullptr )
81 sipType = sipType_QgsLineString;
82 else if ( qgsgeometry_cast<QgsCircularString *>( sipCpp ) !=
nullptr )
83 sipType = sipType_QgsCircularString;
84 else if ( qgsgeometry_cast<QgsCompoundCurve *>( sipCpp ) !=
nullptr )
85 sipType = sipType_QgsCompoundCurve;
86 else if ( qgsgeometry_cast<QgsTriangle *>( sipCpp ) !=
nullptr )
87 sipType = sipType_QgsTriangle;
88 else if ( qgsgeometry_cast<QgsPolygon *>( sipCpp ) !=
nullptr )
89 sipType = sipType_QgsPolygon;
90 else if ( qgsgeometry_cast<QgsCurvePolygon *>( sipCpp ) !=
nullptr )
91 sipType = sipType_QgsCurvePolygon;
92 else if ( qgsgeometry_cast<QgsMultiPoint *>( sipCpp ) !=
nullptr )
93 sipType = sipType_QgsMultiPoint;
94 else if ( qgsgeometry_cast<QgsMultiLineString *>( sipCpp ) !=
nullptr )
95 sipType = sipType_QgsMultiLineString;
96 else if ( qgsgeometry_cast<QgsMultiPolygon *>( sipCpp ) !=
nullptr )
97 sipType = sipType_QgsMultiPolygon;
98 else if ( qgsgeometry_cast<QgsMultiSurface *>( sipCpp ) !=
nullptr )
99 sipType = sipType_QgsMultiSurface;
100 else if ( qgsgeometry_cast<QgsMultiCurve *>( sipCpp ) !=
nullptr )
101 sipType = sipType_QgsMultiCurve;
102 else if ( qgsgeometry_cast<QgsGeometryCollection *>( sipCpp ) !=
nullptr )
103 sipType = sipType_QgsGeometryCollection;
129 Q_ENUM( SegmentationToleranceType )
166 virtual
void clear() = 0;
179 virtual
int dimension() const = 0;
186 virtual QString geometryType() const = 0;
200 QString wktTypeStr()
const;
241 virtual bool fromWkt(
const QString &wkt ) = 0;
251 FlagExportTrianglesAsPolygons = 1 << 0,
253 Q_DECLARE_FLAGS( WkbFlags, WkbFlag )
363 virtual
void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
364 double mTranslate = 0.0,
double mScale = 1.0 ) = 0;
370 virtual
void draw( QPainter &p ) const = 0;
380 virtual QPainterPath asQPainterPath() const = 0;
418 virtual
int nCoordinates() const;
439 int *
leftOf SIP_OUT =
nullptr,
double epsilon = 4 * std::numeric_limits<
double>::epsilon() ) const = 0;
484 virtual
double length() const;
498 virtual
double perimeter() const;
512 virtual
double area() const;
522 virtual
double segmentLength(
QgsVertexId startVertex ) const = 0;
530 virtual
bool isEmpty() const;
535 virtual
bool hasCurvedSegments() const;
597 virtual
bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) = 0;
611 virtual
int vertexCount(
int part = 0,
int ring = 0 ) const = 0;
616 virtual
int ringCount(
int part = 0 ) const = 0;
623 virtual
int partCount() const = 0;
633 virtual
bool addZValue(
double zValue = 0 ) = 0;
643 virtual
bool addMValue(
double mValue = 0 ) = 0;
652 virtual
bool dropZValue() = 0;
661 virtual
bool dropMValue() = 0;
669 virtual
void swapXy() = 0;
689 virtual
bool isValid( QString &error
SIP_OUT,
int flags = 0 ) const = 0;
702 virtual void filterVertices(
const std::function<
bool(
const QgsPoint & ) > &filter );
718 virtual void transformVertices(
const std::function<
QgsPoint(
const QgsPoint & ) > &transform );
752 int partNumber()
const;
779 part_iterator parts_end();
822 int partNumber()
const;
847 const_part_iterator const_parts_end()
const;
872 std::array<Level, 3> levels;
1006 virtual bool hasChildGeometries()
const;
1027 virtual QgsPoint childPoint(
int index )
const;
1046 virtual void clearCache()
const;
1048 friend class TestQgsGeometry;
1087 return part == other.part && ring == other.ring && vertex == other.vertex;
1091 return part != other.part || ring != other.ring || vertex != other.vertex;
1099 return part >= 0 && o.part == part;
1108 return partEqual( o ) && ( ring >= 0 && o.ring == ring );
1117 return ringEqual( o ) && ( vertex >= 0 && o.ring == ring );
1125 return ( part >= 0 && part < geom->partCount() ) &&
1126 ( ring < geom->ringCount( part ) ) &&
1127 ( vertex < 0 || vertex < geom->vertexCount( part, ring ) );
1143 SIP_PYOBJECT __repr__();
1145 QString str = QStringLiteral(
"<QgsVertexId: %1,%2,%3%4>" ).arg( sipCpp->part ).arg( sipCpp->ring ).arg( sipCpp->vertex ).arg( sipCpp->type ==
QgsVertexId::CurveVertex ? QStringLiteral(
" CurveVertex" ) : QString() );
1146 sipRes = PyUnicode_FromString( str.toUtf8().data() );
1157 return const_cast<T
>(
reinterpret_cast<T
>( 0 )->cast( geom ) );
1178 , i( g->vertices_begin() )
1179 , n( g->vertices_end() )
1186 return g && g->vertices_end() != i;
1200 if ( sipCpp->hasNext() )
1201 sipRes = sipConvertFromType( new
QgsPoint( sipCpp->next() ), sipType_QgsPoint, Py_None );
1203 PyErr_SetString( PyExc_StopIteration, "" );
1227 , i( g->parts_begin() )
1228 , n( g->parts_end() )
1235 return g && g->parts_end() != i;
1249 if ( sipCpp->hasNext() )
1250 sipRes = sipConvertFromType( sipCpp->next(), sipType_QgsAbstractGeometry, NULL );
1252 PyErr_SetString( PyExc_StopIteration, "" );
1277 , i( g->const_parts_begin() )
1278 , n( g->const_parts_end() )
1285 return g && g->const_parts_end() != i;
1299 if ( sipCpp->hasNext() )
1300 sipRes = sipConvertFromType( const_cast<
QgsAbstractGeometry * >( sipCpp->next() ), sipType_QgsAbstractGeometry, NULL );
1302 PyErr_SetString( PyExc_StopIteration, "" );
1314 #endif //QGSABSTRACTGEOMETRYV2
Abstract base class for curved geometry type.
vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
QVector< QgsRingSequence > QgsCoordinateSequence
virtual bool fromWkt(const QString &wkt)=0
Sets the geometry from a WKT string.
bool operator!=(part_iterator other) const
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Point geometry type, with support for z-dimension and m-values.
Java-style iterator for const traversal of parts of a geometry.
bool hasNext() const SIP_HOLDGIL
Find out whether there are more parts.
Type
The WKB type describes the number of dimensions a geometry has.
bool operator!=(const vertex_iterator &other) const
QgsVertexIterator()=default
Constructor for QgsVertexIterator.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
virtual QgsAbstractGeometry * childGeometry(int index) const
Returns pointer to child geometry (for geometries with child geometries - i.e.
bool operator!=(const_part_iterator other) const
double closestSegment(const QgsPolylineXY &pl, const QgsPointXY &pt, int &vertexAfter, double epsilon)
bool partEqual(QgsVertexId o) const SIP_HOLDGIL
Returns true if this vertex ID belongs to the same part as another vertex ID.
A rectangle specified with double values.
#define SIP_TYPEHINT(type)
QgsVertexIterator(const QgsAbstractGeometry *geometry)
Constructs iterator for the given geometry.
QgsGeometryPartIterator()=default
Constructor for QgsGeometryPartIterator.
bool isMeasure() const SIP_HOLDGIL
Returns true if the geometry contains m values.
The part_iterator class provides STL-style iterator for geometry parts.
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'. Negative values mean left ...
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
QgsGeometryPartIterator(QgsAbstractGeometry *geometry)
Constructs iterator for the given geometry.
QgsVertexId(int _part=-1, int _ring=-1, int _vertex=-1, VertexType _type=SegmentVertex) SIP_HOLDGIL
Constructor for QgsVertexId.
Custom exception class for Coordinate Reference System related exceptions.
QgsGeometryConstPartIterator()=default
Constructor for QgsGeometryConstPartIterator.
AxisOrder
Axis order for GML generation.
Multi curve geometry collection.
The part_iterator class provides STL-style iterator for const references to geometry parts.
vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
const_part_iterator()=default
Create invalid iterator.
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
static bool hasM(Type type) SIP_HOLDGIL
Tests whether a WKB type contains m values.
QgsMargins operator*(const QgsMargins &margins, double factor)
Returns a QgsMargins object that is formed by multiplying each component of the given margins by fact...
T qgsgeometry_cast(const QgsAbstractGeometry *geom)
part_iterator()=default
Create invalid iterator.
QVector< QgsPointSequence > QgsRingSequence
virtual bool fromWkb(QgsConstWkbPtr &wkb)=0
Sets the geometry from a WKB string.
Multi point geometry collection.
Abstract base class for all geometries.
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
bool vertexEqual(QgsVertexId o) const SIP_HOLDGIL
Returns true if this vertex ID corresponds to the same vertex as another vertex ID (i....
bool isValid() const SIP_HOLDGIL
Returns true if the vertex id is valid.
virtual QgsAbstractGeometry * createEmptyWithSameType() const =0
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
The vertex_iterator class provides STL-style iterator for vertices.
QVector< QgsPoint > QgsPointSequence
Perform transforms between map coordinates and device coordinates.
Java-style iterator for traversal of parts of a geometry.
bool hasNext() const SIP_HOLDGIL
Find out whether there are more parts.
virtual int childCount() const
Returns number of child geometries (for geometries with child geometries) or child points (for geomet...
Utility class for identifying a unique vertex within a geometry.
QgsGeometryConstPartIterator(const QgsAbstractGeometry *geometry)
Constructs iterator for the given geometry.
bool ringEqual(QgsVertexId o) const SIP_HOLDGIL
Returns true if this vertex ID belongs to the same ring as another vertex ID (i.e.
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
VertexType
Type of vertex.
Java-style iterator for traversal of vertices of a geometry.
static bool hasZ(Type type) SIP_HOLDGIL
Tests whether a WKB type contains the z-dimension.
bool hasNext() const
Find out whether there are more vertices.
Handles storage of information regarding WKB types and their properties.
bool operator!=(QgsVertexId other) const SIP_HOLDGIL
part_iterator parts_begin()
Returns STL-style iterator pointing to the first part of the geometry.
const_part_iterator const_parts_begin() const
Returns STL-style iterator pointing to the const first part of the geometry.
vertex_iterator()=default
Create invalid iterator.
@ CurveVertex
An intermediate point on a segment defining the curvature of the segment.
bool isValid(const QgsAbstractGeometry *geom) const SIP_HOLDGIL
Returns true if this vertex ID is valid for the specified geom.
bool operator==(QgsVertexId other) const SIP_HOLDGIL