29using namespace Qt::StringLiterals;
56 Q_PROPERTY(
double x READ
x WRITE
setX )
57 Q_PROPERTY(
double y READ
y WRITE
setY )
58 Q_PROPERTY(
double z READ
z WRITE
setZ )
59 Q_PROPERTY(
double m READ
m WRITE
setM )
90 QgsPoint(
double x = std::numeric_limits<double>::quiet_NaN(),
double y = std::numeric_limits<double>::quiet_NaN(),
double z = std::numeric_limits<double>::quiet_NaN(),
double m = std::numeric_limits<double>::quiet_NaN(),
Qgis::WkbType wkbType =
Qgis::WkbType::Unknown );
92 QgsPoint( SIP_PYOBJECT
x SIP_TYPEHINT( Optional[Union[
QgsPoint, QPointF,
float]] ) = Py_None, SIP_PYOBJECT
y SIP_TYPEHINT( Optional[
float] ) = Py_None, SIP_PYOBJECT
z SIP_TYPEHINT( Optional[
float] ) = Py_None, SIP_PYOBJECT
m SIP_TYPEHINT( Optional[
float] ) = Py_None, SIP_PYOBJECT
wkbType SIP_TYPEHINT( Optional[
int] ) = Py_None ) [(
double x = 0.0,
double y = 0.0,
double z = 0.0,
double m = 0.0,
Qgis::WkbType wkbType =
Qgis::WkbType::Unknown )];
94 if ( sipCanConvertToType( a0, sipType_QgsPointXY, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
99 QgsPointXY *p =
reinterpret_cast<QgsPointXY *
>( sipConvertToType( a0, sipType_QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
102 sipCpp =
new sipQgsPoint(
QgsPoint( *p ) );
104 sipReleaseType( p, sipType_QgsPointXY, state );
106 else if ( sipCanConvertToType( a0, sipType_QPointF, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
111 QPointF *p =
reinterpret_cast<QPointF *
>( sipConvertToType( a0, sipType_QPointF, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
114 sipCpp =
new sipQgsPoint( QgsPoint( *p ) );
116 sipReleaseType( p, sipType_QPointF, state );
119 ( a0 == Py_None || PyFloat_AsDouble( a0 ) != -1.0 || !PyErr_Occurred() ) &&
120 ( a1 == Py_None || PyFloat_AsDouble( a1 ) != -1.0 || !PyErr_Occurred() ) &&
121 ( a2 == Py_None || PyFloat_AsDouble( a2 ) != -1.0 || !PyErr_Occurred() ) &&
122 ( a3 == Py_None || PyFloat_AsDouble( a3 ) != -1.0 || !PyErr_Occurred() ) )
124 double x = a0 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a0 );
125 double y = a1 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a1 );
126 double z = a2 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a2 );
127 double m = a3 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a3 );
129 sipCpp =
new sipQgsPoint( QgsPoint( x, y, z, m, wkbType ) );
133 PyErr_SetString( PyExc_TypeError, u
"Invalid type in constructor arguments."_s.toUtf8().constData() );
142 explicit QgsPoint(
const QgsPointXY &p )
SIP_SKIP;
147 explicit QgsPoint( QPointF p )
SIP_SKIP;
154 explicit QgsPoint(
Qgis::WkbType wkbType,
double x = std::numeric_limits<double>::quiet_NaN(),
double y = std::numeric_limits<double>::quiet_NaN(),
double z = std::numeric_limits<double>::quiet_NaN(),
double m = std::numeric_limits<double>::quiet_NaN() )
SIP_SKIP;
164 explicit QgsPoint( const QVector3D &vect,
double m = std::numeric_limits<
double>::quiet_NaN() )
SIP_SKIP;
173 explicit QgsPoint( const QVector4D &vect )
SIP_SKIP;
183 explicit QgsPoint( const QgsVector3D &vect,
double m = std::numeric_limits<
double>::quiet_NaN() )
SIP_SKIP;
187 bool fuzzyHelper(
double epsilon,
188 const QgsAbstractGeometry &other,
191 std::function<
bool(
double,
double,
double,
double,
double,
double,
double,
double,
double )> comparator3DMeasure,
192 std::function<
bool(
double,
double,
double,
double,
double,
double,
double )> comparator3D,
193 std::function<
bool(
double,
double,
double,
double,
double,
double,
double )> comparatorMeasure,
194 std::function<
bool(
double,
double,
double,
double,
double )> comparator2D )
const
205 if ( is3DFlag && isMeasureFlag )
207 return comparator3DMeasure( epsilon, mX, mY, mZ, mM, pt->
x(), pt->
y(), pt->
z(), pt->
m() );
211 return comparator3D( epsilon, mX, mY, mZ, pt->
x(), pt->
y(), pt->
z() );
213 else if ( isMeasureFlag )
215 return comparatorMeasure( epsilon, mX, mY, mM, pt->
x(), pt->
y(), pt->
m() );
217 return comparator2D( epsilon, mX, mY, pt->
x(), pt->
y() );
229 [](
double epsilon,
double x1,
double y1,
double z1,
double m1,
230 double x2,
double y2,
double z2,
double m2 )
234 [](
double epsilon,
double x1,
double y1,
double z1,
235 double x2,
double y2,
double z2 )
239 [](
double epsilon,
double x1,
double y1,
double m1,
240 double x2,
double y2,
double m2 )
244 [](
double epsilon,
double x1,
double y1,
245 double x2,
double y2 )
258 [](
double epsilon,
double x1,
double y1,
double z1,
double m1,
259 double x2,
double y2,
double z2,
double m2 )
263 [](
double epsilon,
double x1,
double y1,
double z1,
264 double x2,
double y2,
double z2 )
268 [](
double epsilon,
double x1,
double y1,
double m1,
269 double x2,
double y2,
double m2 )
273 [](
double epsilon,
double x1,
double y1,
274 double x2,
double y2 )
411 return QPointF( mX, mY );
421 return QVector3D(
static_cast<float>( mX ),
static_cast<float>( mY ),
static_cast<float>( mZ ) );
431 return QVector4D(
static_cast<float>( mX ),
static_cast<float>( mY ),
static_cast<float>( mZ ),
static_cast<float>( mM ) );
495 if (
is3D() || !std::isnan(
z ) )
525 if (
is3D() || !std::isnan(
z ) )
587 QgsPoint project(
double distance,
double azimuth,
double inclination = 90.0 ) const
SIP_HOLDGIL;
621 QgsPoint *snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0,
bool removeRedundantPoints = false ) const override
SIP_FACTORY;
623 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) override;
624 void clear() override;
626 bool fromWkt( const QString &wkt ) override;
629 QString asWkt(
int precision = 17 ) const override;
632 json asJsonObject(
int precision = 17 ) const override
SIP_SKIP;
633 QString asKml(
int precision = 17 ) const override;
634 void draw( QPainter &p ) const override;
635 QPainterPath asQPainterPath() const override;
637 void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 ) override;
640 int vertexNumberFromVertexId(
QgsVertexId id ) const override;
642 bool isValid( QString &error
SIP_OUT,
Qgis::GeometryValidityFlags flags =
Qgis::GeometryValidityFlags() ) const override
SIP_HOLDGIL;
647 bool deleteVertex(
QgsVertexId position ) override;
658 double vertexAngle(
QgsVertexId vertex ) const override;
660 int vertexCount(
int = 0,
int = 0 ) const override;
661 int ringCount(
int = 0 ) const override;
662 int partCount() const override;
665 double segmentLength(
QgsVertexId startVertex ) const override;
669 bool addZValue(
double zValue = 0 ) override;
670 bool addMValue(
double mValue = 0 ) override;
671 bool dropZValue() override;
672 bool dropMValue() override;
673 void swapXy() override;
674 bool convertTo(
Qgis::WkbType type ) override;
694 return static_cast<const QgsPoint *
>( geom );
709 return static_cast<QgsPoint *
>( geom );
717 SIP_PYOBJECT __repr__();
719 QString str = u
"<QgsPoint: %1>"_s.arg( sipCpp->asWkt() );
720 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
Provides global constants and enumerations for use throughout the application.
WkbType
The WKB type describes the number of dimensions a geometry has.
Abstract base class for all geometries.
virtual QgsPoint childPoint(int index) const
Returns point at index (for geometries without child geometries - i.e.
bool isMeasure() const
Returns true if the geometry contains m values.
virtual int childCount() const
Returns number of child geometries (for geometries with child geometries) or child points (for geomet...
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.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
virtual QgsAbstractGeometry * createEmptyWithSameType() const =0
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
virtual void clearCache() const
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
virtual bool fuzzyEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const =0
Performs fuzzy comparison between this geometry and other using an epsilon.
virtual void normalize()=0
Reorganizes the geometry into a normalized form (or "canonical" form).
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...
QgsAbstractGeometry()=default
virtual int compareToSameClass(const QgsAbstractGeometry *other) const =0
Compares to an other geometry of the same class, and returns a integer for sorting of the two geometr...
A 3-dimensional box composed of x, y, z coordinates.
Custom exception class for Coordinate Reference System related exceptions.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
static double sqrDistance2D(double x1, double y1, double x2, double y2)
Returns the squared 2D distance between (x1, y1) and (x2, y2).
static double distance2D(double x1, double y1, double x2, double y2)
Returns the 2D distance between (x1, y1) and (x2, y2).
static bool fuzzyEqual(T epsilon, const Args &... args) noexcept
Performs fuzzy comparison between pairs of values within a specified epsilon.
static double distance3D(double x1, double y1, double z1, double x2, double y2, double z2)
Returns the 3D distance between (x1, y1, z1) and (x2, y2, z2).
static double sqrDistance3D(double x1, double y1, double z1, double x2, double y2, double z2)
Returns the squared 3D distance between (x1, y1, z1) and (x2, y2, z2).
static bool fuzzyDistanceEqual(T epsilon, const Args &... args) noexcept
Compare equality between multiple pairs of values with a specified epsilon.
Point geometry type, with support for z-dimension and m-values.
double z() const
Returns the point's z-coordinate.
bool fuzzyDistanceEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const override
Performs fuzzy distance comparison between this geometry and other using an epsilon.
void setY(double y)
Sets the point's y-coordinate.
bool operator==(const QgsAbstractGeometry &other) const override
double distance3D(const QgsPoint &other) const
Returns the Cartesian 3D distance between this point and another point.
QgsPoint operator-(QgsVector v) const
Subtracts a vector from this point.
double & rx()
Returns a reference to the x-coordinate of this point.
QgsVector3D toQgsVector3D() const
Returns the point as a QgsVector3D.
QVector3D toVector3D() const
Returns the point as a QVector3D.
QgsPoint operator+(QgsVector v) const
Adds a vector to this point.
double distanceSquared3D(const QgsPoint &other) const
Returns the Cartesian 3D squared distance between this point and another point.
void setX(double x)
Sets the point's x-coordinate.
QgsPoint & operator+=(QgsVector v)
Adds a vector to this point in place.
static QgsPoint * cast(QgsAbstractGeometry *geom)
Cast the geom to a QgsPoint.
static const QgsPoint * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsPoint.
QPointF toQPointF() const
Returns the point as a QPointF.
double distance(const QgsPoint &other) const
Returns the Cartesian 2D distance between this point and another point.
double distance3D(double x, double y, double z) const
Returns the Cartesian 3D distance between this point and a specified x, y, z coordinate.
double distanceSquared3D(double x, double y, double z) const
Returns the Cartesian 3D squared distance between this point and a specified x, y,...
void setM(double m)
Sets the point's m-value.
double y() const
Returns the point's y-coordinate.
QgsPoint & operator-=(QgsVector v)
Subtracts a vector from this point in place.
bool fuzzyEqual(const QgsAbstractGeometry &other, double epsilon=1e-8) const override
Performs fuzzy comparison between this geometry and other using an epsilon.
double distanceSquared(const QgsPoint &other) const
Returns the Cartesian 2D squared distance between this point another point.
QVector4D toVector4D() const
Returns the point as a QVector4D.
double distance(double x, double y) const
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
double m() const
Returns the point's m value.
double & ry()
Returns a reference to the y-coordinate of this point.
void setZ(double z)
Sets the point's z-coordinate.
double distanceSquared(double x, double y) const
Returns the Cartesian 2D squared distance between this point a specified x, y coordinate.
bool operator!=(const QgsAbstractGeometry &other) const override
QgsPoint(double x=std::numeric_limits< double >::quiet_NaN(), double y=std::numeric_limits< double >::quiet_NaN(), double z=std::numeric_limits< double >::quiet_NaN(), double m=std::numeric_limits< double >::quiet_NaN(), Qgis::WkbType wkbType=Qgis::WkbType::Unknown)
Construct a point with the provided initial coordinate values.
double & rz()
Returns a reference to the z-coordinate of this point.
double & rm()
Returns a reference to the m value of this point.
double x() const
Returns the point's x-coordinate.
A rectangle specified with double values.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Represent a 2-dimensional vector.
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
#define SIP_TYPEHINT(type)
#define SIP_THROW(name,...)
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QVector< QgsRingSequence > QgsCoordinateSequence
double closestSegment(const QgsPolylineXY &pl, const QgsPointXY &pt, int &vertexAfter, double epsilon)
Utility class for identifying a unique vertex within a geometry.