QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
Classes | Public Types | Static Public Member Functions | List of all members
QgsGeometryUtils Class Reference

Contains various geometry utility functions. More...

#include <qgsgeometryutils.h>

Classes

struct  SelfIntersection
 

Public Types

enum  ComponentType { Vertex , Ring , Part }
 

Static Public Member Functions

static Q_DECL_DEPRECATED double angleBetweenThreePoints (double x1, double y1, double x2, double y2, double x3, double y3)
 Calculates the angle between the lines AB and BC, where AB and BC described by points a, b and b, c.
 
static Q_DECL_DEPRECATED bool angleBisector (double aX, double aY, double bX, double bY, double cX, double cY, double dX, double dY, double &pointX, double &pointY, double &angle)
 Returns the point (pointX, pointY) forming the bisector from segment (aX aY) (bX bY) and segment (bX, bY) (dX, dY).
 
static Q_DECL_DEPRECATED bool angleOnCircle (double angle, double angle1, double angle2, double angle3)
 Returns true if an angle is between angle1 and angle3 on a circle described by angle1, angle2 and angle3.
 
static Q_DECL_DEPRECATED double averageAngle (double a1, double a2)
 Averages two angles, correctly handling negative angles and ensuring the result is between 0 and 2 pi.
 
static Q_DECL_DEPRECATED double averageAngle (double x1, double y1, double x2, double y2, double x3, double y3)
 Calculates the average angle (in radians) between the two linear segments from (x1, y1) to (x2, y2) and (x2, y2) to (x3, y3).
 
static Q_DECL_DEPRECATED bool bisector (double aX, double aY, double bX, double bY, double cX, double cY, double &pointX, double &pointY)
 Returns the point (pointX, pointY) forming the bisector from point (aX, aY) to the segment (bX, bY) (cX, cY).
 
static Q_DECL_DEPRECATED double ccwAngle (double dy, double dx)
 Returns the counter clockwise angle between a line with components dx, dy and the line with dx > 0 and dy = 0.
 
static Q_DECL_DEPRECATED bool circleAngleBetween (double angle, double angle1, double angle2, bool clockwise)
 Returns true if, in a circle, angle is between angle1 and angle2.
 
static void circleCenterRadius (const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double &radius, double &centerX, double &centerY)
 Returns radius and center of the circle through pt1, pt2, pt3.
 
static int circleCircleInnerTangents (const QgsPointXY &center1, double radius1, const QgsPointXY &center2, double radius2, QgsPointXY &line1P1, QgsPointXY &line1P2, QgsPointXY &line2P1, QgsPointXY &line2P2)
 Calculates the inner tangent points for two circles, centered at center1 and center2 and with radii of radius1 and radius2 respectively.
 
static int circleCircleIntersections (const QgsPointXY &center1, double radius1, const QgsPointXY &center2, double radius2, QgsPointXY &intersection1, QgsPointXY &intersection2)
 Calculates the intersections points between the circle with center center1 and radius radius1 and the circle with center center2 and radius radius2.
 
static int circleCircleOuterTangents (const QgsPointXY &center1, double radius1, const QgsPointXY &center2, double radius2, QgsPointXY &line1P1, QgsPointXY &line1P2, QgsPointXY &line2P1, QgsPointXY &line2P2)
 Calculates the outer tangent points for two circles, centered at center1 and center2 and with radii of radius1 and radius2 respectively.
 
static Q_DECL_DEPRECATED bool circleClockwise (double angle1, double angle2, double angle3)
 Returns true if the circle defined by three angles is ordered clockwise.
 
static Q_DECL_DEPRECATED double circleLength (double x1, double y1, double x2, double y2, double x3, double y3)
 Length of a circular string segment defined by pt1, pt2, pt3.
 
static double circleTangentDirection (const QgsPoint &tangentPoint, const QgsPoint &cp1, const QgsPoint &cp2, const QgsPoint &cp3)
 Calculates the direction angle of a circle tangent (clockwise from north in radians)
 
static QgsPoint closestPoint (const QgsAbstractGeometry &geometry, const QgsPoint &point)
 Returns the nearest point on a segment of a geometry for the specified point.
 
template<class T >
static double closestSegmentFromComponents (T &container, ComponentType ctype, const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, int *leftOf, double epsilon)
 
static Q_DECL_DEPRECATED int closestSideOfRectangle (double right, double bottom, double left, double top, double x, double y)
 Returns a number representing the closest side of a rectangle defined by /a right, bottom, left, top to the point at (x, y), where the point may be in the interior of the rectangle or outside it.
 
static QgsPoint closestVertex (const QgsAbstractGeometry &geom, const QgsPoint &pt, QgsVertexId &id)
 Returns the closest vertex to a geometry for a specified point.
 
static void coefficients (const QgsPoint &pt1, const QgsPoint &pt2, double &a, double &b, double &c)
 Returns the coefficients (a, b, c for equation "ax + by + c = 0") of a line defined by points pt1 and pt2.
 
static double distance2D (const QgsPoint &pt1, const QgsPoint &pt2)
 Returns the 2D distance between two points.
 
static Q_DECL_DEPRECATED double distance2D (double x1, double y1, double x2, double y2)
 Returns the 2D distance between (x1, y1) and (x2, y2).
 
static double distance3D (const QgsPoint &pt1, const QgsPoint &pt2)
 Returns the 3D distance between two points.
 
static double distanceToVertex (const QgsAbstractGeometry &geom, QgsVertexId id)
 Returns the distance along a geometry from its first vertex to the specified vertex.
 
static double distToInfiniteLine (const QgsPoint &point, const QgsPoint &linePoint1, const QgsPoint &linePoint2, double epsilon=1e-7)
 Returns the distance between a point and an infinite line.
 
static QVector< QgsLineString * > extractLineStrings (const QgsAbstractGeometry *geom)
 Returns list of linestrings extracted from the passed geometry.
 
static double gradient (const QgsPoint &pt1, const QgsPoint &pt2)
 Returns the gradient of a line defined by points pt1 and pt2.
 
static Q_DECL_DEPRECATED double interpolateArcValue (double angle, double a1, double a2, double a3, double zm1, double zm2, double zm3)
 Interpolate a value at given angle on circular arc given values (zm1, zm2, zm3) at three different angles (a1, a2, a3).
 
static QgsPoint interpolatePointOnArc (const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double distance)
 Interpolates a point on an arc defined by three points, pt1, pt2 and pt3.
 
static QgsPoint interpolatePointOnLine (const QgsPoint &p1, const QgsPoint &p2, double fraction)
 Interpolates the position of a point a fraction of the way along the line from p1 to p2.
 
static QgsPointXY interpolatePointOnLine (double x1, double y1, double x2, double y2, double fraction)
 Interpolates the position of a point a fraction of the way along the line from (x1, y1) to (x2, y2).
 
static QgsPointXY interpolatePointOnLineByValue (double x1, double y1, double v1, double x2, double y2, double v2, double value)
 Interpolates the position of a point along the line from (x1, y1) to (x2, y2).
 
static Q_DECL_DEPRECATED int leftOfLine (const double x, const double y, const double x1, const double y1, const double x2, const double y2)
 Returns a value < 0 if the point (x, y) is left of the line from (x1, y1) -> (x2, y2).
 
static int leftOfLine (const QgsPoint &point, const QgsPoint &p1, const QgsPoint &p2)
 Returns a value < 0 if the point point is left of the line from p1 -> p2.
 
static Q_DECL_DEPRECATED double lineAngle (double x1, double y1, double x2, double y2)
 Calculates the direction of line joining two points in radians, clockwise from the north direction.
 
static bool lineCircleIntersection (const QgsPointXY &center, double radius, const QgsPointXY &linePoint1, const QgsPointXY &linePoint2, QgsPointXY &intersection)
 Compute the intersection of a line and a circle.
 
static bool lineIntersection (const QgsPoint &p1, QgsVector v1, const QgsPoint &p2, QgsVector v2, QgsPoint &intersection)
 Computes the intersection between two lines.
 
static Q_DECL_DEPRECATED double linePerpendicularAngle (double x1, double y1, double x2, double y2)
 Calculates the perpendicular angle to a line joining two points.
 
static Q_DECL_DEPRECATED bool linesIntersection3D (const QgsVector3D &La1, const QgsVector3D &La2, const QgsVector3D &Lb1, const QgsVector3D &Lb2, QgsVector3D &intersection)
 An algorithm to calculate an (approximate) intersection of two lines in 3D.
 
