16 #ifndef QGSABSTRACTGEOMETRYV2
17 #define QGSABSTRACTGEOMETRYV2
22 #include "qgis_core.h"
28 #include "json_fwd.hpp"
29 using namespace nlohmann;
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;
125 Q_ENUM( SegmentationToleranceType )
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;
247 FlagExportTrianglesAsPolygons = 1 << 0,
249 Q_DECLARE_FLAGS( WkbFlags, WkbFlag )
262 virtual QByteArray asWkb( WkbFlags flags = QgsAbstractGeometry::WkbFlags() )
const = 0;
272 virtual QString asWkt(
int precision = 17 )
const = 0;
285 virtual QDomElement asGml2( QDomDocument &doc,
int precision = 17,
const QString &ns =
"gml", AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY )
const = 0;
298 virtual QDomElement asGml3( QDomDocument &doc,
int precision = 17,
const QString &ns =
"gml", AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY )
const = 0;
327 virtual QString asKml(
int precision = 17 ) const = 0;
350 virtual
void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
351 double mTranslate = 0.0,
double mScale = 1.0 ) = 0;
357 virtual
void draw( QPainter &p ) const = 0;
369 virtual
int vertexNumberFromVertexId(
QgsVertexId id ) const = 0;
395 virtual
int nCoordinates() const;
416 int *
leftOf SIP_OUT =
nullptr,
double epsilon = 4 * std::numeric_limits<
double>::epsilon() ) const = 0;
447 virtual
bool deleteVertex(
QgsVertexId position ) = 0;
461 virtual
double length() const;
475 virtual
double perimeter() const;
489 virtual
double area() const;
499 virtual
double segmentLength(
QgsVertexId startVertex ) const = 0;
507 virtual
bool isEmpty() const;
512 virtual
bool hasCurvedSegments() const;
520 virtual
QgsAbstractGeometry *segmentize(
double tolerance = M_PI / 180., SegmentationToleranceType toleranceType = MaximumAngle ) const
SIP_FACTORY;
574 virtual
bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) = 0;
583 virtual
double vertexAngle(
QgsVertexId vertex ) const = 0;
588 virtual
int vertexCount(
int part = 0,
int ring = 0 ) const = 0;
593 virtual
int ringCount(
int part = 0 ) const = 0;
600 virtual
int partCount() const = 0;
610 virtual
bool addZValue(
double zValue = 0 ) = 0;
620 virtual
bool addMValue(
double mValue = 0 ) = 0;
629 virtual
bool dropZValue() = 0;
638 virtual
bool dropMValue() = 0;
646 virtual
void swapXy() = 0;
666 virtual
bool isValid( QString &error
SIP_OUT,
int flags = 0 ) const = 0;
679 virtual void filterVertices(
const std::function<
bool(
const QgsPoint & ) > &filter );
695 virtual void transformVertices(
const std::function<
QgsPoint(
const QgsPoint & ) > &transform );
729 int partNumber()
const;
756 part_iterator parts_end();
799 int partNumber()
const;
824 const_part_iterator const_parts_end()
const;
981 virtual bool hasChildGeometries()
const;
1002 virtual QgsPoint childPoint(
int index )
const;
1021 virtual void clearCache()
const;
1023 friend class TestQgsGeometry;
1051 bool isValid()
const {
return part >= 0 && ring >= 0 && vertex >= 0; }
1055 return part == other.
part && ring == other.
ring && vertex == other.
vertex;
1059 return part != other.
part || ring != other.
ring || vertex != other.
vertex;
1063 return part >= 0 && o.
part == part;
1067 return partEqual( o ) && ( ring >= 0 && o.
ring == ring );
1071 return ringEqual( o ) && ( vertex >= 0 && o.
ring == ring );
1075 return ( part >= 0 && part < geom->partCount() ) &&
1077 ( vertex < 0 || vertex < geom->vertexCount( part, ring ) );
1086 SIP_PYOBJECT __repr__();
1088 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() );
1089 sipRes = PyUnicode_FromString( str.toUtf8().data() );
1100 return const_cast<T
>(
reinterpret_cast<T
>( 0 )->cast( geom ) );
1121 , i( g->vertices_begin() )
1122 , n( g->vertices_end() )
1129 return g && g->vertices_end() != i;
1143 if ( sipCpp->hasNext() )
1144 sipRes = sipConvertFromType( new
QgsPoint( sipCpp->next() ), sipType_QgsPoint, Py_None );
1146 PyErr_SetString( PyExc_StopIteration, "" );
1170 , i( g->parts_begin() )
1171 , n( g->parts_end() )
1178 return g && g->parts_end() != i;
1192 if ( sipCpp->hasNext() )
1193 sipRes = sipConvertFromType( sipCpp->next(), sipType_QgsAbstractGeometry, NULL );
1195 PyErr_SetString( PyExc_StopIteration, "" );
1220 , i( g->const_parts_begin() )
1221 , n( g->const_parts_end() )
1228 return g && g->const_parts_end() != i;
1242 if ( sipCpp->hasNext() )
1243 sipRes = sipConvertFromType( const_cast<
QgsAbstractGeometry * >( sipCpp->next() ), sipType_QgsAbstractGeometry, NULL );
1245 PyErr_SetString( PyExc_StopIteration, "" );
1255 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsAbstractGeometry::WkbFlags )
1257 #endif //QGSABSTRACTGEOMETRYV2