Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add test for QgsGeometryUtils::sqrDistToLine
See #13952
  • Loading branch information
strk committed Jun 28, 2016
1 parent 323abe4 commit f0e0ba5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/src/core/testqgsgeometryutils.cpp
Expand Up @@ -46,6 +46,7 @@ class TestQgsGeometryUtils: public QObject
void testDistanceToVertex();
void testCircleCenterRadius_data();
void testCircleCenterRadius();
void testSqrDistToLine();
};


Expand Down Expand Up @@ -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.