static QgsPoint midpoint (const QgsPoint &pt1, const QgsPoint &pt2)
 Returns a middle point between points pt1 and pt2.
 
static Q_DECL_DEPRECATED double normalizedAngle (double angle)
 Ensures that an angle is in the range 0 <= angle < 2 pi.
 
static Q_DECL_DEPRECATED void perpendicularCenterSegment (double centerPointX, double centerPointY, double segmentPoint1x, double segmentPoint1y, double segmentPoint2x, double segmentPoint2y, double &perpendicularSegmentPoint1x, double &perpendicularSegmentPoint1y, double &perpendicularSegmentPoint2x, double &perpendicularSegmentPoint2y, double segmentLength=0)
 Create a perpendicular line segment to a given segment [segmentPoint1,segmentPoint2] with its center at centerPoint.
 
static Q_DECL_DEPRECATED void perpendicularOffsetPointAlongSegment (double x1, double y1, double x2, double y2, double proportion, double offset, double *x, double *y)
 Calculates a point a certain proportion of the way along the segment from (x1, y1) to (x2, y2), offset from the segment by the specified offset amount.
 
static QgsLineString perpendicularSegment (const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2)
 Create a perpendicular line segment from p to segment [s1, s2].
 
static bool pointContinuesArc (const QgsPoint &a1, const QgsPoint &a2, const QgsPoint &a3, const QgsPoint &b, double distanceTolerance, double pointSpacingAngleTolerance)
 Returns true if point b is on the arc formed by points a1, a2, and a3, but not within that arc portion already described by a1, a2 and a3.
 
static Q_DECL_DEPRECATED double pointFractionAlongLine (double x1, double y1, double x2, double y2, double px, double py)
 Given the line (x1, y1) to (x2, y2) and a point (px, py) returns the fraction of the line length at which the point lies.
 
static QgsPoint pointOnLineWithDistance (const QgsPoint &startPoint, const QgsPoint &directionPoint, double distance)
 Returns a point a specified distance toward a second point.
 
static Q_DECL_DEPRECATED void pointOnLineWithDistance (double x1, double y1, double x2, double y2, double distance, double &x, double &y, double *z1=nullptr, double *z2=nullptr, double *z=nullptr, double *m1=nullptr, double *m2=nullptr, double *m=nullptr)
 Calculates the point a specified distance from (x1, y1) toward a second point (x2, y2).
 
static Q_DECL_DEPRECATED bool pointsAreCollinear (double x1, double y1, double x2, double y2, double x3, double y3, double epsilon)
 Given the points (x1, y1), (x2, y2) and (x3, y3) returns true if these points can be considered collinear with a specified tolerance epsilon.
 
static QgsPointSequence pointsFromWKT (const QString &wktCoordinateList, bool is3D, bool isMeasure)
 Returns a list of points contained in a WKT string.
 
static QDomElement pointsToGML2 (const QgsPointSequence &points, QDomDocument &doc, int precision, const QString &ns, QgsAbstractGeometry::AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY)
 Returns a gml::coordinates DOM element.
 
static QDomElement pointsToGML3 (const QgsPointSequence &points, QDomDocument &doc, int precision, const QString &ns, bool is3D, QgsAbstractGeometry::AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY)
 Returns a gml::posList DOM element.
 
static QString pointsToJSON (const QgsPointSequence &points, int precision)
 Returns a geoJSON coordinates string.
 
static json pointsToJson (const QgsPointSequence &points, int precision)
 Returns coordinates as json object.
 
static void pointsToWKB (QgsWkbPtr &wkb, const QgsPointSequence &points, bool is3D, bool isMeasure, QgsAbstractGeometry::WkbFlags flags)
 Returns a LinearRing { uint32 numPoints; Point points[numPoints]; }.
 
static QString pointsToWKT (const QgsPointSequence &points, int precision, bool is3D, bool isMeasure)
 Returns a WKT coordinate list.
 
static QgsPoint projectPointOnSegment (const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2)
 Project the point on a segment.
 
static bool segmentIntersection (const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &intersectionPoint, bool &isIntersection, double tolerance=1e-8, bool acceptImproperIntersection=false)
 Compute the intersection between two segments.
 
static void segmentizeArc (const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, QgsPointSequence &points, double tolerance=M_PI_2/90, QgsAbstractGeometry::SegmentationToleranceType toleranceType=QgsAbstractGeometry::MaximumAngle, bool hasZ=false, bool hasM=false)
 Convert circular arc defined by p1, p2, p3 (p1/p3 being start resp.
 
static bool segmentMidPoint (const QgsPoint &p1, const QgsPoint &p2, QgsPoint &result, double radius, const QgsPoint &mousePos)
 Calculates midpoint on circle passing through p1 and p2, closest to the given coordinate mousePos.
 
static QgsPoint segmentMidPointFromCenter (const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &center, bool useShortestArc=true)
 Calculates the midpoint on the circle passing through p1 and p2, with the specified center coordinate.
 
static int segmentSide (const QgsPoint &pt1, const QgsPoint &pt3, const QgsPoint &pt2)
 For line defined by points pt1 and pt3, find out on which side of the line is point pt2.
 
static QVector< SelfIntersectionselfIntersections (const QgsAbstractGeometry *geom, int part, int ring, double tolerance)
 Find self intersections in a polyline.
 
static Q_DECL_DEPRECATED bool setZValueFromPoints (const QgsPointSequence &points, QgsPoint &point)
 A Z dimension is added to point if one of the point in the list points is in 3D.
 
static Q_DECL_DEPRECATED double skewLinesDistance (const QgsVector3D &P1, const QgsVector3D &P12, const QgsVector3D &P2, const QgsVector3D &P22)
 An algorithm to calculate the shortest distance between two skew lines.
 
static Q_DECL_DEPRECATED bool skewLinesProjection (const QgsVector3D &P1, const QgsVector3D &P12, const QgsVector3D &P2, const QgsVector3D &P22, QgsVector3D &X1, double epsilon=0.0001)
 A method to project one skew line onto another.
 
static double sqrDistance2D (const QgsPoint &pt1, const QgsPoint &pt2)
 Returns the squared 2D distance between two points.
 
static Q_DECL_DEPRECATED double sqrDistance2D (double x1, double y1, double x2, double y2)
 Returns the squared 2D distance between (x1, y1) and (x2, y2).
 
static double sqrDistance3D (const QgsPoint &pt1, const QgsPoint &pt2)
 Returns the squared 3D distance between two points.
 
static Q_DECL_DEPRECATED double sqrDistToLine (double ptX, double ptY, double x1, double y1, double x2, double y2, double &minDistX, double &minDistY, double epsilon)
 Returns the squared distance between a point and a line.
 
static Q_DECL_DEPRECATED double sweepAngle (double centerX, double centerY, double x1, double y1, double x2, double y2, double x3, double y3)
 Calculates angle of a circular string part defined by pt1, pt2, pt3.
 
static bool tangentPointAndCircle (const QgsPointXY &center, double radius, const QgsPointXY &p, QgsPointXY &pt1, QgsPointXY &pt2)
 Calculates the tangent points between the circle with the specified center and radius and the point p.
 
static bool transferFirstMValueToPoint (const QgsPointSequence &points, QgsPoint &point)
 A M dimension is added to point if one of the points in the list points contains an M value.
 
static bool transferFirstZOrMValueToPoint (const QgsGeometry &geom, QgsPoint &point)
 A Z or M dimension is added to point if one of the points in the list points contains Z or M value.
 
static bool transferFirstZOrMValueToPoint (const QgsPointSequence &points, QgsPoint &point)
 A Z or M dimension is added to point if one of the points in the list points contains Z or M value.
 
template<class Iterator >
static bool transferFirstZOrMValueToPoint (Iterator verticesBegin, Iterator verticesEnd, QgsPoint &point)
 A Z or M dimension is added to point if one of the points in the list points contains Z or M value.
 
static bool transferFirstZValueToPoint (const QgsPointSequence &points, QgsPoint &point)
 A Z dimension is added to point if one of the point in the list points is in 3D.
 
static Q_DECL_DEPRECATED double triangleArea (double aX, double aY, double bX, double bY, double cX, double cY)
 Returns the area of the triangle denoted by the points (aX, aY), (bX, bY) and (cX, cY).
 
static bool verticesAtDistance (const QgsAbstractGeometry &geometry, double distance, QgsVertexId &previousVertex, QgsVertexId &nextVertex)
 Retrieves the vertices which are before and after the interpolated point at a specified distance along a linestring (or polygon boundary).
 
static Q_DECL_DEPRECATED void weightedPointInTriangle (double aX, double aY, double bX, double bY, double cX, double cY, double weightB, double weightC, double &pointX, double &pointY)
 Returns a weighted point inside the triangle denoted by the points (aX, aY), (bX, bY) and (cX, cY).
 
static QStringList wktGetChildBlocks (const QString &wkt, const QString &defaultType=QString())
 Parses a WKT string and returns of list of blocks contained in the WKT.
 
static QPair< Qgis::WkbType, QString > wktReadBlock (const QString &wkt)
 Parses a WKT block of the format "TYPE( contents )" and returns a pair of geometry type to contents ("Pair(wkbType, "contents")")
 

Detailed Description

Contains various geometry utility functions.

Definition at line 37 of file qgsgeometryutils.h.

Member Enumeration Documentation

◆ ComponentType

Note
not available in Python bindings
Enumerator
Vertex 
Ring 
Part 

Definition at line 588 of file qgsgeometryutils.h.

Member Function Documentation

◆ angleBetweenThreePoints()

static Q_DECL_DEPRECATED double QgsGeometryUtils::angleBetweenThreePoints ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
)
inlinestatic

