QGIS/python/core/auto_generated/geometry/qgsabstractgeometry.sip.in

949 lines
26 KiB
Plaintext
Raw Normal View History

2017-04-27 07:55:22 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/geometry/qgsabstractgeometry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2015-05-15 15:41:56 +02:00
2015-05-15 15:41:56 +02:00
typedef QVector< QgsPoint > QgsPointSequence;
typedef QVector< QVector< QgsPoint > > QgsRingSequence;
typedef QVector< QVector< QVector< QgsPoint > > > QgsCoordinateSequence;
2017-04-27 07:55:22 +02:00
2016-08-06 11:01:42 +02:00
class QgsAbstractGeometry
2015-05-15 15:41:56 +02:00
{
2017-04-27 07:55:22 +02:00
%Docstring
Abstract base class for all geometries
2017-12-15 10:36:55 -04:00
2017-04-27 07:55:22 +02:00
.. versionadded:: 2.10
%End
2015-05-15 15:41:56 +02:00
%TypeHeaderCode
2017-04-27 07:55:22 +02:00
#include "qgsabstractgeometry.h"
2015-05-15 15:41:56 +02:00
%End
%ConvertToSubClassCode
2017-07-17 09:06:23 +02:00
if ( qgsgeometry_cast<QgsPoint *>( sipCpp ) != nullptr )
sipType = sipType_QgsPoint;
2017-07-17 09:06:23 +02:00
else if ( qgsgeometry_cast<QgsLineString *>( sipCpp ) != nullptr )
2017-04-27 07:55:22 +02:00
sipType = sipType_QgsLineString;
2017-07-17 09:06:23 +02:00
else if ( qgsgeometry_cast<QgsCircularString *>( sipCpp ) != nullptr )
2017-04-27 07:55:22 +02:00
sipType = sipType_QgsCircularString;
2017-07-17 09:06:23 +02:00
else if ( qgsgeometry_cast<QgsCompoundCurve *>( sipCpp ) != nullptr )
2017-04-27 07:55:22 +02:00
sipType = sipType_QgsCompoundCurve;
2017-07-17 09:06:23 +02:00
else if ( qgsgeometry_cast<QgsTriangle *>( sipCpp ) != nullptr )
2017-04-27 07:55:22 +02:00
sipType = sipType_QgsTriangle;
2017-10-29 12:08:07 +01:00
else if ( qgsgeometry_cast<QgsPolygon *>( sipCpp ) != nullptr )
sipType = sipType_QgsPolygon;
2017-07-17 09:06:23 +02:00
else if ( qgsgeometry_cast<QgsCurvePolygon *>( sipCpp ) != nullptr )
2017-04-27 07:55:22 +02:00
sipType = sipType_QgsCurvePolygon;
else if ( qgsgeometry_cast<QgsMultiPoint *>( sipCpp ) != nullptr )
sipType = sipType_QgsMultiPoint;
2017-07-17 09:06:23 +02:00
else if ( qgsgeometry_cast<QgsMultiLineString *>( sipCpp ) != nullptr )
2017-04-27 07:55:22 +02:00
sipType = sipType_QgsMultiLineString;
else if ( qgsgeometry_cast<QgsMultiPolygon *>( sipCpp ) != nullptr )
sipType = sipType_QgsMultiPolygon;
2017-07-17 09:06:23 +02:00
else if ( qgsgeometry_cast<QgsMultiSurface *>( sipCpp ) != nullptr )
2017-04-27 07:55:22 +02:00
sipType = sipType_QgsMultiSurface;
2017-07-17 09:06:23 +02:00
else if ( qgsgeometry_cast<QgsMultiCurve *>( sipCpp ) != nullptr )
2017-04-27 07:55:22 +02:00
sipType = sipType_QgsMultiCurve;
2017-07-17 09:06:23 +02:00
else if ( qgsgeometry_cast<QgsGeometryCollection *>( sipCpp ) != nullptr )
2017-04-27 07:55:22 +02:00
sipType = sipType_QgsGeometryCollection;
else
sipType = 0;
%End
public:
static const QMetaObject staticMetaObject;
2017-04-27 07:55:22 +02:00
public:
enum SegmentationToleranceType
{
2017-04-27 07:55:22 +02:00
MaximumAngle,
2017-04-27 07:55:22 +02:00
MaximumDifference
};
enum AxisOrder
{
XY,
YX
};
2016-08-06 11:01:42 +02:00
QgsAbstractGeometry();
%Docstring
2017-12-15 10:36:55 -04:00
Constructor for QgsAbstractGeometry.
%End
2016-08-06 11:01:42 +02:00
virtual ~QgsAbstractGeometry();
2017-04-27 07:55:22 +02:00
QgsAbstractGeometry( const QgsAbstractGeometry &geom );
2015-05-15 15:41:56 +02:00
virtual bool operator==( const QgsAbstractGeometry &other ) const = 0;
virtual bool operator!=( const QgsAbstractGeometry &other ) const = 0;
2017-04-27 07:55:22 +02:00
virtual QgsAbstractGeometry *clone() const = 0 /Factory/;
%Docstring
2017-12-15 10:36:55 -04:00
Clones the geometry by performing a deep copy
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
2015-05-15 15:41:56 +02:00
virtual void clear() = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Clears the geometry, ie reset it to a null geometry
2017-04-27 07:55:22 +02:00
%End
2015-05-15 15:41:56 +02:00
virtual QgsRectangle boundingBox() const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the minimal bounding box for the geometry
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
2015-05-15 15:41:56 +02:00
virtual int dimension() const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the inherent dimension of the geometry. For example, this is 0 for a point geometry,
1 for a linestring and 2 for a polygon.
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
2015-05-15 15:41:56 +02:00
virtual QString geometryType() const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns a unique string representing the geometry type.
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`wkbType`
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`wktTypeStr`
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
QgsWkbTypes::Type wkbType() const;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the WKB type of the geometry.
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`geometryType`
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`wktTypeStr`
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
2015-05-15 15:41:56 +02:00
QString wktTypeStr() const;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the WKT type string of the geometry.
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`geometryType`
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`wkbType`
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
2015-05-15 15:41:56 +02:00
bool is3D() const;
2017-04-27 07:55:22 +02:00
%Docstring
2019-02-26 19:54:09 +10:00
Returns ``True`` if the geometry is 3D and contains a z-value.
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`isMeasure`
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
2015-05-15 15:41:56 +02:00
bool isMeasure() const;
2017-04-27 07:55:22 +02:00
%Docstring
2019-02-26 19:54:09 +10:00
Returns ``True`` if the geometry contains m values.
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`is3D`
2017-04-27 07:55:22 +02:00
%End
virtual QgsAbstractGeometry *boundary() const = 0 /Factory/;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the geometry).
For instance, a polygon geometry will have a boundary consisting of the linestrings for each ring in the polygon.
2019-03-21 12:44:16 +10:00
:return: boundary for geometry. May be ``None`` for some geometry types.
2017-12-15 10:36:55 -04:00
2017-04-27 07:55:22 +02:00
.. versionadded:: 3.0
%End
virtual bool fromWkb( QgsConstWkbPtr &wkb ) = 0;
%Docstring
2017-12-15 10:36:55 -04:00
Sets the geometry from a WKB string.
After successful read the wkb argument will be at the position where the reading has stopped.
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`fromWkt`
2017-04-27 07:55:22 +02:00
%End
virtual bool fromWkt( const QString &wkt ) = 0;
%Docstring
2017-12-15 10:36:55 -04:00
Sets the geometry from a WKT string.
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`fromWkb`
2017-04-27 07:55:22 +02:00
%End
2015-05-15 15:41:56 +02:00
virtual QByteArray asWkb() const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns a WKB representation of the geometry.
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`asWkt`
2017-12-15 10:36:55 -04:00
2018-05-25 09:00:58 +10:00
.. seealso:: :py:func:`asGml2`
2017-12-15 10:36:55 -04:00
2018-05-25 09:00:58 +10:00
.. seealso:: :py:func:`asGml3`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asJson`
2017-12-15 10:36:55 -04:00
2017-04-27 07:55:22 +02:00
.. versionadded:: 3.0
%End
2016-01-28 10:30:06 +01:00
2015-05-15 15:41:56 +02:00
virtual QString asWkt( int precision = 17 ) const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns a WKT representation of the geometry.
2017-12-15 21:36:08 -04:00
:param precision: number of decimal places for coordinates
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asWkb`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asGml2`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asGml3`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asJson`
2017-04-27 07:55:22 +02:00
%End
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns a GML2 representation of the geometry.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param doc: DOM document
:param precision: number of decimal places for coordinates
:param ns: XML namespace
:param axisOrder: Axis order for generated GML
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asWkb`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asWkt`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asGml3`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asJson`
2017-04-27 07:55:22 +02:00
%End
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns a GML3 representation of the geometry.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param doc: DOM document
:param precision: number of decimal places for coordinates
:param ns: XML namespace
:param axisOrder: Axis order for generated GML
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asWkb`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asWkt`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asGml2`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asJson`
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
2019-05-02 13:52:46 +02:00
QString asJson( int precision = 17 );
2017-04-27 07:55:22 +02:00
%Docstring
2019-05-02 13:52:46 +02:00
Returns a GeoJSON representation of the geometry as a QString.
2017-12-15 10:36:55 -04:00
2017-12-15 21:36:08 -04:00
:param precision: number of decimal places for coordinates
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asWkb`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asWkt`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`asGml2`
2017-12-15 10:36:55 -04:00
2019-04-05 15:07:17 +02:00
.. seealso:: :py:func:`asGml3`
2019-05-02 13:52:46 +02:00
.. seealso:: :py:func:`asJsonObject`
2019-04-05 15:07:17 +02:00
%End
2019-04-16 15:13:29 +02:00
2015-05-15 15:41:56 +02:00
2016-01-28 10:30:06 +01:00
virtual void transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform, bool transformZ = false ) throw( QgsCsException ) = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Transforms the geometry using a coordinate transform
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param ct: coordinate transform
:param d: transformation direction
2019-02-26 19:54:09 +10:00
:param transformZ: set to ``True`` to also transform z coordinates. This requires that
the z coordinates in the geometry represent height relative to the vertical datum
of the source CRS (generally ellipsoidal heights) and are expressed in its vertical
2019-02-26 19:54:09 +10:00
units (generally meters). If ``False``, then z coordinates will not be changed by the
transform.
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
virtual void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0,
double mTranslate = 0.0, double mScale = 1.0 ) = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Transforms the x and y components of the geometry using a QTransform object ``t``.
2017-12-15 10:36:55 -04:00
Optionally, the geometry's z values can be scaled via ``zScale`` and translated via ``zTranslate``.
Similarly, m-values can be scaled via ``mScale`` and translated via ``mTranslate``.
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
2017-04-27 07:55:22 +02:00
virtual void draw( QPainter &p ) const = 0;
%Docstring
2017-12-15 10:36:55 -04:00
Draws the geometry using the specified QPainter.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param p: destination QPainter
2017-04-27 07:55:22 +02:00
%End
2015-05-15 15:41:56 +02:00
virtual int vertexNumberFromVertexId( QgsVertexId id ) const = 0;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the vertex number corresponding to a vertex ``id``.
The vertex numbers start at 0, so a return value of 0 corresponds
to the first vertex.
2017-12-15 10:36:55 -04:00
Returns -1 if a corresponding vertex could not be found.
.. versionadded:: 3.0
%End
virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex /Out/ ) const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns next vertex id and coordinates
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param id: initial value should be the starting vertex id. The next vertex id will be stored
in this variable if found.
2017-12-15 10:36:55 -04:00
2019-02-26 19:54:09 +10:00
:return: - ``False`` if at end
- vertex: container for found node
2017-04-27 07:55:22 +02:00
%End
2015-05-15 15:41:56 +02:00
virtual void adjacentVertices( QgsVertexId vertex, QgsVertexId &previousVertex /Out/, QgsVertexId &nextVertex /Out/ ) const = 0;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the vertices adjacent to a specified ``vertex`` within a geometry.
.. versionadded:: 3.0
%End
2017-04-27 07:55:22 +02:00
virtual QgsCoordinateSequence coordinateSequence() const = 0;
%Docstring
2017-12-15 10:36:55 -04:00
Retrieves the sequence of geometries, rings and nodes.
:return: coordinate sequence
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
virtual int nCoordinates() const;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the number of nodes contained in the geometry
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
virtual QgsPoint vertexAt( QgsVertexId id ) const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the point corresponding to a specified vertex id
2017-04-27 07:55:22 +02:00
%End
virtual double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt /Out/,
2017-04-27 07:55:22 +02:00
QgsVertexId &vertexAfter /Out/,
int *leftOf /Out/ = 0, double epsilon = 4 * DBL_EPSILON ) const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Searches for the closest segment of the geometry to a given point.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param pt: specifies the point to find closest segment to
:param segmentPt: storage for the closest point within the geometry
:param vertexAfter: storage for the ID of the vertex at the end of the closest segment
:param epsilon: epsilon for segment snapping
2018-12-19 08:04:27 -04:00
:return: - squared distance to closest segment or negative value on error
2019-02-26 19:54:09 +10:00
- leftOf: indicates whether the point lies on the left side of the geometry (-1 if point is to the left of the geometry, +1 if the point is to the right of the geometry, or 0 for cases where left/right could not be determined, e.g. point exactly on a line) ``False`` if point is to right of segment)
2017-04-27 07:55:22 +02:00
%End
virtual bool insertVertex( QgsVertexId position, const QgsPoint &vertex ) = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Inserts a vertex into the geometry
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param position: vertex id for position of inserted vertex
:param vertex: vertex to insert
2019-02-26 19:54:09 +10:00
:return: ``True`` if insert was successful
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`moveVertex`
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`deleteVertex`
2017-04-27 07:55:22 +02:00
%End
virtual bool moveVertex( QgsVertexId position, const QgsPoint &newPos ) = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Moves a vertex within the geometry
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param position: vertex id for vertex to move
:param newPos: new position of vertex
2019-02-26 19:54:09 +10:00
:return: ``True`` if move was successful
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`insertVertex`
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`deleteVertex`
2017-04-27 07:55:22 +02:00
%End
virtual bool deleteVertex( QgsVertexId position ) = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Deletes a vertex within the geometry
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param position: vertex id for vertex to delete
2019-02-26 19:54:09 +10:00
:return: ``True`` if delete was successful
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`insertVertex`
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`moveVertex`
2017-04-27 07:55:22 +02:00
%End
2015-05-15 15:41:56 +02:00
virtual double length() const;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the length of the geometry.
.. seealso:: :py:func:`area`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`perimeter`
2017-04-27 07:55:22 +02:00
%End
virtual double perimeter() const;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the perimeter of the geometry.
.. seealso:: :py:func:`area`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`length`
2017-04-27 07:55:22 +02:00
%End
2015-05-15 15:41:56 +02:00
virtual double area() const;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the area of the geometry.
.. seealso:: :py:func:`length`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`perimeter`
2017-04-27 07:55:22 +02:00
%End
2015-05-29 17:59:52 +02:00
virtual double segmentLength( QgsVertexId startVertex ) const = 0;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the length of the segment of the geometry which begins at ``startVertex``.
.. versionadded:: 3.0
%End
virtual QgsPoint centroid() const;
2017-04-27 07:55:22 +02:00
%Docstring
Returns the centroid of the geometry
%End
virtual bool isEmpty() const;
2017-04-27 07:55:22 +02:00
%Docstring
2019-02-26 19:54:09 +10:00
Returns ``True`` if the geometry is empty
2017-04-27 07:55:22 +02:00
%End
2015-05-29 17:59:52 +02:00
virtual bool hasCurvedSegments() const;
2017-04-27 07:55:22 +02:00
%Docstring
2019-02-26 19:54:09 +10:00
Returns ``True`` if the geometry contains curved segments
2017-04-27 07:55:22 +02:00
%End
virtual QgsAbstractGeometry *segmentize( double tolerance = M_PI / 180., SegmentationToleranceType toleranceType = MaximumAngle ) const /Factory/;
%Docstring
2017-12-15 10:36:55 -04:00
Returns a version of the geometry without curves. Caller takes ownership of
the returned geometry.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param tolerance: segmentation tolerance
:param toleranceType: maximum segmentation angle or maximum difference between approximation and curve
2017-04-27 07:55:22 +02:00
%End
virtual QgsAbstractGeometry *toCurveType() const = 0 /Factory/;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the geometry converted to the more generic curve type.
2017-12-19 11:43:52 -04:00
E.g. :py:class:`QgsLineString` -> :py:class:`QgsCompoundCurve`, :py:class:`QgsPolygon` -> QgsCurvePolygon,
:py:class:`QgsMultiLineString` -> :py:class:`QgsMultiCurve`, :py:class:`QgsMultiPolygon` -> :py:class:`QgsMultiSurface`
2017-12-15 10:36:55 -04:00
:return: the converted geometry. Caller takes ownership
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
virtual QgsAbstractGeometry *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const = 0 /Factory/;
%Docstring
2017-12-15 10:36:55 -04:00
Makes a new geometry with all the points or vertices snapped to the closest point of the grid.
Ownership is transferred to the caller.
If the gridified geometry could not be calculated ``None`` will be returned.
2017-12-15 10:36:55 -04:00
It may generate an invalid geometry (in some corner cases).
It can also be thought as rounding the edges and it may be useful for removing errors.
Example:
2017-12-19 16:36:51 -04:00
2017-12-15 10:36:55 -04:00
In this case we use a 2D grid of 1x1 to gridify.
In this case, it can be thought like rounding the x and y of all the points/vertices to full units (remove all decimals).
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param hSpacing: Horizontal spacing of the grid (x axis). 0 to disable.
:param vSpacing: Vertical spacing of the grid (y axis). 0 to disable.
:param dSpacing: Depth spacing of the grid (z axis). 0 (default) to disable.
:param mSpacing: Custom dimension spacing of the grid (m axis). 0 (default) to disable.
.. versionadded:: 3.0
%End
virtual bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false ) = 0;
%Docstring
2017-12-15 10:36:55 -04:00
Removes duplicate nodes from the geometry, wherever removing the nodes does not result in a
degenerate geometry.
2017-12-15 10:36:55 -04:00
The ``epsilon`` parameter specifies the tolerance for coordinates when determining that
vertices are identical.
2017-12-15 10:36:55 -04:00
By default, z values are not considered when detecting duplicate nodes. E.g. two nodes
with the same x and y coordinate but different z values will still be considered
2019-02-26 19:54:09 +10:00
duplicate and one will be removed. If ``useZValues`` is ``True``, then the z values are
2017-12-15 10:36:55 -04:00
also tested and nodes with the same x and y but different z will be maintained.
2017-12-15 10:36:55 -04:00
Note that duplicate nodes are not tested between different parts of a multipart geometry. E.g.
a multipoint geometry with overlapping points will not be changed by this method.
2019-02-26 19:54:09 +10:00
The function will return ``True`` if nodes were removed, or ``False`` if no duplicate nodes
2017-12-15 10:36:55 -04:00
were found.
.. versionadded:: 3.0
%End
virtual double vertexAngle( QgsVertexId vertex ) const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns approximate angle at a vertex. This is usually the average angle between adjacent
segments, and can be pictured as the orientation of a line following the curvature of the
geometry at the specified vertex.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param vertex: the vertex id
:return: rotation in radians, clockwise from north
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
virtual int vertexCount( int part = 0, int ring = 0 ) const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the number of vertices of which this geometry is built.
2017-04-27 07:55:22 +02:00
%End
2016-01-28 10:30:06 +01:00
virtual int ringCount( int part = 0 ) const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the number of rings of which this geometry is built.
2017-04-27 07:55:22 +02:00
%End
2015-12-11 19:30:15 +11:00
virtual int partCount() const = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns count of parts contained in the geometry.
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`vertexCount`
2017-12-15 10:36:55 -04:00
2017-12-05 20:04:14 -04:00
.. seealso:: :py:func:`ringCount`
2017-04-27 07:55:22 +02:00
%End
virtual bool addZValue( double zValue = 0 ) = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Adds a z-dimension to the geometry, initialized to a preset value.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param zValue: initial z-value for all nodes
2019-02-26 19:54:09 +10:00
:return: ``True`` on success
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`dropZValue`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`addMValue`
2018-05-28 11:31:08 -04:00
.. versionadded:: 2.12
2017-04-27 07:55:22 +02:00
%End
virtual bool addMValue( double mValue = 0 ) = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Adds a measure to the geometry, initialized to a preset value.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param mValue: initial m-value for all nodes
2019-02-26 19:54:09 +10:00
:return: ``True`` on success
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`dropMValue`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`addZValue`
2018-05-28 11:31:08 -04:00
.. versionadded:: 2.12
2017-04-27 07:55:22 +02:00
%End
virtual bool dropZValue() = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Drops any z-dimensions which exist in the geometry.
2019-02-26 19:54:09 +10:00
:return: ``True`` if Z values were present and have been removed
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`addZValue`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`dropMValue`
2017-12-15 10:36:55 -04:00
2017-04-27 07:55:22 +02:00
.. versionadded:: 2.14
%End
virtual bool dropMValue() = 0;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Drops any measure values which exist in the geometry.
2019-02-26 19:54:09 +10:00
:return: ``True`` if m-values were present and have been removed
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`addMValue`
2017-12-15 10:36:55 -04:00
.. seealso:: :py:func:`dropZValue`
2017-12-15 10:36:55 -04:00
2017-04-27 07:55:22 +02:00
.. versionadded:: 2.14
%End
virtual void swapXy() = 0;
%Docstring
Swaps the x and y coordinates from the geometry. This can be used
to repair geometries which have accidentally had their latitude and longitude
coordinates reversed.
.. versionadded:: 3.2
2017-04-27 07:55:22 +02:00
%End
virtual bool convertTo( QgsWkbTypes::Type type );
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Converts the geometry to a specified type.
2019-02-26 19:54:09 +10:00
:return: ``True`` if conversion was successful
2017-12-15 10:36:55 -04:00
2017-04-27 07:55:22 +02:00
.. versionadded:: 2.14
%End
virtual bool isValid( QString &error /Out/, int flags = 0 ) const = 0;
%Docstring
Checks validity of the geometry, and returns ``True`` if the geometry is valid.
:param flags: indicates optional flags which control the type of validity checking performed
(corresponding to QgsGeometry.ValidityFlags).
:return: - ``True`` if geometry is valid
- error: will be set to the validity error message
.. versionadded:: 3.8
%End
QgsGeometryPartIterator parts();
%Docstring
Returns Java-style iterator for traversal of parts of the geometry. This iterator
can safely be used to modify parts of the geometry.
* Example:
.. code-block:: python
# print the WKT representation of each part in a multi-point geometry
geometry = QgsMultiPoint.fromWkt( 'MultiPoint( 0 0, 1 1, 2 2)' )
for part in geometry.parts():
print(part.asWkt())
# single part geometries only have one part - this loop will iterate once only
geometry = QgsLineString.fromWkt( 'LineString( 0 0, 10 10 )' )
for part in geometry.parts():
print(part.asWkt())
# parts can be modified during the iteration
geometry = QgsMultiPoint.fromWkt( 'MultiPoint( 0 0, 1 1, 2 2)' )
for part in geometry.parts():
part.transform(ct)
# part iteration can also be combined with vertex iteration
geometry = QgsMultiPolygon.fromWkt( 'MultiPolygon((( 0 0, 0 10, 10 10, 10 0, 0 0 ),( 5 5, 5 6, 6 6, 6 5, 5 5)),((20 2, 22 2, 22 4, 20 4, 20 2)))' )
for part in geometry.parts():
for v in part.vertices():
print(v.x(), v.y())
.. seealso:: :py:func:`vertices`
.. versionadded:: 3.6
%End
QgsVertexIterator vertices() const;
%Docstring
Returns a read-only, Java-style iterator for traversal of vertices of all the geometry, including all geometry parts and rings.
.. warning::
The iterator returns a copy of individual vertices, and accordingly geometries cannot be
modified using the iterator. See transformVertices() for a safe method to modify vertices "in-place".
* Example:
.. code-block:: python
# print the x and y coordinate for each vertex in a LineString
geometry = QgsLineString.fromWkt( 'LineString( 0 0, 1 1, 2 2)' )
for v in geometry.vertices():
print(v.x(), v.y())
# vertex iteration includes all parts and rings
geometry = QgsMultiPolygon.fromWkt( 'MultiPolygon((( 0 0, 0 10, 10 10, 10 0, 0 0 ),( 5 5, 5 6, 6 6, 6 5, 5 5)),((20 2, 22 2, 22 4, 20 4, 20 2)))' )
for v in geometry.vertices():
print(v.x(), v.y())
.. seealso:: :py:func:`parts`
2017-12-15 10:36:55 -04:00
.. versionadded:: 3.0
%End
virtual QgsAbstractGeometry *createEmptyWithSameType() const = 0 /Factory/;
%Docstring
2017-12-15 10:36:55 -04:00
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
To create it, the geometry is default constructed and then the WKB is changed.
.. seealso:: :py:func:`clone`
2017-12-15 10:36:55 -04:00
.. versionadded:: 3.0
%End
protected:
virtual bool hasChildGeometries() const;
%Docstring
2019-02-26 19:54:09 +10:00
Returns whether the geometry has any child geometries (``False`` for point / curve, ``True`` otherwise)
2017-12-15 10:36:55 -04:00
.. note::
used for vertex_iterator implementation
2017-12-15 10:36:55 -04:00
.. versionadded:: 3.0
%End
virtual int childCount() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns number of child geometries (for geometries with child geometries) or child points (for geometries without child geometries - i.e. curve / point)
.. note::
used for vertex_iterator implementation
2017-12-15 10:36:55 -04:00
.. versionadded:: 3.0
%End
virtual QgsAbstractGeometry *childGeometry( int index ) const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns pointer to child geometry (for geometries with child geometries - i.e. geom. collection / polygon)
.. note::
used for vertex_iterator implementation
2017-12-15 10:36:55 -04:00
.. versionadded:: 3.0
%End
virtual QgsPoint childPoint( int index ) const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns point at index (for geometries without child geometries - i.e. curve / point)
.. note::
used for vertex_iterator implementation
2017-12-15 10:36:55 -04:00
.. versionadded:: 3.0
%End
protected:
2017-04-27 07:55:22 +02:00
void setZMTypeFromSubGeometry( const QgsAbstractGeometry *subggeom, QgsWkbTypes::Type baseGeomType );
%Docstring
2017-12-15 10:36:55 -04:00
Updates the geometry type based on whether sub geometries contain z or m values.
2017-04-27 07:55:22 +02:00
%End
virtual QgsRectangle calculateBoundingBox() const;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Default calculator for the minimal bounding box for the geometry. Derived classes should override this method
if a more efficient bounding box calculation is available.
2017-04-27 07:55:22 +02:00
%End
virtual void clearCache() const;
2017-04-27 07:55:22 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Clears any cached parameters associated with the geometry, e.g., bounding boxes
2017-04-27 07:55:22 +02:00
%End
2015-05-15 15:41:56 +02:00
};
2017-04-27 07:55:22 +02:00
struct QgsVertexId
{
enum VertexType
{
SegmentVertex,
CurveVertex
};
explicit QgsVertexId( int _part = -1, int _ring = -1, int _vertex = -1, VertexType _type = SegmentVertex );
bool isValid() const;
%Docstring
2019-02-26 19:54:09 +10:00
Returns ``True`` if the vertex id is valid
2017-04-27 07:55:22 +02:00
%End
bool operator==( QgsVertexId other ) const;
bool operator!=( QgsVertexId other ) const;
bool partEqual( QgsVertexId o ) const;
bool ringEqual( QgsVertexId o ) const;
bool vertexEqual( QgsVertexId o ) const;
bool isValid( const QgsAbstractGeometry *geom ) const;
int part;
int ring;
int vertex;
VertexType type;
};
2017-09-25 14:20:39 +10:00
class QgsVertexIterator
{
%Docstring
Java-style iterator for traversal of vertices of a geometry
2017-12-15 10:36:55 -04:00
.. versionadded:: 3.0
%End
%TypeHeaderCode
#include "qgsabstractgeometry.h"
%End
public:
QgsVertexIterator();
%Docstring
Constructor for QgsVertexIterator
%End
QgsVertexIterator( const QgsAbstractGeometry *geometry );
%Docstring
Constructs iterator for the given geometry
%End
bool hasNext() const;
%Docstring
Find out whether there are more vertices
%End
QgsPoint next();
%Docstring
2019-02-26 19:54:09 +10:00
Returns next vertex of the geometry (undefined behavior if hasNext() returns ``False`` before calling next())
%End
QgsVertexIterator *__iter__();
%MethodCode
sipRes = sipCpp;
%End
SIP_PYOBJECT __next__() /TypeHint="QgsPoint"/;
%MethodCode
if ( sipCpp->hasNext() )
sipRes = sipConvertFromType( new QgsPoint( sipCpp->next() ), sipType_QgsPoint, Py_None );
else
PyErr_SetString( PyExc_StopIteration, "" );
%End
};
class QgsGeometryPartIterator
{
%Docstring
Java-style iterator for traversal of parts of a geometry
.. versionadded:: 3.6
%End
%TypeHeaderCode
#include "qgsabstractgeometry.h"
%End
public:
QgsGeometryPartIterator();
%Docstring
Constructor for QgsGeometryPartIterator
%End
QgsGeometryPartIterator( QgsAbstractGeometry *geometry );
%Docstring
Constructs iterator for the given geometry
%End
bool hasNext() const;
%Docstring
Find out whether there are more parts
%End
QgsAbstractGeometry *next();
%Docstring
2019-02-26 19:54:09 +10:00
Returns next part of the geometry (undefined behavior if hasNext() returns ``False`` before calling next())
%End
QgsGeometryPartIterator *__iter__();
%MethodCode
sipRes = sipCpp;
%End
SIP_PYOBJECT __next__() /TypeHint="QgsAbstractGeometry"/;
%MethodCode
if ( sipCpp->hasNext() )
sipRes = sipConvertFromType( sipCpp->next(), sipType_QgsAbstractGeometry, NULL );
else
PyErr_SetString( PyExc_StopIteration, "" );
%End
};
class QgsGeometryConstPartIterator
{
%Docstring
Java-style iterator for const traversal of parts of a geometry
.. versionadded:: 3.6
%End
%TypeHeaderCode
#include "qgsabstractgeometry.h"
%End
public:
QgsGeometryConstPartIterator();
%Docstring
Constructor for QgsGeometryConstPartIterator
%End
QgsGeometryConstPartIterator( const QgsAbstractGeometry *geometry );
%Docstring
Constructs iterator for the given geometry
%End
bool hasNext() const;
%Docstring
Find out whether there are more parts
%End
const QgsAbstractGeometry *next();
%Docstring
2019-02-26 19:54:09 +10:00
Returns next part of the geometry (undefined behavior if hasNext() returns ``False`` before calling next())
%End
QgsGeometryConstPartIterator *__iter__();
%MethodCode
sipRes = sipCpp;
%End
SIP_PYOBJECT __next__() /TypeHint="QgsAbstractGeometry"/;
%MethodCode
if ( sipCpp->hasNext() )
sipRes = sipConvertFromType( const_cast< QgsAbstractGeometry * >( sipCpp->next() ), sipType_QgsAbstractGeometry, NULL );
else
PyErr_SetString( PyExc_StopIteration, "" );
%End
};
2017-04-27 07:55:22 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/geometry/qgsabstractgeometry.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/