Skip to content
Permalink
Browse files
replace setMValueFromPoints by transferFirstMValuteToPoint
  • Loading branch information
lbartoletti authored and nyalldawson committed Apr 29, 2021
1 parent 4231134 commit 95cff79cec4f6a0179485aac6df6e43f46edd5a6
@@ -763,7 +763,7 @@ 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 );
static bool transferFirstMValueToPoint( const QgsPointSequence &points, QgsPoint &point );
%Docstring
A M dimension is added to ``point`` if one of the points in the list
``points`` contains an M value. Moreover, the M value of ``point`` is
@@ -255,7 +255,7 @@ 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 );
QgsGeometryUtils::transferFirstMValueToPoint( QgsPointSequence() << p1 << p2, intersection );

return true;
}
@@ -857,7 +857,7 @@ 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 );
QgsGeometryUtils::transferFirstMValueToPoint( QgsPointSequence() << p1 << p2, result );

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

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

@@ -797,7 +797,7 @@ class CORE_EXPORT QgsGeometryUtils
*
* \since QGIS 3.20
*/
static bool setMValueFromPoints( const QgsPointSequence &points, QgsPoint &point );
static bool transferFirstMValueToPoint( 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)
@@ -86,7 +86,7 @@ class TestQgsGeometryUtils: public QObject
void testPerpendicularOffsetPoint();
void testClosestSideOfRectangle();
void setZValueFromPoints();
void setMValueFromPoints();
void transferFirstMValueToPoint();
};


@@ -1637,34 +1637,34 @@ void TestQgsGeometryUtils::setZValueFromPoints()
QCOMPARE( pointM.z(), 4.0 );
}

void TestQgsGeometryUtils::setMValueFromPoints()
void TestQgsGeometryUtils::transferFirstMValueToPoint()
{
QgsPoint point( 1, 2 );

// Type: Point
bool ret = QgsGeometryUtils::setMValueFromPoints( QgsPointSequence() << QgsPoint( 0, 2 ), point );
bool ret = QgsGeometryUtils::transferFirstMValueToPoint( QgsPointSequence() << QgsPoint( 0, 2 ), point );
QCOMPARE( ret, false );

// Type: PointZ
ret = QgsGeometryUtils::setMValueFromPoints( QgsPointSequence() << QgsPoint( 0, 2, 4 ), point );
ret = QgsGeometryUtils::transferFirstMValueToPoint( QgsPointSequence() << QgsPoint( 0, 2, 4 ), point );
QCOMPARE( ret, false );

// Type: PointM
ret = QgsGeometryUtils::setMValueFromPoints( QgsPointSequence() << QgsPoint( QgsWkbTypes::PointM, 0, 2, 0, 4 ), point );
ret = QgsGeometryUtils::transferFirstMValueToPoint( QgsPointSequence() << QgsPoint( QgsWkbTypes::PointM, 0, 2, 0, 4 ), point );
QCOMPARE( ret, true );
QCOMPARE( point.wkbType(), QgsWkbTypes::PointM );
QCOMPARE( point.m(), 4.0 );

// Type: PointM
ret = QgsGeometryUtils::setMValueFromPoints( QgsPointSequence() << QgsPoint( QgsWkbTypes::PointM, 0, 2, 0, 5 ), point );
ret = QgsGeometryUtils::transferFirstMValueToPoint( QgsPointSequence() << QgsPoint( QgsWkbTypes::PointM, 0, 2, 0, 5 ), point );
QCOMPARE( ret, true );
QCOMPARE( point.wkbType(), QgsWkbTypes::PointM );
QCOMPARE( point.m(), 5.0 ); // now point.z == 5. Shouldn't the current M be left if the point is already of type PointM?

// Add M to a PointZ
QgsPoint pointZ( 1, 2, 4 );
// Type: PointM
ret = QgsGeometryUtils::setMValueFromPoints( QgsPointSequence() << QgsPoint( QgsWkbTypes::PointM, 0, 2, 0, 5 ), pointZ );
ret = QgsGeometryUtils::transferFirstMValueToPoint( QgsPointSequence() << QgsPoint( QgsWkbTypes::PointM, 0, 2, 0, 5 ), pointZ );
QCOMPARE( ret, true );
QCOMPARE( pointZ.wkbType(), QgsWkbTypes::PointZM );
QCOMPARE( pointZ.m(), 5.0 );

0 comments on commit 95cff79

Please sign in to comment.