Calculates the angle between the lines AB and BC, where AB and BC described by points a, b and b, c.

Parameters
x1x-coordinate of point a
y1y-coordinate of point a
x2x-coordinate of point b
y2y-coordinate of point b
x3x-coordinate of point c
y3y-coordinate of point c
Returns
angle between lines in radians. Returned value is undefined if two or more points are equal.
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 900 of file qgsgeometryutils.h.

◆ angleBisector()

static Q_DECL_DEPRECATED bool QgsGeometryUtils::angleBisector ( double  aX,
double  aY,
double  bX,
double  bY,
double  cX,
double  cY,
double  dX,
double  dY,
double &  pointX,
double &  pointY,
double &  angle 
)
inlinestatic

Returns the point (pointX, pointY) forming the bisector from segment (aX aY) (bX bY) and segment (bX, bY) (dX, dY).

The bisector segment of AB-CD is (point, projection of point by angle)

Parameters
aXx-coordinate of first vertex of the segment ab
aYy-coordinate of first vertex of the segment ab
bXx-coordinate of second vertex of the segment ab
bYy-coordinate of second vertex of the segment ab
cXx-coordinate of first vertex of the segment cd
cYy-coordinate of first vertex of the segment cd
dXx-coordinate of second vertex of the segment cd
dYy-coordinate of second vertex of the segment cd
pointXx-coordinate of generated point
pointYy-coordinate of generated point
angleangle of the bisector from pointX, pointY origin on [ab-cd]
Returns
true if the bisector exists (A B and C D are not collinear)
Since
QGIS 3.18
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 1171 of file qgsgeometryutils.h.

◆ angleOnCircle()

static Q_DECL_DEPRECATED bool QgsGeometryUtils::angleOnCircle ( double  angle,
double  angle1,
double  angle2,
double  angle3 
)
inlinestatic

Returns true if an angle is between angle1 and angle3 on a circle described by angle1, angle2 and angle3.

Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 826 of file qgsgeometryutils.h.

◆ averageAngle() [1/2]

static Q_DECL_DEPRECATED double QgsGeometryUtils::averageAngle ( double  a1,
double  a2 
)
inlinestatic

Averages two angles, correctly handling negative angles and ensuring the result is between 0 and 2 pi.

Parameters
a1first angle (in radians)
a2second angle (in radians)
Returns
average angle (in radians)
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 940 of file qgsgeometryutils.h.

◆ averageAngle() [2/2]

static Q_DECL_DEPRECATED double QgsGeometryUtils::averageAngle ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
)
inlinestatic

Calculates the average angle (in radians) between the two linear segments from (x1, y1) to (x2, y2) and (x2, y2) to (x3, y3).

Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 927 of file qgsgeometryutils.h.

◆ bisector()

static Q_DECL_DEPRECATED bool QgsGeometryUtils::bisector ( double  aX,
double  aY,
double  bX,
double  bY,
double  cX,
double  cY,
double &  pointX,
double &  pointY 
)
inlinestatic

Returns the point (pointX, pointY) forming the bisector from point (aX, aY) to the segment (bX, bY) (cX, cY).

The bisector segment of ABC is (A-point)

Parameters
aXx-coordinate of first vertex in triangle
aYy-coordinate of first vertex in triangle
bXx-coordinate of second vertex in triangle
bYy-coordinate of second vertex in triangle
cXx-coordinate of third vertex in triangle
cYy-coordinate of third vertex in triangle
pointXx-coordinate of generated point
pointYy-coordinate of generated point
Returns
true if the bisector exists (A B and C are not collinear)
Since
QGIS 3.18
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 1194 of file qgsgeometryutils.h.

◆ ccwAngle()

static Q_DECL_DEPRECATED double QgsGeometryUtils::ccwAngle ( double  dy,
double  dx 
)
inlinestatic

Returns the counter clockwise angle between a line with components dx, dy and the line with dx > 0 and dy = 0.

Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 791 of file qgsgeometryutils.h.

◆ circleAngleBetween()

static Q_DECL_DEPRECATED bool QgsGeometryUtils::circleAngleBetween ( double  angle,
double  angle1,
double  angle2,
bool  clockwise 
)
inlinestatic

Returns true if, in a circle, angle is between angle1 and angle2.

Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 815 of file qgsgeometryutils.h.

◆ circleCenterRadius()

static void QgsGeometryUtils::circleCenterRadius ( const QgsPoint pt1,
const QgsPoint pt2,
const QgsPoint pt3,
double &  radius,
double &  centerX,
double &  centerY 
)
inlinestatic

Returns radius and center of the circle through pt1, pt2, pt3.

Definition at line 1203 of file qgsgeometryutils.h.

◆ circleCircleInnerTangents()

int QgsGeometryUtils::circleCircleInnerTangents ( const QgsPointXY center1,
double  radius1,
const QgsPointXY center2,
double  radius2,
QgsPointXY line1P1,
QgsPointXY line1P2,
QgsPointXY line2P1,
QgsPointXY line2P2 
)
static

Calculates the inner tangent points for two circles, centered at center1 and center2 and with radii of radius1 and radius2 respectively.

The inner tangent points correspond to the points at which the two lines which are drawn so that they are tangential to both circles and are crossing each other.

The first tangent line is described by the points stored in line1P1 and line1P2, and the second line is described by the points stored in line2P1 and line2P2.

Returns the number of tangents (either 0 or 2).

Since
QGIS 3.6

Definition at line 410 of file qgsgeometryutils.cpp.

◆ circleCircleIntersections()

int QgsGeometryUtils::circleCircleIntersections ( const QgsPointXY center1,
double  radius1,
const QgsPointXY center2,
double  radius2,
QgsPointXY intersection1,
QgsPointXY intersection2 
)
static

Calculates the intersections points between the circle with center center1 and radius radius1 and the circle with center center2 and radius radius2.

If found, the intersection points will be stored in intersection1 and intersection2.

Returns
number of intersection points found.
Since
QGIS 3.2

Definition at line 272 of file qgsgeometryutils.cpp.

◆ circleCircleOuterTangents()

int QgsGeometryUtils::circleCircleOuterTangents ( const QgsPointXY center1,
double  radius1,
const QgsPointXY center2,
double  radius2,
QgsPointXY line1P1,
QgsPointXY line1P2,
QgsPointXY line2P1,
QgsPointXY line2P2 
)
static

Calculates the outer tangent points for two circles, centered at center1 and center2 and with radii of radius1 and radius2 respectively.

The outer tangent points correspond to the points at which the two lines which are drawn so that they are tangential to both circles touch the circles.

The first tangent line is described by the points stored in line1P1 and line1P2, and the second line is described by the points stored in line2P1 and line2P2.

Returns the number of tangents (either 0 or 2).

Since
QGIS 3.2

Definition at line 374 of file qgsgeometryutils.cpp.

◆ circleClockwise()

