QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
28 const QgsCurve *otherCurve = qgsgeometry_cast< const QgsCurve * >( &other );
32 return equals( *otherCurve );
51 if (
is3D() && closed )
52 closed &=
qgsDoubleNear( start.
z(), end.
z() ) || ( std::isnan( start.
z() ) && std::isnan( end.
z() ) );
73 points( sequence.back().back() );
100 return pointAt(
id.vertex, vertex,
id.type );
121 if ( vertex.
vertex == n - 1 )
133 if (
id.part != 0 ||
id.ring != 0 )
135 if (
id.vertex < 0 || id.vertex >=
numPoints() )
157 std::unique_ptr<QgsLineString> lineString(
curveToLine() );
162 QString kml = lineString->asKml(
precision );
204 if ( mBoundingBox.
isNull() )
213 if ( flags == 0 && mHasCachedValidity )
216 error = mValidityFailureReason;
217 return error.isEmpty();
224 mValidityFailureReason = !res ? error : QString();
225 mHasCachedValidity =
true;
232 std::unique_ptr< QgsLineString > segmentized(
curveToLine() );
233 return segmentized->asQPolygonF();
245 return std::numeric_limits<double>::quiet_NaN();
260 mHasCachedValidity =
false;
261 mValidityFailureReason.clear();
274 bool res =
pointAt( index, point, type );
281 const QVector<double> &srcX,
const QVector<double> &srcY,
const QVector<double> &srcZ,
const QVector<double> &srcM,
282 QVector<double> &outX, QVector<double> &outY, QVector<double> &outZ, QVector<double> &outM )
const
293 auto roundVertex = [hSpacing, vSpacing, dSpacing, mSpacing, hasZ, hasM, &srcX, &srcY, &srcZ, &srcM](
QgsPoint & out,
int i )
296 out.setX( std::round( srcX.at( i ) / hSpacing ) * hSpacing );
298 out.setX( srcX.at( i ) );
301 out.setY( std::round( srcY.at( i ) / vSpacing ) * vSpacing );
303 out.setY( srcY.at( i ) );
308 out.setZ( std::round( srcZ.at( i ) / dSpacing ) * dSpacing );
310 out.setZ( srcZ.at( i ) );
316 out.setM( std::round( srcM.at( i ) / mSpacing ) * mSpacing );
318 out.setM( srcM.at( i ) );
323 auto append = [hasZ, hasM, &outX, &outY, &outM, &outZ](
QgsPoint const & point )
325 outX.append( point.x() );
327 outY.append( point.y() );
330 outZ.append( point.z() );
333 outM.append( point.m() );
336 auto isPointEqual = [dSpacing, mSpacing, hasZ, hasM](
const QgsPoint & a,
const QgsPoint & b )
338 return ( a.x() == b.x() )
339 && ( a.y() == b.y() )
340 && ( !hasZ || dSpacing <= 0 || a.z() == b.z() )
341 && ( !hasM || mSpacing <= 0 || a.m() == b.m() );
350 roundVertex( last, 0 );
353 for (
int i = 1; i <
length; ++i )
355 roundVertex( current, i );
356 if ( !isPointEqual( current, last ) )
365 if ( outX.length() < 2 || (
isClosed() && outX.length() < 4 ) )
bool isValid(QString &error, int flags=0) const override
Checks validity of the geometry, and returns true if the geometry is valid.
Abstract base class for curved geometry type.
bool nextVertex(QgsVertexId &id, QgsPoint &vertex) const override
Returns next vertex id and coordinates.
virtual bool pointAt(int node, QgsPoint &point, QgsVertexId::VertexType &type) const =0
Returns the point and vertex id of a point within the curve.
QVector< QgsRingSequence > QgsCoordinateSequence
virtual bool isRing() const SIP_HOLDGIL
Returns true if the curve is a ring.
virtual void clearCache() const
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
virtual QgsPoint startPoint() const =0
Returns the starting point of the curve.
double distance(double x, double y) const SIP_HOLDGIL
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
QPainterPath asQPainterPath() const override
Returns the geometry represented as a QPainterPath.
Point geometry type, with support for z-dimension and m-values.
bool operator==(const QgsAbstractGeometry &other) const override
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
Contains geos related utilities and functions.
int childCount() const override
Returns number of child geometries (for geometries with child geometries) or child points (for geomet...
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.
virtual void sumUpArea(double &sum) const =0
Sums up the area of the curve by iterating over the vertices (shoelace formula).
A rectangle specified with double values.
int partCount() const override
Returns count of parts contained in the geometry.
void clearCache() const override
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
bool isMeasure() const SIP_HOLDGIL
Returns true if the geometry contains m values.
QString asKml(int precision=17) const override
Returns a KML representation of the geometry.
void adjacentVertices(QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex) const override
Returns the vertices adjacent to a specified vertex within a geometry.
QgsPoint childPoint(int index) const override
Returns point at index (for geometries without child geometries - i.e.
virtual void addToPainterPath(QPainterPath &path) const =0
Adds a curve to a painter path.
virtual QgsPoint endPoint() const =0
Returns the end point of the curve.
int vertexNumberFromVertexId(QgsVertexId id) const override
Returns the vertex number corresponding to a vertex id.
virtual QPolygonF asQPolygonF() const
Returns a QPolygonF representing the points.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
@ FlagAllowSelfTouchingHoles
Indicates that self-touching holes are permitted. OGC validity states that self-touching holes are NO...
@ Clockwise
Clockwise orientation.
virtual bool equals(const QgsCurve &other) const =0
Checks whether this curve exactly equals another curve.
Does vector analysis using the geos library and handles import, export, exception handling*.
@ CounterClockwise
Counter-clockwise orientation.
static Type zmType(Type type, bool hasZ, bool hasM) SIP_HOLDGIL
Returns the modified input geometry type according to hasZ / hasM.
QgsPoint vertexAt(QgsVertexId id) const override
Returns the point corresponding to a specified vertex id.
QVector< QgsPointSequence > QgsRingSequence
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.
virtual bool isEmpty() const
Returns true if the geometry is empty.
QgsCoordinateSequence coordinateSequence() const override
Retrieves the sequence of geometries, rings and nodes.
Multi point geometry collection.
Abstract base class for all geometries.
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
int vertexCount(int part=0, int ring=0) const override
Returns the number of vertices of which this geometry is built.
QVector< QgsPoint > QgsPointSequence
int ringCount(int part=0) const override
Returns the number of rings of which this geometry is built.
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.
Utility class for identifying a unique vertex within a geometry.
QgsAbstractGeometry * boundary() const override
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
VertexType
Type of vertex.
double straightDistance2d() const
Returns the straight distance of the curve, i.e.
virtual void points(QgsPointSequence &pt) const =0
Returns a list of points within the curve.
virtual int numPoints() const =0
Returns the number of points in the curve.
QgsCurve * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
virtual bool isClosed() const SIP_HOLDGIL
Returns true if the curve is closed.
Orientation orientation() const
Returns the curve's orientation, e.g.
void reserve(int size) SIP_HOLDGIL
Attempts to allocate memory for at least size geometries.
Orientation
Curve orientation.
double sinuosity() const
Returns the curve sinuosity, which is the ratio of the curve length() to curve straightDistance2d().
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 operator!=(const QgsAbstractGeometry &other) const override
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
virtual QgsRectangle calculateBoundingBox() const
Default calculator for the minimal bounding box for the geometry.