Skip to content
Permalink
Browse files

Add test for QgsGeometryUtils::sqrDistToLine

See #13952
  • Loading branch information
strk committed Jun 28, 2016
1 parent 323abe4 commit f0e0ba5bb0f844e9ee28eb9572340f31ae13c6ee
Showing with 19 additions and 0 deletions.
  1. +19 −0 tests/src/core/testqgsgeometryutils.cpp
@@ -46,6 +46,7 @@ class TestQgsGeometryUtils: public QObject
void testDistanceToVertex();
void testCircleCenterRadius_data();
void testCircleCenterRadius();
void testSqrDistToLine();
};


@@ -398,6 +399,24 @@ void TestQgsGeometryUtils::testCircleCenterRadius()
QVERIFY( qgsDoubleNear( expectedCenterY, centerY ) );
}

//QgsGeometryUtils::sqrDistToLine
void TestQgsGeometryUtils::testSqrDistToLine()
{

// See http://hub.qgis.org/issues/13952#note-26
QgsPoint qp( 771938, 6.95593e+06 );
QgsPoint p1( 771946, 6.95593e+06 );
QgsPoint p2( 771904, 6.95595e+06 );
double rx = 0, ry = 0;
double epsilon = 1e-18;
double sqrDist = QgsGeometryUtils::sqrDistToLine( qp.x(), qp.y(),
p1.x(), p1.y(),
p2.x(), p2.y(),
rx, ry, epsilon );
sqrDist = round( sqrDist * 100 ) / 100;
QCOMPARE( sqrDist, 11.83 );
}


QTEST_MAIN( TestQgsGeometryUtils )
#include "testqgsgeometryutils.moc"

0 comments on commit f0e0ba5

Please sign in to comment.
You can’t perform that action at this time.