static Q_DECL_DEPRECATED bool QgsGeometryUtils::circleClockwise ( double  angle1,
double  angle2,
double  angle3 
)
inlinestatic

Returns true if the circle defined by three angles is ordered clockwise.

The angles are defined counter-clockwise from the origin, i.e. using Euclidean angles as opposed to geographic "North up" angles.

Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 805 of file qgsgeometryutils.h.

◆ circleLength()

static Q_DECL_DEPRECATED double QgsGeometryUtils::circleLength ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
)
inlinestatic

Length of a circular string segment defined by pt1, pt2, pt3.

Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 836 of file qgsgeometryutils.h.

◆ circleTangentDirection()

double QgsGeometryUtils::circleTangentDirection ( const QgsPoint tangentPoint,
const QgsPoint cp1,
const QgsPoint cp2,
const QgsPoint cp3 
)
static

Calculates the direction angle of a circle tangent (clockwise from north in radians)

Definition at line 589 of file qgsgeometryutils.cpp.

◆ closestPoint()

QgsPoint QgsGeometryUtils::closestPoint ( const QgsAbstractGeometry geometry,
const QgsPoint point 
)
static

Returns the nearest point on a segment of a geometry for the specified point.

The z and m values will be linearly interpolated between the two neighbouring vertices.

Definition at line 100 of file qgsgeometryutils.cpp.

◆ closestSegmentFromComponents()

template<class T >
static double QgsGeometryUtils::closestSegmentFromComponents ( T &  container,
ComponentType  ctype,
const QgsPoint pt,
QgsPoint segmentPt,
QgsVertexId vertexAfter,
int *  leftOf,
double  epsilon 
)
inlinestatic
Note
not available in Python bindings

Definition at line 596 of file qgsgeometryutils.h.

◆ closestSideOfRectangle()

static Q_DECL_DEPRECATED int QgsGeometryUtils::closestSideOfRectangle ( double  right,
double  bottom,
double  left,
double  top,
double  x,
double  y 
)
inlinestatic

Returns a number representing the closest side of a rectangle defined by /a right, bottom, left, top to the point at (x, y), where the point may be in the interior of the rectangle or outside it.

The returned value may be:

  1. Point is closest to top side of rectangle
  2. Point is located on the top-right diagonal of rectangle, equally close to the top and right sides
  3. Point is closest to right side of rectangle
  4. Point is located on the bottom-right diagonal of rectangle, equally close to the bottom and right sides
  5. Point is closest to bottom side of rectangle
  6. Point is located on the bottom-left diagonal of rectangle, equally close to the bottom and left sides
  7. Point is closest to left side of rectangle
  8. Point is located on the top-left diagonal of rectangle, equally close to the top and left sides
Note
This method effectively partitions the space outside of the rectangle into Voronoi cells, so a point to the top left of the rectangle may be assigned to the left or top sides based on its position relative to the diagonal line extended from the rectangle's top-left corner.
Since
QGIS 3.20
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 969 of file qgsgeometryutils.h.

◆ closestVertex()

QgsPoint QgsGeometryUtils::closestVertex ( const QgsAbstractGeometry geom,
const QgsPoint pt,
QgsVertexId id 
)
static

Returns the closest vertex to a geometry for a specified point.

On error null point will be returned and "id" argument will be invalid.

Definition at line 66 of file qgsgeometryutils.cpp.

◆ coefficients()

void QgsGeometryUtils::coefficients ( const QgsPoint pt1,
const QgsPoint pt2,
double &  a,
double &  b,
double &  c 
)
static

Returns the coefficients (a, b, c for equation "ax + by + c = 0") of a line defined by points pt1 and pt2.

Parameters
pt1first point.
pt2second point.
aOutput parameter, a coefficient of the equation.
bOutput parameter, b coefficient of the equation.
cOutput parameter, c coefficient of the equation.

Definition at line 1158 of file qgsgeometryutils.cpp.

◆ distance2D() [1/2]

static double QgsGeometryUtils::distance2D ( const QgsPoint pt1,
const QgsPoint pt2 
)
inlinestatic

Returns the 2D distance between two points.

Definition at line 693 of file qgsgeometryutils.h.

◆ distance2D() [2/2]

static Q_DECL_DEPRECATED double QgsGeometryUtils::distance2D ( double  x1,
double  y1,
double  x2,
double  y2 
)
inlinestatic

Returns the 2D distance between (x1, y1) and (x2, y2).

Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 688 of file qgsgeometryutils.h.

◆ distance3D()

static double QgsGeometryUtils::distance3D ( const QgsPoint pt1,
const QgsPoint pt2 
)
inlinestatic

Returns the 3D distance between two points.

Warning
No check is done if z contains NaN value. This is the caller's responsibility.
Since
QGIS 3.36

Definition at line 701 of file qgsgeometryutils.h.

◆ distanceToVertex()

double QgsGeometryUtils::distanceToVertex ( const QgsAbstractGeometry geom,
QgsVertexId  id 
)
static

Returns the distance along a geometry from its first vertex to the specified vertex.

Parameters
geomgeometry
idvertex id to find distance to
Returns
distance to vertex (following geometry)

Definition at line 133 of file qgsgeometryutils.cpp.

◆ distToInfiniteLine()

double QgsGeometryUtils::distToInfiniteLine ( const QgsPoint point,
const QgsPoint linePoint1,
const QgsPoint linePoint2,
double  epsilon = 1e-7 
)
static

Returns the distance between a point and an infinite line.

Parameters
pointThe point to find the distance to the line
linePoint1The first point of the line
linePoint2The second point of the line
epsilonThe tolerance to use
Since
QGIS 3.26

Definition at line 202 of file qgsgeometryutils.cpp.

◆ extractLineStrings()

QVector< QgsLineString * > QgsGeometryUtils::extractLineStrings ( const QgsAbstractGeometry geom)
static

Returns list of linestrings extracted from the passed geometry.

The returned objects have to be deleted by the caller.

Definition at line 30 of file qgsgeometryutils.cpp.

◆ gradient()

double QgsGeometryUtils::gradient ( const QgsPoint pt1,
const QgsPoint pt2 
)
static

Returns the gradient of a line defined by points pt1 and pt2.

Parameters
pt1first point.
pt2second point.
Returns
The gradient of this linear entity, or infinity if vertical

Definition at line 1146 of file qgsgeometryutils.cpp.

◆ interpolateArcValue()

static Q_DECL_DEPRECATED double QgsGeometryUtils::interpolateArcValue ( double  angle,
double  a1,
double  a2,
double  a3,
double  zm1,
double  zm2,
double  zm3 
)
inlinestatic

Interpolate a value at given angle on circular arc given values (zm1, zm2, zm3) at three different angles (a1, a2, a3).

Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 855 of file qgsgeometryutils.h.

◆ interpolatePointOnArc()

QgsPoint QgsGeometryUtils::interpolatePointOnArc ( const QgsPoint pt1,
const QgsPoint pt2,
const QgsPoint pt3,
double  distance 
)
static

Interpolates a point on an arc defined by three points, pt1, pt2 and pt3.

The arc will be interpolated by the specified distance from pt1.

Any z or m values present in the points will also be linearly interpolated in the output.

Since
QGIS 3.4

Definition at line 508 of file qgsgeometryutils.cpp.

◆ interpolatePointOnLine() [1/2]

QgsPoint QgsGeometryUtils::interpolatePointOnLine ( const QgsPoint p1,
const QgsPoint p2,
double  fraction 
)
static

Interpolates the position of a point a fraction of the way along the line from p1 to p2.

Usually the fraction should be between 0 and 1, where 0 represents the point at the start of the line (p1) and 1 represents the end of the line (p2). However, it is possible to use a fraction < 0 or > 1, in which case the returned point is extrapolated from the supplied line.

Any Z or M values present in the input points will also be interpolated and present in the returned point.

See also
interpolatePointOnLineByValue()

Definition at line 1120 of file qgsgeometryutils.cpp.

◆ interpolatePointOnLine() [2/2]

QgsPointXY QgsGeometryUtils::interpolatePointOnLine ( double  x1,
double  y1,
double  x2,
double  y2,
double  fraction 
)
static

Interpolates the position of a point a fraction of the way along the line from (x1, y1) to (x2, y2).

Usually the fraction should be between 0 and 1, where 0 represents the point at the start of the line (x1, y1) and 1 represents the end of the line (x2, y2). However, it is possible to use a fraction < 0 or > 1, in which case the returned point is extrapolated from the supplied line.

