16 #ifndef QGSABSTRACTGEOMETRYV2 17 #define QGSABSTRACTGEOMETRYV2 21 #include <type_traits> 24 #include "qgis_core.h" 30 #include "json_fwd.hpp" 79 if ( qgsgeometry_cast<QgsPoint *>( sipCpp ) !=
nullptr )
80 sipType = sipType_QgsPoint;
81 else if ( qgsgeometry_cast<QgsLineString *>( sipCpp ) !=
nullptr )
82 sipType = sipType_QgsLineString;
83 else if ( qgsgeometry_cast<QgsCircularString *>( sipCpp ) !=
nullptr )
84 sipType = sipType_QgsCircularString;
85 else if ( qgsgeometry_cast<QgsCompoundCurve *>( sipCpp ) !=
nullptr )
86 sipType = sipType_QgsCompoundCurve;
87 else if ( qgsgeometry_cast<QgsTriangle *>( sipCpp ) !=
nullptr )
88 sipType = sipType_QgsTriangle;
89 else if ( qgsgeometry_cast<QgsPolygon *>( sipCpp ) !=
nullptr )
90 sipType = sipType_QgsPolygon;
91 else if ( qgsgeometry_cast<QgsCurvePolygon *>( sipCpp ) !=
nullptr )
92 sipType = sipType_QgsCurvePolygon;
93 else if ( qgsgeometry_cast<QgsMultiPoint *>( sipCpp ) !=
nullptr )
94 sipType = sipType_QgsMultiPoint;
95 else if ( qgsgeometry_cast<QgsMultiLineString *>( sipCpp ) !=
nullptr )
96 sipType = sipType_QgsMultiLineString;
97 else if ( qgsgeometry_cast<QgsMultiPolygon *>( sipCpp ) !=
nullptr )
98 sipType = sipType_QgsMultiPolygon;
99 else if ( qgsgeometry_cast<QgsMultiSurface *>( sipCpp ) !=
nullptr )
100 sipType = sipType_QgsMultiSurface;
101 else if ( qgsgeometry_cast<QgsMultiCurve *>( sipCpp ) !=
nullptr )
102 sipType = sipType_QgsMultiCurve;
103 else if ( qgsgeometry_cast<QgsGeometryCollection *>( sipCpp ) !=
nullptr )
104 sipType = sipType_QgsGeometryCollection;
167 virtual void clear() = 0;
180 virtual int dimension()
const = 0;
187 virtual QString geometryType()
const = 0;
201 QString wktTypeStr()
const;
242 virtual bool fromWkt(
const QString &wkt ) = 0;
252 FlagExportTrianglesAsPolygons = 1 << 0,
254 Q_DECLARE_FLAGS( WkbFlags,
WkbFlag )
263 virtual int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() )
const = 0;
276 virtual QByteArray asWkb( WkbFlags flags = QgsAbstractGeometry::WkbFlags() )
const = 0;
286 virtual QString asWkt(
int precision = 17 )
const = 0;
299 virtual QDomElement asGml2( QDomDocument &doc,
int precision = 17,
const QString &ns =
"gml",
AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY )
const = 0;
312 virtual QDomElement asGml3( QDomDocument &doc,
int precision = 17,
const QString &ns =
"gml",
AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY )
const = 0;
341 virtual QString asKml(
int precision = 17 ) const = 0;
364 virtual
void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
365 double mTranslate = 0.0,
double mScale = 1.0 ) = 0;
371 virtual
void draw( QPainter &p ) const = 0;
381 virtual QPainterPath asQPainterPath() const = 0;
393 virtual
int vertexNumberFromVertexId(
QgsVertexId id ) const = 0;
419 virtual
int nCoordinates() const;
440 int *
leftOf SIP_OUT =
nullptr,
double epsilon = 4 * std::numeric_limits<
double>::epsilon() ) const = 0;
471 virtual
bool deleteVertex(
QgsVertexId position ) = 0;
485 virtual
double length() const;
499 virtual
double perimeter() const;
513 virtual
double area() const;
523 virtual
double segmentLength(
QgsVertexId startVertex ) const = 0;
531 virtual
bool isEmpty() const;
536 virtual
bool hasCurvedSegments() const;
576 virtual
QgsAbstractGeometry *snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const = 0 SIP_FACTORY;
598 virtual
bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) = 0;
607 virtual
double vertexAngle(
QgsVertexId vertex ) const = 0;
612 virtual
int vertexCount(
int part = 0,
int ring = 0 ) const = 0;
617 virtual
int ringCount(
int part = 0 ) const = 0;
624 virtual
int partCount() const = 0;
634 virtual
bool addZValue(
double zValue = 0 ) = 0;
644 virtual
bool addMValue(
double mValue = 0 ) = 0;
653 virtual
bool dropZValue() = 0;
662 virtual
bool dropMValue() = 0;
670 virtual
void swapXy() = 0;
690 virtual
bool isValid( QString &error SIP_OUT,
int flags = 0 ) const = 0;
703 virtual void filterVertices(
const std::function<
bool(
const QgsPoint & ) > &filter );
719 virtual void transformVertices(
const std::function<
QgsPoint(
const QgsPoint & ) > &transform );
753 int partNumber()
const;
823 int partNumber()
const;
873 std::array<Level, 3> levels;
1007 virtual bool hasChildGeometries()
const;
1028 virtual QgsPoint childPoint(
int index )
const;
1047 virtual void clearCache()
const;
1049 friend class TestQgsGeometry;
1088 return part == other.part && ring == other.ring && vertex == other.vertex;
1092 return part != other.part || ring != other.ring || vertex != other.vertex;
1100 return part >= 0 && o.part == part;
1109 return partEqual( o ) && ( ring >= 0 && o.ring == ring );
1118 return ringEqual( o ) && ( vertex >= 0 && o.ring == ring );
1126 return ( part >= 0 && part < geom->partCount() ) &&
1127 ( ring < geom->ringCount( part ) ) &&
1128 ( vertex < 0 || vertex < geom->vertexCount( part, ring ) );
1144 SIP_PYOBJECT __repr__();
1146 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() );
1147 sipRes = PyUnicode_FromString( str.toUtf8().data() );
1158 return const_cast<T
>( std::remove_pointer<T>::type::cast( geom ) );
1179 , i( g->vertices_begin() )
1180 , n( g->vertices_end() )
1187 return g && g->vertices_end() != i;
1201 if ( sipCpp->hasNext() )
1202 sipRes = sipConvertFromType(
new QgsPoint( sipCpp->next() ), sipType_QgsPoint, Py_None );
1204 PyErr_SetString( PyExc_StopIteration,
"" );
1228 , i( g->parts_begin() )
1229 , n( g->parts_end() )
1236 return g && g->parts_end() != i;
1250 if ( sipCpp->hasNext() )
1251 sipRes = sipConvertFromType( sipCpp->next(), sipType_QgsAbstractGeometry, NULL );
1253 PyErr_SetString( PyExc_StopIteration,
"" );
1278 , i( g->const_parts_begin() )
1279 , n( g->const_parts_end() )
1286 return g && g->const_parts_end() != i;
1300 if ( sipCpp->hasNext() )
1301 sipRes = sipConvertFromType( const_cast< QgsAbstractGeometry * >( sipCpp->next() ), sipType_QgsAbstractGeometry, NULL );
1303 PyErr_SetString( PyExc_StopIteration,
"" );
1315 #endif //QGSABSTRACTGEOMETRYV2
A rectangle specified with double values.
Java-style iterator for traversal of parts of a geometry.
virtual int childCount() const
Returns number of child geometries (for geometries with child geometries) or child points (for geomet...
bool operator!=(const_part_iterator other) const
Java-style iterator for traversal of vertices of a geometry.
Multi point geometry collection.
bool operator==(QgsVertexId other) const SIP_HOLDGIL
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QVector< QgsRingSequence > QgsCoordinateSequence
Java-style iterator for const traversal of parts of a geometry.
bool hasNext() const SIP_HOLDGIL
Find out whether there are more parts.
Handles storage of information regarding WKB types and their properties.
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
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.
virtual QgsAbstractGeometry * childGeometry(int index) const
Returns pointer to child geometry (for geometries with child geometries - i.e.
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...
bool operator!=(const vertex_iterator &other) const
#define SIP_TYPEHINT(type)
QgsVertexIterator(const QgsAbstractGeometry *geometry)
Constructs iterator for the given geometry.
Perform transforms between map coordinates and device coordinates.
bool ringEqual(QgsVertexId o) const SIP_HOLDGIL
Returns true if this vertex ID belongs to the same ring as another vertex ID (i.e.
static bool hasM(Type type) SIP_HOLDGIL
Tests whether a WKB type contains m values.
Type
The WKB type describes the number of dimensions a geometry has.
QgsGeometryPartIterator(QgsAbstractGeometry *geometry)
Constructs iterator for the given geometry.
Utility class for identifying a unique vertex within a geometry.
VertexType
Type of vertex.
The part_iterator class provides STL-style iterator for geometry parts.
bool vertexEqual(QgsVertexId o) const SIP_HOLDGIL
Returns true if this vertex ID corresponds to the same vertex as another vertex ID (i...
vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry...
T qgsgeometry_cast(const QgsAbstractGeometry *geom)
Multi curve geometry collection.
An intermediate point on a segment defining the curvature of the segment.
Abstract base class for curved geometry type.
Abstract base class for all geometries.
The vertex_iterator class provides STL-style iterator for vertices.
bool partEqual(QgsVertexId o) const SIP_HOLDGIL
Returns true if this vertex ID belongs to the same part as another vertex ID.
Point geometry type, with support for z-dimension and m-values.
AxisOrder
Axis order for GML generation.
QgsGeometryConstPartIterator(const QgsAbstractGeometry *geometry)
Constructs iterator for the given geometry.
bool operator!=(QgsVertexId other) const SIP_HOLDGIL
double closestSegment(const QgsPolylineXY &pl, const QgsPointXY &pt, int &vertexAfter, double epsilon)
QVector< QgsPoint > QgsPointSequence
static bool hasZ(Type type) SIP_HOLDGIL
Tests whether a WKB type contains the z-dimension.
QVector< QgsPointSequence > QgsRingSequence
const_part_iterator const_parts_begin() const
Returns STL-style iterator pointing to the const first part of the geometry.
bool isMeasure() const SIP_HOLDGIL
Returns true if the geometry contains m values.
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
QgsVertexId(int _part=-1, int _ring=-1, int _vertex=-1, VertexType _type=SegmentVertex) SIP_HOLDGIL
Constructor for QgsVertexId.
QgsMargins operator*(const QgsMargins &margins, double factor)
Returns a QgsMargins object that is formed by multiplying each component of the given margins by fact...
Custom exception class for Coordinate Reference System related exceptions.
vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
bool hasNext() const
Find out whether there are more vertices.
bool hasNext() const SIP_HOLDGIL
Find out whether there are more parts.
bool operator!=(part_iterator other) const
part_iterator parts_begin()
Returns STL-style iterator pointing to the first part of the geometry.
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 ...
bool isValid(const QgsAbstractGeometry *geom) const SIP_HOLDGIL
Returns true if this vertex ID is valid for the specified geom.
bool isValid() const SIP_HOLDGIL
Returns true if the vertex id is valid.