Skip to content
Permalink
Browse files

Add unit test if circular arc segmentation produces the same vertices…

… in both directions
  • Loading branch information
mhugent committed Feb 22, 2017
1 parent 07cbfdd commit 08c2e66b8840174c9b06e3efc057e60fca4707f3
Showing with 24 additions and 0 deletions.
  1. +24 −0 tests/src/core/testqgsgeometry.cpp
@@ -111,6 +111,7 @@ class TestQgsGeometry : public QObject
void wkbInOut();

void segmentizeCircularString();
void directionNeutralSegmentation();
void poleOfInaccessibility();

void makeValid();
@@ -4035,6 +4036,29 @@ void TestQgsGeometry::segmentizeCircularString()
QVERIFY( points.contains( QgsPointV2( 0.5, 0.5 ) ) );
}

void TestQgsGeometry::directionNeutralSegmentation()
{
//Tests, if segmentation of a circularstring is the same in both directions
QString CWCircularStringWkt( QStringLiteral( "CIRCULARSTRING( 0 0, 0.5 0.5, 0.83 7.33 )" ) );
QgsCircularString* CWCircularString = dynamic_cast<QgsCircularString*>( QgsGeometryFactory::geomFromWkt( CWCircularStringWkt ) );
QgsLineString* CWLineString = CWCircularString->curveToLine();

QString CCWCircularStringWkt( QStringLiteral( "CIRCULARSTRING( 0.83 7.33, 0.5 0.5, 0 0 )" ) );
QgsCircularString* CCWCircularString = dynamic_cast<QgsCircularString*>( QgsGeometryFactory::geomFromWkt( CCWCircularStringWkt ) );
QgsLineString* CCWLineString = CCWCircularString->curveToLine();
QgsLineString* reversedCCWLineString = CCWLineString->reversed();

bool equal = ( *CWLineString == *reversedCCWLineString );

delete CWCircularString;
delete CCWCircularString;
delete CWLineString;
delete CCWLineString;
delete reversedCCWLineString;

QVERIFY( equal );
}

void TestQgsGeometry::poleOfInaccessibility()
{
QString poly1Wkt( "Polygon ((3116 3071, 3394 3431, 3563 3362, 3611 3205, 3599 3181, 3477 3281, 3449 3160, 3570 3127, 3354 3116,"

0 comments on commit 08c2e66

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