See also
interpolatePointOnLineByValue()

Definition at line 1130 of file qgsgeometryutils.cpp.

◆ interpolatePointOnLineByValue()

QgsPointXY QgsGeometryUtils::interpolatePointOnLineByValue ( double  x1,
double  y1,
double  v1,
double  x2,
double  y2,
double  v2,
double  value 
)
static

Interpolates the position of a point along the line from (x1, y1) to (x2, y2).

The position is interpolated using a supplied target value and the value at the start of the line (v1) and end of the line (v2). The returned point will be linearly interpolated to match position corresponding to the target value.

See also
interpolatePointOnLine()

Definition at line 1137 of file qgsgeometryutils.cpp.

◆ leftOfLine() [1/2]

static Q_DECL_DEPRECATED int QgsGeometryUtils::leftOfLine ( const double  x,
const double  y,
const double  x1,
const double  y1,
const double  x2,
const double  y2 
)
inlinestatic

Returns a value < 0 if the point (x, y) is left of the line from (x1, y1) -> (x2, y2).

A positive return value indicates the point is to the right of the line.

If the return value is 0, then the test was unsuccessful (e.g. due to testing a point exactly on the line, or exactly in line with the segment) and the result is undefined.

Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 726 of file qgsgeometryutils.h.

◆ leftOfLine() [2/2]

int QgsGeometryUtils::leftOfLine ( const QgsPoint point,
const QgsPoint p1,
const QgsPoint p2 
)
static

Returns a value < 0 if the point point is left of the line from p1 -> p2.

A positive return value indicates the point is to the right of the line.

If the return value is 0, then the test was unsuccessful (e.g. due to testing a point exactly on the line, or exactly in line with the segment) and the result is undefined.

Since
QGIS 3.6

Definition at line 495 of file qgsgeometryutils.cpp.

◆ lineAngle()

static Q_DECL_DEPRECATED double QgsGeometryUtils::lineAngle ( double  x1,
double  y1,
double  x2,
double  y2 
)
inlinestatic

Calculates the direction of line joining two points in radians, clockwise from the north direction.

Parameters
x1x-coordinate of line start
y1y-coordinate of line start
x2x-coordinate of line end
y2y-coordinate of line end
Returns
angle in radians. Returned value is undefined if start and end point are the same.
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 882 of file qgsgeometryutils.h.

◆ lineCircleIntersection()

bool QgsGeometryUtils::lineCircleIntersection ( const QgsPointXY center,
double  radius,
const QgsPointXY linePoint1,
const QgsPointXY linePoint2,
QgsPointXY intersection 
)
static

Compute the intersection of a line and a circle.

If the intersection has two solutions (points), the closest point to the initial intersection point is returned.

Parameters
centerthe center of the circle
radiusthe radius of the circle
linePoint1a first point on the line
linePoint2a second point on the line
intersectionthe initial point and the returned intersection point
Returns
true if an intersection has been found

Definition at line 218 of file qgsgeometryutils.cpp.

◆ lineIntersection()

static bool QgsGeometryUtils::lineIntersection ( const QgsPoint p1,
QgsVector  v1,
const QgsPoint p2,
QgsVector  v2,
QgsPoint intersection 
)
inlinestatic

Computes the intersection between two lines.

Z dimension is supported and is retrieved from the first 3D point amongst p1 and p2.

Parameters
p1Point on the first line
v1Direction vector of the first line
p2Point on the second line
v2Direction vector of the second line
intersectionOutput parameter, the intersection point
Returns
Whether the lines intersect

Definition at line 1220 of file qgsgeometryutils.h.

◆ linePerpendicularAngle()

static Q_DECL_DEPRECATED double QgsGeometryUtils::linePerpendicularAngle ( double  x1,
double  y1,
double  x2,
double  y2 
)
inlinestatic

Calculates the perpendicular angle to a line joining two points.

Returned angle is in radians, clockwise from the north direction.

Parameters
x1x-coordinate of line start
y1y-coordinate of line start
x2x-coordinate of line end
y2y-coordinate of line end
Returns
angle in radians. Returned value is undefined if start and end point are the same.
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 916 of file qgsgeometryutils.h.

◆ linesIntersection3D()

static Q_DECL_DEPRECATED bool QgsGeometryUtils::linesIntersection3D ( const QgsVector3D La1,
const QgsVector3D La2,
const QgsVector3D Lb1,
const QgsVector3D Lb2,
QgsVector3D intersection 
)
inlinestatic

An algorithm to calculate an (approximate) intersection of two lines in 3D.

Parameters
La1is the first point on the first line,
La2is the second point on the first line,
Lb1is the first point on the second line,
Lb2is the second point on the second line,
intersectionis the result intersection, of it can be found.
Returns
true if the intersection can be found, false - otherwise.

Example

# (True, PyQt5.QtGui.QgsVector3D(2.0, 0.0, 0.0))
# (True, PyQt5.QtGui.QgsVector3D(2.0, 0.0, 0.0))
# (True, PyQt5.QtGui.QgsVector3D(0.0, 0.0, 0.0))
# (True, PyQt5.QtGui.QgsVector3D(0.0, 0.0, 0.0))
# (False, PyQt5.QtGui.QgsVector3D(0.0, 0.0, 0.0))
# (False, PyQt5.QtGui.QgsVector3D(0.0, 0.0, 0.0))
# (True, PyQt5.QtGui.QgsVector3D(3.0, 3.0, 0.0))
# (True, PyQt5.QtGui.QgsVector3D(3.0, 3.0, 0.0))
# (True, PyQt5.QtGui.QgsVector3D(2.5, 2.5, 2.5))
# (True, PyQt5.QtGui.QgsVector3D(2.5, 2.5, 2.5))
# (True, PyQt5.QtGui.QgsVector3D(0.0, 5.0, 5.0))
static Q_DECL_DEPRECATED bool linesIntersection3D(const QgsVector3D &La1, const QgsVector3D &La2, const QgsVector3D &Lb1, const QgsVector3D &Lb2, QgsVector3D &intersection)
An algorithm to calculate an (approximate) intersection of two lines in 3D.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition qgsvector3d.h:31
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 1081 of file qgsgeometryutils.h.

◆ midpoint()

QgsPoint QgsGeometryUtils::midpoint ( const QgsPoint pt1,
const QgsPoint pt2 
)
static

Returns a middle point between points pt1 and pt2.

Z value is computed if one of this point have Z. M value is computed if one of this point have M.

Parameters
pt1first point.
pt2second point.
Returns
New point at middle between points pt1 and pt2.

Example

p = QgsPoint( 4, 6 ) # 2D point
pr = midpoint ( p, QgsPoint( 2, 2 ) )
# pr is a 2D point: 'Point (3 4)'
pr = midpoint ( p, QgsPoint( QgsWkbTypes.PointZ, 2, 2, 2 ) )
# pr is a 3D point: 'PointZ (3 4 1)'
pr = midpoint ( p, QgsPoint( QgsWkbTypes.PointM, 2, 2, 0, 2 ) )
# pr is a 3D point: 'PointM (3 4 1)'
pr = midpoint ( p, QgsPoint( QgsWkbTypes.PointZM, 2, 2, 2, 2 ) )
# pr is a 3D point: 'PointZM (3 4 1 1)'
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49

Definition at line 1095 of file qgsgeometryutils.cpp.

◆ normalizedAngle()

static Q_DECL_DEPRECATED double QgsGeometryUtils::normalizedAngle ( double  angle)
inlinestatic

Ensures that an angle is in the range 0 <= angle < 2 pi.

Parameters
angleangle in radians
Returns
equivalent angle within the range [0, 2 pi)
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 867 of file qgsgeometryutils.h.

◆ perpendicularCenterSegment()

static Q_DECL_DEPRECATED void QgsGeometryUtils::perpendicularCenterSegment ( double  centerPointX,
double  centerPointY,
double  segmentPoint1x,
double  segmentPoint1y,
double  segmentPoint2x,
double  segmentPoint2y,
double &  perpendicularSegmentPoint1x,
double &  perpendicularSegmentPoint1y,
double &  perpendicularSegmentPoint2x,
double &  perpendicularSegmentPoint2y,
double  segmentLength = 0 
)
inlinestatic

Create a perpendicular line segment to a given segment [segmentPoint1,segmentPoint2] with its center at centerPoint.

