62 bool hasZ = subgeom->
is3D();
85 double xmin = std::numeric_limits<double>::max();
86 double ymin = std::numeric_limits<double>::max();
87 double xmax = -std::numeric_limits<double>::max();
88 double ymax = -std::numeric_limits<double>::max();
176 for ( ; j < n; i = j++ )
184 double d = vi.
x() * vj.
y() - vj.
x() * vi.
y();
186 Cx += ( vi.
x() + vj.
x() ) * d;
187 Cy += ( vi.
y() + vj.
y() ) * d;
193 for (
int i = 0; i < n - 1; ++i )
199 return QgsPoint( Cx / ( n - 1 ), Cy / ( n - 1 ) );
203 return QgsPoint( v0.
x() + Cx / ( 3. * A ), v0.
y() + Cy / ( 3. * A ) );
223 addZValue( std::numeric_limits<double>::quiet_NaN() );
232 addMValue( std::numeric_limits<double>::quiet_NaN() );
273 Q_UNUSED( tolerance );
274 Q_UNUSED( toleranceType );
282 ::memset( levels, 0,
sizeof( Level ) * 3 );
284 levels[0].index = index;
291 if ( depth == 0 && levels[0].index >= levels[0].g->childCount() )
294 Q_ASSERT( !levels[depth].g->hasChildGeometries() );
296 ++levels[depth].index;
299 while ( depth > 0 && levels[depth].index >= levels[depth].g->childCount() )
302 ++levels[depth].index;
319 Q_ASSERT( !levels[depth].g->hasChildGeometries() );
320 return levels[depth].g->childPoint( levels[depth].index );
325 int part = 0, ring = 0, vertex = levels[depth].index;
330 else if ( depth == 1 )
333 part = levels[0].index;
335 ring = levels[0].index;
337 else if ( depth == 2 )
339 part = levels[0].index;
340 ring = levels[1].index;
350 if (
const QgsCurve *curve = dynamic_cast<const QgsCurve *>( levels[depth].g ) )
353 curve->pointAt( vertex, p, vertexType );
356 return QgsVertexId( part, ring, vertex, vertexType );
361 if ( depth != other.depth )
363 int res = ::memcmp( levels, other.levels,
sizeof( Level ) * ( depth + 1 ) );
367 void QgsAbstractGeometry::vertex_iterator::digDown()
369 if ( levels[depth].g->hasChildGeometries() && levels[depth].index >= levels[depth].g->childCount() )
373 while ( levels[depth].g->hasChildGeometries() )
376 Q_ASSERT( depth < 3 );
377 levels[depth].index = 0;
378 levels[depth].g = levels[depth - 1].g->childGeometry( levels[depth - 1].index );
bool isMeasure() const
Returns true if the geometry contains m values.
virtual bool hasChildGeometries() const
Returns whether the geometry has any child geometries (false for point / curve, true otherwise) ...
A rectangle specified with double values.
virtual bool isEmpty() const
Returns true if the geometry is empty.
QgsAbstractGeometry & operator=(const QgsAbstractGeometry &geom)
Java-style iterator for traversal of vertices of a geometry.
static bool isMultiType(Type type)
Returns true if the WKB type is a multi type.
QgsAbstractGeometry()=default
Constructor for QgsAbstractGeometry.
virtual QgsPoint childPoint(int index) const
Returns point at index (for geometries without child geometries - i.e.
QVector< QgsRingSequence > QgsCoordinateSequence
QgsVertexId vertexId() const
Returns vertex ID of the current item.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle...
virtual bool nextVertex(QgsVertexId &id, QgsPoint &vertex) const =0
Returns next vertex id and coordinates.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
vertex_iterator & operator++()
The prefix ++ operator (++it) advances the iterator to the next vertex and returns an iterator to the...
QgsWkbTypes::Type mWkbType
vertex_iterator()=default
Create invalid iterator.
virtual QgsPoint centroid() const
Returns the centroid of the geometry.
bool operator==(const vertex_iterator &other) const
QString wktTypeStr() const
Returns the WKT type string of the geometry.
virtual double length() const
Returns the length of the geometry.
Type
The WKB type describes the number of dimensions a geometry has.
virtual void clearCache() const
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
static Type addM(Type type)
Adds the m dimension to a WKB type and returns the new 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...
Utility class for identifying a unique vertex within a geometry.
void setZMTypeFromSubGeometry(const QgsAbstractGeometry *subggeom, QgsWkbTypes::Type baseGeomType)
Updates the geometry type based on whether sub geometries contain z or m values.
static Type addZ(Type type)
Adds the z dimension to a WKB type and returns the new type.
virtual double area() const
Returns the area of the geometry.
Abstract base class for curved geometry type.
double & rx()
Returns a reference to the x-coordinate of this point.
Abstract base class for all geometries.
virtual int dimension() const =0
Returns the inherent dimension of the geometry.
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.
QVector< QgsPoint > QgsPointSequence
virtual QgsCoordinateSequence coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
QVector< QgsPointSequence > QgsRingSequence
QgsPoint operator*() const
Returns the current item.
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...
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
virtual double perimeter() const
Returns the perimeter of the geometry.
virtual int vertexCount(int part=0, int ring=0) const =0
Returns the number of vertices of which this geometry is built.
virtual QgsRectangle calculateBoundingBox() const
Default calculator for the minimal bounding box for the geometry.
virtual bool convertTo(QgsWkbTypes::Type type)
Converts the geometry to a specified type.
static bool hasM(Type type)
Tests whether a WKB type contains m values.
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
static Type flatType(Type type)
Returns the flat type for a WKB type.
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
virtual QgsAbstractGeometry * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves.
QgsVertexIterator vertices() const
Returns Java-style iterator for traversal of vertices of the geometry.
double & ry()
Returns a reference to the y-coordinate of this point.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
virtual QString geometryType() const =0
Returns a unique string representing the geometry type.