QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
24 #include <nlohmann/json.hpp>
64 bool hasZ = subgeom->
is3D();
87 double xmin = std::numeric_limits<double>::max();
88 double ymin = std::numeric_limits<double>::max();
89 double xmax = -std::numeric_limits<double>::max();
90 double ymax = -std::numeric_limits<double>::max();
188 for ( ; j < n; i = j++ )
196 double d = vi.
x() * vj.
y() - vj.
x() * vi.
y();
198 Cx += ( vi.
x() + vj.
x() ) * d;
199 Cy += ( vi.
y() + vj.
y() ) * d;
205 for (
int i = 0; i < n - 1; ++i )
211 return QgsPoint( Cx / ( n - 1 ), Cy / ( n - 1 ) );
215 return QgsPoint( v0.
x() + Cx / ( 3. * A ), v0.
y() + Cy / ( 3. * A ) );
235 addZValue( std::numeric_limits<double>::quiet_NaN() );
244 addMValue( std::numeric_limits<double>::quiet_NaN() );
312 Q_UNUSED( tolerance )
313 Q_UNUSED( toleranceType )
321 levels.fill( Level() );
323 levels[0].index = index;
330 if ( depth == 0 && levels[0].index >= levels[0].g->childCount() )
333 Q_ASSERT( !levels[depth].g->hasChildGeometries() );
335 ++levels[depth].index;
338 while ( depth > 0 && levels[depth].index >= levels[depth].g->childCount() )
341 ++levels[depth].index;
358 Q_ASSERT( !levels[depth].g->hasChildGeometries() );
359 return levels[depth].g->childPoint( levels[depth].index );
364 int part = 0, ring = 0, vertex = levels[depth].index;
369 else if ( depth == 1 )
372 part = levels[0].index;
374 ring = levels[0].index;
376 else if ( depth == 2 )
378 part = levels[0].index;
379 ring = levels[1].index;
389 if (
const QgsCurve *curve =
dynamic_cast<const QgsCurve *
>( levels[depth].g ) )
392 curve->pointAt( vertex, p, vertexType );
395 return QgsVertexId( part, ring, vertex, vertexType );
400 if ( depth != other.depth )
402 return std::equal( std::begin( levels ), std::begin( levels ) + depth + 1, std::begin( other.levels ) );
405 void QgsAbstractGeometry::vertex_iterator::digDown()
407 if ( levels[depth].g->hasChildGeometries() && levels[depth].index >= levels[depth].g->childCount() )
411 while ( levels[depth].g->hasChildGeometries() )
414 Q_ASSERT( depth < 3 );
415 levels[depth].index = 0;
416 levels[depth].g = levels[depth - 1].g->childGeometry( levels[depth - 1].index );
434 const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( mGeometry );
473 return mGeometry == other.mGeometry && mIndex == other.mIndex;
492 const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( mGeometry );
515 const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( mGeometry );
531 return mGeometry == other.mGeometry && mIndex == other.mIndex;
542 return g == other.g && index == other.index;
Abstract base class for curved geometry type.
virtual QgsCoordinateSequence coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
QVector< QgsRingSequence > QgsCoordinateSequence
bool operator==(const_part_iterator other) const
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
virtual void clearCache() const
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
QgsAbstractGeometry * operator*() const
Returns the current item.
@ SegmentVertex
The actual start or end point of a segment.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
vertex_iterator & operator++()
The prefix ++ operator (++it) advances the iterator to the next vertex and returns an iterator to the...
Point geometry type, with support for z-dimension and m-values.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
static Type flatType(Type type) SIP_HOLDGIL
Returns the flat type for a WKB type.
virtual void filterVertices(const std::function< bool(const QgsPoint &) > &filter)
Filters the vertices from the geometry in place, removing any which do not return true for the filter...
QgsGeometryConstPartIterator parts() const
Returns Java-style iterator for traversal of parts of the geometry.
static Type addZ(Type type) SIP_HOLDGIL
Adds the z dimension to a WKB type and returns the new type.
Java-style iterator for const traversal of parts of a geometry.
QString wktTypeStr() const
Returns the WKT type string of the geometry.
virtual double length() const
Returns the planar, 2-dimensional length of the geometry.
Type
The WKB type describes the number of dimensions a geometry has.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle.
QgsPoint operator*() const
Returns the current item.
QgsWkbTypes::Type mWkbType
A rectangle specified with double values.
virtual int vertexCount(int part=0, int ring=0) const =0
Returns the number of vertices of which this geometry is built.
bool operator==(const vertex_iterator &other) const
QgsAbstractGeometry()=default
Constructor for QgsAbstractGeometry.
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
bool isMeasure() const SIP_HOLDGIL
Returns true if the geometry contains m values.
const QgsAbstractGeometry * operator*() const
Returns the current item.
The part_iterator class provides STL-style iterator for geometry parts.
virtual double area() const
Returns the planar, 2-dimensional area of the geometry.
static Type addM(Type type) SIP_HOLDGIL
Adds the m dimension to a WKB type and returns the new type.
double & rx()
Returns a reference to the x-coordinate of this point.
virtual int dimension() const =0
Returns the inherent dimension of the geometry.
int partCount() const override
Returns count of parts contained in the geometry.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
virtual bool hasChildGeometries() const
Returns whether the geometry has any child geometries (false for point / curve, true otherwise)
virtual json asJsonObject(int precision=17) const
Returns a json object representation of the geometry.
The part_iterator class provides STL-style iterator for const references to geometry parts.
virtual QgsPoint childPoint(int index) const
Returns point at index (for geometries without child geometries - i.e.
const_part_iterator()=default
Create invalid iterator.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
const_part_iterator & operator++()
The prefix ++ operator (++it) advances the iterator to the next part and returns an iterator to the n...
static bool hasM(Type type) SIP_HOLDGIL
Tests whether a WKB type contains m values.
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
part_iterator()=default
Create invalid iterator.
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
QgsVertexId vertexId() const
Returns vertex ID of the current item.
const_part_iterator const_parts_end() const
Returns STL-style iterator pointing to the imaginary const part after the last part of the geometry.
virtual void clear()=0
Clears the geometry, ie reset it to a null geometry.
QgsPoint next()
Returns next vertex of the geometry (undefined behavior if hasNext() returns false before calling nex...
QVector< QgsPointSequence > QgsRingSequence
virtual bool isEmpty() const
Returns true if the geometry is empty.
part_iterator & operator++()
The prefix ++ operator (++it) advances the iterator to the next part and returns an iterator to the n...
Abstract base class for all geometries.
const QgsAbstractGeometry * next()
Returns next part of the geometry (undefined behavior if hasNext() returns false before calling next(...
virtual QgsAbstractGeometry * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves.
virtual QString geometryType() const =0
Returns a unique string representing the geometry type.
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
The vertex_iterator class provides STL-style iterator for vertices.
virtual QgsPoint centroid() const
Returns the centroid of the geometry.
QgsAbstractGeometry & operator=(const QgsAbstractGeometry &geom)
QVector< QgsPoint > QgsPointSequence
Java-style iterator for traversal of parts of a geometry.
part_iterator parts_end()
Returns STL-style iterator pointing to the imaginary part after the last part of the geometry.
QgsVertexIterator vertices() const
Returns a read-only, Java-style iterator for traversal of vertices of all the geometry,...
Utility class for identifying a unique vertex within a geometry.
QgsAbstractGeometry * next()
Returns next part of the geometry (undefined behavior if hasNext() returns false before calling next(...
virtual double perimeter() const
Returns the planar, 2-dimensional perimeter of the geometry.
bool operator==(part_iterator other) const
virtual void transformVertices(const std::function< QgsPoint(const QgsPoint &) > &transform)
Transforms the vertices from the geometry in place, applying the transform function to every vertex.
int partNumber() const
Returns the part number of the current item.
VertexType
Type of vertex.
Java-style iterator for traversal of vertices of a geometry.
virtual bool convertTo(QgsWkbTypes::Type type)
Converts the geometry to a specified type.
static bool hasZ(Type type) SIP_HOLDGIL
Tests whether a WKB type contains the z-dimension.
void setZMTypeFromSubGeometry(const QgsAbstractGeometry *subggeom, QgsWkbTypes::Type baseGeomType)
Updates the geometry type based on whether sub geometries contain z or m values.
double & ry()
Returns a reference to the y-coordinate of this point.
vertex_iterator()=default
Create invalid iterator.
QString asJson(int precision=17)
Returns a GeoJSON representation of the geometry as a QString.
static bool isMultiType(Type type) SIP_HOLDGIL
Returns true if the WKB type is a multi type.
int partNumber() const
Returns the part number of the current item.
virtual bool nextVertex(QgsVertexId &id, QgsPoint &vertex) const =0
Returns next vertex id and coordinates.
virtual QgsRectangle calculateBoundingBox() const
Default calculator for the minimal bounding box for the geometry.