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(
223 static int circleCircleInnerTangents(
237 double nx = s2.
y() - s1.
y();
238 double ny = -( s2.
x() - s1.
x() );
239 double t = ( p.
x() * ny - p.
y() * nx - s1.
x() * ny + s1.
y() * nx ) / ( ( s2.
x() - s1.
x() ) * ny - ( s2.
y() - s1.
y() ) * nx );
240 return t < 0. ? s1 : t > 1. ? s2 :
QgsPoint( s1.
x() + ( s2.
x() - s1.
x() ) * t, s1.
y() + ( s2.
y() - s1.
y() ) * t );
261 static QVector<SelfIntersection> selfIntersections(
const QgsAbstractGeometry *geom,
int part,
int ring,
double tolerance )
SIP_SKIP;
270 static int leftOfLine(
const double x,
const double y,
const double x1,
const double y1,
const double x2,
const double y2 );
286 static QgsPoint pointOnLineWithDistance(
const QgsPoint &startPoint,
const QgsPoint &directionPoint,
double distance );
297 static void pointOnLineWithDistance(
double x1,
double y1,
double x2,
double y2,
double distance,
double &x,
double &y,
298 double *z1 =
nullptr,
double *z2 =
nullptr,
double *z =
nullptr,
299 double *m1 =
nullptr,
double *m2 =
nullptr,
double *m =
nullptr ) SIP_SKIP;
312 static
double ccwAngle(
double dy,
double dx );
315 static
void circleCenterRadius( const
QgsPoint &pt1, const
QgsPoint &pt2, const
QgsPoint &pt3,
double &radius SIP_OUT,
316 double ¢erX SIP_OUT,
double ¢erY SIP_OUT );
324 static
bool circleClockwise(
double angle1,
double angle2,
double angle3 );
327 static
bool circleAngleBetween(
double angle,
double angle1,
double angle2,
bool clockwise );
333 static
bool angleOnCircle(
double angle,
double angle1,
double angle2,
double angle3 );
336 static
double circleLength(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
339 static
double sweepAngle(
double centerX,
double centerY,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
372 bool hasZ = false,
bool hasM = false );
385 static
double interpolateArcValue(
double angle,
double a1,
double a2,
double a3,
double zm1,
double zm2,
double zm3 );
391 static
QgsPointSequence pointsFromWKT( const QString &wktCoordinateList,
bool is3D,
bool isMeasure ) SIP_SKIP;
421 static QString pointsToJSON( const
QgsPointSequence &points,
int precision ) SIP_SKIP;
428 static
double normalizedAngle(
double angle );
438 static
double lineAngle(
double x1,
double y1,
double x2,
double y2 );
451 static
double angleBetweenThreePoints(
double x1,
double y1,
double x2,
double y2,
452 double x3,
double y3 );
463 static
double linePerpendicularAngle(
double x1,
double y1,
double x2,
double y2 );
469 static
double averageAngle(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
477 static
double averageAngle(
double a1,
double a2 );
483 static QPair<
QgsWkbTypes::Type, QString> wktReadBlock( const QString &wkt ) SIP_SKIP;
492 static QStringList wktGetChildBlocks( const QString &wkt, const QString &defaultType = QString() ) SIP_SKIP;
530 static
QgsPointXY interpolatePointOnLine(
double x1,
double y1,
double x2,
double y2,
double fraction );
562 static
QgsPointXY interpolatePointOnLineByValue(
double x1,
double y1,
double v1,
double x2,
double y2,
double v2,
double value );
583 double &a SIP_OUT,
double &b SIP_OUT,
double &
c SIP_OUT );
619 double epsilon = 0.0001 );
682 double minDist = std::numeric_limits<double>::max();
683 double minDistSegmentX = 0.0, minDistSegmentY = 0.0;
685 int minDistLeftOf = 0;
686 double sqrDist = 0.0;
687 int vertexOffset = 0;
691 for (
int i = 0; i < container.size(); ++i )
693 sqrDist = container.at( i )->closestSegment( pt, segmentPt, vertexAfter,
leftOf, epsilon );
694 if ( sqrDist >= 0 && sqrDist < minDist )
697 minDistSegmentX = segmentPt.x();
698 minDistSegmentY = segmentPt.y();
699 minDistVertexAfter = vertexAfter;
700 minDistVertexAfter.
vertex = vertexAfter.vertex + vertexOffset;
701 minDistVertexAfter.
part = vertexAfter.part + partOffset;
702 minDistVertexAfter.
ring = vertexAfter.ring + ringOffset;
709 if ( ctype == Vertex )
712 vertexOffset += container.at( i )->nCoordinates() - 1;
714 else if ( ctype == Ring )
718 else if ( ctype == Part )
724 if ( minDist == std::numeric_limits<double>::max() )
727 segmentPt.setX( minDistSegmentX );
728 segmentPt.setY( minDistSegmentY );
729 vertexAfter = minDistVertexAfter;
738 #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)