Skip to content
Permalink
Browse files
Adds setMValueFromPoints
  • Loading branch information
lbartoletti authored and nyalldawson committed Apr 29, 2021
1 parent 62a09aa commit 9e8101190814f57d342b71836f76a0fab3fec5a9
@@ -757,6 +757,19 @@ A Z dimension is added to ``point`` if one of the point in the list
.. versionadded:: 3.0
%End

static bool setMValueFromPoints( const QgsPointSequence &points, QgsPoint &point );
%Docstring
A M dimension is added to ``point`` if one of the point in the list
``points`` is in 3D. Moreover, the M value of ``point`` is updated with.

:param points: List of points in which a 3D point is searched.
:param point: The point to update with M dimension and value.

:return: ``True`` if the point is updated, ``False`` otherwise

.. versionadded:: 3.20
%End


static bool angleBisector( double aX, double aY, double bX, double bY, double cX, double cY, double dX, double dY,
double &pointX /Out/, double &pointY /Out/, double &angle /Out/ ) /HoldGIL/;
@@ -254,6 +254,8 @@ bool QgsGeometryUtils::lineIntersection( const QgsPoint &p1, QgsVector v1, const

// z support for intersection point
QgsGeometryUtils::setZValueFromPoints( QgsPointSequence() << p1 << p2, intersection );
// m support for intersection point
QgsGeometryUtils::setMValueFromPoints( QgsPointSequence() << p1 << p2, intersection );

return true;
}
@@ -854,6 +856,8 @@ bool QgsGeometryUtils::segmentMidPoint( const QgsPoint &p1, const QgsPoint &p2,

// add z support if necessary
QgsGeometryUtils::setZValueFromPoints( QgsPointSequence() << p1 << p2, result );
// add m support if necessary
QgsGeometryUtils::setMValueFromPoints( QgsPointSequence() << p1 << p2, result );

return true;
}
@@ -1806,6 +1810,24 @@ void QgsGeometryUtils::weightedPointInTriangle( const double aX, const double aY
pointY = rBy + rCy + aY;
}

bool QgsGeometryUtils::setMValueFromPoints( const QgsPointSequence &points, QgsPoint &point )
{
bool rc = false;

for ( const QgsPoint &pt : points )
{
if ( pt.isMeasure() )
{
point.convertTo( QgsWkbTypes::addM( point.wkbType() ) );
point.setM( pt.m() );
rc = true;
break;
}
}

return rc;
}

bool QgsGeometryUtils::setZValueFromPoints( const QgsPointSequence &points, QgsPoint &point )
{
bool rc = false;
@@ -780,6 +780,18 @@ class CORE_EXPORT QgsGeometryUtils
*/
static bool setZValueFromPoints( const QgsPointSequence &points, QgsPoint &point );

/**
* A M dimension is added to \a point if one of the point in the list
* \a points is in 3D. Moreover, the M value of \a point is updated with.
*
* \param points List of points in which a 3D point is searched.
* \param point The point to update with M dimension and value.
* \returns TRUE if the point is updated, FALSE otherwise
*
* \since QGIS 3.20
*/
static bool setMValueFromPoints( const QgsPointSequence &points, QgsPoint &point );

/**
* Returns the point (\a pointX, \a pointY) forming the bisector from segment (\a aX \a aY) (\a bX \a bY)
* and segment (\a bX, \a bY) (\a dX, \a dY).

0 comments on commit 9e81011

Please sign in to comment.