May be used to split geometries. Unless segmentLength is specified the new centered perpendicular line segment will have double the length of the input segment.

The result is a line (segment) centered in point p and perpendicular to segment [segmentPoint1, segmentPoint2].

Parameters
centerPointXx-coordinate of the point where the center of the perpendicular should be located
centerPointYy-coordinate of the point where the center of the perpendicular should be located
segmentPoint1xx-coordinate of segmentPoint1, the segment's start point
segmentPoint1yy-coordinate of segmentPoint1, the segment's start point
segmentPoint2xx-coordinate of segmentPoint2, the segment's end point
segmentPoint2yy-coordinate of segmentPoint2, the segment's end point
perpendicularSegmentPoint1xx-coordinate of the perpendicularCenterSegment's start point
perpendicularSegmentPoint1yy-coordinate of the perpendicularCenterSegment's start point
perpendicularSegmentPoint2xx-coordinate of the perpendicularCenterSegment's end point
perpendicularSegmentPoint2yy-coordinate of the perpendicularCenterSegment's end point
segmentLength(optional) Trims to given length. A segmentLength value of 0 refers to the default length which is double the length of the input segment. Set to 1 for a normalized length.
Since
QGIS 3.24
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 997 of file qgsgeometryutils.h.

◆ perpendicularOffsetPointAlongSegment()

static Q_DECL_DEPRECATED void QgsGeometryUtils::perpendicularOffsetPointAlongSegment ( double  x1,
double  y1,
double  x2,
double  y2,
double  proportion,
double  offset,
double *  x,
double *  y 
)
inlinestatic

Calculates a point a certain proportion of the way along the segment from (x1, y1) to (x2, y2), offset from the segment by the specified offset amount.

Parameters
x1x-coordinate of start of segment
y1y-coordinate of start of segment
x2x-coordinate of end of segment
y2y-coordinate of end of segment
proportionproportion of the segment's length at which to place the point (between 0.0 and 1.0)
offsetperpendicular offset from segment to apply to point. A negative offset shifts the point to the left of the segment, while a positive offset will shift it to the right of the segment.
xcalculated point x-coordinate
ycalculated point y-coordinate

Example

# Offset point at center of segment by 2 units to the right
# (6.0, 3.0)
# Offset point at center of segment by 2 units to the left
# (6.0, 7.0)
static Q_DECL_DEPRECATED void perpendicularOffsetPointAlongSegment(double x1, double y1, double x2, double y2, double proportion, double offset, double *x, double *y)
Calculates a point a certain proportion of the way along the segment from (x1, y1) to (x2,...
Since
QGIS 3.20
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 778 of file qgsgeometryutils.h.

◆ perpendicularSegment()

QgsLineString QgsGeometryUtils::perpendicularSegment ( const QgsPoint p,
const QgsPoint s1,
const QgsPoint s2 
)
static

Create a perpendicular line segment from p to segment [s1, s2].

Parameters
pThe point
s1The segment start point
s2The segment end point
Returns
A line (segment) from p to perpendicular point on segment [s1, s2]

Definition at line 1181 of file qgsgeometryutils.cpp.

◆ pointContinuesArc()

bool QgsGeometryUtils::pointContinuesArc ( const QgsPoint a1,
const QgsPoint a2,
const QgsPoint a3,
const QgsPoint b,
double  distanceTolerance,
double  pointSpacingAngleTolerance 
)
static

Returns true if point b is on the arc formed by points a1, a2, and a3, but not within that arc portion already described by a1, a2 and a3.

The distanceTolerance specifies the maximum deviation allowed between the original location of point and where it would fall on the candidate arc.

This method only consider a segments as continuing an arc if the points are all regularly spaced on the candidate arc. The pointSpacingAngleTolerance parameter specifies the maximum angular deviation (in radians) allowed when testing for regular point spacing.

Note
The API is considered EXPERIMENTAL and can be changed without a notice
Since
QGIS 3.14

Definition at line 614 of file qgsgeometryutils.cpp.

◆ pointFractionAlongLine()

static Q_DECL_DEPRECATED double QgsGeometryUtils::pointFractionAlongLine ( double  x1,
double  y1,
double  x2,
double  y2,
double  px,
double  py 
)
inlinestatic

Given the line (x1, y1) to (x2, y2) and a point (px, py) returns the fraction of the line length at which the point lies.

Warning
this method requires that the point definitely lies on the line!
Since
QGIS 3.32
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 1109 of file qgsgeometryutils.h.

◆ pointOnLineWithDistance() [1/2]

QgsPoint QgsGeometryUtils::pointOnLineWithDistance ( const QgsPoint startPoint,
const QgsPoint directionPoint,
double  distance 
)
static

Returns a point a specified distance toward a second point.

Definition at line 500 of file qgsgeometryutils.cpp.

◆ pointOnLineWithDistance() [2/2]

static Q_DECL_DEPRECATED void QgsGeometryUtils::pointOnLineWithDistance ( double  x1,
double  y1,
double  x2,
double  y2,
double  distance,
double &  x,
double &  y,
double *  z1 = nullptr,
double *  z2 = nullptr,
double *  z = nullptr,
double *  m1 = nullptr,
double *  m2 = nullptr,
double *  m = nullptr 
)
inlinestatic

Calculates the point a specified distance from (x1, y1) toward a second point (x2, y2).

Optionally, interpolated z and m values can be obtained by specifying the z1, z2 and z arguments and/or the m1, m2, m arguments.

Note
Not available in Python bindings
Since
QGIS 3.4
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 741 of file qgsgeometryutils.h.

◆ pointsAreCollinear()

static Q_DECL_DEPRECATED bool QgsGeometryUtils::pointsAreCollinear ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3,
double  epsilon 
)
inlinestatic

Given the points (x1, y1), (x2, y2) and (x3, y3) returns true if these points can be considered collinear with a specified tolerance epsilon.

Since
QGIS 3.32
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 1145 of file qgsgeometryutils.h.

◆ pointsFromWKT()

QgsPointSequence QgsGeometryUtils::pointsFromWKT ( const QString &  wktCoordinateList,
bool  is3D,
bool  isMeasure 
)
static

Returns a list of points contained in a WKT string.

Note
not available in Python bindings

Definition at line 815 of file qgsgeometryutils.cpp.

◆ pointsToGML2()

QDomElement QgsGeometryUtils::pointsToGML2 ( const QgsPointSequence points,
QDomDocument &  doc,
int  precision,
const QString &  ns,
QgsAbstractGeometry::AxisOrder  axisOrder = QgsAbstractGeometry::AxisOrder::XY 
)
static

Returns a gml::coordinates DOM element.

Note
not available in Python bindings

Definition at line 936 of file qgsgeometryutils.cpp.

◆ pointsToGML3()

QDomElement QgsGeometryUtils::pointsToGML3 ( const QgsPointSequence points,
QDomDocument &  doc,
int  precision,
const QString &  ns,
bool  is3D,
QgsAbstractGeometry::AxisOrder  axisOrder = QgsAbstractGeometry::AxisOrder::XY 
)
static

Returns a gml::posList DOM element.

Note
not available in Python bindings

Definition at line 963 of file qgsgeometryutils.cpp.

◆ pointsToJSON()

QString QgsGeometryUtils::pointsToJSON ( const QgsPointSequence points,
int  precision 
)
static

Returns a geoJSON coordinates string.

Note
not available in Python bindings

Definition at line 985 of file qgsgeometryutils.cpp.

◆ pointsToJson()

json QgsGeometryUtils::pointsToJson ( const QgsPointSequence points,
int  precision 
)
static

Returns coordinates as json object.

Note
not available in Python bindings

Definition at line 1001 of file qgsgeometryutils.cpp.

◆ pointsToWKB()

void QgsGeometryUtils::pointsToWKB ( QgsWkbPtr wkb,
const QgsPointSequence points,
bool  is3D,
bool  isMeasure,
QgsAbstractGeometry::WkbFlags  flags 
)
static

Returns a LinearRing { uint32 numPoints; Point points[numPoints]; }.

Note
not available in Python bindings

Definition at line 890 of file qgsgeometryutils.cpp.

◆ pointsToWKT()

QString QgsGeometryUtils::pointsToWKT ( const QgsPointSequence points,
int  precision,
bool  is3D,
bool  isMeasure 
)
static

