Skip to content

Commit

Permalink
replace setMValueFromPoints by transferFirstMValuteToPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lbartoletti authored and nyalldawson committed Apr 29, 2021
1 parent 4231134 commit 95cff79
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Expand Up @@ -763,7 +763,7 @@ A Z dimension is added to ``point`` if one of the point in the list
.. versionadded:: 3.0 .. versionadded:: 3.0
%End %End


static bool setMValueFromPoints( const QgsPointSequence &points, QgsPoint &point ); static bool transferFirstMValueToPoint( const QgsPointSequence &points, QgsPoint &point );
%Docstring %Docstring
A M dimension is added to ``point`` if one of the points in the list 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 ``points`` contains an M value. Moreover, the M value of ``point`` is
Expand Down
6 changes: 3 additions & 3 deletions src/core/geometry/qgsgeometryutils.cpp
Expand Up @@ -255,7 +255,7 @@ bool QgsGeometryUtils::lineIntersection( const QgsPoint &p1, QgsVector v1, const
// z support for intersection point // z support for intersection point
QgsGeometryUtils::setZValueFromPoints( QgsPointSequence() << p1 << p2, intersection ); QgsGeometryUtils::setZValueFromPoints( QgsPointSequence() << p1 << p2, intersection );
// m support for intersection point // m support for intersection point
QgsGeometryUtils::setMValueFromPoints( QgsPointSequence() << p1 << p2, intersection ); QgsGeometryUtils::transferFirstMValueToPoint( QgsPointSequence() << p1 << p2, intersection );


return true; return true;
} }
Expand Down Expand Up @@ -857,7 +857,7 @@ bool QgsGeometryUtils::segmentMidPoint( const QgsPoint &p1, const QgsPoint &p2,
// add z support if necessary // add z support if necessary
QgsGeometryUtils::setZValueFromPoints( QgsPointSequence() << p1 << p2, result ); QgsGeometryUtils::setZValueFromPoints( QgsPointSequence() << p1 << p2, result );
// add m support if necessary // add m support if necessary
QgsGeometryUtils::setMValueFromPoints( QgsPointSequence() << p1 << p2, result ); QgsGeometryUtils::transferFirstMValueToPoint( QgsPointSequence() << p1 << p2, result );


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


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


Expand Down
2 changes: 1 addition & 1 deletion src/core/geometry/qgsgeometryutils.h
Expand Up @@ -797,7 +797,7 @@ class CORE_EXPORT QgsGeometryUtils
* *
* \since QGIS 3.20 * \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) * Returns the point (\a pointX, \a pointY) forming the bisector from segment (\a aX \a aY) (\a bX \a bY)
Expand Down
14 changes: 7 additions & 7 deletions tests/src/core/testqgsgeometryutils.cpp
Expand Up @@ -86,7 +86,7 @@ class TestQgsGeometryUtils: public QObject
void testPerpendicularOffsetPoint(); void testPerpendicularOffsetPoint();
void testClosestSideOfRectangle(); void testClosestSideOfRectangle();
void setZValueFromPoints(); void setZValueFromPoints();
void setMValueFromPoints(); void transferFirstMValueToPoint();
}; };




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


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


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


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


// Type: PointM // 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( ret, true );
QCOMPARE( point.wkbType(), QgsWkbTypes::PointM ); QCOMPARE( point.wkbType(), QgsWkbTypes::PointM );
QCOMPARE( point.m(), 4.0 ); QCOMPARE( point.m(), 4.0 );


// Type: PointM // 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( ret, true );
QCOMPARE( point.wkbType(), QgsWkbTypes::PointM ); 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? 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 // Add M to a PointZ
QgsPoint pointZ( 1, 2, 4 ); QgsPoint pointZ( 1, 2, 4 );
// Type: PointM // 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( ret, true );
QCOMPARE( pointZ.wkbType(), QgsWkbTypes::PointZM ); QCOMPARE( pointZ.wkbType(), QgsWkbTypes::PointZM );
QCOMPARE( pointZ.m(), 5.0 ); QCOMPARE( pointZ.m(), 5.0 );
Expand Down

0 comments on commit 95cff79

Please sign in to comment.