16 #ifndef QGSABSTRACTGEOMETRYV2 17 #define QGSABSTRACTGEOMETRYV2 22 #include "qgis_core.h" 28 #include "json_fwd.hpp" 76 if ( qgsgeometry_cast<QgsPoint *>( sipCpp ) !=
nullptr )
77 sipType = sipType_QgsPoint;
78 else if ( qgsgeometry_cast<QgsLineString *>( sipCpp ) !=
nullptr )
79 sipType = sipType_QgsLineString;
80 else if ( qgsgeometry_cast<QgsCircularString *>( sipCpp ) !=
nullptr )
81 sipType = sipType_QgsCircularString;
82 else if ( qgsgeometry_cast<QgsCompoundCurve *>( sipCpp ) !=
nullptr )
83 sipType = sipType_QgsCompoundCurve;
84 else if ( qgsgeometry_cast<QgsTriangle *>( sipCpp ) !=
nullptr )
85 sipType = sipType_QgsTriangle;
86 else if ( qgsgeometry_cast<QgsPolygon *>( sipCpp ) !=
nullptr )
87 sipType = sipType_QgsPolygon;
88 else if ( qgsgeometry_cast<QgsCurvePolygon *>( sipCpp ) !=
nullptr )
89 sipType = sipType_QgsCurvePolygon;
90 else if ( qgsgeometry_cast<QgsMultiPoint *>( sipCpp ) !=
nullptr )
91 sipType = sipType_QgsMultiPoint;
92 else if ( qgsgeometry_cast<QgsMultiLineString *>( sipCpp ) !=
nullptr )
93 sipType = sipType_QgsMultiLineString;
94 else if ( qgsgeometry_cast<QgsMultiPolygon *>( sipCpp ) !=
nullptr )
95 sipType = sipType_QgsMultiPolygon;
96 else if ( qgsgeometry_cast<QgsMultiSurface *>( sipCpp ) !=
nullptr )
97 sipType = sipType_QgsMultiSurface;
98 else if ( qgsgeometry_cast<QgsMultiCurve *>( sipCpp ) !=
nullptr )
99 sipType = sipType_QgsMultiCurve;
100 else if ( qgsgeometry_cast<QgsGeometryCollection *>( sipCpp ) !=
nullptr )
101 sipType = sipType_QgsGeometryCollection;
162 virtual void clear() = 0;
175 virtual int dimension()
const = 0;
182 virtual QString geometryType()
const = 0;
196 QString wktTypeStr()
const;
237 virtual bool fromWkt(
const QString &wkt ) = 0;
249 virtual QByteArray asWkb()
const = 0;
259 virtual QString asWkt(
int precision = 17 )
const = 0;
272 virtual QDomElement asGml2( QDomDocument &doc,
int precision = 17,
const QString &ns =
"gml",
AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY )
const = 0;
285 virtual QDomElement asGml3( QDomDocument &doc,
int precision = 17,
const QString &ns =
"gml",
AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY )
const = 0;
314 virtual QString asKml(
int precision = 17 )
const = 0;
337 virtual void transform(
const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
338 double mTranslate = 0.0,
double mScale = 1.0 ) = 0;
344 virtual void draw( QPainter &p )
const = 0;
356 virtual int vertexNumberFromVertexId(
QgsVertexId id )
const = 0;
382 virtual int nCoordinates()
const;
403 int *
leftOf SIP_OUT =
nullptr,
double epsilon = 4 * std::numeric_limits<double>::epsilon() )
const = 0;
434 virtual bool deleteVertex(
QgsVertexId position ) = 0;
448 virtual double length()
const;
462 virtual double perimeter()
const;
476 virtual double area()
const;
486 virtual double segmentLength(
QgsVertexId startVertex )
const = 0;
494 virtual bool isEmpty()
const;
499 virtual bool hasCurvedSegments()
const;
558 virtual bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<double>::epsilon(),
bool useZValues =
false ) = 0;
567 virtual double vertexAngle(
QgsVertexId vertex )
const = 0;
572 virtual int vertexCount(
int part = 0,
int ring = 0 )
const = 0;
577 virtual int ringCount(
int part = 0 )
const = 0;
584 virtual int partCount()
const = 0;
594 virtual bool addZValue(
double zValue = 0 ) = 0;
604 virtual bool addMValue(
double mValue = 0 ) = 0;
613 virtual bool dropZValue() = 0;
622 virtual bool dropMValue() = 0;
630 virtual void swapXy() = 0;
650 virtual bool isValid( QString &error SIP_OUT,
int flags = 0 )
const = 0;
663 virtual void filterVertices(
const std::function<
bool(
const QgsPoint & ) > &filter );
679 virtual void transformVertices(
const std::function<
QgsPoint(
const QgsPoint & ) > &transform );
713 int partNumber()
const;
783 int partNumber()
const;
963 virtual bool hasChildGeometries()
const;
984 virtual QgsPoint childPoint(
int index )
const;
1003 virtual void clearCache()
const;
1005 friend class TestQgsGeometry;
1033 bool isValid()
const {
return part >= 0 && ring >= 0 && vertex >= 0; }
1037 return part == other.
part && ring == other.
ring && vertex == other.
vertex;
1041 return part != other.
part || ring != other.
ring || vertex != other.
vertex;
1045 return part >= 0 && o.
part == part;
1049 return partEqual( o ) && ( ring >= 0 && o.
ring == ring );
1053 return ringEqual( o ) && ( vertex >= 0 && o.
ring == ring );
1057 return ( part >= 0 && part < geom->partCount() ) &&
1059 ( vertex < 0 || vertex < geom->vertexCount( part, ring ) );
1073 return const_cast<T
>(
reinterpret_cast<T
>( 0 )->cast( geom ) );
1094 , i( g->vertices_begin() )
1095 , n( g->vertices_end() )
1102 return g && g->vertices_end() != i;
1116 if ( sipCpp->hasNext() )
1117 sipRes = sipConvertFromType(
new QgsPoint( sipCpp->next() ), sipType_QgsPoint, Py_None );
1119 PyErr_SetString( PyExc_StopIteration,
"" );
1143 , i( g->parts_begin() )
1144 , n( g->parts_end() )
1151 return g && g->parts_end() != i;
1165 if ( sipCpp->hasNext() )
1166 sipRes = sipConvertFromType( sipCpp->next(), sipType_QgsAbstractGeometry, NULL );
1168 PyErr_SetString( PyExc_StopIteration,
"" );
1193 , i( g->const_parts_begin() )
1194 , n( g->const_parts_end() )
1201 return g && g->const_parts_end() != i;
1215 if ( sipCpp->hasNext() )
1216 sipRes = sipConvertFromType( const_cast< QgsAbstractGeometry * >( sipCpp->next() ), sipType_QgsAbstractGeometry, NULL );
1218 PyErr_SetString( PyExc_StopIteration,
"" );
1228 #endif //QGSABSTRACTGEOMETRYV2 bool isMeasure() const
Returns true if the geometry contains m values.
A rectangle specified with double values.
Java-style iterator for traversal of parts of a geometry.
QgsVertexId(int _part=-1, int _ring=-1, int _vertex=-1, VertexType _type=SegmentVertex)
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 isValid() const
Returns true if the vertex id is valid.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QVector< QgsRingSequence > QgsCoordinateSequence
Java-style iterator for const traversal of parts of a geometry.
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
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)
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
bool vertexEqual(QgsVertexId o) const
bool operator!=(QgsVertexId other) const
bool hasNext() const
Find out whether there are more parts.
QgsVertexIterator(const QgsAbstractGeometry *geometry)
Constructs iterator for the given geometry.
Perform transforms between map coordinates and device coordinates.
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.
The part_iterator class provides STL-style iterator for geometry parts.
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.
virtual int ringCount(int part=0) const =0
Returns the number of rings of which this geometry is built.
Abstract base class for curved geometry type.
Abstract base class for all geometries.
The vertex_iterator class provides STL-style iterator for vertices.
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
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.
double closestSegment(const QgsPolylineXY &pl, const QgsPointXY &pt, int &vertexAfter, double epsilon)
QVector< QgsPoint > QgsPointSequence
bool operator==(QgsVertexId other) const
QVector< QgsPointSequence > QgsRingSequence
bool partEqual(QgsVertexId o) const
bool ringEqual(QgsVertexId o) const
const_part_iterator const_parts_begin() const
Returns STL-style iterator pointing to the const first part of the geometry.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
static bool hasM(Type type)
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...
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 is3D() const
Returns true if the geometry is 3D and contains a z-value.
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
bool hasNext() const
Find out whether there are more parts.