Returns a WKT coordinate list.

Note
not available in Python bindings

Definition at line 917 of file qgsgeometryutils.cpp.

◆ projectPointOnSegment()

static QgsPoint QgsGeometryUtils::projectPointOnSegment ( const QgsPoint p,
const QgsPoint s1,
const QgsPoint s2 
)
inlinestatic

Project the point on a segment.

Parameters
pThe point
s1The segment start point
s2The segment end point
Returns
The projection of the point on the segment

Definition at line 185 of file qgsgeometryutils.h.

◆ segmentIntersection()

static bool QgsGeometryUtils::segmentIntersection ( const QgsPoint p1,
const QgsPoint p2,
const QgsPoint q1,
const QgsPoint q2,
QgsPoint intersectionPoint,
bool &  isIntersection,
double  tolerance = 1e-8,
bool  acceptImproperIntersection = false 
)
inlinestatic

Compute the intersection between two segments.

Parameters
p1First segment start point
p2First segment end point
q1Second segment start point
q2Second segment end point
intersectionPointOutput parameter, the intersection point
isIntersectionOutput parameter, return true if an intersection is found
toleranceThe tolerance to use
acceptImproperIntersectionBy default, this method returns true only if segments have proper intersection. If set true, returns also TRUE if segments have improper intersection (end of one segment on other segment ; continuous segments).
Returns
Whether the segments intersect

Example

ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 1 ), QgsPoint( 1, 1 ), QgsPoint( 1, 0 ) )
ret[0], ret[1].asWkt(), ret[2]
# Whether the segments intersect, the intersection point, is intersect
# (False, 'Point (0 0)', False)
ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 5 ), QgsPoint( 1, 5 ) )
ret[0], ret[1].asWkt(), ret[2]
# (False, 'Point (0 5)', True)
ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 5 ), QgsPoint( 1, 5 ), acceptImproperIntersection=True )
ret[0], ret[1].asWkt(), ret[2]
# (True, 'Point (0 5)', True)
ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 2 ), QgsPoint( 1, 5 ) )
ret[0], ret[1].asWkt(), ret[2]
# (False, 'Point (0 2)', True)
ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, 0 ), QgsPoint( 0, 5 ), QgsPoint( 0, 2 ), QgsPoint( 1, 5 ), acceptImproperIntersection=True )
ret[0], ret[1].asWkt(), ret[2]
# (True, 'Point (0 2)', True)
ret = QgsGeometryUtils.segmentIntersection( QgsPoint( 0, -5 ), QgsPoint( 0, 5 ), QgsPoint( 2, 0 ), QgsPoint( -1, 0 ) )
ret[0], ret[1].asWkt(), ret[2]
# (True, 'Point (0 0)', True)
static bool segmentIntersection(const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &intersectionPoint, bool &isIntersection, double tolerance=1e-8, bool acceptImproperIntersection=false)
Compute the intersection between two segments.

Definition at line 1268 of file qgsgeometryutils.h.

◆ segmentizeArc()

void QgsGeometryUtils::segmentizeArc ( const QgsPoint p1,
const QgsPoint p2,
const QgsPoint p3,
QgsPointSequence points,
double  tolerance = M_PI_2 / 90,
QgsAbstractGeometry::SegmentationToleranceType  toleranceType = QgsAbstractGeometry::MaximumAngle,
bool  hasZ = false,
bool  hasM = false 
)
static

Convert circular arc defined by p1, p2, p3 (p1/p3 being start resp.

end point, p2 lies on the arc) into a sequence of points.

Definition at line 673 of file qgsgeometryutils.cpp.

◆ segmentMidPoint()

bool QgsGeometryUtils::segmentMidPoint ( const QgsPoint p1,
const QgsPoint p2,
QgsPoint result,
double  radius,
const QgsPoint mousePos 
)
static

Calculates midpoint on circle passing through p1 and p2, closest to the given coordinate mousePos.

Z dimension is supported and is retrieved from the first 3D point amongst p1 and p2.

See also
segmentMidPointFromCenter()

Definition at line 533 of file qgsgeometryutils.cpp.

◆ segmentMidPointFromCenter()

QgsPoint QgsGeometryUtils::segmentMidPointFromCenter ( const QgsPoint p1,
const QgsPoint p2,
const QgsPoint center,
bool  useShortestArc = true 
)
static

Calculates the midpoint on the circle passing through p1 and p2, with the specified center coordinate.

If useShortestArc is true, then the midpoint returned will be that corresponding to the shorter arc from p1 to p2. If it is false, the longer arc from p1 to p2 will be used (i.e. winding the other way around the circle).

See also
segmentMidPoint()
Since
QGIS 3.2

Definition at line 580 of file qgsgeometryutils.cpp.

◆ segmentSide()

int QgsGeometryUtils::segmentSide ( const QgsPoint pt1,
const QgsPoint pt3,
const QgsPoint pt2 
)
static

For line defined by points pt1 and pt3, find out on which side of the line is point pt2.

Returns -1 if pt2 on the left side, 1 if pt2 is on the right side or 0 if pt2 lies on the line.

Definition at line 794 of file qgsgeometryutils.cpp.

◆ selfIntersections()

QVector< QgsGeometryUtils::SelfIntersection > QgsGeometryUtils::selfIntersections ( const QgsAbstractGeometry geom,
int  part,
int  ring,
double  tolerance 
)
static

Find self intersections in a polyline.

Parameters
geomThe geometry to check
partThe part of the geometry to check
ringThe ring of the geometry part to check
toleranceThe tolerance to use
Returns
The list of self intersections
Note
not available in Python bindings

Definition at line 455 of file qgsgeometryutils.cpp.

◆ setZValueFromPoints()

static Q_DECL_DEPRECATED bool QgsGeometryUtils::setZValueFromPoints ( const QgsPointSequence points,
QgsPoint point 
)
inlinestatic

A Z dimension is added to point if one of the point in the list points is in 3D.

Moreover, the Z value of point is updated with the first Z value found in list points even if point already contains a Z value.

Parameters
pointsList of points in which a 3D point is searched.
pointThe point to update with Z dimension and value.
Returns
true if the point is updated, false otherwise
Warning
This method does not copy the z value of the coordinate from the points whose z value is closest to the original x/y point, but only the first one found.
Deprecated:
QGIS 3.20. Use transferFirstZValueToPoint( const QgsPointSequence &points, QgsPoint &point ) instead.

Definition at line 462 of file qgsgeometryutils.h.

◆ skewLinesDistance()

static Q_DECL_DEPRECATED double QgsGeometryUtils::skewLinesDistance ( const QgsVector3D P1,
const QgsVector3D P12,
const QgsVector3D P2,
const QgsVector3D P22 
)
inlinestatic

An algorithm to calculate the shortest distance between two skew lines.

Parameters
P1is the first point of the first line,
P12is the second point on the first line,
P2is the first point on the second line,
P22is the second point on the second line.
Returns
the shortest distance
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 1017 of file qgsgeometryutils.h.

◆ skewLinesProjection()

static Q_DECL_DEPRECATED bool QgsGeometryUtils::skewLinesProjection ( const QgsVector3D P1,
const QgsVector3D P12,
const QgsVector3D P2,
const QgsVector3D P22,
QgsVector3D X1,
double  epsilon = 0.0001 
)
inlinestatic

A method to project one skew line onto another.

Parameters
P1is a first point that belonds to first skew line,
P12is the second point that belongs to first skew line,
P2is the first point that belongs to second skew line,
P22is the second point that belongs to second skew line,
X1is the result projection point of line P2P22 onto line P1P12,
epsilonthe tolerance to use.
Returns
true if such point exists, false - otherwise.
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 1034 of file qgsgeometryutils.h.

◆ sqrDistance2D() [1/2]

static double QgsGeometryUtils::sqrDistance2D ( const QgsPoint pt1,
const QgsPoint pt2 
)
inlinestatic

Returns the squared 2D distance between two points.

Definition at line 667 of file qgsgeometryutils.h.

◆ sqrDistance2D() [2/2]

static Q_DECL_DEPRECATED double QgsGeometryUtils::sqrDistance2D ( double  x1,
double  y1,
double  x2,
double  y2 
)
inlinestatic

Returns the squared 2D distance between (x1, y1) and (x2, y2).

Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 662 of file qgsgeometryutils.h.

◆ sqrDistance3D()

