16 #ifndef QGSGEOMETRYUTILS_H 17 #define QGSGEOMETRYUTILS_H 21 #include "qgis_core.h" 93 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 );
142 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 );
155 static bool lineCircleIntersection(
const QgsPointXY ¢er,
double radius,
169 static int circleCircleIntersections(
QgsPointXY center1,
double radius1,
181 static bool tangentPointAndCircle(
const QgsPointXY ¢er,
double radius,
201 static int circleCircleOuterTangents(
224 static int circleCircleInnerTangents(
238 double nx = s2.
y() - s1.
y();
239 double ny = -( s2.
x() - s1.
x() );
240 double t = ( p.
x() * ny - p.
y() * nx - s1.
x() * ny + s1.
y() * nx ) / ( ( s2.
x() - s1.
x() ) * ny - ( s2.
y() - s1.
y() ) * nx );
241 return t < 0. ? s1 : t > 1. ? s2 :
QgsPoint( s1.
x() + ( s2.
x() - s1.
x() ) * t, s1.
y() + ( s2.
y() - s1.
y() ) * t );
262 static QVector<SelfIntersection> selfIntersections(
const QgsAbstractGeometry *geom,
int part,
int ring,
double tolerance )
SIP_SKIP;
271 static int leftOfLine(
const double x,
const double y,
const double x1,
const double y1,
const double x2,
const double y2 );
287 static QgsPoint pointOnLineWithDistance(
const QgsPoint &startPoint,
const QgsPoint &directionPoint,
double distance );
298 static void pointOnLineWithDistance(
double x1,
double y1,
double x2,
double y2,
double distance,
double &x,
double &y,
299 double *z1 =
nullptr,
double *z2 =
nullptr,
double *z =
nullptr,
300 double *m1 =
nullptr,
double *m2 =
nullptr,
double *m =
nullptr ) SIP_SKIP;
313 static
double ccwAngle(
double dy,
double dx );
316 static
void circleCenterRadius( const
QgsPoint &pt1, const
QgsPoint &pt2, const
QgsPoint &pt3,
double &radius SIP_OUT,
317 double ¢erX SIP_OUT,
double ¢erY SIP_OUT );
325 static
bool circleClockwise(
double angle1,
double angle2,
double angle3 );
328 static
bool circleAngleBetween(
double angle,
double angle1,
double angle2,
bool clockwise );
334 static
bool angleOnCircle(
double angle,
double angle1,
double angle2,
double angle3 );
337 static
double circleLength(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
340 static
double sweepAngle(
double centerX,
double centerY,
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
373 bool hasZ = false,
bool hasM = false );
386 static
double interpolateArcValue(
double angle,
double a1,
double a2,
double a3,
double zm1,
double zm2,
double zm3 );
392 static
QgsPointSequence pointsFromWKT( const QString &wktCoordinateList,
bool is3D,
bool isMeasure ) SIP_SKIP;
422 static QString pointsToJSON( const
QgsPointSequence &points,
int precision ) SIP_SKIP;
428 static json pointsToJson( const
QgsPointSequence &points,
int precision ) SIP_SKIP;
435 static
double normalizedAngle(
double angle );
445 static
double lineAngle(
double x1,
double y1,
double x2,
double y2 );
458 static
double angleBetweenThreePoints(
double x1,
double y1,
double x2,
double y2,
459 double x3,
double y3 );
470 static
double linePerpendicularAngle(
double x1,
double y1,
double x2,
double y2 );
476 static
double averageAngle(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3 );
484 static
double averageAngle(
double a1,
double a2 );
490 static QPair<
QgsWkbTypes::Type, QString> wktReadBlock( const QString &wkt ) SIP_SKIP;
499 static QStringList wktGetChildBlocks( const QString &wkt, const QString &defaultType = QString() ) SIP_SKIP;
537 static
QgsPointXY interpolatePointOnLine(
double x1,
double y1,
double x2,
double y2,
double fraction );
569 static
QgsPointXY interpolatePointOnLineByValue(
double x1,
double y1,
double v1,
double x2,
double y2,
double v2,
double value );
590 double &a SIP_OUT,
double &b SIP_OUT,
double &
c SIP_OUT );
626 double epsilon = 0.0001 );
672 static
double triangleArea(
double aX,
double aY,
double bX,
double bY,
double cX,
double cY );
691 static
void weightedPointInTriangle(
double aX,
double aY,
double bX,
double bY,
double cX,
double cY,
692 double weightB,
double weightC,
double &pointX SIP_OUT,
double &pointY SIP_OUT );
717 double minDist = std::numeric_limits<double>::max();
718 double minDistSegmentX = 0.0, minDistSegmentY = 0.0;
720 int minDistLeftOf = 0;
721 double sqrDist = 0.0;
722 int vertexOffset = 0;
726 for (
int i = 0; i < container.size(); ++i )
728 sqrDist = container.at( i )->closestSegment( pt, segmentPt, vertexAfter,
leftOf, epsilon );
729 if ( sqrDist >= 0 && sqrDist < minDist )
732 minDistSegmentX = segmentPt.x();
733 minDistSegmentY = segmentPt.y();
734 minDistVertexAfter = vertexAfter;
735 minDistVertexAfter.
vertex = vertexAfter.vertex + vertexOffset;
736 minDistVertexAfter.
part = vertexAfter.part + partOffset;
737 minDistVertexAfter.
ring = vertexAfter.ring + ringOffset;
744 if ( ctype == Vertex )
747 vertexOffset += container.at( i )->nCoordinates() - 1;
749 else if ( ctype == Ring )
753 else if ( ctype == Part )
759 if ( minDist == std::numeric_limits<double>::max() )
762 segmentPt.setX( minDistSegmentX );
763 segmentPt.setY( minDistSegmentY );
764 vertexAfter = minDistVertexAfter;
773 #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)