21 #include "qgis_core.h"
41 Q_PROPERTY(
double x READ x WRITE setX )
42 Q_PROPERTY(
double y READ y WRITE setY )
43 Q_PROPERTY(
double z READ z WRITE setZ )
44 Q_PROPERTY(
double m READ m WRITE setM )
75 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(),
QgsWkbTypes::Type wkbType =
QgsWkbTypes::Unknown );
77 QgsPoint( SIP_PYOBJECT x = Py_None, SIP_PYOBJECT y = Py_None, SIP_PYOBJECT z = Py_None, SIP_PYOBJECT m = Py_None, SIP_PYOBJECT wkbType = Py_None ) [(
double x = 0.0,
double y = 0.0,
double z = 0.0,
double m = 0.0,
QgsWkbTypes::Type wkbType =
QgsWkbTypes::Unknown )];
79 if ( sipCanConvertToType( a0, sipType_QgsPointXY, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
84 QgsPointXY *p =
reinterpret_cast<QgsPointXY *
>( sipConvertToType( a0, sipType_QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
87 sipReleaseType( p, sipType_QgsPointXY, state );
91 sipCpp =
new sipQgsPoint(
QgsPoint( *p ) );
94 else if ( sipCanConvertToType( a0, sipType_QPointF, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
99 QPointF *p =
reinterpret_cast<QPointF *
>( sipConvertToType( a0, sipType_QPointF, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
102 sipReleaseType( p, sipType_QPointF, state );
106 sipCpp =
new sipQgsPoint(
QgsPoint( *p ) );
110 ( a0 == Py_None || PyFloat_AsDouble( a0 ) != -1.0 || !PyErr_Occurred() ) &&
111 ( a1 == Py_None || PyFloat_AsDouble( a1 ) != -1.0 || !PyErr_Occurred() ) &&
112 ( a2 == Py_None || PyFloat_AsDouble( a2 ) != -1.0 || !PyErr_Occurred() ) &&
113 ( a3 == Py_None || PyFloat_AsDouble( a3 ) != -1.0 || !PyErr_Occurred() ) )
115 double x = a0 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a0 );
116 double y = a1 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a1 );
117 double z = a2 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a2 );
118 double m = a3 == Py_None ? std::numeric_limits<double>::quiet_NaN() : PyFloat_AsDouble( a3 );
120 sipCpp =
new sipQgsPoint(
QgsPoint( x, y, z, m, wkbType ) );
124 PyErr_SetString( PyExc_TypeError, QStringLiteral(
"Invalid type in constructor arguments." ).toUtf8().constData() );
145 explicit QgsPoint(
QgsWkbTypes::Type 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;
149 const QgsPoint *pt = qgsgeometry_cast< const QgsPoint * >( &other );
158 const bool nan1X = std::isnan( mX );
159 const bool nan2X = std::isnan( pt->
x() );
160 if ( nan1X != nan2X )
165 const bool nan1Y = std::isnan( mY );
166 const bool nan2Y = std::isnan( pt->
y() );
167 if ( nan1Y != nan2Y )
174 const bool nan1Z = std::isnan( mZ );
175 const bool nan2Z = std::isnan( pt->
z() );
176 if ( nan1Z != nan2Z )
184 const bool nan1M = std::isnan( mM );
185 const bool nan2M = std::isnan( pt->
m() );
186 if ( nan1M != nan2M )
322 return QPointF( mX, mY );
334 return std::sqrt( ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y ) );
345 return std::sqrt( ( mX - other.x() ) * ( mX - other.x() ) + ( mY - other.y() ) * ( mY - other.y() ) );
357 return ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y );
369 return ( mX - other.x() ) * ( mX - other.x() ) + ( mY - other.y() ) * ( mY - other.y() );
379 double distance3D(
double x,
double y,
double z )
const SIP_HOLDGIL;
396 double distanceSquared3D(
double x,
double y,
double z )
const SIP_HOLDGIL;
450 QgsPoint project(
double distance,
double azimuth,
double inclination = 90.0 ) const
SIP_HOLDGIL;
488 QgsPoint *snappedToGrid(
double hSpacing,
double vSpacing,
double dSpacing = 0,
double mSpacing = 0 ) const override
SIP_FACTORY;
489 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<
double>::epsilon(),
bool useZValues = false ) override;
490 void clear() override;
492 bool fromWkt( const QString &wkt ) override;
495 QString asWkt(
int precision = 17 ) const override;
499 QString asKml(
int precision = 17 ) const override;
500 void draw( QPainter &p ) const override;
501 QPainterPath asQPainterPath() const override;
503 void transform( const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 ) override;
506 int vertexNumberFromVertexId(
QgsVertexId id ) const override;
513 bool deleteVertex(
QgsVertexId position ) override;
524 double vertexAngle(
QgsVertexId vertex ) const override;
526 int vertexCount(
int = 0,
int = 0 ) const override;
527 int ringCount(
int = 0 ) const override;
528 int partCount() const override;
531 double segmentLength(
QgsVertexId startVertex ) const override;
533 bool addZValue(
double zValue = 0 ) override;
534 bool addMValue(
double mValue = 0 ) override;
535 bool dropZValue() override;
536 bool dropMValue() override;
537 void swapXy() override;
557 return static_cast<const QgsPoint *
>( geom );
565 SIP_PYOBJECT __repr__();
567 QString str = QStringLiteral(
"<QgsPoint: %1>" ).arg( sipCpp->asWkt() );
568 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
Abstract base class for all geometries.
virtual QgsPoint childPoint(int index) const
Returns point at index (for geometries without child geometries - i.e.
bool is3D() const SIP_HOLDGIL
Returns true if the geometry is 3D and contains a z-value.
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.
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.
virtual bool isEmpty() const
Returns true if the geometry is empty.
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...
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
virtual bool operator==(const QgsAbstractGeometry &other) const =0
bool isMeasure() const SIP_HOLDGIL
Returns true if the geometry contains m values.
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.
A class to represent a 2D point.
Point geometry type, with support for z-dimension and m-values.
double distance(double x, double y) const SIP_HOLDGIL
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
double m() const SIP_HOLDGIL
Returns the point's m value.
double & ry()
Returns a reference to the y-coordinate of this point.
QPointF toQPointF() const SIP_HOLDGIL
Returns the point as a QPointF.
static const QgsPoint * cast(const QgsAbstractGeometry *geom)
Cast the geom to a QgsPoint.
void setX(double x) SIP_HOLDGIL
Sets the point's x-coordinate.
double distance(const QgsPoint &other) const SIP_HOLDGIL
Returns the Cartesian 2D distance between this point and another point.
void setY(double y) SIP_HOLDGIL
Sets the point's y-coordinate.
double & rz()
Returns a reference to the z-coordinate of this point.
double & rm()
Returns a reference to the m value of this point.
void setZ(double z) SIP_HOLDGIL
Sets the point's z-coordinate.
QgsPoint operator-(QgsVector v) const SIP_HOLDGIL
Subtracts a vector from this point.
double y() const SIP_HOLDGIL
Returns the point's y-coordinate.
double distanceSquared(const QgsPoint &other) const SIP_HOLDGIL
Returns the Cartesian 2D squared distance between this point another point.
double distanceSquared(double x, double y) const SIP_HOLDGIL
Returns the Cartesian 2D squared distance between this point a specified x, y coordinate.
QgsPoint operator+(QgsVector v) const SIP_HOLDGIL
Adds a vector to this point.
double x() const SIP_HOLDGIL
Returns the point's x-coordinate.
double & rx()
Returns a reference to the x-coordinate of this point.
double z() const SIP_HOLDGIL
Returns the point's z-coordinate.
QgsPoint & operator-=(QgsVector v) SIP_HOLDGIL
Subtracts a vector from this point in place.
bool operator!=(const QgsAbstractGeometry &other) const override SIP_HOLDGIL
void setM(double m) SIP_HOLDGIL
Sets the point's m-value.
QgsPoint & operator+=(QgsVector v) SIP_HOLDGIL
Adds a vector to this point in place.
A rectangle specified with double values.
A class to represent a vector.
Handles storage of information regarding WKB types and their properties.
static bool hasM(Type type) SIP_HOLDGIL
Tests whether a WKB type contains m values.
Type
The WKB type describes the number of dimensions a geometry has.
static Type flatType(Type type) SIP_HOLDGIL
Returns the flat type for a WKB type.
static bool hasZ(Type type) SIP_HOLDGIL
Tests whether a WKB type contains the z-dimension.
double ANALYSIS_EXPORT leftOf(const QgsPoint &thepoint, const QgsPoint *p1, const QgsPoint *p2)
Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'. Negative values mean left ...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
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.