16 #ifndef QGSGEOMETRYUTILS_H 
   17 #define QGSGEOMETRYUTILS_H 
   21 #include "qgis_core.h" 
   94     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 ) 
SIP_HOLDGIL;
 
  158     static bool lineCircleIntersection( 
const QgsPointXY ¢er, 
double radius,
 
  172     static int circleCircleIntersections( 
QgsPointXY center1, 
double radius1,
 
  184     static bool tangentPointAndCircle( 
const QgsPointXY ¢er, 
double radius,
 
  204     static int circleCircleOuterTangents(
 
  227     static int circleCircleInnerTangents(
 
  241       double nx = s2.y() - s1.y();
 
  242       double ny = -( s2.x() - s1.x() );
 
  243       double t = ( p.
x() * ny - p.
y() * nx - s1.x() * ny + s1.y() * nx ) / ( ( s2.x() - s1.x() ) * ny - ( s2.y() - s1.y() ) * nx );
 
  244       return t < 0. ? s1 : t > 1. ? s2 : 
QgsPoint( s1.x() + ( s2.x() - s1.x() ) * t, s1.y() + ( s2.y() - s1.y() ) * t );
 
  265     static QVector<SelfIntersection> selfIntersections( 
const QgsAbstractGeometry *geom, 
int part, 
int ring, 
double tolerance ) 
SIP_SKIP;
 
  274     static int leftOfLine( 
const double x, 
const double y, 
const double x1, 
const double y1, 
const double x2, 
const double y2 ) 
SIP_HOLDGIL;
 
  301     static void pointOnLineWithDistance( 
double x1, 
double y1, 
double x2, 
double y2, 
double distance, 
double &x, 
double &y,
 
  302                                          double *z1 = 
nullptr, 
double *z2 = 
nullptr, 
double *z = 
nullptr,
 
  303                                          double *m1 = 
nullptr, 
double *m2 = 
nullptr, 
double *m = 
nullptr ) 
SIP_SKIP;
 
  332     static 
void perpendicularOffsetPointAlongSegment( 
double x1, 
double y1, 
double x2, 
double y2, 
double proportion, 
double offset, 
double *x 
SIP_OUT, 
double *y  
SIP_OUT );
 
  345     static 
double ccwAngle( 
double dy, 
double dx ) 
SIP_HOLDGIL;
 
  357     static 
bool circleClockwise( 
double angle1, 
double angle2, 
double angle3 ) 
SIP_HOLDGIL;
 
  360     static 
bool circleAngleBetween( 
double angle, 
double angle1, 
double angle2, 
bool clockwise ) 
SIP_HOLDGIL;
 
  366     static 
bool angleOnCircle( 
double angle, 
double angle1, 
double angle2, 
double angle3 ) 
SIP_HOLDGIL;
 
  369     static 
double circleLength( 
double x1, 
double y1, 
double x2, 
double y2, 
double x3, 
double y3 ) 
SIP_HOLDGIL;
 
  372     static 
double sweepAngle( 
double centerX, 
double centerY, 
double x1, 
double y1, 
double x2, 
double y2, 
double x3, 
double y3 ) 
SIP_HOLDGIL;
 
  405                                bool hasZ = false, 
bool hasM = false );
 
  436     static 
double interpolateArcValue( 
double angle, 
double a1, 
double a2, 
double a3, 
double zm1, 
double zm2, 
double zm3 ) 
SIP_HOLDGIL;
 
  495     static 
double lineAngle( 
double x1, 
double y1, 
double x2, 
double y2 ) 
SIP_HOLDGIL;
 
  508     static 
double angleBetweenThreePoints( 
double x1, 
double y1, 
double x2, 
double y2,
 
  520     static 
double linePerpendicularAngle( 
double x1, 
double y1, 
double x2, 
double y2 ) 
SIP_HOLDGIL;
 
  526     static 
double averageAngle( 
double x1, 
double y1, 
double x2, 
double y2, 
double x3, 
double y3 ) 
SIP_HOLDGIL;
 
  534     static 
double averageAngle( 
double a1, 
double a2 ) 
SIP_HOLDGIL;
 
  549     static QStringList wktGetChildBlocks( const QString &wkt, const QString &defaultType = QString() ) 
SIP_SKIP;
 
  573     static 
int closestSideOfRectangle( 
double right, 
double bottom, 
double left, 
double top, 
double x, 
double y );
 
  613     static 
QgsPointXY interpolatePointOnLine( 
double x1, 
double y1, 
double x2, 
double y2, 
double fraction ) 
SIP_HOLDGIL;
 
  645     static 
QgsPointXY interpolatePointOnLineByValue( 
double x1, 
double y1, 
double v1, 
double x2, 
double y2, 
double v2, 
double value ) 
SIP_HOLDGIL;
 
  750     static 
double triangleArea( 
double aX, 
double aY, 
double bX, 
double bY, 
double cX, 
double cY ) 
SIP_HOLDGIL;
 
  769     static 
void weightedPointInTriangle( 
double aX, 
double aY, 
double bX, 
double bY, 
double cX, 
double cY,
 
  790       return transferFirstZValueToPoint( points, point );
 
  850       for ( 
auto it = verticesBegin ; it != verticesEnd ; ++it )
 
  852         if ( !mFound && ( *it ).isMeasure() )
 
  855           point.
setM( ( *it ).m() );
 
  858         if ( !zFound && ( *it ).is3D() )
 
  861           point.
setZ( ( *it ).z() );
 
  864         if ( zFound && mFound )
 
  868       return zFound || mFound;
 
  934     static bool angleBisector( 
double aX, 
double aY, 
double bX, 
double bY, 
double cX, 
double cY, 
double dX, 
double dY,
 
  953     static bool bisector( 
double aX, 
double aY, 
double bX, 
double bY, 
double cX, 
double cY,
 
  967       double minDist = std::numeric_limits<double>::max();
 
  968       double minDistSegmentX = 0.0, minDistSegmentY = 0.0;
 
  970       int minDistLeftOf = 0;
 
  971       double sqrDist = 0.0;
 
  972       int vertexOffset = 0;
 
  976       for ( 
int i = 0; i < container.size(); ++i )
 
  978         sqrDist = container.at( i )->closestSegment( pt, segmentPt, vertexAfter, 
leftOf, epsilon );
 
  979         if ( sqrDist >= 0 && sqrDist < minDist )
 
  982           minDistSegmentX = segmentPt.x();
 
  983           minDistSegmentY = segmentPt.y();
 
  984           minDistVertexAfter = vertexAfter;
 
  985           minDistVertexAfter.
vertex = vertexAfter.vertex + vertexOffset;
 
  986           minDistVertexAfter.
part = vertexAfter.part + partOffset;
 
  987           minDistVertexAfter.
ring = vertexAfter.ring + ringOffset;
 
  994         if ( ctype == Vertex )
 
  997           vertexOffset += container.at( i )->nCoordinates() - 1;
 
  999         else if ( ctype == Ring )
 
 1003         else if ( ctype == Part )
 
 1009       if ( minDist == std::numeric_limits<double>::max() )
 
 1012       segmentPt.setX( minDistSegmentX );
 
 1013       segmentPt.setY( minDistSegmentY );
 
 1014       vertexAfter = minDistVertexAfter;
 
Abstract base class for all geometries.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
Contains various geometry utility functions.
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.
static QgsPoint projectPointOnSegment(const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2) SIP_HOLDGIL
Project the point on a segment.
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 double closestSegmentFromComponents(T &container, ComponentType ctype, const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, int *leftOf, double epsilon)
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.
A geometry is the spatial representation of a feature.
QgsAbstractGeometry::vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
QgsAbstractGeometry::vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
Line string geometry type, with support for z-dimension and m-values.
A class to represent a 2D point.
Point geometry type, with support for z-dimension and m-values.
bool convertTo(QgsWkbTypes::Type type) override
Converts the geometry to a specified type.
void setZ(double z) SIP_HOLDGIL
Sets the point's z-coordinate.
void setM(double m) SIP_HOLDGIL
Sets the point's m-value.
A class to represent a vector.
Handles storage of information regarding WKB types and their properties.
static Type addZ(Type type) SIP_HOLDGIL
Adds the z dimension to a WKB type and returns the new type.
static Type addM(Type type) SIP_HOLDGIL
Adds the m dimension to a WKB type and returns the new type.
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)
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 leftOf(const QgsPoint &thepoint, const QgsPoint *p1, const QgsPoint *p2)
Returns whether 'thepoint' is left or right of the line from 'p1' to 'p2'. Negative values mean left ...
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
#define SIP_PYALTERNATIVETYPE(type)
QVector< QgsPoint > QgsPointSequence
Utility class for identifying a unique vertex within a geometry.