QGIS API Documentation 4.3.0-Master (58212645307)
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:
47 static QVector<QgsLineString *> extractLineStrings( const QgsAbstractGeometry *geom ) SIP_FACTORY;
48
53 static QgsPoint closestVertex( const QgsAbstractGeometry &geom, const QgsPoint &pt, QgsVertexId &id SIP_OUT );
54
60 static QgsPoint closestPoint( const QgsAbstractGeometry &geometry, const QgsPoint &point );
61
68 static double distanceToVertex( const QgsAbstractGeometry &geom, QgsVertexId id );
69
80 static bool verticesAtDistance( const QgsAbstractGeometry &geometry, double distance, QgsVertexId &previousVertex SIP_OUT, QgsVertexId &nextVertex SIP_OUT );
81
90 static double distToInfiniteLine( const QgsPoint &point, const QgsPoint &linePoint1, const QgsPoint &linePoint2, double epsilon = 1e-7 );
91
92 // clang-format off
104 static bool lineCircleIntersection( const QgsPointXY &center, double radius, const QgsPointXY &linePoint1, const QgsPointXY &linePoint2, QgsPointXY &intersection SIP_INOUT ) SIP_HOLDGIL;
105 // clang-format on
106
117 static int circleCircleIntersections( const QgsPointXY &center1, double radius1,
118 const QgsPointXY &center2, double radius2,
119 QgsPointXY &intersection1 SIP_OUT, QgsPointXY &intersection2 SIP_OUT ) SIP_HOLDGIL;
120
129 static bool tangentPointAndCircle( const QgsPointXY &center, double radius,
131
149 static int circleCircleOuterTangents(
150 const QgsPointXY &center1, double radius1, const QgsPointXY &center2, double radius2,
151 QgsPointXY &line1P1 SIP_OUT, QgsPointXY &line1P2 SIP_OUT,
152 QgsPointXY &line2P1 SIP_OUT, QgsPointXY &line2P2 SIP_OUT ) SIP_HOLDGIL;
153
172 static int circleCircleInnerTangents(
173 const QgsPointXY &center1, double radius1, const QgsPointXY &center2, double radius2,
174 QgsPointXY &line1P1 SIP_OUT, QgsPointXY &line1P2 SIP_OUT,
175 QgsPointXY &line2P1 SIP_OUT, QgsPointXY &line2P2 SIP_OUT ) SIP_HOLDGIL;
176
184 static QgsPoint projectPointOnSegment( const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2 ) SIP_HOLDGIL
185 {
186 const double nx = s2.y() - s1.y();
187 const double ny = -( s2.x() - s1.x() );
188 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 );
189 return t < 0. ? s1 : t > 1. ? s2 : QgsPoint( s1.x() + ( s2.x() - s1.x() ) * t, s1.y() + ( s2.y() - s1.y() ) * t );
190 }
191
199
209 static QVector<SelfIntersection> selfIntersections( const QgsAbstractGeometry *geom, int part, int ring, double tolerance ) SIP_SKIP;
210
220 static int leftOfLine( const QgsPoint &point, const QgsPoint &p1, const QgsPoint &p2 ) SIP_HOLDGIL;
221
225 static QgsPoint pointOnLineWithDistance( const QgsPoint &startPoint, const QgsPoint &directionPoint, double distance ) SIP_HOLDGIL;
226
235 static QgsPoint interpolatePointOnArc( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double distance ) SIP_HOLDGIL;
236
257 static QgsPoint interpolatePointOnCubicBezier( const QgsPoint &p0, const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, double t ) SIP_HOLDGIL;
258
265 static bool segmentMidPoint( const QgsPoint &p1, const QgsPoint &p2, QgsPoint &result SIP_OUT, double radius, const QgsPoint &mousePos ) SIP_HOLDGIL;
266
278 static QgsPoint segmentMidPointFromCenter( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &center, bool useShortestArc = true ) SIP_HOLDGIL;
279
281 static double circleTangentDirection( const QgsPoint &tangentPoint, const QgsPoint &cp1, const QgsPoint &cp2, const QgsPoint &cp3 ) SIP_HOLDGIL;
282
286 static void segmentizeArc( const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3,
287 QgsPointSequence SIP_PYALTERNATIVETYPE( QVector<QgsPoint> ) &points SIP_OUT, double tolerance = M_PI_2 / 90,
288 QgsAbstractGeometry::SegmentationToleranceType toleranceType = QgsAbstractGeometry::MaximumAngle,
289 bool hasZ = false, bool hasM = false );
290
306 static bool pointContinuesArc( const QgsPoint &a1, const QgsPoint &a2, const QgsPoint &a3, const QgsPoint &b, double distanceTolerance,
307 double pointSpacingAngleTolerance ) SIP_HOLDGIL;
308
313 static int segmentSide( const QgsPoint &pt1, const QgsPoint &pt3, const QgsPoint &pt2 ) SIP_HOLDGIL;
314
319 static QgsPointSequence pointsFromWKT( const QString &wktCoordinateList, bool is3D, bool isMeasure ) SIP_SKIP;
320
325 static void pointsToWKB( QgsWkbPtr &wkb, const QgsPointSequence &points, bool is3D, bool isMeasure, QgsAbstractGeometry::WkbFlags flags ) SIP_SKIP;
326
331 static QString pointsToWKT( const QgsPointSequence &points, int precision, bool is3D, bool isMeasure ) SIP_SKIP;
332
337 static QDomElement pointsToGML2( const QgsPointSequence &points, QDomDocument &doc, int precision, const QString &ns, QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) SIP_SKIP;
338
343 static QDomElement pointsToGML3( const QgsPointSequence &points, QDomDocument &doc, int precision, const QString &ns, bool is3D, QgsAbstractGeometry::AxisOrder axisOrder = QgsAbstractGeometry::AxisOrder::XY ) SIP_SKIP;
344
350 Q_DECL_DEPRECATED static QString pointsToJSON( const QgsPointSequence &points, int precision ) SIP_SKIP;
351
356 static json pointsToJson( const QgsPointSequence &points, int precision, Qgis::GeoJsonProfile profile ) SIP_SKIP;
357
362 static QPair<Qgis::WkbType, QString> wktReadBlock( const QString &wkt ) SIP_SKIP;
363
371 static QStringList wktGetChildBlocks( const QString &wkt, const QString &defaultType = QString() ) SIP_SKIP;
372
395 static QgsPoint midpoint( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL;
396
409 static QgsPointXY interpolatePointOnLine( double x1, double y1, double x2, double y2, double fraction ) SIP_HOLDGIL;
410
426 static QgsPoint interpolatePointOnLine( const QgsPoint &p1, const QgsPoint &p2, double fraction ) SIP_HOLDGIL;
427
439 static QgsPointXY interpolatePointOnLineByValue( double x1, double y1, double v1, double x2, double y2, double v2, double value ) SIP_HOLDGIL;
440
447 static double gradient( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL;
448
457 static void coefficients( const QgsPoint &pt1, const QgsPoint &pt2,
458 double &a SIP_OUT, double &b SIP_OUT, double &c SIP_OUT ) SIP_HOLDGIL;
459
467 static QgsLineString perpendicularSegment( const QgsPoint &p, const QgsPoint &s1, const QgsPoint &s2 ) SIP_HOLDGIL;
468
484 Q_DECL_DEPRECATED static bool setZValueFromPoints( const QgsPointSequence &points, QgsPoint &point ) SIP_DEPRECATED
485 {
486 return transferFirstZValueToPoint( points, point );
487 }
488
504 static bool transferFirstZValueToPoint( const QgsPointSequence &points, QgsPoint &point );
505
521 static bool transferFirstMValueToPoint( const QgsPointSequence &points, QgsPoint &point );
522
541 template <class Iterator> static bool transferFirstZOrMValueToPoint( Iterator verticesBegin, Iterator verticesEnd, QgsPoint &point ) SIP_SKIP
542 {
543 bool zFound = false;
544 bool mFound = false;
545
546 for ( auto it = verticesBegin ; it != verticesEnd ; ++it )
547 {
548 if ( !mFound && ( *it ).isMeasure() )
549 {
550 point.convertTo( QgsWkbTypes::addM( point.wkbType() ) );
551 point.setM( ( *it ).m() );
552 mFound = true;
553 }
554 if ( !zFound && ( *it ).is3D() )
555 {
556 point.convertTo( QgsWkbTypes::addZ( point.wkbType() ) );
557 point.setZ( ( *it ).z() );
558 zFound = true;
559 }
560 if ( zFound && mFound )
561 break;
562 }
563
564 return zFound || mFound;
565 }
566
583 static bool transferFirstZOrMValueToPoint( const QgsPointSequence &points, QgsPoint &point )
584 {
585 return QgsGeometryUtils::transferFirstZOrMValueToPoint( points.constBegin(), points.constEnd(), point );
586 }
587
604 static bool transferFirstZOrMValueToPoint( const QgsGeometry &geom, QgsPoint &point )
605 {
607 }
608
616
618 template<class T> static double closestSegmentFromComponents( T &container, ComponentType ctype, const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, int *leftOf, double epsilon ) SIP_SKIP
619 {
620 double minDist = std::numeric_limits<double>::max();
621 double minDistSegmentX = 0.0, minDistSegmentY = 0.0;
622 QgsVertexId minDistVertexAfter;
623 int minDistLeftOf = 0;
624 double sqrDist = 0.0;
625 int vertexOffset = 0;
626 int ringOffset = 0;
627 int partOffset = 0;
628
629 for ( int i = 0; i < container.size(); ++i )
630 {
631 sqrDist = container.at( i )->closestSegment( pt, segmentPt, vertexAfter, leftOf, epsilon );
632 if ( sqrDist >= 0 && sqrDist < minDist )
633 {
634 minDist = sqrDist;
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;
641 if ( leftOf )
642 {
643 minDistLeftOf = *leftOf;
644 }
645 }
646
647 if ( ctype == Vertex )
648 {
649 //-1 because compoundcurve counts duplicated vertices of neighbour curves as one node
650 vertexOffset += container.at( i )->nCoordinates() - 1;
651 }
652 else if ( ctype == Ring )
653 {
654 ringOffset += 1;
655 }
656 else if ( ctype == Part )
657 {
658 partOffset += 1;
659 }
660 }
661
662 if ( minDist == std::numeric_limits<double>::max() )
663 return -1; // error: no segments
664
665 segmentPt.setX( minDistSegmentX );
666 segmentPt.setY( minDistSegmentY );
667 vertexAfter = minDistVertexAfter;
668 if ( leftOf )
669 {
670 *leftOf = minDistLeftOf;
671 }
672 return minDist;
673 }
674
675 /******************************/
676 /* From QgsGeometryUtils_Base */
677 /******************************/
678
684 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 ); }
685
689 static double sqrDistance2D( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL
690 {
691 return QgsGeometryUtilsBase::sqrDistance2D( pt1.x(), pt1.y(), pt2.x(), pt2.y() );
692 }
693
700 static double sqrDistance3D( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL
701 {
702 return QgsGeometryUtilsBase::sqrDistance3D( pt1.x(), pt1.y(), pt1.z(), pt2.x(), pt2.y(), pt2.z() );
703 }
704
710 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 ); }
711
715 static double distance2D( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL { return QgsGeometryUtilsBase::distance2D( pt1.x(), pt1.y(), pt2.x(), pt2.y() );}
716
723 static double distance3D( const QgsPoint &pt1, const QgsPoint &pt2 ) SIP_HOLDGIL
724 {
725 return QgsGeometryUtilsBase::distance3D( pt1.x(), pt1.y(), pt1.z(), pt2.x(), pt2.y(), pt2.z() );
726 }
727
728
734 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
735 {
736 return QgsGeometryUtilsBase::sqrDistToLine( ptX, ptY, x1, y1, x2, y2, minDistX, minDistY, epsilon );
737 }
738
748 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
749 {
750 return QgsGeometryUtilsBase::leftOfLine( x, y, x1, y1, x2, y2 ) ;
751 }
752
763 Q_DECL_DEPRECATED static void pointOnLineWithDistance( double x1, double y1, double x2, double y2, double distance, double &x, double &y,
764 double *z1 = nullptr, double *z2 = nullptr, double *z = nullptr,
765 double *m1 = nullptr, double *m2 = nullptr, double *m = nullptr ) SIP_SKIP
766 {
767 return QgsGeometryUtilsBase::pointOnLineWithDistance( x1, y1, x2, y2, distance, x, y,
768 z1, z2, z,
769 m1, m2, m );
770 }
771
800 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 )
801 {
802 QgsGeometryUtilsBase::perpendicularOffsetPointAlongSegment( x1, y1, x2, y2, proportion, offset, x, y );
803 }
804
805
806
807
813 Q_DECL_DEPRECATED static double ccwAngle( double dy, double dx ) SIP_DEPRECATED SIP_HOLDGIL
814 {
815 return QgsGeometryUtilsBase::ccwAngle( dy, dx );
816 }
817
818
827 Q_DECL_DEPRECATED static bool circleClockwise( double angle1, double angle2, double angle3 ) SIP_DEPRECATED SIP_HOLDGIL
828 {
829 return QgsGeometryUtilsBase::circleClockwise( angle1, angle2, angle3 );
830 }
831
837 Q_DECL_DEPRECATED static bool circleAngleBetween( double angle, double angle1, double angle2, bool clockwise ) SIP_DEPRECATED SIP_HOLDGIL
838 {
839 return QgsGeometryUtilsBase::circleAngleBetween( angle, angle1, angle2, clockwise );
840 }
841
848 Q_DECL_DEPRECATED static bool angleOnCircle( double angle, double angle1, double angle2, double angle3 ) SIP_DEPRECATED SIP_HOLDGIL
849 {
850 return QgsGeometryUtilsBase::angleOnCircle( angle, angle1, angle2, angle3 );
851 }
852
858 Q_DECL_DEPRECATED static double circleLength( double x1, double y1, double x2, double y2, double x3, double y3 ) SIP_DEPRECATED SIP_HOLDGIL
859 {
860 return QgsGeometryUtilsBase::circleLength( x1, y1, x2, y2, x3, y3 );
861 }
862
868 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
869 {
870 return QgsGeometryUtilsBase::sweepAngle( centerX, centerY, x1, y1, x2, y2, x3, y3 );
871 }
872
877 Q_DECL_DEPRECATED static double interpolateArcValue( double angle, double a1, double a2, double a3, double zm1, double zm2, double zm3 ) SIP_DEPRECATED SIP_HOLDGIL
878 {
879 return QgsGeometryUtilsBase::interpolateArcValue( angle, a1, a2, a3, zm1, zm2, zm3 );
880 }
881
889 Q_DECL_DEPRECATED static double normalizedAngle( double angle ) SIP_DEPRECATED SIP_HOLDGIL
890 {
892 }
893
904 Q_DECL_DEPRECATED static double lineAngle( double x1, double y1, double x2, double y2 ) SIP_DEPRECATED SIP_HOLDGIL
905 {
906 return QgsGeometryUtilsBase::lineAngle( x1, y1, x2, y2 );
907 }
908
922 Q_DECL_DEPRECATED static double angleBetweenThreePoints( double x1, double y1, double x2, double y2, double x3, double y3 ) SIP_DEPRECATED SIP_HOLDGIL
923 {
924 return QgsGeometryUtilsBase::angleBetweenThreePoints( x1, y1, x2, y2, x3, y3 );
925 }
926
938 Q_DECL_DEPRECATED static double linePerpendicularAngle( double x1, double y1, double x2, double y2 ) SIP_DEPRECATED SIP_HOLDGIL
939 {
940 return QgsGeometryUtilsBase::linePerpendicularAngle( x1, y1, x2, y2 );
941 }
942
949 Q_DECL_DEPRECATED static double averageAngle( double x1, double y1, double x2, double y2, double x3, double y3 ) SIP_DEPRECATED SIP_HOLDGIL
950 {
951 return QgsGeometryUtilsBase::averageAngle( x1, y1, x2, y2, x3, y3 );
952 }
953
962 Q_DECL_DEPRECATED static double averageAngle( double a1, double a2 ) SIP_DEPRECATED SIP_HOLDGIL
963 {
964 return QgsGeometryUtilsBase::averageAngle( a1, a2 );
965 }
966
967
991 Q_DECL_DEPRECATED static int closestSideOfRectangle( double right, double bottom, double left, double top, double x, double y )
992 {
993 return QgsGeometryUtilsBase::closestSideOfRectangle( right, bottom, left, top, x, y );
994 }
995
1019 Q_DECL_DEPRECATED static void perpendicularCenterSegment( double centerPointX, double centerPointY,
1020 double segmentPoint1x, double segmentPoint1y,
1021 double segmentPoint2x, double segmentPoint2y,
1022 double &perpendicularSegmentPoint1x SIP_OUT, double &perpendicularSegmentPoint1y SIP_OUT,
1023 double &perpendicularSegmentPoint2x SIP_OUT, double &perpendicularSegmentPoint2y SIP_OUT,
1024 double segmentLength = 0 ) SIP_HOLDGIL
1025 {
1026 return QgsGeometryUtilsBase::perpendicularCenterSegment( centerPointX, centerPointY, segmentPoint1x, segmentPoint1y, segmentPoint2x, segmentPoint2y, perpendicularSegmentPoint1x, perpendicularSegmentPoint1y, perpendicularSegmentPoint2x, perpendicularSegmentPoint2y, segmentLength );
1027 }
1028
1039 Q_DECL_DEPRECATED static double skewLinesDistance( const QgsVector3D &P1, const QgsVector3D &P12, const QgsVector3D &P2, const QgsVector3D &P22 ) SIP_DEPRECATED SIP_HOLDGIL
1040 {
1041 return QgsGeometryUtilsBase::skewLinesDistance( P1, P12, P2, P22 );
1042 }
1043
1056 Q_DECL_DEPRECATED static bool skewLinesProjection( const QgsVector3D &P1, const QgsVector3D &P12,
1057 const QgsVector3D &P2, const QgsVector3D &P22,
1058 QgsVector3D &X1 SIP_OUT,
1059 double epsilon = 0.0001 ) SIP_HOLDGIL
1060 {
1061 return QgsGeometryUtilsBase::skewLinesProjection( P1, P12, P2, P22, X1, epsilon );
1062 }
1063
1064
1103 Q_DECL_DEPRECATED static bool linesIntersection3D( const QgsVector3D &La1, const QgsVector3D &La2,
1104 const QgsVector3D &Lb1, const QgsVector3D &Lb2,
1105 QgsVector3D &intersection SIP_OUT ) SIP_HOLDGIL
1106 {
1107 return QgsGeometryUtilsBase::linesIntersection3D( La1, La2, Lb1, Lb2, intersection );
1108 }
1109
1117 Q_DECL_DEPRECATED static double triangleArea( double aX, double aY, double bX, double bY, double cX, double cY ) SIP_DEPRECATED SIP_HOLDGIL
1118 {
1119 return QgsGeometryUtilsBase::triangleArea( aX, aY, bX, bY, cX, cY );
1120 }
1121
1131 Q_DECL_DEPRECATED static double pointFractionAlongLine( double x1, double y1, double x2, double y2, double px, double py )
1132 {
1133 return QgsGeometryUtilsBase::pointFractionAlongLine( x1, y1, x2, y2, px, py );
1134 }
1135
1154 Q_DECL_DEPRECATED static void weightedPointInTriangle( double aX, double aY, double bX, double bY, double cX, double cY,
1155 double weightB, double weightC, double &pointX SIP_OUT, double &pointY SIP_OUT ) SIP_HOLDGIL
1156 {
1157 return QgsGeometryUtilsBase::weightedPointInTriangle( aX, aY, bX, bY, cX, cY, weightB, weightC, pointX, pointY );
1158 }
1159
1167 Q_DECL_DEPRECATED static bool pointsAreCollinear( double x1, double y1, double x2, double y2, double x3, double y3, double epsilon )
1168 {
1169 return QgsGeometryUtilsBase::pointsAreCollinear( x1, y1, x2, y2, x3, y3, epsilon );
1170 }
1171
1193 Q_DECL_DEPRECATED static bool angleBisector( double aX, double aY, double bX, double bY, double cX, double cY, double dX, double dY,
1194 double &pointX SIP_OUT, double &pointY SIP_OUT, double &angle SIP_OUT ) SIP_HOLDGIL
1195 {
1196 return QgsGeometryUtilsBase::angleBisector( aX, aY, bX, bY, cX, cY, dX, dY, pointX, pointY, angle );
1197 }
1198
1216 Q_DECL_DEPRECATED static bool bisector( double aX, double aY, double bX, double bY, double cX, double cY,
1217 double &pointX SIP_OUT, double &pointY SIP_OUT ) SIP_HOLDGIL
1218 {
1219 return QgsGeometryUtilsBase::bisector( aX, aY, bX, bY, cX, cY, pointX, pointY );
1220 }
1221
1225 static void circleCenterRadius( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double &radius SIP_OUT,
1226 double &centerX SIP_OUT, double &centerY SIP_OUT ) SIP_HOLDGIL
1227 {
1228 return QgsGeometryUtilsBase::circleCenterRadius( pt1.x(), pt1.y(), pt2.x(), pt2.y(), pt3.x(), pt3.y(), radius, centerX, centerY );
1229 }
1230
1242 static bool lineIntersection( const QgsPoint &p1, QgsVector v1, const QgsPoint &p2, QgsVector v2, QgsPoint &intersection SIP_OUT ) SIP_HOLDGIL
1243 {
1244 double intersectionX = 0.0, intersectionY = 0.0;
1245 bool result = QgsGeometryUtilsBase::lineIntersection( p1.x(), p1.y(), v1, p2.x(), p2.y(), v2, intersectionX, intersectionY );
1246 intersection = QgsPoint( intersectionX, intersectionY );
1247
1248 // z and m support for intersection point
1250
1251 return result;
1252 }
1253
1273 static bool intersectionPointOfLinesByBearing( const QgsPoint &pt1, double bearing1, const QgsPoint &pt2, double bearing2, QgsPoint &intersection SIP_OUT ) SIP_HOLDGIL
1274 {
1275 double intersectionX = 0.0, intersectionY = 0.0;
1276 const bool found = QgsGeometryUtilsBase::intersectionPointOfLinesByBearing( pt1.x(), pt1.y(), bearing1, pt2.x(), pt2.y(), bearing2, intersectionX, intersectionY );
1277
1278 intersection = QgsPoint( intersectionX, intersectionY );
1279
1280 // z and m support for intersection point
1282
1283 return found;
1284 }
1285
1286
1323 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
1324 {
1325 double intersectionPointX = 0.0, intersectionPointY = 0.0;
1326 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 );
1327 intersectionPoint.setX( intersectionPointX );
1328 intersectionPoint.setY( intersectionPointY );
1329 return result;
1330 }
1331
1340 static QgsPoint createPointWithMatchingDimensions( double x, double y, const QgsPoint &reference ) SIP_HOLDGIL;
1341
1351 static QgsPoint interpolatePointOnSegment( double x, double y,
1352 const QgsPoint &segmentStart, const QgsPoint &segmentEnd ) SIP_HOLDGIL;
1353
1370 static bool createChamfer( const QgsPoint &segment1Start, const QgsPoint &segment1End,
1371 const QgsPoint &segment2Start, const QgsPoint &segment2End,
1372 double distance1, double distance2,
1373 QgsPoint &chamferStart SIP_OUT, QgsPoint &chamferEnd SIP_OUT,
1374 double epsilon = 1e-8 ) SIP_THROW( QgsInvalidArgumentException ) SIP_HOLDGIL;
1375
1395 static bool createFillet( const QgsPoint &segment1Start, const QgsPoint &segment1End,
1396 const QgsPoint &segment2Start, const QgsPoint &segment2End,
1397 double radius,
1398 QgsPoint &filletPoint1 SIP_OUT,
1399 QgsPoint &filletMidPoint SIP_OUT,
1400 QgsPoint &filletPoint2 SIP_OUT,
1401 double epsilon = 1e-8 ) SIP_THROW( QgsInvalidArgumentException ) SIP_HOLDGIL;
1402
1416 static std::unique_ptr< QgsLineString > createChamferGeometry(
1417 const QgsPoint &segment1Start, const QgsPoint &segment1End,
1418 const QgsPoint &segment2Start, const QgsPoint &segment2End,
1419 double distance1, double distance2
1421
1435 static std::unique_ptr< QgsAbstractGeometry > createFilletGeometry(
1436 const QgsPoint &segment1Start, const QgsPoint &segment1End,
1437 const QgsPoint &segment2Start, const QgsPoint &segment2End,
1438 double radius, int segments
1440
1453 static double maxFilletRadius( const QgsPoint &segment1Start, const QgsPoint &segment1End,
1454 const QgsPoint &segment2Start, const QgsPoint &segment2End,
1455 double epsilon = 1e-8 ) SIP_HOLDGIL;
1456
1471 static std::unique_ptr< QgsAbstractGeometry > chamferVertex(
1472 const QgsCurve *curve, int vertexIndex,
1473 double distance1, double distance2
1475
1490 static std::unique_ptr< QgsAbstractGeometry > filletVertex(
1491 const QgsCurve *curve, int vertexIndex,
1492 double radius, int segments
1494
1502 static bool createFilletArray( const QgsPoint &segment1Start, const QgsPoint &segment1End,
1503 const QgsPoint &segment2Start, const QgsPoint &segment2End,
1504 double radius,
1505 QgsPoint filletPoints[3],
1506 double epsilon = 1e-8 ) SIP_SKIP;
1507
1523 static bool pointsAreCollinear( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double epsilon );
1524
1525
1546 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() );
1547
1558 static double interpolateZ( const QgsPoint &a, const QgsPoint &b, const QgsPoint &c, double x, double y );
1559
1560 private:
1561
1574 static std::unique_ptr< QgsAbstractGeometry > doChamferFilletOnVertex(
1575 QgsGeometry::ChamferFilletOperationType operation, const QgsCurve *curve, int vertexIndex,
1576 double value1, double value2, int segments
1577 );
1578};
1579#include "qgsgeometryutils_base.h"
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
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 intersectionPointOfLinesByBearing(double x1, double y1, double bearing1, double x2, double y2, double bearing2, double &intersectionX, double &intersectionY)
Calculates the intersection point of two lines defined by point and bearing.
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 Q_DECL_DEPRECATED 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 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 intersectionPointOfLinesByBearing(const QgsPoint &pt1, double bearing1, const QgsPoint &pt2, double bearing2, QgsPoint &intersection)
Calculates the intersection point of two lines defined by point and bearing.
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 json pointsToJson(const QgsPointSequence &points, int precision, Qgis::GeoJsonProfile profile)
Returns coordinates as json object.
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:415
bool convertTo(Qgis::WkbType type) override
Converts the geometry to a specified type.
Definition qgspoint.cpp:672
void setZ(double z)
Sets the point's z-coordinate.
Definition qgspoint.h:400
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:47
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:148
#define SIP_DEPRECATED
Definition qgis_sip.h:113
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_OUT
Definition qgis_sip.h:57
#define SIP_HOLDGIL
Definition qgis_sip.h:178
#define SIP_FACTORY
Definition qgis_sip.h:83
#define SIP_INOUT
Definition qgis_sip.h:78
#define SIP_THROW(name,...)
Definition qgis_sip.h:210
QVector< QgsPoint > QgsPointSequence
Utility class for identifying a unique vertex within a geometry.
Definition qgsvertexid.h:35
int vertex
Vertex number.
int part
Part number.
Definition qgsvertexid.h:94
int ring
Ring number.
Definition qgsvertexid.h:97