mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-12 00:06:54 -05:00
The comparisons among QGIS were conducted on coordinates using a fixed epsilon: specifically, 1e-8 for QgsPoint and the default value for qgsDoubleNear: 4 * DBL_EPSILON. Initially, I've standardized its use to 1e-8 universally; it's already significantly adequate for our Cartesian cases (1e-3 should suffice for many), potentially fitting just right for geographical contexts. Furthermore, in response to precision concerns, we're using the fuzzyEqual and fuzzyDistanceEqual methods. These methods enable users/developers to compare geometries more easily and with a given precision. The API remains intact as operator==/equals() have been shifted into fuzzyEqual (with an epsilon of 1e-8). To consolidate the code between fuzzyEqual and fuzzyDistanceEqual, helper functions, fuzzyHelpers, have been introduced following the logic of the respective segments to be executed.
895 lines
26 KiB
Plaintext
895 lines
26 KiB
Plaintext
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/core/geometry/qgslinestring.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class QgsLineString: QgsCurve
|
|
{
|
|
%Docstring(signature="appended")
|
|
Line string geometry type, with support for z-dimension and m-values.
|
|
|
|
.. versionadded:: 2.10
|
|
%End
|
|
|
|
%TypeHeaderCode
|
|
#include "qgslinestring.h"
|
|
%End
|
|
public:
|
|
|
|
QgsLineString() /HoldGIL/;
|
|
%Docstring
|
|
Constructor for an empty linestring geometry.
|
|
%End
|
|
|
|
QgsLineString( SIP_PYOBJECT points /TypeHint="Sequence[Union[QgsPoint, QgsPointXY, Sequence[float]]]"/ ) /HoldGIL/ [( const QVector<double> &x, const QVector<double> &y, const QVector<double> &z = QVector<double>(), const QVector<double> &m = QVector<double>(), bool is25DType = false )];
|
|
%Docstring
|
|
Construct a linestring from a sequence of points (:py:class:`QgsPoint` objects, :py:class:`QgsPointXY` objects, or sequences of float values).
|
|
|
|
The linestring Z and M type will be set based on the type of the first point in the sequence.
|
|
|
|
.. versionadded:: 3.20
|
|
%End
|
|
%MethodCode
|
|
if ( !PySequence_Check( a0 ) )
|
|
{
|
|
PyErr_SetString( PyExc_TypeError, QStringLiteral( "A sequence of QgsPoint, QgsPointXY or array of floats is expected" ).toUtf8().constData() );
|
|
sipIsErr = 1;
|
|
}
|
|
else
|
|
{
|
|
int state;
|
|
const int size = PySequence_Size( a0 );
|
|
QVector< double > xl;
|
|
QVector< double > yl;
|
|
bool hasZ = false;
|
|
QVector< double > zl;
|
|
bool hasM = false;
|
|
QVector< double > ml;
|
|
xl.reserve( size );
|
|
yl.reserve( size );
|
|
|
|
bool is25D = false;
|
|
|
|
sipIsErr = 0;
|
|
for ( int i = 0; i < size; ++i )
|
|
{
|
|
PyObject *value = PySequence_GetItem( a0, i );
|
|
if ( !value )
|
|
{
|
|
PyErr_SetString( PyExc_TypeError, QStringLiteral( "Invalid type at index %1." ).arg( i ) .toUtf8().constData() );
|
|
sipIsErr = 1;
|
|
break;
|
|
}
|
|
|
|
if ( PySequence_Check( value ) )
|
|
{
|
|
const int elementSize = PySequence_Size( value );
|
|
if ( elementSize < 2 || elementSize > 4 )
|
|
{
|
|
sipIsErr = 1;
|
|
PyErr_SetString( PyExc_TypeError, QStringLiteral( "Invalid sequence size at index %1. Expected an array of 2-4 float values, got %2." ).arg( i ).arg( elementSize ).toUtf8().constData() );
|
|
Py_DECREF( value );
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
sipIsErr = 0;
|
|
for ( int j = 0; j < elementSize; ++j )
|
|
{
|
|
PyObject *element = PySequence_GetItem( value, j );
|
|
if ( !element )
|
|
{
|
|
PyErr_SetString( PyExc_TypeError, QStringLiteral( "Invalid type at index %1." ).arg( i ) .toUtf8().constData() );
|
|
sipIsErr = 1;
|
|
break;
|
|
}
|
|
|
|
PyErr_Clear();
|
|
double d = PyFloat_AsDouble( element );
|
|
if ( PyErr_Occurred() )
|
|
{
|
|
Py_DECREF( value );
|
|
sipIsErr = 1;
|
|
break;
|
|
}
|
|
if ( j == 0 )
|
|
xl.append( d );
|
|
else if ( j == 1 )
|
|
yl.append( d );
|
|
|
|
if ( i == 0 && j == 2 )
|
|
{
|
|
hasZ = true;
|
|
zl.reserve( size );
|
|
zl.append( d );
|
|
}
|
|
else if ( i > 0 && j == 2 && hasZ )
|
|
{
|
|
zl.append( d );
|
|
}
|
|
|
|
if ( i == 0 && j == 3 )
|
|
{
|
|
hasM = true;
|
|
ml.reserve( size );
|
|
ml.append( d );
|
|
}
|
|
else if ( i > 0 && j == 3 && hasM )
|
|
{
|
|
ml.append( d );
|
|
}
|
|
|
|
Py_DECREF( element );
|
|
}
|
|
|
|
if ( hasZ && elementSize < 3 )
|
|
zl.append( std::numeric_limits< double >::quiet_NaN() );
|
|
if ( hasM && elementSize < 4 )
|
|
ml.append( std::numeric_limits< double >::quiet_NaN() );
|
|
|
|
Py_DECREF( value );
|
|
if ( sipIsErr )
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ( sipCanConvertToType( value, sipType_QgsPointXY, SIP_NOT_NONE ) )
|
|
{
|
|
sipIsErr = 0;
|
|
QgsPointXY *p = reinterpret_cast<QgsPointXY *>( sipConvertToType( value, sipType_QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
|
|
if ( !sipIsErr )
|
|
{
|
|
xl.append( p->x() );
|
|
yl.append( p->y() );
|
|
}
|
|
sipReleaseType( p, sipType_QgsPointXY, state );
|
|
}
|
|
else if ( sipCanConvertToType( value, sipType_QgsPoint, SIP_NOT_NONE ) )
|
|
{
|
|
sipIsErr = 0;
|
|
QgsPoint *p = reinterpret_cast<QgsPoint *>( sipConvertToType( value, sipType_QgsPoint, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
|
|
if ( !sipIsErr )
|
|
{
|
|
xl.append( p->x() );
|
|
yl.append( p->y() );
|
|
|
|
if ( i == 0 && p->is3D() )
|
|
{
|
|
hasZ = true;
|
|
zl.reserve( size );
|
|
zl.append( p->z() );
|
|
}
|
|
else if ( i > 0 && hasZ )
|
|
{
|
|
zl.append( p->z() );
|
|
}
|
|
|
|
if ( i == 0 && p->isMeasure() )
|
|
{
|
|
hasM = true;
|
|
ml.reserve( size );
|
|
ml.append( p->m() );
|
|
}
|
|
else if ( i > 0 && hasM )
|
|
{
|
|
ml.append( p->m() );
|
|
}
|
|
|
|
if ( i == 0 && p->wkbType() == Qgis::WkbType::Point25D )
|
|
is25D = true;
|
|
}
|
|
sipReleaseType( p, sipType_QgsPoint, state );
|
|
}
|
|
else
|
|
{
|
|
sipIsErr = 1;
|
|
}
|
|
|
|
Py_DECREF( value );
|
|
|
|
if ( sipIsErr )
|
|
{
|
|
// couldn't convert the sequence value to a QgsPoint or QgsPointXY
|
|
PyErr_SetString( PyExc_TypeError, QStringLiteral( "Invalid type at index %1. Expected QgsPoint, QgsPointXY or array of floats." ).arg( i ) .toUtf8().constData() );
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if ( sipIsErr == 0 )
|
|
sipCpp = new sipQgsLineString( QgsLineString( xl, yl, zl, ml, is25D ) );
|
|
}
|
|
%End
|
|
|
|
explicit QgsLineString( const QgsLineSegment2D &segment ) /HoldGIL/;
|
|
%Docstring
|
|
Construct a linestring from a single 2d line segment.
|
|
|
|
.. versionadded:: 3.2
|
|
%End
|
|
|
|
QgsLineString( const QVector<double> &x, const QVector<double> &y,
|
|
const QVector<double> &z = QVector<double>(),
|
|
const QVector<double> &m = QVector<double>(), bool is25DType = false ) /HoldGIL/;
|
|
%Docstring
|
|
Construct a linestring from arrays of coordinates. If the z or m
|
|
arrays are non-empty then the resultant linestring will have
|
|
z and m types accordingly.
|
|
This constructor is more efficient then calling :py:func:`~QgsLineString.setPoints`
|
|
or repeatedly calling :py:func:`~QgsLineString.addVertex`
|
|
|
|
If the ``z`` vector is filled, then the geometry type will either
|
|
be a LineStringZ(M) or LineString25D depending on the ``is25DType``
|
|
argument. If ``is25DType`` is ``True`` (and the ``m`` vector is unfilled) then
|
|
the created Linestring will be a LineString25D type. Otherwise, the
|
|
LineString will be LineStringZ (or LineStringZM) type.
|
|
|
|
If the sizes of ``x`` and ``y`` are non-equal then the resultant linestring
|
|
will be created using the minimum size of these arrays.
|
|
|
|
.. versionadded:: 3.0
|
|
%End
|
|
|
|
QgsLineString( const QgsPoint &p1, const QgsPoint &p2 ) /HoldGIL/;
|
|
%Docstring
|
|
Constructs a linestring with a single segment from ``p1`` to ``p2``.
|
|
|
|
.. versionadded:: 3.2
|
|
%End
|
|
|
|
static QgsLineString *fromBezierCurve( const QgsPoint &start, const QgsPoint &controlPoint1, const QgsPoint &controlPoint2, const QgsPoint &end, int segments = 30 ) /Factory/;
|
|
%Docstring
|
|
Returns a new linestring created by segmentizing the bezier curve between ``start`` and ``end``, with
|
|
the specified control points.
|
|
|
|
The ``segments`` parameter controls how many line segments will be present in the returned linestring.
|
|
|
|
Any z or m values present in the input coordinates will be interpolated along with the x and y values.
|
|
|
|
.. versionadded:: 3.10
|
|
%End
|
|
|
|
static QgsLineString *fromQPolygonF( const QPolygonF &polygon ) /Factory/;
|
|
%Docstring
|
|
Returns a new linestring from a QPolygonF ``polygon`` input.
|
|
|
|
.. versionadded:: 3.10
|
|
%End
|
|
|
|
public:
|
|
virtual bool fuzzyEqual( const QgsAbstractGeometry &other, double epsilon = 1e-8 ) const /HoldGIL/;
|
|
|
|
virtual bool fuzzyDistanceEqual( const QgsAbstractGeometry &other, double epsilon = 1e-8 ) const /HoldGIL/;
|
|
|
|
virtual bool equals( const QgsCurve &other ) const;
|
|
|
|
|
|
|
|
SIP_PYOBJECT pointN( int i ) const /TypeHint="QgsPoint"/;
|
|
%Docstring
|
|
Returns the point at the specified index.
|
|
|
|
Indexes can be less than 0, in which case they correspond to positions from the end of the line. E.g. an index of -1
|
|
corresponds to the last point in the line.
|
|
|
|
:raises IndexError: if no point with the specified index exists.
|
|
%End
|
|
%MethodCode
|
|
const int count = sipCpp->numPoints();
|
|
if ( a0 < -count || a0 >= count )
|
|
{
|
|
PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
|
|
sipIsErr = 1;
|
|
}
|
|
else
|
|
{
|
|
std::unique_ptr< QgsPoint > p;
|
|
if ( a0 >= 0 )
|
|
p = std::make_unique< QgsPoint >( sipCpp->pointN( a0 ) );
|
|
else // negative index, count backwards from end
|
|
p = std::make_unique< QgsPoint >( sipCpp->pointN( count + a0 ) );
|
|
sipRes = sipConvertFromType( p.release(), sipType_QgsPoint, Py_None );
|
|
}
|
|
%End
|
|
|
|
|
|
virtual double xAt( int index ) const;
|
|
|
|
%Docstring
|
|
Returns the x-coordinate of the specified node in the line string.
|
|
|
|
Indexes can be less than 0, in which case they correspond to positions from the end of the line. E.g. an index of -1
|
|
corresponds to the last point in the line.
|
|
|
|
:raises IndexError: if no point with the specified index exists.
|
|
%End
|
|
%MethodCode
|
|
const int count = sipCpp->numPoints();
|
|
if ( a0 < -count || a0 >= count )
|
|
{
|
|
PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
|
|
sipIsErr = 1;
|
|
}
|
|
else
|
|
{
|
|
if ( a0 >= 0 )
|
|
return PyFloat_FromDouble( sipCpp->xAt( a0 ) );
|
|
else
|
|
return PyFloat_FromDouble( sipCpp->xAt( count + a0 ) );
|
|
}
|
|
%End
|
|
|
|
|
|
virtual double yAt( int index ) const;
|
|
|
|
%Docstring
|
|
Returns the y-coordinate of the specified node in the line string.
|
|
|
|
Indexes can be less than 0, in which case they correspond to positions from the end of the line. E.g. an index of -1
|
|
corresponds to the last point in the line.
|
|
|
|
:raises IndexError: if no point with the specified index exists.
|
|
%End
|
|
%MethodCode
|
|
const int count = sipCpp->numPoints();
|
|
if ( a0 < -count || a0 >= count )
|
|
{
|
|
PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
|
|
sipIsErr = 1;
|
|
}
|
|
else
|
|
{
|
|
if ( a0 >= 0 )
|
|
return PyFloat_FromDouble( sipCpp->yAt( a0 ) );
|
|
else
|
|
return PyFloat_FromDouble( sipCpp->yAt( count + a0 ) );
|
|
}
|
|
%End
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual double zAt( int index ) const;
|
|
|
|
%Docstring
|
|
Returns the z-coordinate of the specified node in the line string.
|
|
|
|
If the LineString does not have a z-dimension then ``nan`` will be returned.
|
|
|
|
Indexes can be less than 0, in which case they correspond to positions from the end of the line. E.g. an index of -1
|
|
corresponds to the last point in the line.
|
|
|
|
:raises IndexError: if no point with the specified index exists.
|
|
%End
|
|
%MethodCode
|
|
const int count = sipCpp->numPoints();
|
|
if ( a0 < -count || a0 >= count )
|
|
{
|
|
PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
|
|
sipIsErr = 1;
|
|
}
|
|
else
|
|
{
|
|
if ( a0 >= 0 )
|
|
return PyFloat_FromDouble( sipCpp->zAt( a0 ) );
|
|
else
|
|
return PyFloat_FromDouble( sipCpp->zAt( count + a0 ) );
|
|
}
|
|
%End
|
|
|
|
|
|
virtual double mAt( int index ) const;
|
|
|
|
%Docstring
|
|
Returns the m-coordinate of the specified node in the line string.
|
|
|
|
If the LineString does not have a m-dimension then ``nan`` will be returned.
|
|
|
|
Indexes can be less than 0, in which case they correspond to positions from the end of the line. E.g. an index of -1
|
|
corresponds to the last point in the line.
|
|
|
|
:raises IndexError: if no point with the specified index exists.
|
|
%End
|
|
%MethodCode
|
|
const int count = sipCpp->numPoints();
|
|
if ( a0 < -count || a0 >= count )
|
|
{
|
|
PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
|
|
sipIsErr = 1;
|
|
}
|
|
else
|
|
{
|
|
if ( a0 >= 0 )
|
|
return PyFloat_FromDouble( sipCpp->mAt( a0 ) );
|
|
else
|
|
return PyFloat_FromDouble( sipCpp->mAt( count + a0 ) );
|
|
}
|
|
%End
|
|
|
|
|
|
void setXAt( int index, double x );
|
|
%Docstring
|
|
Sets the x-coordinate of the specified node in the line string.
|
|
The corresponding node must already exist in line string.
|
|
|
|
Indexes can be less than 0, in which case they correspond to positions from the end of the line. E.g. an index of -1
|
|
corresponds to the last point in the line.
|
|
|
|
:raises IndexError: if no point with the specified index exists.
|
|
|
|
.. seealso:: :py:func:`xAt`
|
|
%End
|
|
%MethodCode
|
|
const int count = sipCpp->numPoints();
|
|
if ( a0 < -count || a0 >= count )
|
|
{
|
|
PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
|
|
sipIsErr = 1;
|
|
}
|
|
else
|
|
{
|
|
if ( a0 >= 0 )
|
|
sipCpp->setXAt( a0, a1 );
|
|
else
|
|
sipCpp->setXAt( count + a0, a1 );
|
|
}
|
|
%End
|
|
|
|
|
|
void setYAt( int index, double y );
|
|
%Docstring
|
|
Sets the y-coordinate of the specified node in the line string.
|
|
The corresponding node must already exist in line string.
|
|
|
|
Indexes can be less than 0, in which case they correspond to positions from the end of the line. E.g. an index of -1
|
|
corresponds to the last point in the line.
|
|
|
|
:raises IndexError: if no point with the specified index exists.
|
|
|
|
.. seealso:: :py:func:`yAt`
|
|
%End
|
|
%MethodCode
|
|
const int count = sipCpp->numPoints();
|
|
if ( a0 < -count || a0 >= count )
|
|
{
|
|
PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
|
|
sipIsErr = 1;
|
|
}
|
|
else
|
|
{
|
|
if ( a0 >= 0 )
|
|
sipCpp->setYAt( a0, a1 );
|
|
else
|
|
sipCpp->setYAt( count + a0, a1 );
|
|
}
|
|
%End
|
|
|
|
|
|
void setZAt( int index, double z );
|
|
%Docstring
|
|
Sets the z-coordinate of the specified node in the line string.
|
|
The corresponding node must already exist in line string and the line string must have z-dimension.
|
|
|
|
Indexes can be less than 0, in which case they correspond to positions from the end of the line. E.g. an index of -1
|
|
corresponds to the last point in the line.
|
|
|
|
:raises IndexError: if no point with the specified index exists.
|
|
|
|
.. seealso:: :py:func:`zAt`
|
|
%End
|
|
%MethodCode
|
|
const int count = sipCpp->numPoints();
|
|
if ( a0 < -count || a0 >= count )
|
|
{
|
|
PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
|
|
sipIsErr = 1;
|
|
}
|
|
else
|
|
{
|
|
if ( a0 >= 0 )
|
|
sipCpp->setZAt( a0, a1 );
|
|
else
|
|
sipCpp->setZAt( count + a0, a1 );
|
|
}
|
|
%End
|
|
|
|
|
|
void setMAt( int index, double m );
|
|
%Docstring
|
|
Sets the m-coordinate of the specified node in the line string.
|
|
The corresponding node must already exist in line string and the line string must have m-dimension.
|
|
|
|
Indexes can be less than 0, in which case they correspond to positions from the end of the line. E.g. an index of -1
|
|
corresponds to the last point in the line.
|
|
|
|
:raises IndexError: if no point with the specified index exists.
|
|
|
|
.. seealso:: :py:func:`mAt`
|
|
%End
|
|
%MethodCode
|
|
const int count = sipCpp->numPoints();
|
|
if ( a0 < -count || a0 >= count )
|
|
{
|
|
PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
|
|
sipIsErr = 1;
|
|
}
|
|
else
|
|
{
|
|
if ( a0 >= 0 )
|
|
sipCpp->setMAt( a0, a1 );
|
|
else
|
|
sipCpp->setMAt( count + a0, a1 );
|
|
}
|
|
%End
|
|
|
|
|
|
void setPoints( const QgsPointSequence &points );
|
|
%Docstring
|
|
Resets the line string to match the specified list of points. The line string will
|
|
inherit the dimensionality of the first point in the list.
|
|
|
|
:param points: new points for line string. If empty, line string will be cleared.
|
|
%End
|
|
|
|
void append( const QgsLineString *line );
|
|
%Docstring
|
|
Appends the contents of another line string to the end of this line string.
|
|
|
|
:param line: line to append. Ownership is not transferred.
|
|
%End
|
|
|
|
void addVertex( const QgsPoint &pt );
|
|
%Docstring
|
|
Adds a new vertex to the end of the line string.
|
|
|
|
:param pt: vertex to add
|
|
%End
|
|
|
|
void close();
|
|
%Docstring
|
|
Closes the line string by appending the first point to the end of the line, if it is not already closed.
|
|
%End
|
|
|
|
virtual QgsCompoundCurve *toCurveType() const /Factory/;
|
|
|
|
%Docstring
|
|
Returns the geometry converted to the more generic curve type :py:class:`QgsCompoundCurve`
|
|
|
|
:return: the converted geometry. Caller takes ownership
|
|
%End
|
|
|
|
void extend( double startDistance, double endDistance );
|
|
%Docstring
|
|
Extends the line geometry by extrapolating out the start or end of the line
|
|
by a specified distance. Lines are extended using the bearing of the first or last
|
|
segment in the line.
|
|
|
|
.. versionadded:: 3.0
|
|
%End
|
|
|
|
|
|
virtual QString geometryType() const /HoldGIL/;
|
|
|
|
virtual int dimension() const /HoldGIL/;
|
|
|
|
virtual QgsLineString *clone() const /Factory/;
|
|
|
|
virtual void clear();
|
|
|
|
virtual bool isEmpty() const /HoldGIL/;
|
|
|
|
int indexOf( const QgsPoint &point ) const final;
|
|
virtual bool isValid( QString &error /Out/, Qgis::GeometryValidityFlags flags = Qgis::GeometryValidityFlags() ) const;
|
|
|
|
virtual QgsLineString *snappedToGrid( double hSpacing, double vSpacing, double dSpacing = 0, double mSpacing = 0 ) const /Factory/;
|
|
|
|
virtual bool removeDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false );
|
|
|
|
virtual bool isClosed() const /HoldGIL/;
|
|
|
|
virtual bool isClosed2D() const /HoldGIL/;
|
|
|
|
virtual bool boundingBoxIntersects( const QgsRectangle &rectangle ) const /HoldGIL/;
|
|
|
|
virtual bool boundingBoxIntersects( const QgsBox3D &box3d ) const /HoldGIL/;
|
|
|
|
|
|
QVector< QgsVertexId > collectDuplicateNodes( double epsilon = 4 * DBL_EPSILON, bool useZValues = false ) const;
|
|
%Docstring
|
|
Returns a list of any duplicate nodes contained in the geometry, within the specified tolerance.
|
|
|
|
If ``useZValues`` is ``True`` then z values will also be considered when testing for duplicates.
|
|
|
|
.. versionadded:: 3.16
|
|
%End
|
|
|
|
virtual QPolygonF asQPolygonF() const;
|
|
|
|
|
|
virtual bool fromWkb( QgsConstWkbPtr &wkb );
|
|
|
|
virtual bool fromWkt( const QString &wkt );
|
|
|
|
|
|
virtual int wkbSize( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
|
|
|
|
virtual QByteArray asWkb( QgsAbstractGeometry::WkbFlags flags = QgsAbstractGeometry::WkbFlags() ) const;
|
|
|
|
virtual QString asWkt( int precision = 17 ) const;
|
|
|
|
virtual QDomElement asGml2( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const;
|
|
|
|
virtual QDomElement asGml3( QDomDocument &doc, int precision = 17, const QString &ns = "gml", QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) const;
|
|
|
|
virtual QString asKml( int precision = 17 ) const;
|
|
|
|
|
|
virtual double length() const /HoldGIL/;
|
|
|
|
|
|
|
|
double length3D() const /HoldGIL/;
|
|
%Docstring
|
|
Returns the length in 3D world of the line string.
|
|
If it is not a 3D line string, return its 2D length.
|
|
|
|
.. seealso:: :py:func:`length`
|
|
|
|
.. versionadded:: 3.10
|
|
%End
|
|
virtual QgsPoint startPoint() const /HoldGIL/;
|
|
|
|
virtual QgsPoint endPoint() const /HoldGIL/;
|
|
|
|
|
|
virtual QgsLineString *curveToLine( double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const /Factory/;
|
|
|
|
%Docstring
|
|
Returns a new line string geometry corresponding to a segmentized approximation
|
|
of the curve.
|
|
|
|
:param tolerance: segmentation tolerance
|
|
:param toleranceType: maximum segmentation angle or maximum difference between approximation and curve
|
|
%End
|
|
|
|
virtual int numPoints() const /HoldGIL/;
|
|
|
|
virtual int nCoordinates() const /HoldGIL/;
|
|
|
|
virtual void points( QgsPointSequence &pt /Out/ ) const;
|
|
|
|
|
|
virtual void draw( QPainter &p ) const;
|
|
|
|
|
|
virtual void transform( const QgsCoordinateTransform &ct, Qgis::TransformDirection d = Qgis::TransformDirection::Forward, bool transformZ = false ) throw( QgsCsException );
|
|
|
|
virtual void transform( const QTransform &t, double zTranslate = 0.0, double zScale = 1.0, double mTranslate = 0.0, double mScale = 1.0 );
|
|
|
|
|
|
virtual void addToPainterPath( QPainterPath &path ) const;
|
|
|
|
virtual void drawAsPolygon( QPainter &p ) const;
|
|
|
|
|
|
virtual bool insertVertex( QgsVertexId position, const QgsPoint &vertex );
|
|
|
|
virtual bool moveVertex( QgsVertexId position, const QgsPoint &newPos );
|
|
|
|
virtual bool deleteVertex( QgsVertexId position );
|
|
|
|
|
|
virtual QgsLineString *reversed() const /Factory/;
|
|
|
|
virtual QgsPoint *interpolatePoint( double distance ) const /Factory/;
|
|
|
|
virtual QgsLineString *curveSubstring( double startDistance, double endDistance ) const /Factory/;
|
|
|
|
|
|
virtual double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt /Out/, QgsVertexId &vertexAfter /Out/, int *leftOf /Out/ = 0, double epsilon = 4 * DBL_EPSILON ) const;
|
|
|
|
virtual bool pointAt( int node, QgsPoint &point, Qgis::VertexType &type ) const;
|
|
|
|
|
|
virtual QgsPoint centroid() const;
|
|
|
|
|
|
virtual void sumUpArea( double &sum /Out/ ) const;
|
|
|
|
%Docstring
|
|
Calculates the shoelace/triangle formula sum for the points in the linestring.
|
|
If the linestring is closed (i.e. a polygon) then the polygon area is equal to the absolute value of the sum.
|
|
Please note that the sum will be negative if the points are defined in clockwise order.
|
|
Therefore, if you want to use the sum as an area (as the method name indicates) then you probably should use the absolute value,
|
|
since otherwise a bug can be introduced (such as the bug fixed for github issue 49578)
|
|
|
|
.. seealso:: :py:func:`https`
|
|
%End
|
|
|
|
virtual double vertexAngle( QgsVertexId vertex ) const;
|
|
|
|
virtual double segmentLength( QgsVertexId startVertex ) const;
|
|
|
|
virtual bool addZValue( double zValue = 0 );
|
|
|
|
virtual bool addMValue( double mValue = 0 );
|
|
|
|
|
|
virtual bool dropZValue();
|
|
|
|
virtual bool dropMValue();
|
|
|
|
virtual void swapXy();
|
|
|
|
|
|
virtual bool convertTo( Qgis::WkbType type );
|
|
|
|
|
|
virtual bool transform( QgsAbstractGeometryTransformer *transformer, QgsFeedback *feedback = 0 );
|
|
|
|
void scroll( int firstVertexIndex ) final;
|
|
|
|
|
|
virtual QgsLineString *createEmptyWithSameType() const /Factory/;
|
|
|
|
|
|
SIP_PYOBJECT __repr__();
|
|
%MethodCode
|
|
QString wkt = sipCpp->asWkt();
|
|
if ( wkt.length() > 1000 )
|
|
wkt = wkt.left( 1000 ) + QStringLiteral( "..." );
|
|
QString str = QStringLiteral( "<QgsLineString: %1>" ).arg( wkt );
|
|
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
|
|
%End
|
|
|
|
SIP_PYOBJECT __getitem__( int index ) /TypeHint="QgsPoint"/;
|
|
%Docstring
|
|
Returns the point at the specified ``index``.
|
|
|
|
Indexes can be less than 0, in which case they correspond to positions from the end of the line. E.g. an index of -1
|
|
corresponds to the last point in the line.
|
|
|
|
:raises IndexError: if no point with the specified ``index`` exists.
|
|
|
|
.. versionadded:: 3.6
|
|
%End
|
|
%MethodCode
|
|
const int count = sipCpp->numPoints();
|
|
if ( a0 < -count || a0 >= count )
|
|
{
|
|
PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
|
|
sipIsErr = 1;
|
|
}
|
|
else
|
|
{
|
|
std::unique_ptr< QgsPoint > p;
|
|
if ( a0 >= 0 )
|
|
p = std::make_unique< QgsPoint >( sipCpp->pointN( a0 ) );
|
|
else
|
|
p = std::make_unique< QgsPoint >( sipCpp->pointN( count + a0 ) );
|
|
sipRes = sipConvertFromType( p.release(), sipType_QgsPoint, Py_None );
|
|
}
|
|
%End
|
|
|
|
void __setitem__( int index, const QgsPoint &point );
|
|
%Docstring
|
|
Sets the point at the specified ``index``.
|
|
|
|
Indexes can be less than 0, in which case they correspond to positions from the end of the line. E.g. an index of -1
|
|
corresponds to the last point in the line.
|
|
|
|
:raises IndexError: if no point with the specified ``index`` exists.
|
|
|
|
.. versionadded:: 3.6
|
|
%End
|
|
%MethodCode
|
|
const int count = sipCpp->numPoints();
|
|
if ( a0 < -count || a0 >= count )
|
|
{
|
|
PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
|
|
sipIsErr = 1;
|
|
}
|
|
else
|
|
{
|
|
if ( a0 < 0 )
|
|
a0 = count + a0;
|
|
sipCpp->setXAt( a0, a1->x() );
|
|
sipCpp->setYAt( a0, a1->y() );
|
|
if ( sipCpp->isMeasure() )
|
|
sipCpp->setMAt( a0, a1->m() );
|
|
if ( sipCpp->is3D() )
|
|
sipCpp->setZAt( a0, a1->z() );
|
|
}
|
|
%End
|
|
|
|
|
|
void __delitem__( int index );
|
|
%Docstring
|
|
Deletes the vertex at the specified ``index``.
|
|
|
|
Indexes can be less than 0, in which case they correspond to positions from the end of the line. E.g. an index of -1
|
|
corresponds to the last point in the line.
|
|
|
|
:raises IndexError: if no point with the specified ``index`` exists.
|
|
|
|
.. versionadded:: 3.6
|
|
%End
|
|
%MethodCode
|
|
const int count = sipCpp->numPoints();
|
|
if ( a0 >= 0 && a0 < count )
|
|
sipCpp->deleteVertex( QgsVertexId( -1, -1, a0 ) );
|
|
else if ( a0 < 0 && a0 >= -count )
|
|
sipCpp->deleteVertex( QgsVertexId( -1, -1, count + a0 ) );
|
|
else
|
|
{
|
|
PyErr_SetString( PyExc_IndexError, QByteArray::number( a0 ) );
|
|
sipIsErr = 1;
|
|
}
|
|
%End
|
|
|
|
|
|
QgsBox3D calculateBoundingBox3d() const /Deprecated/;
|
|
%Docstring
|
|
Calculates the minimal 3D bounding box for the geometry.
|
|
Deprecated: use calculateBoundingBox3D instead
|
|
|
|
.. seealso:: :py:func:`calculateBoundingBox`
|
|
|
|
.. versionadded:: 3.26
|
|
|
|
.. deprecated:: QGIS 3.34
|
|
%End
|
|
|
|
virtual QgsBox3D calculateBoundingBox3D() const;
|
|
|
|
%Docstring
|
|
Calculates the minimal 3D bounding box for the geometry.
|
|
|
|
.. seealso:: :py:func:`calculateBoundingBox`
|
|
|
|
.. versionadded:: 3.34
|
|
%End
|
|
|
|
|
|
QgsLineString *measuredLine( double start, double end ) const /Factory/;
|
|
%Docstring
|
|
Re-write the measure ordinate (or add one, if it isn't already there) interpolating
|
|
the measure between the supplied ``start`` and ``end`` values.
|
|
|
|
.. versionadded:: 3.36
|
|
%End
|
|
|
|
protected:
|
|
|
|
int compareToSameClass( const QgsAbstractGeometry *other ) const final;
|
|
|
|
};
|
|
|
|
|
|
/************************************************************************
|
|
* This file has been generated automatically from *
|
|
* *
|
|
* src/core/geometry/qgslinestring.h *
|
|
* *
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
************************************************************************/
|