32 return equals( *otherCurve );
51 if (
is3D() && closed )
52 closed &=
qgsDoubleNear( start.
z(), end.
z(), 1E-8 ) || ( std::isnan( start.
z() ) && std::isnan( end.
z() ) );
66 points( sequence.back().back() );
93 return pointAt(
id.vertex, vertex,
id.type );
114 if ( vertex.
vertex == n - 1 )
126 if (
id.part != 0 ||
id.ring != 0 )
128 if (
id.vertex < 0 || id.vertex >=
numPoints() )
186 if ( mBoundingBox.
isNull() )
195 if ( flags == 0 && mHasCachedValidity )
198 error = mValidityFailureReason;
199 return error.isEmpty();
206 mValidityFailureReason = !res ? error : QString();
207 mHasCachedValidity =
true;
216 points.reserve( nb );
217 for (
int i = 0; i < nb; ++i )
219 points << QPointF(
xAt( i ),
yAt( i ) );
233 return std::numeric_limits<double>::quiet_NaN();
248 mHasCachedValidity =
false;
249 mValidityFailureReason.clear();
262 bool res =
pointAt( index, point, type );
269 const QVector<double> &srcX,
const QVector<double> &srcY,
const QVector<double> &srcZ,
const QVector<double> &srcM,
270 QVector<double> &outX, QVector<double> &outY, QVector<double> &outZ, QVector<double> &outM )
const 281 auto roundVertex = [hSpacing, vSpacing, dSpacing, mSpacing, hasZ, hasM, &srcX, &srcY, &srcZ, &srcM](
QgsPoint & out,
int i )
284 out.setX( std::round( srcX.at( i ) / hSpacing ) * hSpacing );
286 out.setX( srcX.at( i ) );
289 out.setY( std::round( srcY.at( i ) / vSpacing ) * vSpacing );
291 out.setY( srcY.at( i ) );
296 out.setZ( std::round( srcZ.at( i ) / dSpacing ) * dSpacing );
298 out.setZ( srcZ.at( i ) );
304 out.setM( std::round( srcM.at( i ) / mSpacing ) * mSpacing );
306 out.setM( srcM.at( i ) );
311 auto append = [hasZ, hasM, &outX, &outY, &outM, &outZ](
QgsPoint const & point )
313 outX.append( point.x() );
315 outY.append( point.y() );
318 outZ.append( point.z() );
321 outM.append( point.m() );
324 auto isPointEqual = [dSpacing, mSpacing, hasZ, hasM](
const QgsPoint & a,
const QgsPoint & b )
326 return ( a.x() == b.x() )
327 && ( a.y() == b.y() )
328 && ( !hasZ || dSpacing <= 0 || a.z() == b.z() )
329 && ( !hasM || mSpacing <= 0 || a.m() == b.m() );
338 roundVertex( last, 0 );
341 for (
int i = 1; i <
length; ++i )
343 roundVertex( current, i );
344 if ( !isPointEqual( current, last ) )
353 if ( outX.length() < 2 || (
isClosed() && outX.length() < 4 ) )
bool isMeasure() const
Returns true if the geometry contains m values.
A rectangle specified with double values.
virtual bool isEmpty() const
Returns true if the geometry is empty.
int partCount() const override
Returns count of parts contained in the geometry.
bool operator==(const QgsAbstractGeometry &other) const override
double sinuosity() const
Returns the curve sinuosity, which is the ratio of the curve length() to curve straightDistance2d().
Multi point geometry collection.
QVector< QgsRingSequence > QgsCoordinateSequence
double distance(double x, double y) const
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
bool nextVertex(QgsVertexId &id, QgsPoint &vertex) const override
Returns next vertex id and coordinates.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
bool isValid(QString *errorMsg=nullptr, bool allowSelfTouchingHoles=false, QgsGeometry *errorLoc=nullptr) const override
Returns true if the geometry is valid.
virtual void sumUpArea(double &sum) const =0
Sums up the area of the curve by iterating over the vertices (shoelace formula).
virtual bool isRing() const
Returns true if the curve is a ring.
void clearCache() const override
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle...
virtual bool pointAt(int node, QgsPoint &point, QgsVertexId::VertexType &type) const =0
Returns the point and vertex id of a point within the curve.
virtual bool equals(const QgsCurve &other) const =0
Checks whether this curve exactly equals another curve.
QgsPoint childPoint(int index) const override
Returns point at index (for geometries without child geometries - i.e.
int childCount() const override
Returns number of child geometries (for geometries with child geometries) or child points (for geomet...
Indicates that self-touching holes are permitted. OGC validity states that self-touching holes are NO...
virtual QgsPoint endPoint() const =0
Returns the end point of the curve.
virtual QPolygonF asQPolygonF() const
Returns a QPolygonF representing the points.
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.
virtual void clearCache() const
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
Utility class for identifying a unique vertex within a geometry.
int vertexCount(int part=0, int ring=0) const override
Returns the number of vertices of which this geometry is built.
T qgsgeometry_cast(const QgsAbstractGeometry *geom)
virtual double xAt(int index) const =0
Returns the x-coordinate of the specified node in the line string.
Orientation
Curve orientation.
Abstract base class for curved geometry type.
Abstract base class for all geometries.
Does vector analysis using the geos library and handles import, export, exception handling*...
QgsPoint vertexAt(QgsVertexId id) const override
Returns the point corresponding to a specified vertex id.
Counter-clockwise orientation.
Point geometry type, with support for z-dimension and m-values.
int vertexNumberFromVertexId(QgsVertexId id) const override
Returns the vertex number corresponding to a vertex id.
QgsAbstractGeometry * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
Contains geos related utilities and functions.
virtual bool isClosed() const
Returns true if the curve is closed.
bool snapToGridPrivate(double hSpacing, double vSpacing, double dSpacing, double mSpacing, const QVector< double > &srcX, const QVector< double > &srcY, const QVector< double > &srcZ, const QVector< double > &srcM, QVector< double > &outX, QVector< double > &outY, QVector< double > &outZ, QVector< double > &outM) const
Helper function for QgsCurve subclasses to snap to grids.
QgsCoordinateSequence coordinateSequence() const override
Retrieves the sequence of geometries, rings and nodes.
Orientation orientation() const
Returns the curve's orientation, e.g.
QVector< QgsPoint > QgsPointSequence
QgsCurve * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
QVector< QgsPointSequence > QgsRingSequence
void reserve(int size)
Attempts to allocate memory for at least size geometries.
QgsCurve * toCurveType() const override
Returns the geometry converted to the more generic curve type.
QgsRectangle boundingBox() const override
Returns the minimal bounding box for the geometry.
double straightDistance2d() const
Returns the straight distance of the curve, i.e.
int ringCount(int part=0) const override
Returns the number of rings of which this geometry is built.
void adjacentVertices(QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex) const override
Returns the vertices adjacent to a specified vertex within a geometry.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
virtual QgsLineString * curveToLine(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const =0
Returns a new line string geometry corresponding to a segmentized approximation of the curve...
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
bool isValid(QString &error, int flags=0) const override
Checks validity of the geometry, and returns true if the geometry is valid.
virtual QgsRectangle calculateBoundingBox() const
Default calculator for the minimal bounding box for the geometry.
virtual double yAt(int index) const =0
Returns the y-coordinate of the specified node in the line string.
static Type zmType(Type type, bool hasZ, bool hasM)
Returns the modified input geometry type according to hasZ / hasM.
virtual QgsPoint startPoint() const =0
Returns the starting point of the curve.
bool operator!=(const QgsAbstractGeometry &other) const override
virtual int numPoints() const =0
Returns the number of points in the curve.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
virtual void points(QgsPointSequence &pt) const =0
Returns a list of points within the curve.