static double QgsGeometryUtils::sqrDistance3D ( const QgsPoint pt1,
const QgsPoint pt2 
)
inlinestatic

Returns the squared 3D distance between two points.

Warning
No check is done if z contains NaN value. This is the caller's responsibility.
Since
QGIS 3.36

Definition at line 678 of file qgsgeometryutils.h.

◆ sqrDistToLine()

static Q_DECL_DEPRECATED double QgsGeometryUtils::sqrDistToLine ( double  ptX,
double  ptY,
double  x1,
double  y1,
double  x2,
double  y2,
double &  minDistX,
double &  minDistY,
double  epsilon 
)
inlinestatic

Returns the squared distance between a point and a line.

Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 712 of file qgsgeometryutils.h.

◆ sweepAngle()

static Q_DECL_DEPRECATED double QgsGeometryUtils::sweepAngle ( double  centerX,
double  centerY,
double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3 
)
inlinestatic

Calculates angle of a circular string part defined by pt1, pt2, pt3.

Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 846 of file qgsgeometryutils.h.

◆ tangentPointAndCircle()

bool QgsGeometryUtils::tangentPointAndCircle ( const QgsPointXY center,
double  radius,
const QgsPointXY p,
QgsPointXY pt1,
QgsPointXY pt2 
)
static

Calculates the tangent points between the circle with the specified center and radius and the point p.

If found, the tangent points will be stored in pt1 and pt2.

Since
QGIS 3.2

Definition at line 350 of file qgsgeometryutils.cpp.

◆ transferFirstMValueToPoint()

bool QgsGeometryUtils::transferFirstMValueToPoint ( const QgsPointSequence points,
QgsPoint point 
)
static

A M dimension is added to point if one of the points in the list points contains an M value.

Moreover, the M value of point is updated with the first M value found in list points even if point already contains a M value.

Parameters
pointsList of points in which a M point is searched.
pointThe point to update with M dimension and value.
Returns
true if the point is updated, false otherwise
Warning
This method does not copy the m value of the coordinate from the points whose m value is closest to the original x/y point, but only the first one found.
Since
QGIS 3.20

Definition at line 1219 of file qgsgeometryutils.cpp.

◆ transferFirstZOrMValueToPoint() [1/3]

static bool QgsGeometryUtils::transferFirstZOrMValueToPoint ( const QgsGeometry geom,
QgsPoint point 
)
inlinestatic

A Z or M dimension is added to point if one of the points in the list points contains Z or M value.

This method is equivalent to successively calling Z and M but avoiding looping twice over the set of points.

Parameters
geomgeometry in which a M point is searched.
pointThe point to update with Z or M dimension and value.
Returns
true if the point is updated, false otherwise
Warning
This method does not copy the z or m value of the coordinate from the points whose z or m value is closest to the original x/y point, but only the first one found.
Since
QGIS 3.20

Definition at line 582 of file qgsgeometryutils.h.

◆ transferFirstZOrMValueToPoint() [2/3]

static bool QgsGeometryUtils::transferFirstZOrMValueToPoint ( const QgsPointSequence points,
QgsPoint point 
)
inlinestatic

A Z or M dimension is added to point if one of the points in the list points contains Z or M value.

This method is equivalent to successively calling Z and M but avoiding looping twice over the set of points.

Parameters
pointsList of points in which a M point is searched.
pointThe point to update with Z or M dimension and value.
Returns
true if the point is updated, false otherwise
Warning
This method does not copy the z or m value of the coordinate from the points whose z or m value is closest to the original x/y point, but only the first one found.
Since
QGIS 3.20

Definition at line 561 of file qgsgeometryutils.h.

◆ transferFirstZOrMValueToPoint() [3/3]

template<class Iterator >
static bool QgsGeometryUtils::transferFirstZOrMValueToPoint ( Iterator  verticesBegin,
Iterator  verticesEnd,
QgsPoint point 
)
inlinestatic

A Z or M dimension is added to point if one of the points in the list points contains Z or M value.

This method is equivalent to successively calling Z and M but avoiding looping twice over the set of points.

Parameters
verticesBeginbegin vertex which a Z or M point is searched.
verticesEndend vertex which a Z or M point is searched.
pointThe point to update with Z or M dimension and value.
Returns
true if the point is updated, false otherwise
Warning
This method does not copy the z or m value of the coordinate from the points whose z or m value is closest to the original x/y point, but only the first one found.
Note
Not available in Python bindings
Since
QGIS 3.20

Definition at line 519 of file qgsgeometryutils.h.

◆ transferFirstZValueToPoint()

bool QgsGeometryUtils::transferFirstZValueToPoint ( const QgsPointSequence points,
QgsPoint point 
)
static

A Z dimension is added to point if one of the point in the list points is in 3D.

Moreover, the Z value of point is updated with the first Z value found in list points even if point already contains a Z value.

Parameters
pointsList of points in which a 3D point is searched.
pointThe point to update with Z dimension and value.
Returns
true if the point is updated, false otherwise
Warning
This method does not copy the z value of the coordinate from the points whose z value is closest to the original x/y point, but only the first one found.
Since
QGIS 3.20

Definition at line 1237 of file qgsgeometryutils.cpp.

◆ triangleArea()

static Q_DECL_DEPRECATED double QgsGeometryUtils::triangleArea ( double  aX,
double  aY,
double  bX,
double  bY,
double  cX,
double  cY 
)
inlinestatic

Returns the area of the triangle denoted by the points (aX, aY), (bX, bY) and (cX, cY).

Since
QGIS 3.10
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 1095 of file qgsgeometryutils.h.

◆ verticesAtDistance()

bool QgsGeometryUtils::verticesAtDistance ( const QgsAbstractGeometry geometry,
double  distance,
QgsVertexId previousVertex,
QgsVertexId nextVertex 
)
static

Retrieves the vertices which are before and after the interpolated point at a specified distance along a linestring (or polygon boundary).

Parameters
geometryline or polygon geometry
distancedistance to traverse along geometry
previousVertexwill be set to previous vertex ID
nextVertexwill be set to next vertex ID
Returns
true if vertices were successfully retrieved
Note
if the distance coincides exactly with a vertex, then both previousVertex and nextVertex will be set to this vertex

Definition at line 152 of file qgsgeometryutils.cpp.

◆ weightedPointInTriangle()

static Q_DECL_DEPRECATED void QgsGeometryUtils::weightedPointInTriangle ( double  aX,
double  aY,
double  bX,
double  bY,
double  cX,
double  cY,
double  weightB,
double  weightC,
double &  pointX,
double &  pointY 
)
inlinestatic

Returns a weighted point inside the triangle denoted by the points (aX, aY), (bX, bY) and (cX, cY).

Parameters
aXx-coordinate of first vertex in triangle
aYy-coordinate of first vertex in triangle
bXx-coordinate of second vertex in triangle
bYy-coordinate of second vertex in triangle
cXx-coordinate of third vertex in triangle
cYy-coordinate of third vertex in triangle
weightBweighting factor along axis A-B (between 0 and 1)
weightCweighting factor along axis A-C (between 0 and 1)
pointXx-coordinate of generated point
pointYy-coordinate of generated point
Since
QGIS 3.10
Deprecated:
QGIS 3.40. Use QgsGeometryUtilsBase methods instead.

Definition at line 1132 of file qgsgeometryutils.h.

◆ wktGetChildBlocks()

QStringList QgsGeometryUtils::wktGetChildBlocks ( const QString &  wkt,
const QString &  defaultType = QString() 
)
static

Parses a WKT string and returns of list of blocks contained in the WKT.

Parameters
wktWKT string in the format "TYPE1 (contents1), TYPE2 (TYPE3 (contents3), TYPE4 (contents4))"
defaultTypedefault geometry type for children
Returns
list of WKT child block strings, e.g., List("TYPE1 (contents1)", "TYPE2 (TYPE3 (contents3), TYPE4 (contents4))")
Note
not available in Python bindings

Definition at line 1055 of file qgsgeometryutils.cpp.

◆ wktReadBlock()

QPair< Qgis::WkbType, QString > QgsGeometryUtils::wktReadBlock ( const QString &  wkt)
static

Parses a WKT block of the format "TYPE( contents )" and returns a pair of geometry type to contents ("Pair(wkbType, "contents")")

Note
not available in Python bindings

Definition at line 1018 of file qgsgeometryutils.cpp.


The documentation for this class was generated from the following files: