QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgsgeometryutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsgeometryutils.h
3 -------------------------------------------------------------------
4Date : 21 Nov 2014
5Copyright : (C) 2014 by Marco Hugentobler
6email : marco.hugentobler at sourcepole dot com
7***************************************************************************
8* *
9* This program is free software; you can redistribute it and/or modify *
10* it under the terms of the GNU General Public License as published by *
11* the Free Software Foundation; either version 2 of the License, or *
12* (at your option) any later version. *
13* *
14***************************************************************************/
15
16#pragma once
17
18#include <limits>
19
20#include "qgis_core.h"
21#include "qgis_sip.h"
22#include "qgsgeometry.h"
24#include "qgspoint.h"
25#include "qgsvector3d.h"
26#include "qgsvertexid.h"
27
28#include <QJsonArray>
29
30class QgsLineString;
31
40class CORE_EXPORT QgsGeometryUtils
41{
42 public:
43
48 static QVector<QgsLineString *> extractLineStrings( const QgsAbstractGeometry *geom ) SIP_FACTORY;
49
54 static QgsPoint closestVertex( const QgsAbstractGeometry &geom, const QgsPoint &pt, QgsVertexId &id SIP_OUT );
55
61 static QgsPoint closestPoint( const QgsAbstractGeometry &geometry, const QgsPoint &point );
62
69 static double distanceToVertex( const QgsAbstractGeometry &geom, QgsVertexId id );
70
81 static bool verticesAtDistance( const QgsAbstractGeometry &geometry,
82 double distance,
83 QgsVertexId &previousVertex SIP_OUT,
84 QgsVertexId &nextVertex SIP_OUT );
85
94 static double distToInfiniteLine( const QgsPoint &point, const QgsPoint &linePoint1, const QgsPoint &linePoint2, double epsilon = 1e-7 );
95
107 static bool lineCircleIntersection( const QgsPointXY &center, double radius,
108 const QgsPointXY &linePoint1, const QgsPointXY &linePoint2,
109 QgsPointXY &intersection SIP_INOUT ) SIP_HOLDGIL;
110
121 static int circleCircleIntersections( const QgsPointXY &center1, double radius1,
122 const QgsPointXY &center2, double radius2,
123 QgsPointXY &intersection1 SIP_OUT, QgsPointXY &intersection2 SIP_OUT ) SIP_HOLDGIL;
124
133 static bool tangentPointAndCircle( const QgsPointXY &center, double radius,
135
153 static int circleCircleOuterTangents(
154 const QgsPointXY &center1, double radius1, const QgsPointXY &center2, double radius2,
155 QgsPointXY &line1P1 SIP_OUT, QgsPointXY &line1P2 SIP_OUT,
156 QgsPointXY &line2P1 SIP_OUT, QgsPointXY &line2P2 SIP_OUT ) SIP_HOLDGIL;
157
176 static int circleCircleInnerTangents(
177 const QgsPointXY &center1, double radius1, const QgsPointXY &center2, double radius2,
178 QgsPointXY &line1P1 SIP_OUT, QgsPointXY &line1P2 SIP_OUT,
179 QgsPointXY &line2P1 SIP_OUT, QgsPointXY &line2P2 SIP_OUT ) SIP_HOLDGIL;
180
188 static QgsPoint projectPointOnSegment( const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2 ) SIP_HOLDGIL
189 {
190 const double nx = s2.y() - s1.y();
191 const double ny = -( s2.x() - s1.x() );
192 const double t = ( p.x() * ny - p.y() * nx - s1.x() * ny + s1.y() * nx ) / ( ( s2.x() - s1.x() ) * ny - ( s2.y() - s1.y() ) * nx );
193 return t < 0. ? s1 : t > 1. ? s2 : QgsPoint( s1.x() + ( s2.x() - s1.x() ) * t, s1.y() + ( s2.y() - s1.y() ) * t );
194 }
195
203
213 static QVector<SelfIntersection> selfIntersections( const QgsAbstractGeometry *geom, int part, int ring, double tolerance ) SIP_SKIP;
214
224 static int leftOfLine( const QgsPoint &point, const QgsPoint &p1, const QgsPoint &p2 ) SIP_HOLDGIL;
225
229 static QgsPoint pointOnLineWithDistance( const QgsPoint &startPoint, const QgsPoint &directionPoint, double distance ) SIP_HOLDGIL;
230
239 static QgsPoint interpolatePointOnArc( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double distance ) SIP_HOLDGIL;
240
261 static QgsPoint interpolatePointOnCubicBezier( const QgsPoint &p0, const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, double t ) SIP_HOLDGIL;
262
269 static bool segmentMidPoint( const QgsPoint &p1, const QgsPoint &p2, QgsPoint &result SIP_OUT, double radius, const QgsPoint &mousePos ) SIP_HOLDGIL;
270
282 static QgsPoint segmentMidPointFromCenter( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &center, bool useShortestArc = true ) SIP_HOLDGIL;
283
285 static double circleTangentDirection( const QgsPoint &tangentPoint, const QgsPoint &cp1, const QgsPoint &cp2, const QgsPoint &cp3 ) SIP_HOLDGIL;
286
290 static void segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3,
291 QgsPointSequence SIP_PYALTERNATIVETYPE( QVector<QgsPoint> ) &points SIP_OUT, double tolerance = M_PI_2 / 90,
292 QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle,
293 bool hasZ = false, bool hasM = false );
294
310 static bool pointContinuesArc( const QgsPoint &a1, const QgsPoint &a2, const QgsPoint &a3, const QgsPoint &b, double distanceTolerance,
311 double pointSpacingAngleTolerance ) SIP_HOLDGIL;
312
317 static int segmentSide( const QgsPoint &pt1, const QgsPoint &pt3, const QgsPoint &pt2 ) SIP_HOLDGIL;
318
323 static QgsPointSequence pointsFromWKT( const QString &wktCoordinateList, bool is3D, bool isMeasure ) SIP_SKIP;
324
329 static void pointsToWKB( QgsWkbPtr &wkb, const QgsPointSequence &points, bool is3D, bool isMeasure, QgsAbstractGeometry::WkbFlags flags ) SIP_SKIP;
330
335 static QString pointsToWKT( const QgsPointSequence &points, int precision, bool is3D, bool isMeasure ) SIP_SKIP;
336
341 static QDomElement pointsToGML2( const QgsPointSequence &points, QDomDocument &doc, int precision, const QString &ns, QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) SIP_SKIP;
342
347 static QDomElement pointsToGML3( const QgsPointSequence &points, QDomDocument &doc, int precision, const QString &ns, bool is3D, QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) SIP_SKIP;
348
353 static QString pointsToJSON( const QgsPointSequence &points, int precision ) SIP_SKIP;
354
359 static json pointsToJson( const QgsPointSequence &points, int precision ) SIP_SKIP;
360
365 static QPair<Qgis::WkbType, QString> wktReadBlock( const QString &wkt ) SIP_SKIP;
366
374 static QStringList wktGetChildBlocks( const QString &wkt, const QString &defaultType = QString() ) SIP_SKIP;
375
398 static QgsPoint midpoint( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL;
399
412 static QgsPointXY interpolatePointOnLine( double x1, double y1, double x2, double y2, double fraction ) SIP_HOLDGIL;
413
429 static QgsPoint interpolatePointOnLine( const QgsPoint &p1, const QgsPoint &p2, double fraction ) SIP_HOLDGIL;
430
442 static QgsPointXY interpolatePointOnLineByValue( double x1, double y1, double v1, double x2, double y2, double v2, double value ) SIP_HOLDGIL;
443
450 static double gradient( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL;
451
460 static void coefficients( const QgsPoint &pt1, const QgsPoint &pt2,
461 double &a SIP_OUT, double &b SIP_OUT, double &c SIP_OUT ) SIP_HOLDGIL;
462
470 static QgsLineString perpendicularSegment( const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2 ) SIP_HOLDGIL;
471
487 Q_DECL_DEPRECATED static bool setZValueFromPoints( const QgsPointSequence &points, QgsPoint &point ) SIP_DEPRECATED
488 {
489 return transferFirstZValueToPoint( points, point );
490 }
491
507 static bool transferFirstZValueToPoint( const QgsPointSequence &points, QgsPoint &point );
508
524 static bool transferFirstMValueToPoint( const QgsPointSequence &points, QgsPoint &point );
525
544 template <class Iterator> static bool transferFirstZOrMValueToPoint( Iterator verticesBegin, Iterator verticesEnd, QgsPoint &point ) SIP_SKIP
545 {
546 bool zFound = false;
547 bool mFound = false;
548
549 for ( auto it = verticesBegin ; it != verticesEnd ; ++it )
550 {
551 if ( !mFound && ( *it ).isMeasure() )
552 {
553 point.convertTo( QgsWkbTypes::addM( point.wkbType() ) );
554 point.setM( ( *it ).m() );
555 mFound = true;
556 }
557 if ( !zFound && ( *it ).is3D() )
558 {
559 point.convertTo( QgsWkbTypes::addZ( point.wkbType() ) );
560 point.setZ( ( *it ).z() );
561 zFound = true;
562 }
563 if ( zFound && mFound )
564 break;
565 }
566
567 return zFound || mFound;
568 }
569
586 static bool transferFirstZOrMValueToPoint( const QgsPointSequence &points, QgsPoint &point )
587 {
588 return QgsGeometryUtils::transferFirstZOrMValueToPoint( points.constBegin(), points.constEnd(), point );
589 }
590
607 static bool transferFirstZOrMValueToPoint( const QgsGeometry &geom, QgsPoint &point )
608 {
610 }
611
619
621 template<class T> static double closestSegmentFromComponents( T &container, ComponentType ctype, const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, int *leftOf, double epsilon ) SIP_SKIP
622 {
623 double minDist = std::numeric_limits<double>::max();
624 double minDistSegmentX = 0.0, minDistSegmentY = 0.0;
625 QgsVertexId minDistVertexAfter;
626 int minDistLeftOf = 0;
627 double sqrDist = 0.0;
628 int vertexOffset = 0;
629 int ringOffset = 0;
630 int partOffset = 0;
631
632 for ( int i = 0; i < container.size(); ++i )
633 {
634 sqrDist = container.at( i )->closestSegment( pt, segmentPt, vertexAfter, leftOf, epsilon );
635 if ( sqrDist >= 0 && sqrDist < minDist )
636 {
637 minDist = sqrDist;
638 minDistSegmentX = segmentPt.x();
639 minDistSegmentY = segmentPt.y();
640 minDistVertexAfter = vertexAfter;
641 minDistVertexAfter.vertex = vertexAfter.vertex + vertexOffset;
642 minDistVertexAfter.part = vertexAfter.part + partOffset;
643 minDistVertexAfter.ring = vertexAfter.ring + ringOffset;
644 if ( leftOf )
645 {
646 minDistLeftOf = *leftOf;
647 }
648 }
649
650 if ( ctype == Vertex )
651 {
652 //-1 because compoundcurve counts duplicated vertices of neighbour curves as one node
653 vertexOffset += container.at( i )->nCoordinates() - 1;
654 }
655 else if ( ctype == Ring )
656 {
657 ringOffset += 1;
658 }
659 else if ( ctype == Part )
660 {
661 partOffset += 1;
662 }
663 }
664
665 if ( minDist == std::numeric_limits<double>::max() )
666 return -1; // error: no segments
667
668 segmentPt.setX( minDistSegmentX );
669 segmentPt.setY( minDistSegmentY );
670 vertexAfter = minDistVertexAfter;
671 if ( leftOf )
672 {
673 *leftOf = minDistLeftOf;
674 }
675 return minDist;
676 }
677
678 /******************************/
679 /* From QgsGeometryUtils_Base */
680 /******************************/
681
687 Q_DECL_DEPRECATED static double sqrDistance2D( double x1, double y1, double x2, double y2 ) SIP_DEPRECATED SIP_HOLDGIL {return QgsGeometryUtilsBase::sqrDistance2D( x1, y1, x2, y2 ); }
688
692 static double sqrDistance2D( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL
693 {
694 return QgsGeometryUtilsBase::sqrDistance2D( pt1.x(), pt1.y(), pt2.x(), pt2.y() );
695 }
696
703 static double sqrDistance3D( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL
704 {
705 return QgsGeometryUtilsBase::sqrDistance3D( pt1.x(), pt1.y(), pt1.z(), pt2.x(), pt2.y(), pt2.z() );
706 }
707
713 Q_DECL_DEPRECATED static double distance2D( double x1, double y1, double x2, double y2 ) SIP_DEPRECATED SIP_HOLDGIL {return QgsGeometryUtilsBase::distance2D( x1, y1, x2, y2 ); }
714
718 static double distance2D( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL { return QgsGeometryUtilsBase::distance2D( pt1.x(), pt1.y(), pt2.x(), pt2.y() );}
719
726 static double distance3D( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL
727 {
728 return QgsGeometryUtilsBase::distance3D( pt1.x(), pt1.y(), pt1.z(), pt2.x(), pt2.y(), pt2.z() );
729 }
730
731
737 Q_DECL_DEPRECATED 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_DEPRECATED SIP_HOLDGIL
738 {
739 return QgsGeometryUtilsBase::sqrDistToLine( ptX, ptY, x1, y1, x2, y2, minDistX, minDistY, epsilon );
740 }
741
751 Q_DECL_DEPRECATED static int leftOfLine( const double x, const double y, const double x1, const double y1, const double x2, const double y2 ) SIP_DEPRECATED SIP_HOLDGIL
752 {
753 return QgsGeometryUtilsBase::leftOfLine( x, y, x1, y1, x2, y2 ) ;
754 }
755
766 Q_DECL_DEPRECATED static void pointOnLineWithDistance( double x1, double y1, double x2, double y2, double distance, double &x, double &y,
767 double *z1 = nullptr, double *z2 = nullptr, double *z = nullptr,
768 double *m1 = nullptr, double *m2 = nullptr, double *m = nullptr ) SIP_SKIP
769 {
770 return QgsGeometryUtilsBase::pointOnLineWithDistance( x1, y1, x2, y2, distance, x, y,
771 z1, z2, z,
772 m1, m2, m );
773 }
774
803 Q_DECL_DEPRECATED static void perpendicularOffsetPointAlongSegment( double x1, double y1, double x2, double y2, double proportion, double offset, double *x SIP_OUT, double *y SIP_OUT )
804 {
805 QgsGeometryUtilsBase::perpendicularOffsetPointAlongSegment( x1, y1, x2, y2, proportion, offset, x, y );
806 }
807
808
809
810
816 Q_DECL_DEPRECATED static double ccwAngle( double dy, double dx ) SIP_DEPRECATED SIP_HOLDGIL
817 {
818 return QgsGeometryUtilsBase::ccwAngle( dy, dx );
819 }
820
821
830 Q_DECL_DEPRECATED static bool circleClockwise( double angle1, double angle2, double angle3 ) SIP_DEPRECATED SIP_HOLDGIL
831 {
832 return QgsGeometryUtilsBase::circleClockwise( angle1, angle2, angle3 );
833 }
834
840 Q_DECL_DEPRECATED static bool circleAngleBetween( double angle, double angle1, double angle2, bool clockwise ) SIP_DEPRECATED SIP_HOLDGIL
841 {
842 return QgsGeometryUtilsBase::circleAngleBetween( angle, angle1, angle2, clockwise );
843 }
844
851 Q_DECL_DEPRECATED static bool angleOnCircle( double angle, double angle1, double angle2, double angle3 ) SIP_DEPRECATED SIP_HOLDGIL
852 {
853 return QgsGeometryUtilsBase::angleOnCircle( angle, angle1, angle2, angle3 );
854 }
855
861 Q_DECL_DEPRECATED static double circleLength( double x1, double y1, double x2, double y2, double x3, double y3 ) SIP_DEPRECATED SIP_HOLDGIL
862 {
863 return QgsGeometryUtilsBase::circleLength( x1, y1, x2, y2, x3, y3 );
864 }
865
871 Q_DECL_DEPRECATED static double sweepAngle( double centerX, double centerY, double x1, double y1, double x2, double y2, double x3, double y3 ) SIP_DEPRECATED SIP_HOLDGIL
872 {
873 return QgsGeometryUtilsBase::sweepAngle( centerX, centerY, x1, y1, x2, y2, x3, y3 );
874 }
875
880 Q_DECL_DEPRECATED static double interpolateArcValue( double angle, double a1, double a2, double a3, double zm1, double zm2, double zm3 ) SIP_DEPRECATED SIP_HOLDGIL
881 {
882 return QgsGeometryUtilsBase::interpolateArcValue( angle, a1, a2, a3, zm1, zm2, zm3 );
883 }
884
892 Q_DECL_DEPRECATED static double normalizedAngle( double angle ) SIP_DEPRECATED SIP_HOLDGIL
893 {
895 }
896
907 Q_DECL_DEPRECATED static double lineAngle( double x1, double y1, double x2, double y2 ) SIP_DEPRECATED SIP_HOLDGIL
908 {
909 return QgsGeometryUtilsBase::lineAngle( x1, y1, x2, y2 );
910 }
911
925 Q_DECL_DEPRECATED static double angleBetweenThreePoints( double x1, double y1, double x2, double y2, double x3, double y3 ) SIP_DEPRECATED SIP_HOLDGIL
926 {
927 return QgsGeometryUtilsBase::angleBetweenThreePoints( x1, y1, x2, y2, x3, y3 );
928 }
929
941 Q_DECL_DEPRECATED static double linePerpendicularAngle( double x1, double y1, double x2, double y2 ) SIP_DEPRECATED SIP_HOLDGIL
942 {
943 return QgsGeometryUtilsBase::linePerpendicularAngle( x1, y1, x2, y2 );
944 }
945
952 Q_DECL_DEPRECATED static double averageAngle( double x1, double y1, double x2, double y2, double x3, double y3 ) SIP_DEPRECATED SIP_HOLDGIL
953 {
954 return QgsGeometryUtilsBase::averageAngle( x1, y1, x2, y2, x3, y3 );
955 }
956
965 Q_DECL_DEPRECATED static double averageAngle( double a1, double a2 ) SIP_DEPRECATED SIP_HOLDGIL
966 {
967 return QgsGeometryUtilsBase::averageAngle( a1, a2 );
968 }
969
970
994 Q_DECL_DEPRECATED static int closestSideOfRectangle( double right, double bottom, double left, double top, double x, double y )
995 {
996 return QgsGeometryUtilsBase::closestSideOfRectangle( right, bottom, left, top, x, y );
997 }
998
1022 Q_DECL_DEPRECATED static void perpendicularCenterSegment( double centerPointX, double centerPointY,
1023 double segmentPoint1x, double segmentPoint1y,
1024 double segmentPoint2x, double segmentPoint2y,
1025 double &perpendicularSegmentPoint1x SIP_OUT, double &perpendicularSegmentPoint1y SIP_OUT,
1026 double &perpendicularSegmentPoint2x SIP_OUT, double &perpendicularSegmentPoint2y SIP_OUT,
1027 double segmentLength = 0 ) SIP_HOLDGIL
1028 {
1029 return QgsGeometryUtilsBase::perpendicularCenterSegment( centerPointX, centerPointY, segmentPoint1x, segmentPoint1y, segmentPoint2x, segmentPoint2y, perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y, segmentLength );
1030 }
1031
1042 Q_DECL_DEPRECATED static double skewLinesDistance( const QgsVector3D &P1, const QgsVector3D &P12, const QgsVector3D &P2, const QgsVector3D &P22 ) SIP_DEPRECATED SIP_HOLDGIL
1043 {
1044 return QgsGeometryUtilsBase::skewLinesDistance( P1, P12, P2, P22 );
1045 }
1046
1059 Q_DECL_DEPRECATED static bool skewLinesProjection( const QgsVector3D &P1, const QgsVector3D &P12,
1060 const QgsVector3D &P2, const QgsVector3D &P22,
1061 QgsVector3D &X1 SIP_OUT,
1062 double epsilon = 0.0001 ) SIP_HOLDGIL
1063 {
1064 return QgsGeometryUtilsBase::skewLinesProjection( P1, P12, P2, P22, X1, epsilon );
1065 }
1066
1067
1106 Q_DECL_DEPRECATED static bool linesIntersection3D( const QgsVector3D &La1, const QgsVector3D &La2,
1107 const QgsVector3D &Lb1, const QgsVector3D &Lb2,
1108 QgsVector3D &intersection SIP_OUT ) SIP_HOLDGIL
1109 {
1110 return QgsGeometryUtilsBase::linesIntersection3D( La1, La2, Lb1, Lb2, intersection );
1111 }
1112
1120 Q_DECL_DEPRECATED static double triangleArea( double aX, double aY, double bX, double bY, double cX, double cY ) SIP_DEPRECATED SIP_HOLDGIL
1121 {
1122 return QgsGeometryUtilsBase::triangleArea( aX, aY, bX, bY, cX, cY );
1123 }
1124
1134 Q_DECL_DEPRECATED static double pointFractionAlongLine( double x1, double y1, double x2, double y2, double px, double py )
1135 {
1136 return QgsGeometryUtilsBase::pointFractionAlongLine( x1, y1, x2, y2, px, py );
1137 }
1138
1157 Q_DECL_DEPRECATED static void weightedPointInTriangle( double aX, double aY, double bX, double bY, double cX, double cY,
1158 double weightB, double weightC, double &pointX SIP_OUT, double &pointY SIP_OUT ) SIP_HOLDGIL
1159 {
1160 return QgsGeometryUtilsBase::weightedPointInTriangle( aX, aY, bX, bY, cX, cY, weightB, weightC, pointX, pointY );
1161 }
1162
1170 Q_DECL_DEPRECATED static bool pointsAreCollinear( double x1, double y1, double x2, double y2, double x3, double y3, double epsilon )
1171 {
1172 return QgsGeometryUtilsBase::pointsAreCollinear( x1, y1, x2, y2, x3, y3, epsilon );
1173 }
1174
1196 Q_DECL_DEPRECATED static bool angleBisector( double aX, double aY, double bX, double bY, double cX, double cY, double dX, double dY,
1197 double &pointX SIP_OUT, double &pointY SIP_OUT, double &angle SIP_OUT ) SIP_HOLDGIL
1198 {
1199 return QgsGeometryUtilsBase::angleBisector( aX, aY, bX, bY, cX, cY, dX, dY, pointX, pointY, angle );
1200 }
1201
1219 Q_DECL_DEPRECATED static bool bisector( double aX, double aY, double bX, double bY, double cX, double cY,
1220 double &pointX SIP_OUT, double &pointY SIP_OUT ) SIP_HOLDGIL
1221 {
1222 return QgsGeometryUtilsBase::bisector( aX, aY, bX, bY, cX, cY, pointX, pointY );
1223 }
1224
1228 static void circleCenterRadius( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double &radius SIP_OUT,
1229 double &centerX SIP_OUT, double &centerY SIP_OUT ) SIP_HOLDGIL
1230 {
1231 return QgsGeometryUtilsBase::circleCenterRadius( pt1.x(), pt1.y(), pt2.x(), pt2.y(), pt3.x(), pt3.y(), radius, centerX, centerY );
1232 }
1233
1245 static bool lineIntersection( const QgsPoint &p1, QgsVector v1, const QgsPoint &p2, QgsVector v2, QgsPoint &intersection SIP_OUT ) SIP_HOLDGIL
1246 {
1247 double intersectionX = 0.0, intersectionY = 0.0;
1248 bool result = QgsGeometryUtilsBase::lineIntersection( p1.x(), p1.y(), v1, p2.x(), p2.y(), v2, intersectionX, intersectionY );
1249 intersection = QgsPoint( intersectionX, intersectionY );
1250
1251 // z and m support for intersection point
1253
1254 return result;
1255 }
1256
1293 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 ) SIP_HOLDGIL
1294 {
1295 double intersectionPointX = 0.0, intersectionPointY = 0.0;
1296 bool result = QgsGeometryUtilsBase::segmentIntersection( p1.x(), p1.y(), p2.x(), p2.y(), q1.x(), q1.y(), q2.x(), q2.y(), intersectionPointX, intersectionPointY, isIntersection, tolerance, acceptImproperIntersection );
1297 intersectionPoint.setX( intersectionPointX );
1298 intersectionPoint.setY( intersectionPointY );
1299 return result;
1300 }
1301
1310 static QgsPoint createPointWithMatchingDimensions( double x, double y, const QgsPoint &reference ) SIP_HOLDGIL;
1311
1321 static QgsPoint interpolatePointOnSegment( double x, double y,
1322 const QgsPoint &segmentStart, const QgsPoint &segmentEnd ) SIP_HOLDGIL;
1323
1340 static bool createChamfer( const QgsPoint &segment1Start, const QgsPoint &segment1End,
1341 const QgsPoint &segment2Start, const QgsPoint &segment2End,
1342 double distance1, double distance2,
1343 QgsPoint &chamferStart SIP_OUT, QgsPoint &chamferEnd SIP_OUT,
1344 double epsilon = 1e-8 ) SIP_THROW( QgsInvalidArgumentException ) SIP_HOLDGIL;
1345
1365 static bool createFillet( const QgsPoint &segment1Start, const QgsPoint &segment1End,
1366 const QgsPoint &segment2Start, const QgsPoint &segment2End,
1367 double radius,
1368 QgsPoint &filletPoint1 SIP_OUT,
1369 QgsPoint &filletMidPoint SIP_OUT,
1370 QgsPoint &filletPoint2 SIP_OUT,
1371 double epsilon = 1e-8 ) SIP_THROW( QgsInvalidArgumentException ) SIP_HOLDGIL;
1372
1386 static std::unique_ptr< QgsLineString > createChamferGeometry(
1387 const QgsPoint &segment1Start, const QgsPoint &segment1End,
1388 const QgsPoint &segment2Start, const QgsPoint &segment2End,
1389 double distance1, double distance2
1391
1405 static std::unique_ptr< QgsAbstractGeometry > createFilletGeometry(
1406 const QgsPoint &segment1Start, const QgsPoint &segment1End,
1407 const QgsPoint &segment2Start, const QgsPoint &segment2End,
1408 double radius, int segments
1410
1423 static double maxFilletRadius( const QgsPoint &segment1Start, const QgsPoint &segment1End,
1424 const QgsPoint &segment2Start, const QgsPoint &segment2End,
1425 double epsilon = 1e-8 ) SIP_HOLDGIL;
1426
1441 static std::unique_ptr< QgsAbstractGeometry > chamferVertex(
1442 const QgsCurve *curve, int vertexIndex,
1443 double distance1, double distance2
1445
1460 static std::unique_ptr< QgsAbstractGeometry > filletVertex(
1461 const QgsCurve *curve, int vertexIndex,
1462 double radius, int segments
1464
1472 static bool createFilletArray( const QgsPoint &segment1Start, const QgsPoint &segment1End,
1473 const QgsPoint &segment2Start, const QgsPoint &segment2End,
1474 double radius,
1475 QgsPoint filletPoints[3],
1476 double epsilon = 1e-8 ) SIP_SKIP;
1477
1493 static bool pointsAreCollinear( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double epsilon );
1494
1495
1516 static bool checkWeaklyFor3DPlane( const QgsAbstractGeometry *geom, QgsPoint &pt1 SIP_OUT, QgsPoint &pt2 SIP_OUT, QgsPoint &pt3 SIP_OUT, double epsilon = std::numeric_limits<double>::epsilon() );
1517
1518 private:
1519
1532 static std::unique_ptr< QgsAbstractGeometry > doChamferFilletOnVertex(
1533 QgsGeometry::ChamferFilletOperationType operation, const QgsCurve *curve, int vertexIndex,
1534 double value1, double value2, int segments
1535 );
1536};
1537#include "qgsgeometryutils_base.h"
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:59
Abstract base class for all geometries.
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
Abstract base class for curved geometry type.
Definition qgscurve.h:36
static double circleLength(double x1, double y1, double x2, double y2, double x3, double y3)
Length of a circular string segment defined by pt1, pt2, pt3.
static double sqrDistance2D(double x1, double y1, double x2, double y2)
Returns the squared 2D distance between (x1, y1) and (x2, y2).
static void pointOnLineWithDistance(double x1, double y1, double x2, double y2, double distance, double &x, double &y, double *z1=nullptr, double *z2=nullptr, double *z=nullptr, double *m1=nullptr, double *m2=nullptr, double *m=nullptr)
Calculates the point a specified distance from (x1, y1) toward a second point (x2,...
static double angleBetweenThreePoints(double x1, double y1, double x2, double y2, double x3, double y3)
Calculates the angle between the lines AB and BC, where AB and BC described by points a,...
static double ccwAngle(double dy, double dx)
Returns the counter clockwise angle between a line with components dx, dy and the line with dx > 0 an...
static bool circleClockwise(double angle1, double angle2, double angle3)
Returns true if the circle defined by three angles is ordered clockwise.
static double distance2D(double x1, double y1, double x2, double y2)
Returns the 2D distance between (x1, y1) and (x2, y2).
static double sweepAngle(double centerX, double centerY, double x1, double y1, double x2, double y2, double x3, double y3)
Calculates angle of a circular string part defined by pt1, pt2, pt3.
static double linePerpendicularAngle(double x1, double y1, double x2, double y2)
Calculates the perpendicular angle to a line joining two points.
static bool bisector(double aX, double aY, double bX, double bY, double cX, double cY, double &pointX, double &pointY)
Returns the point (pointX, pointY) forming the bisector from point (aX, aY) to the segment (bX,...
static double lineAngle(double x1, double y1, double x2, double y2)
Calculates the direction of line joining two points in radians, clockwise from the north direction.
static double averageAngle(double x1, double y1, double x2, double y2, double x3, double y3)
Calculates the average angle (in radians) between the two linear segments from (x1,...
static bool skewLinesProjection(const QgsVector3D &P1, const QgsVector3D &P12, const QgsVector3D &P2, const QgsVector3D &P22, QgsVector3D &X1, double epsilon=0.0001)
A method to project one skew line onto another.
static int closestSideOfRectangle(double right, double bottom, double left, double top, double x, double y)
Returns a number representing the closest side of a rectangle defined by /a right,...
static double interpolateArcValue(double angle, double a1, double a2, double a3, double zm1, double zm2, double zm3)
Interpolate a value at given angle on circular arc given values (zm1, zm2, zm3) at three different an...
static void perpendicularOffsetPointAlongSegment(double x1, double y1, double x2, double y2, double proportion, double offset, double *x, double *y)
Calculates a point a certain proportion of the way along the segment from (x1, y1) to (x2,...
static double skewLinesDistance(const QgsVector3D &P1, const QgsVector3D &P12, const QgsVector3D &P2, const QgsVector3D &P22)
An algorithm to calculate the shortest distance between two skew lines.
static double pointFractionAlongLine(double x1, double y1, double x2, double y2, double px, double py)
Given the line (x1, y1) to (x2, y2) and a point (px, py) returns the fraction of the line length at w...
static double normalizedAngle(double angle)
Ensures that an angle is in the range 0 <= angle < 2 pi.
static void weightedPointInTriangle(double aX, double aY, double bX, double bY, double cX, double cY, double weightB, double weightC, double &pointX, double &pointY)
Returns a weighted point inside the triangle denoted by the points (aX, aY), (bX, bY) and (cX,...
static void perpendicularCenterSegment(double centerPointX, double centerPointY, double segmentPoint1x, double segmentPoint1y, double segmentPoint2x, double segmentPoint2y, double &perpendicularSegmentPoint1x, double &perpendicularSegmentPoint1y, double &perpendicularSegmentPoint2x, double &perpendicularSegmentPoint2y, double segmentLength=0)
Create a perpendicular line segment to a given segment [segmentPoint1,segmentPoint2] with its center ...
static double distance3D(double x1, double y1, double z1, double x2, double y2, double z2)
Returns the 3D distance between (x1, y1, z1) and (x2, y2, z2).
static bool circleAngleBetween(double angle, double angle1, double angle2, bool clockwise)
Returns true if, in a circle, angle is between angle1 and angle2.
static double triangleArea(double aX, double aY, double bX, double bY, double cX, double cY)
Returns the area of the triangle denoted by the points (aX, aY), (bX, bY) and (cX,...
static bool angleBisector(double aX, double aY, double bX, double bY, double cX, double cY, double dX, double dY, double &pointX, double &pointY, double &angle)
Returns the point (pointX, pointY) forming the bisector from segment (aX aY) (bX bY) and segment (bX,...
static double sqrDistance3D(double x1, double y1, double z1, double x2, double y2, double z2)
Returns the squared 3D distance between (x1, y1, z1) and (x2, y2, z2).
static double sqrDistToLine(double ptX, double ptY, double x1, double y1, double x2, double y2, double &minDistX, double &minDistY, double epsilon)
Returns the squared distance between a point and a line.
static bool angleOnCircle(double angle, double angle1, double angle2, double angle3)
Returns true if an angle is between angle1 and angle3 on a circle described by angle1,...
static bool segmentIntersection(double p1x, double p1y, double p2x, double p2y, double q1x, double q1y, double q2x, double q2y, double &intersectionPointX, double &intersectionPointY, bool &isIntersection, double tolerance=1e-8, bool acceptImproperIntersection=false)
Compute the intersection between two segments.
static int leftOfLine(const double x, const double y, const double x1, const double y1, const double x2, const double y2)
Returns a value < 0 if the point (x, y) is left of the line from (x1, y1) -> (x2, y2).
static bool linesIntersection3D(const QgsVector3D &La1, const QgsVector3D &La2, const QgsVector3D &Lb1, const QgsVector3D &Lb2, QgsVector3D &intersection)
An algorithm to calculate an (approximate) intersection of two lines in 3D.
static bool pointsAreCollinear(double x1, double y1, double x2, double y2, double x3, double y3, double epsilon)
Given the points (x1, y1), (x2, y2) and (x3, y3) returns true if these points can be considered colli...
static void circleCenterRadius(double x1, double y1, double x2, double y2, double x3, double y3, double &radius, double &centerX, double &centerY)
Returns radius and center of the circle through (x1 y1), (x2 y2), (x3 y3).
static bool lineIntersection(double p1x, double p1y, QgsVector v1, double p2x, double p2y, QgsVector v2, double &intersectionX, double &intersectionY)
Computes the intersection between two lines.
Contains various geometry utility functions.
static Q_DECL_DEPRECATED bool setZValueFromPoints(const QgsPointSequence &points, QgsPoint &point)
A Z dimension is added to point if one of the point in the list points is in 3D.
static int circleCircleIntersections(const QgsPointXY &center1, double radius1, const QgsPointXY &center2, double radius2, QgsPointXY &intersection1, QgsPointXY &intersection2)
Calculates the intersections points between the circle with center center1 and radius radius1 and the...
static QString pointsToJSON(const QgsPointSequence &points, int precision)
Returns a geoJSON coordinates string.
static Q_DECL_DEPRECATED double linePerpendicularAngle(double x1, double y1, double x2, double y2)
Calculates the perpendicular angle to a line joining two points.
static bool lineIntersection(const QgsPoint &p1, QgsVector v1, const QgsPoint &p2, QgsVector v2, QgsPoint &intersection)
Computes the intersection between two lines.
static QgsPointXY interpolatePointOnLine(double x1, double y1, double x2, double y2, double fraction)
Interpolates the position of a point a fraction of the way along the line from (x1,...
static double circleTangentDirection(const QgsPoint &tangentPoint, const QgsPoint &cp1, const QgsPoint &cp2, const QgsPoint &cp3)
Calculates the direction angle of a circle tangent (clockwise from north in radians).
static Q_DECL_DEPRECATED double triangleArea(double aX, double aY, double bX, double bY, double cX, double cY)
Returns the area of the triangle denoted by the points (aX, aY), (bX, bY) and (cX,...
static int leftOfLine(const QgsPoint &point, const QgsPoint &p1, const QgsPoint &p2)
Returns a value < 0 if the point point is left of the line from p1 -> p2.
static QgsPoint pointOnLineWithDistance(const QgsPoint &startPoint, const QgsPoint &directionPoint, double distance)
Returns a point a specified distance toward a second point.
static Q_DECL_DEPRECATED double lineAngle(double x1, double y1, double x2, double y2)
Calculates the direction of line joining two points in radians, clockwise from the north direction.
static double gradient(const QgsPoint &pt1, const QgsPoint &pt2)
Returns the gradient of a line defined by points pt1 and pt2.
static json pointsToJson(const QgsPointSequence &points, int precision)
Returns coordinates as json object.
static Q_DECL_DEPRECATED bool circleClockwise(double angle1, double angle2, double angle3)
Returns true if the circle defined by three angles is ordered clockwise.
static QVector< QgsLineString * > extractLineStrings(const QgsAbstractGeometry *geom)
Returns list of linestrings extracted from the passed geometry.
static QVector< SelfIntersection > selfIntersections(const QgsAbstractGeometry *geom, int part, int ring, double tolerance)
Find self intersections in a polyline.
static bool transferFirstZValueToPoint(const QgsPointSequence &points, QgsPoint &point)
A Z dimension is added to point if one of the point in the list points is in 3D.
static bool segmentMidPoint(const QgsPoint &p1, const QgsPoint &p2, QgsPoint &result, double radius, const QgsPoint &mousePos)
Calculates midpoint on circle passing through p1 and p2, closest to the given coordinate mousePos.
static Q_DECL_DEPRECATED void pointOnLineWithDistance(double x1, double y1, double x2, double y2, double distance, double &x, double &y, double *z1=nullptr, double *z2=nullptr, double *z=nullptr, double *m1=nullptr, double *m2=nullptr, double *m=nullptr)
Calculates the point a specified distance from (x1, y1) toward a second point (x2,...
static QgsPointXY interpolatePointOnLineByValue(double x1, double y1, double v1, double x2, double y2, double v2, double value)
Interpolates the position of a point along the line from (x1, y1) to (x2, y2).
static QgsPoint closestPoint(const QgsAbstractGeometry &geometry, const QgsPoint &point)
Returns the nearest point on a segment of a geometry for the specified point.
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 bool verticesAtDistance(const QgsAbstractGeometry &geometry, double distance, QgsVertexId &previousVertex, QgsVertexId &nextVertex)
Retrieves the vertices which are before and after the interpolated point at a specified distance alon...
static QStringList wktGetChildBlocks(const QString &wkt, const QString &defaultType=QString())
Parses a WKT string and returns of list of blocks contained in the WKT.
static QgsPoint projectPointOnSegment(const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2)
Project the point on a segment.
static Q_DECL_DEPRECATED double sqrDistToLine(double ptX, double ptY, double x1, double y1, double x2, double y2, double &minDistX, double &minDistY, double epsilon)
Returns the squared distance between a point and a line.
static bool segmentIntersection(const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &q1, const QgsPoint &q2, QgsPoint &intersectionPoint, bool &isIntersection, double tolerance=1e-8, bool acceptImproperIntersection=false)
Compute the intersection between two segments.
static QgsLineString perpendicularSegment(const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2)
Create a perpendicular line segment from p to segment [s1, s2].
static int segmentSide(const QgsPoint &pt1, const QgsPoint &pt3, const QgsPoint &pt2)
For line defined by points pt1 and pt3, find out on which side of the line is point pt2.
static Q_DECL_DEPRECATED void perpendicularOffsetPointAlongSegment(double x1, double y1, double x2, double y2, double proportion, double offset, double *x, double *y)
Calculates a point a certain proportion of the way along the segment from (x1, y1) to (x2,...
static QgsPoint interpolatePointOnCubicBezier(const QgsPoint &p0, const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, double t)
Evaluates a point on a cubic Bézier curve defined by four control points.
static Q_DECL_DEPRECATED double interpolateArcValue(double angle, double a1, double a2, double a3, double zm1, double zm2, double zm3)
Interpolate a value at given angle on circular arc given values (zm1, zm2, zm3) at three different an...
static void pointsToWKB(QgsWkbPtr &wkb, const QgsPointSequence &points, bool is3D, bool isMeasure, QgsAbstractGeometry::WkbFlags flags)
Returns a LinearRing { uint32 numPoints; Point points[numPoints]; }.
static double distanceToVertex(const QgsAbstractGeometry &geom, QgsVertexId id)
Returns the distance along a geometry from its first vertex to the specified vertex.
static QPair< Qgis::WkbType, QString > wktReadBlock(const QString &wkt)
Parses a WKT block of the format "TYPE( contents )" and returns a pair of geometry type to contents (...
static Q_DECL_DEPRECATED double averageAngle(double a1, double a2)
Averages two angles, correctly handling negative angles and ensuring the result is between 0 and 2 pi...
static bool lineCircleIntersection(const QgsPointXY &center, double radius, const QgsPointXY &linePoint1, const QgsPointXY &linePoint2, QgsPointXY &intersection)
Compute the intersection of a line and a circle.
static void circleCenterRadius(const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double &radius, double &centerX, double &centerY)
Returns radius and center of the circle through pt1, pt2, pt3.
static double distToInfiniteLine(const QgsPoint &point, const QgsPoint &linePoint1, const QgsPoint &linePoint2, double epsilon=1e-7)
Returns the distance between a point and an infinite line.
static Q_DECL_DEPRECATED double ccwAngle(double dy, double dx)
Returns the counter clockwise angle between a line with components dx, dy and the line with dx > 0 an...
static void coefficients(const QgsPoint &pt1, const QgsPoint &pt2, double &a, double &b, double &c)
Returns the coefficients (a, b, c for equation "ax + by + c = 0") of a line defined by points pt1 and...
static Q_DECL_DEPRECATED double sweepAngle(double centerX, double centerY, double x1, double y1, double x2, double y2, double x3, double y3)
Calculates angle of a circular string part defined by pt1, pt2, pt3.
static QgsPoint midpoint(const QgsPoint &pt1, const QgsPoint &pt2)
Returns a middle point between points pt1 and pt2.
static Q_DECL_DEPRECATED double distance2D(double x1, double y1, double x2, double y2)
Returns the 2D distance between (x1, y1) and (x2, y2).
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 Q_DECL_DEPRECATED void perpendicularCenterSegment(double centerPointX, double centerPointY, double segmentPoint1x, double segmentPoint1y, double segmentPoint2x, double segmentPoint2y, double &perpendicularSegmentPoint1x, double &perpendicularSegmentPoint1y, double &perpendicularSegmentPoint2x, double &perpendicularSegmentPoint2y, double segmentLength=0)
Create a perpendicular line segment to a given segment [segmentPoint1,segmentPoint2] with its center ...
static QgsPoint closestVertex(const QgsAbstractGeometry &geom, const QgsPoint &pt, QgsVertexId &id)
Returns the closest vertex to a geometry for a specified point.
static Q_DECL_DEPRECATED double circleLength(double x1, double y1, double x2, double y2, double x3, double y3)
Length of a circular string segment defined by pt1, pt2, pt3.
static Q_DECL_DEPRECATED bool angleOnCircle(double angle, double angle1, double angle2, double angle3)
Returns true if an angle is between angle1 and angle3 on a circle described by angle1,...
static bool pointContinuesArc(const QgsPoint &a1, const QgsPoint &a2, const QgsPoint &a3, const QgsPoint &b, double distanceTolerance, double pointSpacingAngleTolerance)
Returns true if point b is on the arc formed by points a1, a2, and a3, but not within that arc portio...
static QgsPoint interpolatePointOnArc(const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double distance)
Interpolates a point on an arc defined by three points, pt1, pt2 and pt3.
static Q_DECL_DEPRECATED bool linesIntersection3D(const QgsVector3D &La1, const QgsVector3D &La2, const QgsVector3D &Lb1, const QgsVector3D &Lb2, QgsVector3D &intersection)
An algorithm to calculate an (approximate) intersection of two lines in 3D.
static Q_DECL_DEPRECATED bool pointsAreCollinear(double x1, double y1, double x2, double y2, double x3, double y3, double epsilon)
Given the points (x1, y1), (x2, y2) and (x3, y3) returns true if these points can be considered colli...
static double closestSegmentFromComponents(T &container, ComponentType ctype, const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, int *leftOf, double epsilon)
static bool tangentPointAndCircle(const QgsPointXY &center, double radius, const QgsPointXY &p, QgsPointXY &pt1, QgsPointXY &pt2)
Calculates the tangent points between the circle with the specified center and radius and the point p...
static double distance2D(const QgsPoint &pt1, const QgsPoint &pt2)
Returns the 2D distance between two points.
static double sqrDistance2D(const QgsPoint &pt1, const QgsPoint &pt2)
Returns the squared 2D distance between two points.
static int circleCircleOuterTangents(const QgsPointXY &center1, double radius1, const QgsPointXY &center2, double radius2, QgsPointXY &line1P1, QgsPointXY &line1P2, QgsPointXY &line2P1, QgsPointXY &line2P2)
Calculates the outer tangent points for two circles, centered at center1 and center2 and with radii o...
static Q_DECL_DEPRECATED bool angleBisector(double aX, double aY, double bX, double bY, double cX, double cY, double dX, double dY, double &pointX, double &pointY, double &angle)
Returns the point (pointX, pointY) forming the bisector from segment (aX aY) (bX bY) and segment (bX,...
static Q_DECL_DEPRECATED double normalizedAngle(double angle)
Ensures that an angle is in the range 0 <= angle < 2 pi.
static QgsPointSequence pointsFromWKT(const QString &wktCoordinateList, bool is3D, bool isMeasure)
Returns a list of points contained in a WKT string.
static Q_DECL_DEPRECATED bool circleAngleBetween(double angle, double angle1, double angle2, bool clockwise)
Returns true if, in a circle, angle is between angle1 and angle2.
static void segmentizeArc(const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, QgsPointSequence &points, double tolerance=M_PI_2/90, QgsAbstractGeometry::SegmentationToleranceType toleranceType=QgsAbstractGeometry::MaximumAngle, bool hasZ=false, bool hasM=false)
Convert circular arc defined by p1, p2, p3 (p1/p3 being start resp.
static Q_DECL_DEPRECATED double sqrDistance2D(double x1, double y1, double x2, double y2)
Returns the squared 2D distance between (x1, y1) and (x2, y2).
static QDomElement pointsToGML2(const QgsPointSequence &points, QDomDocument &doc, int precision, const QString &ns, QgsAbstractGeometry::AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY)
Returns a gml::coordinates DOM element.
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.
static Q_DECL_DEPRECATED int leftOfLine(const double x, const double y, const double x1, const double y1, const double x2, const double y2)
Returns a value < 0 if the point (x, y) is left of the line from (x1, y1) -> (x2, y2).
static Q_DECL_DEPRECATED double averageAngle(double x1, double y1, double x2, double y2, double x3, double y3)
Calculates the average angle (in radians) between the two linear segments from (x1,...
static Q_DECL_DEPRECATED bool skewLinesProjection(const QgsVector3D &P1, const QgsVector3D &P12, const QgsVector3D &P2, const QgsVector3D &P22, QgsVector3D &X1, double epsilon=0.0001)
A method to project one skew line onto another.
static double distance3D(const QgsPoint &pt1, const QgsPoint &pt2)
Returns the 3D distance between two points.
static QDomElement pointsToGML3(const QgsPointSequence &points, QDomDocument &doc, int precision, const QString &ns, bool is3D, QgsAbstractGeometry::AxisOrder axisOrder=QgsAbstractGeometry::AxisOrder::XY)
Returns a gml::posList DOM element.
static Q_DECL_DEPRECATED int closestSideOfRectangle(double right, double bottom, double left, double top, double x, double y)
Returns a number representing the closest side of a rectangle defined by /a right,...
static int circleCircleInnerTangents(const QgsPointXY &center1, double radius1, const QgsPointXY &center2, double radius2, QgsPointXY &line1P1, QgsPointXY &line1P2, QgsPointXY &line2P1, QgsPointXY &line2P2)
Calculates the inner tangent points for two circles, centered at center1 and center2 and with radii o...
static Q_DECL_DEPRECATED double angleBetweenThreePoints(double x1, double y1, double x2, double y2, double x3, double y3)
Calculates the angle between the lines AB and BC, where AB and BC described by points a,...
static QString pointsToWKT(const QgsPointSequence &points, int precision, bool is3D, bool isMeasure)
Returns a WKT coordinate list.
static Q_DECL_DEPRECATED double pointFractionAlongLine(double x1, double y1, double x2, double y2, double px, double py)
Given the line (x1, y1) to (x2, y2) and a point (px, py) returns the fraction of the line length at w...
static QgsPoint segmentMidPointFromCenter(const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &center, bool useShortestArc=true)
Calculates the midpoint on the circle passing through p1 and p2, with the specified center coordinate...
static Q_DECL_DEPRECATED bool bisector(double aX, double aY, double bX, double bY, double cX, double cY, double &pointX, double &pointY)
Returns the point (pointX, pointY) forming the bisector from point (aX, aY) to the segment (bX,...
static double sqrDistance3D(const QgsPoint &pt1, const QgsPoint &pt2)
Returns the squared 3D distance between two points.
static Q_DECL_DEPRECATED double skewLinesDistance(const QgsVector3D &P1, const QgsVector3D &P12, const QgsVector3D &P2, const QgsVector3D &P22)
An algorithm to calculate the shortest distance between two skew lines.
static Q_DECL_DEPRECATED void weightedPointInTriangle(double aX, double aY, double bX, double bY, double cX, double cY, double weightB, double weightC, double &pointX, double &pointY)
Returns a weighted point inside the triangle denoted by the points (aX, aY), (bX, bY) and (cX,...
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.
Custom exception class when argument are invalid.
Line string geometry type, with support for z-dimension and m-values.
Represents a 2D point.
Definition qgspointxy.h:62
double y
Definition qgspointxy.h:66
double x
Definition qgspointxy.h:65
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
double x
Definition qgspoint.h:56
void setM(double m)
Sets the point's m-value.
Definition qgspoint.h:369
bool convertTo(Qgis::WkbType type) override
Converts the geometry to a specified type.
Definition qgspoint.cpp:633
void setZ(double z)
Sets the point's z-coordinate.
Definition qgspoint.h:354
double y
Definition qgspoint.h:57
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:33
Represent a 2-dimensional vector.
Definition qgsvector.h:34
WKB pointer handler.
Definition qgswkbptr.h:45
static Qgis::WkbType addM(Qgis::WkbType type)
Adds the m dimension to a WKB type and returns the new type.
static Qgis::WkbType addZ(Qgis::WkbType type)
Adds the z dimension to a WKB type and returns the new type.
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)
Definition qgis_sip.h:149
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_HOLDGIL
Definition qgis_sip.h:179
#define SIP_FACTORY
Definition qgis_sip.h:84
#define SIP_INOUT
Definition qgis_sip.h:79
#define SIP_THROW(name,...)
Definition qgis_sip.h:211
QVector< QgsPoint > QgsPointSequence
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:34
int vertex
Vertex number.
Definition qgsvertexid.h:98
int part
Part number.
Definition qgsvertexid.h:92
int ring
Ring number.
Definition qgsvertexid.h:95