Skip to content

Commit

Permalink
Add unit test if circular arc segmentation produces the same vertices…
Browse files Browse the repository at this point in the history
… in both directions
  • Loading branch information
mhugent committed Feb 22, 2017
1 parent 07cbfdd commit 08c2e66
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/src/core/testqgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class TestQgsGeometry : public QObject
void wkbInOut();

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

void makeValid();
Expand Down Expand Up @@ -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,"
Expand Down

0 comments on commit 08c2e66

Please sign in to comment.