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 );
255 static double ccwAngle(
double dy,
double dx );
258 static void circleCenterRadius(
const QgsPoint &pt1,
const QgsPoint &pt2,
const QgsPoint &pt3,
double &radius SIP_OUT,
259 double ¢erX SIP_OUT,
double ¢erY SIP_OUT );
262 static bool circleClockwise(
double angle1,
double angle2,
double angle3 );
265 static bool circleAngleBetween(
double angle,
double angle1,
double angle2,
bool clockwise );
271 static bool angleOnCircle(
double angle,
double angle1,
double angle2,
double angle3 );
274 static double circleLength(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
277 static double sweepAngle(
double centerX,
double centerY,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
310 bool hasZ =
false,
bool hasM =
false );
323 static double interpolateArcValue(
double angle,
double a1,
double a2,
double a3,
double zm1,
double zm2,
double zm3 );
366 static double normalizedAngle(
double angle );
376 static double lineAngle(
double x1,
double y1,
double x2,
double y2 );
389 static double angleBetweenThreePoints(
double x1,
double y1,
double x2,
double y2,
390 double x3,
double y3 );
401 static double linePerpendicularAngle(
double x1,
double y1,
double x2,
double y2 );
407 static double averageAngle(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
415 static double averageAngle(
double a1,
double a2 );
421 static QPair<QgsWkbTypes::Type, QString> wktReadBlock(
const QString &wkt )
SIP_SKIP;
430 static QStringList wktGetChildBlocks(
const QString &wkt,
const QString &defaultType = QString() ) SIP_SKIP;
468 static
QgsPointXY interpolatePointOnLine(
double x1,
double y1,
double x2,
double y2,
double fraction );
500 static
QgsPointXY interpolatePointOnLineByValue(
double x1,
double y1,
double v1,
double x2,
double y2,
double v2,
double value );
521 double &a SIP_OUT,
double &b SIP_OUT,
double &
c SIP_OUT );
557 double epsilon = 0.0001 );
620 double minDist = std::numeric_limits<double>::max();
621 double minDistSegmentX = 0.0, minDistSegmentY = 0.0;
623 int minDistLeftOf = 0;
624 double sqrDist = 0.0;
625 int vertexOffset = 0;
629 for (
int i = 0; i < container.size(); ++i )
631 sqrDist = container.at( i )->closestSegment( pt, segmentPt, vertexAfter,
leftOf, epsilon );
632 if ( sqrDist >= 0 && sqrDist < minDist )
635 minDistSegmentX = segmentPt.x();
636 minDistSegmentY = segmentPt.y();
637 minDistVertexAfter = vertexAfter;
638 minDistVertexAfter.
vertex = vertexAfter.vertex + vertexOffset;
639 minDistVertexAfter.
part = vertexAfter.part + partOffset;
640 minDistVertexAfter.
ring = vertexAfter.ring + ringOffset;
647 if ( ctype == Vertex )
650 vertexOffset += container.at( i )->nCoordinates() - 1;
652 else if ( ctype == Ring )
656 else if ( ctype == Part )
662 if ( minDist == std::numeric_limits<double>::max() )
665 segmentPt.setX( minDistSegmentX );
666 segmentPt.setY( minDistSegmentY );
667 vertexAfter = minDistVertexAfter;
676 #endif // QGSGEOMETRYUTILS_H 3 Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double preci...
Maximum angle between generating radii (lines from arc center to output vertices) ...
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...
SegmentationToleranceType
Segmentation tolerance as maximum angle or maximum difference between approximation and circle...
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.
AxisOrder
Axis order for GML generation.
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)