16 #ifndef QGSGEOMETRYUTILS_H 17 #define QGSGEOMETRYUTILS_H 21 #include "qgis_core.h" 92 static double sqrDistToLine(
double ptX,
double ptY,
double x1,
double y1,
double x2,
double y2,
double &minDistX SIP_OUT,
double &minDistY SIP_OUT,
double epsilon );
141 static bool segmentIntersection(
const QgsPoint &p1,
const QgsPoint &p2,
const QgsPoint &q1,
const QgsPoint &q2,
QgsPoint &intersectionPoint SIP_OUT,
bool &isIntersection SIP_OUT,
double tolerance = 1e-8,
bool acceptImproperIntersection =
false );
154 static bool lineCircleIntersection(
const QgsPointXY ¢er,
double radius,
168 static int circleCircleIntersections(
QgsPointXY center1,
double radius1,
180 static bool tangentPointAndCircle(
const QgsPointXY ¢er,
double radius,
200 static int circleCircleOuterTangents(
214 double nx = s2.
y() - s1.
y();
215 double ny = -( s2.
x() - s1.
x() );
216 double t = ( p.
x() * ny - p.
y() * nx - s1.
x() * ny + s1.
y() * nx ) / ( ( s2.
x() - s1.
x() ) * ny - ( s2.
y() - s1.
y() ) * nx );
217 return t < 0. ? s1 : t > 1. ? s2 :
QgsPoint( s1.
x() + ( s2.
x() - s1.
x() ) * t, s1.
y() + ( s2.
y() - s1.
y() ) * t );
238 static QVector<SelfIntersection> selfIntersections(
const QgsAbstractGeometry *geom,
int part,
int ring,
double tolerance )
SIP_SKIP;
247 static int leftOfLine(
double x,
double y,
double x1,
double y1,
double x2,
double y2 );
252 static QgsPoint pointOnLineWithDistance(
const QgsPoint &startPoint,
const QgsPoint &directionPoint,
double distance );
263 static void pointOnLineWithDistance(
double x1,
double y1,
double x2,
double y2,
double distance,
double &x,
double &y,
264 double *z1 =
nullptr,
double *z2 =
nullptr,
double *z =
nullptr,
265 double *m1 =
nullptr,
double *m2 =
nullptr,
double *m =
nullptr ) SIP_SKIP;
278 static
double ccwAngle(
double dy,
double dx );
281 static
void circleCenterRadius( const
QgsPoint &pt1, const
QgsPoint &pt2, const
QgsPoint &pt3,
double &radius SIP_OUT,
282 double ¢erX SIP_OUT,
double ¢erY SIP_OUT );
290 static
bool circleClockwise(
double angle1,
double angle2,
double angle3 );
293 static
bool circleAngleBetween(
double angle,
double angle1,
double angle2,
bool clockwise );
299 static
bool angleOnCircle(
double angle,
double angle1,
double angle2,
double angle3 );
302 static
double circleLength(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
305 static
double sweepAngle(
double centerX,
double centerY,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
338 bool hasZ = false,
bool hasM = false );
351 static
double interpolateArcValue(
double angle,
double a1,
double a2,
double a3,
double zm1,
double zm2,
double zm3 );
357 static
QgsPointSequence pointsFromWKT( const QString &wktCoordinateList,
bool is3D,
bool isMeasure ) SIP_SKIP;
387 static QString pointsToJSON( const
QgsPointSequence &points,
int precision ) SIP_SKIP;
394 static
double normalizedAngle(
double angle );
404 static
double lineAngle(
double x1,
double y1,
double x2,
double y2 );
417 static
double angleBetweenThreePoints(
double x1,
double y1,
double x2,
double y2,
418 double x3,
double y3 );
429 static
double linePerpendicularAngle(
double x1,
double y1,
double x2,
double y2 );
435 static
double averageAngle(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
443 static
double averageAngle(
double a1,
double a2 );
449 static QPair<
QgsWkbTypes::Type, QString> wktReadBlock( const QString &wkt ) SIP_SKIP;
458 static QStringList wktGetChildBlocks( const QString &wkt, const QString &defaultType = QString() ) SIP_SKIP;
496 static
QgsPointXY interpolatePointOnLine(
double x1,
double y1,
double x2,
double y2,
double fraction );
528 static
QgsPointXY interpolatePointOnLineByValue(
double x1,
double y1,
double v1,
double x2,
double y2,
double v2,
double value );
549 double &a SIP_OUT,
double &b SIP_OUT,
double &
c SIP_OUT );
585 double epsilon = 0.0001 );
648 double minDist = std::numeric_limits<double>::max();
649 double minDistSegmentX = 0.0, minDistSegmentY = 0.0;
651 int minDistLeftOf = 0;
652 double sqrDist = 0.0;
653 int vertexOffset = 0;
657 for (
int i = 0; i < container.size(); ++i )
659 sqrDist = container.at( i )->closestSegment( pt, segmentPt, vertexAfter,
leftOf, epsilon );
660 if ( sqrDist >= 0 && sqrDist < minDist )
663 minDistSegmentX = segmentPt.x();
664 minDistSegmentY = segmentPt.y();
665 minDistVertexAfter = vertexAfter;
666 minDistVertexAfter.
vertex = vertexAfter.vertex + vertexOffset;
667 minDistVertexAfter.
part = vertexAfter.part + partOffset;
668 minDistVertexAfter.
ring = vertexAfter.ring + ringOffset;
675 if ( ctype == Vertex )
678 vertexOffset += container.at( i )->nCoordinates() - 1;
680 else if ( ctype == Ring )
684 else if ( ctype == Part )
690 if ( minDist == std::numeric_limits<double>::max() )
693 segmentPt.setX( minDistSegmentX );
694 segmentPt.setY( minDistSegmentY );
695 vertexAfter = minDistVertexAfter;
704 #endif // QGSGEOMETRYUTILS_H 3 Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double preci...
Handles storage of information regarding WKB types and their properties.
A class to represent a 2D point.
bool ANALYSIS_EXPORT lineIntersection(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Returns true, if line1 (p1 to p2) and line2 (p3 to p4) intersect. If the lines have an endpoint in co...
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Contains various geometry utility functions.
Utility class for identifying a unique vertex within a geometry.
Abstract base class for all geometries.
Point geometry type, with support for z-dimension and m-values.
A class to represent a vector.
QVector< QgsPoint > QgsPointSequence
Line string geometry type, with support for z-dimension and m-values.
static QgsPoint projectPointOnSegment(const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2)
Project the point on a segment.
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...
static double closestSegmentFromComponents(T &container, ComponentType ctype, const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, int *leftOf, double epsilon)
#define SIP_PYALTERNATIVETYPE(type)