16 #ifndef QGSABSTRACTGEOMETRYV2
17 #define QGSABSTRACTGEOMETRYV2
21 #include <type_traits>
24 #include "qgis_core.h"
30 #include "json_fwd.hpp"
31 using 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<QgsMultiPoint *>( sipCpp ) !=
nullptr )
99 sipType = sipType_QgsMultiPoint;
100 else if ( qgsgeometry_cast<QgsMultiLineString *>( sipCpp ) !=
nullptr )
101 sipType = sipType_QgsMultiLineString;
102 else if ( qgsgeometry_cast<QgsMultiPolygon *>( sipCpp ) !=
nullptr )
103 sipType = sipType_QgsMultiPolygon;
104 else if ( qgsgeometry_cast<QgsMultiSurface *>( sipCpp ) !=
nullptr )
105 sipType = sipType_QgsMultiSurface;
106 else if ( qgsgeometry_cast<QgsMultiCurve *>( sipCpp ) !=
nullptr )
107 sipType = sipType_QgsMultiCurve;
108 else if ( qgsgeometry_cast<QgsGeometryCollection *>( sipCpp ) !=
nullptr )
109 sipType = sipType_QgsGeometryCollection;
135 Q_ENUM( SegmentationToleranceType )
179 virtual void clear() = 0;
192 virtual int dimension()
const = 0;
199 virtual QString geometryType()
const = 0;
213 QString wktTypeStr()
const;
250 virtual void normalize() = 0;
265 virtual bool fromWkt(
const QString &wkt ) = 0;
275 FlagExportTrianglesAsPolygons = 1 << 0,
277 Q_DECLARE_FLAGS( WkbFlags, WkbFlag )
286 virtual int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() )
const = 0;
299 virtual QByteArray asWkb( WkbFlags flags = QgsAbstractGeometry::WkbFlags() )
const = 0;
309 virtual QString asWkt(
int precision = 17 )
const = 0;
322 virtual QDomElement asGml2( QDomDocument &doc,
int precision = 17,
const QString &ns =
"gml", AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY )
const = 0;
335 virtual QDomElement asGml3( QDomDocument &doc,
int precision = 17,
const QString &ns =
"gml", AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY )
const = 0;
364 virtual QString asKml(
int precision = 17 ) const = 0;
387 virtual
void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
388 double mTranslate = 0.0,
double mScale = 1.0 ) = 0;
394 virtual
void draw( QPainter &p ) const = 0;
404 virtual QPainterPath asQPainterPath() const = 0;
416 virtual
int vertexNumberFromVertexId(
QgsVertexId id ) const = 0;
442 virtual
int nCoordinates() const;
463 int *
leftOf SIP_OUT =
nullptr,
double epsilon = 4 * std::numeric_limits<
double>::epsilon() ) const = 0;
494 virtual
bool deleteVertex(
QgsVertexId position ) = 0;
508 virtual
double length() const;
522 virtual
double perimeter() const;
536 virtual
double area() const;
546 virtual
double segmentLength(
QgsVertexId startVertex ) const = 0;
554 virtual
bool isEmpty() const;
559 virtual
bool hasCurvedSegments() const;
577 virtual
QgsAbstractGeometry *segmentize(
double tolerance = M_PI / 180., SegmentationToleranceType toleranceType = MaximumAngle ) const
SIP_FACTORY;
631 virtual
bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) = 0;
640 virtual
double vertexAngle(
QgsVertexId vertex ) const = 0;
645 virtual
int vertexCount(
int part = 0,
int ring = 0 ) const = 0;
650 virtual
int ringCount(
int part = 0 ) const = 0;
657 virtual
int partCount() const = 0;
667 virtual
bool addZValue(
double zValue = 0 ) = 0;
677 virtual
bool addMValue(
double mValue = 0 ) = 0;
686 virtual
bool dropZValue() = 0;
695 virtual
bool dropMValue() = 0;
703 virtual
void swapXy() = 0;
743 virtual
bool isValid( QString &error
SIP_OUT,
Qgis::GeometryValidityFlags flags =
Qgis::GeometryValidityFlags() ) const = 0;
771 virtual void filterVertices(
const std::function<
bool(
const QgsPoint & ) > &filter );
787 virtual void transformVertices(
const std::function<
QgsPoint(
const QgsPoint & ) > &transform );
821 int partNumber()
const;
848 part_iterator parts_end();
891 int partNumber()
const;
916 const_part_iterator const_parts_end()
const;
941 std::array<Level, 3> levels;
1076 int sortIndex()
const;
1095 virtual bool hasChildGeometries()
const;
1116 virtual QgsPoint childPoint(
int index )
const;
1135 virtual void clearCache()
const;
1137 friend class TestQgsGeometry;
1146 return const_cast<T
>( std::remove_pointer<T>::type::cast( geom ) );
1167 , i( g->vertices_begin() )
1168 , n( g->vertices_end() )
1175 return g && g->vertices_end() != i;
1189 if ( sipCpp->hasNext() )
1190 sipRes = sipConvertFromType( new
QgsPoint( sipCpp->next() ), sipType_QgsPoint, Py_None );
1192 PyErr_SetString( PyExc_StopIteration, "" );
1216 , i( g->parts_begin() )
1217 , n( g->parts_end() )
1224 return g && g->parts_end() != i;
1238 if ( sipCpp->hasNext() )
1239 sipRes = sipConvertFromType( sipCpp->next(), sipType_QgsAbstractGeometry, NULL );
1241 PyErr_SetString( PyExc_StopIteration, "" );
1266 , i( g->const_parts_begin() )
1267 , n( g->const_parts_end() )
1274 return g && g->const_parts_end() != i;
1288 if ( sipCpp->hasNext() )
1289 sipRes = sipConvertFromType( const_cast<
QgsAbstractGeometry * >( sipCpp->next() ), sipType_QgsAbstractGeometry, NULL );
1291 PyErr_SetString( PyExc_StopIteration, "" );
1303 #endif //QGSABSTRACTGEOMETRYV2