Skip to content
Permalink
Browse files
add tests
  • Loading branch information
Koyaani authored and nyalldawson committed Oct 20, 2021
1 parent 00ae7b8 commit 8667785b0a344ea58d6836455898dce09494bba2
Showing with 22 additions and 2 deletions.
  1. +22 −2 tests/src/core/geometry/testqgscircle.cpp
@@ -220,11 +220,26 @@ void TestQgsCircle::from3tangentsMulti()

void TestQgsCircle::minimalCircleFrom3points()
{
// equivalent to from2Points
QgsCircle circ = QgsCircle().minimalCircleFrom3Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ), QgsPoint( 1, 2 ) );

QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 0, 0 ), 0.0001 );
QGSCOMPARENEAR( circ.radius(), 5.0, 0.0001 );
QCOMPARE( circ, QgsCircle().from2Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ) ));

circ = QgsCircle().minimalCircleFrom3Points( QgsPoint( 0, -5 ), QgsPoint( 1, 2 ), QgsPoint( 0, 5 ) );

QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 0, 0 ), 0.0001 );
QGSCOMPARENEAR( circ.radius(), 5.0, 0.0001 );
QCOMPARE( circ, QgsCircle().from2Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ) ));

circ = QgsCircle().minimalCircleFrom3Points( QgsPoint( 1, 2 ), QgsPoint( 0, 5 ), QgsPoint( 0, -5 ));

QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 0, 0 ), 0.0001 );
QGSCOMPARENEAR( circ.radius(), 5.0, 0.0001 );
QCOMPARE( circ, QgsCircle().from2Points( QgsPoint( 0, 5 ), QgsPoint( 0, -5 ) ));

// equivalent to from3Points
circ = QgsCircle().minimalCircleFrom3Points( QgsPoint( 0, 5 ), QgsPoint( 5, 0 ), QgsPoint( -5, 0 ) );

QGSCOMPARENEARPOINT( circ.center(), QgsPoint( 0, 0 ), 0.0001 );
@@ -535,9 +550,14 @@ void TestQgsCircle::toString()
void TestQgsCircle::asGML()
{
// asGML3
QgsCircle exportCircle( QgsPoint( 1, 1 ), 3 );
QDomDocument doc( "gml" );
QString expectedGML3( QStringLiteral( "<Circle xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">1 4 4 1 1 -2</posList></Circle>" ) );

QgsCircle exportCircle;
QString expectedGML3( QStringLiteral( "<Circle xmlns=\"gml\"/>" ) );
QGSCOMPAREGML( elemToString( exportCircle.asGml3( doc ) ), expectedGML3 );

exportCircle = QgsCircle( QgsPoint( 1, 1 ), 3 );
expectedGML3 = QString( QStringLiteral( "<Circle xmlns=\"gml\"><posList xmlns=\"gml\" srsDimension=\"2\">1 4 4 1 1 -2</posList></Circle>" ) );
QGSCOMPAREGML( elemToString( exportCircle.asGml3( doc ) ), expectedGML3 );

// asGML2

0 comments on commit 8667785

Please sign in to comment.