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 )
83 z = std::numeric_limits<double>::quiet_NaN();
87 z = PyFloat_AsDouble( a2 );
92 m = std::numeric_limits<double>::quiet_NaN();
96 m = PyFloat_AsDouble( a3 );
99 sipCpp =
new sipQgsPoint( a0, a1, z, m, a4 );
118 explicit QgsPoint(
QgsWkbTypes::Type wkbType,
double x = 0.0,
double y = 0.0,
double z = std::numeric_limits<double>::quiet_NaN(),
double m = std::numeric_limits<double>::quiet_NaN() )
SIP_SKIP;
128 bool equal = pt->
wkbType() == type;
132 equal &=
qgsDoubleNear( pt->
z(), mZ, 1E-8 ) || ( std::isnan( pt->
z() ) && std::isnan( mZ ) );
134 equal &=
qgsDoubleNear( pt->
m(), mM, 1E-8 ) || ( std::isnan( pt->
m() ) && std::isnan( mM ) );
149 double x()
const {
return mX; }
156 double y()
const {
return mY; }
163 double z()
const {
return mZ; }
170 double m()
const {
return mM; }
266 return QPointF( mX, mY );
278 return std::sqrt( ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y ) );
289 return std::sqrt( ( mX - other.
x() ) * ( mX - other.
x() ) + ( mY - other.
y() ) * ( mY - other.
y() ) );
301 return ( mX - x ) * ( mX - x ) + ( mY - y ) * ( mY - y );
313 return ( mX - other.
x() ) * ( mX - other.
x() ) + ( mY - other.
y() ) * ( mY - other.
y() );
323 double distance3D(
double x,
double y,
double z )
const;
331 double distance3D(
const QgsPoint &other )
const;
340 double distanceSquared3D(
double x,
double y,
double z )
const;
349 double distanceSquared3D(
const QgsPoint &other )
const;
355 double azimuth(
const QgsPoint &other )
const;
362 double inclination(
const QgsPoint &other )
const;
392 QgsPoint project(
double distance,
double azimuth,
double inclination = 90.0 )
const;
431 bool removeDuplicateNodes(
double epsilon = 4 * std::numeric_limits<double>::epsilon(),
bool useZValues =
false )
override;
432 void clear()
override;
434 bool fromWkt(
const QString &wkt )
override;
435 QByteArray
asWkb()
const override;
440 void draw( QPainter &p )
const override;
442 void transform(
const QTransform &t,
double zTranslate = 0.0,
double zScale = 1.0,
double mTranslate = 0.0,
double mScale = 1.0 )
override;
463 int vertexCount(
int = 0,
int = 0 )
const override;
470 bool addZValue(
double zValue = 0 )
override;
471 bool addMValue(
double mValue = 0 )
override;
492 return static_cast<const QgsPoint *
>( geom );
500 SIP_PYOBJECT __repr__();
502 QString str = QStringLiteral(
"<QgsPoint: %1>" ).arg( sipCpp->asWkt() );
503 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
521 #endif // QGSPOINTV2_H QgsPoint operator+(QgsVector v) const
Adds a vector to this point.
virtual QString asWkt(int precision=17) const =0
Returns a WKT representation of the geometry.
virtual bool isEmpty() const
Returns true if the geometry is empty.
A rectangle specified with double values.
virtual QgsAbstractGeometry * snappedToGrid(double hSpacing, double vSpacing, double dSpacing=0, double mSpacing=0) const =0
Makes a new geometry with all the points or vertices snapped to the closest point of the grid...
virtual int vertexNumberFromVertexId(QgsVertexId id) const =0
Returns the vertex number corresponding to a vertex id.
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 bool deleteVertex(QgsVertexId position)=0
Deletes a vertex within the geometry.
QgsPoint operator-(QgsVector v) const
Subtracts a vector from this point.
virtual void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)=0
Transforms the geometry using a coordinate transform.
virtual QgsAbstractGeometry * toCurveType() const =0
Returns the geometry converted to the more generic curve type.
virtual QByteArray asWkb() const =0
Returns a WKB representation of the geometry.
double & rz()
Returns a reference to the z-coordinate of this point.
const QgsPoint * cast(const QgsAbstractGeometry *geom) const
Cast the geom to a QgsPoint.
void setZ(double z)
Sets the point's z-coordinate.
virtual bool insertVertex(QgsVertexId position, const QgsPoint &vertex)=0
Inserts a vertex into the geometry.
QVector< QgsRingSequence > QgsCoordinateSequence
A class to represent a 2D point.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
virtual bool operator==(const QgsAbstractGeometry &other) const =0
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
virtual double vertexAngle(QgsVertexId vertex) const =0
Returns approximate angle at a vertex.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
double y() const
Returns the vector's y-component.
virtual QgsAbstractGeometry * createEmptyWithSameType() const =0
Creates a new geometry with the same class and same WKB type as the original and transfers ownership...
virtual QString asJson(int precision=17) const =0
Returns a GeoJSON representation of the geometry.
bool operator!=(const QgsAbstractGeometry &other) const override
virtual QDomElement asGml2(QDomDocument &doc, int precision=17, const QString &ns="gml", AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const =0
Returns a GML2 representation of the geometry.
QgsVector operator-(const QgsPoint &p) const
Calculates the vector obtained by subtracting a point from this point.
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
double m() const
Returns the point's m value.
virtual bool nextVertex(QgsVertexId &id, QgsPoint &vertex) const =0
Returns next vertex id and coordinates.
virtual QgsRectangle boundingBox() const =0
Returns the minimal bounding box for the geometry.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
double distanceSquared(double x, double y) const
Returns the squared distance between this point a specified x, y coordinate.
double x() const
Returns the point's x-coordinate.
Type
The WKB type describes the number of dimensions a geometry has.
QgsPoint & operator-=(QgsVector v)
Subtracts a vector from this point in place.
bool isMeasure() const
Returns true if the geometry contains m values.
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
void setM(double m)
Sets the point's m-value.
virtual double closestSegment(const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, int *leftOf=nullptr, double epsilon=4 *std::numeric_limits< double >::epsilon()) const =0
Searches for the closest segment of the geometry to a given point.
virtual double segmentLength(QgsVertexId startVertex) const =0
Returns the length of the segment of the geometry which begins at startVertex.
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...
Utility class for identifying a unique vertex within a geometry.
virtual QgsPoint childPoint(int index) const
Returns point at index (for geometries without child geometries - i.e.
T qgsgeometry_cast(const QgsAbstractGeometry *geom)
double distanceSquared(const QgsPoint &other) const
Returns the squared distance between this point another point.
virtual int ringCount(int part=0) const =0
Returns the number of rings of which this geometry is built.
double & rx()
Returns a reference to the x-coordinate of this point.
Abstract base class for all geometries.
virtual int dimension() const =0
Returns the inherent dimension of the geometry.
virtual void clearCache() const
Clears any cached parameters associated with the geometry, e.g., bounding boxes.
Point geometry type, with support for z-dimension and m-values.
AxisOrder
Axis order for GML generation.
A class to represent a vector.
void setX(double x)
Sets the point's x-coordinate.
double distance(double x, double y) const
Returns the distance between this point and a specified x, y coordinate.
void setY(double y)
Sets the point's y-coordinate.
virtual QgsCoordinateSequence coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
double z() const
Returns the point's z-coordinate.
virtual void adjacentVertices(QgsVertexId vertex, QgsVertexId &previousVertex, QgsVertexId &nextVertex) const =0
Returns the vertices adjacent to a specified vertex within a geometry.
double & rm()
Returns a reference to the m value of this point.
virtual void clear()=0
Clears the geometry, ie reset it to a null geometry.
virtual bool moveVertex(QgsVertexId position, const QgsPoint &newPos)=0
Moves a vertex within the geometry.
virtual void draw(QPainter &p) const =0
Draws the geometry using the specified QPainter.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
virtual int vertexCount(int part=0, int ring=0) const =0
Returns the number of vertices of which this geometry is built.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
double y() const
Returns the point's y-coordinate.
virtual bool convertTo(QgsWkbTypes::Type type)
Converts the geometry to a specified type.
static bool hasM(Type type)
Tests whether a WKB type contains m values.
virtual bool removeDuplicateNodes(double epsilon=4 *std::numeric_limits< double >::epsilon(), bool useZValues=false)=0
Removes duplicate nodes from the geometry, wherever removing the nodes does not result in a degenerat...
Custom exception class for Coordinate Reference System related exceptions.
virtual int childCount() const
Returns number of child geometries (for geometries with child geometries) or child points (for geomet...
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
virtual bool fromWkt(const QString &wkt)=0
Sets the geometry from a WKT string.
double x() const
Returns the vector's x-component.
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
static Type flatType(Type type)
Returns the flat type for a WKB type.
virtual void swapXy()=0
Swaps the x and y coordinates from the geometry.
double & ry()
Returns a reference to the y-coordinate of this point.
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'. Negativ values mean left a...
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
double distance(const QgsPoint &other) const
Returns the 2D distance between this point and another point.
QgsPoint & operator+=(QgsVector v)
Adds a vector to this point in place.
virtual int partCount() const =0
Returns count of parts contained in the geometry.
virtual QDomElement asGml3(QDomDocument &doc, int precision=17, const QString &ns="gml", AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY) const =0
Returns a GML3 representation of the geometry.
virtual QString geometryType() const =0
Returns a unique string representing the geometry type.
virtual bool fromWkb(QgsConstWkbPtr &wkb)=0
Sets the geometry from a WKB string.
QPointF toQPointF() const
Returns the point as a QPointF.