Skip to content
Permalink
Browse files

Expand QgsTriangle test coverage

  • Loading branch information
nyalldawson committed Sep 18, 2017
1 parent a15340f commit 9b6e79cd1841aaa9915bcba03a51296d2a99075f
@@ -95,7 +95,7 @@ Inherited method not used. You cannot delete or insert a vertex directly. Return

virtual void setExteriorRing( QgsCurve *ring /Transfer/ );

virtual QgsAbstractGeometry *boundary() const /Factory/;
virtual QgsCurve *boundary() const /Factory/;


QgsPoint vertexAt( int atVertex ) const;
@@ -346,7 +346,7 @@ void QgsTriangle::setExteriorRing( QgsCurve *ring )
clearCache();
}

QgsAbstractGeometry *QgsTriangle::boundary() const
QgsCurve *QgsTriangle::boundary() const
{
if ( !mExteriorRing )
return nullptr;
@@ -93,7 +93,7 @@ class CORE_EXPORT QgsTriangle : public QgsPolygonV2

virtual void setExteriorRing( QgsCurve *ring SIP_TRANSFER ) override;

virtual QgsAbstractGeometry *boundary() const override SIP_FACTORY;
virtual QgsCurve *boundary() const override SIP_FACTORY;

// inherited: double pointDistanceToBoundary( double x, double y ) const;

@@ -3489,6 +3489,11 @@ void TestQgsGeometry::triangle()
QVERIFY( !t1.exteriorRing() );
QVERIFY( !t1.interiorRing( 0 ) );

// invalid triangles
QgsTriangle invalid( QgsPointXY( 0, 0 ), QgsPointXY( 0, 0 ), QgsPointXY( 10, 10 ) );
QVERIFY( invalid.isEmpty() );
invalid = QgsTriangle( QPointF( 0, 0 ), QPointF( 0, 0 ), QPointF( 10, 10 ) );
QVERIFY( invalid.isEmpty() );
//set exterior ring

//try with no ring
@@ -3583,6 +3588,14 @@ void TestQgsGeometry::triangle()
t2.setExteriorRing( ext );
QVERIFY( t2.isEmpty() );

ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 0, 0 ) );
t2.setExteriorRing( ext );
QVERIFY( t2.isEmpty() );

ext->setPoints( QgsPointSequence() << QgsPoint( 0, 0 ) << QgsPoint( 0, 0 ) << QgsPoint( 0, 10 ) << QgsPoint( 0, 0 ) );
t2.setExteriorRing( ext );
QVERIFY( t2.isEmpty() );

// circular ring
QgsCircularString *circularRing = new QgsCircularString();
t2.clear();
@@ -3906,6 +3919,26 @@ void TestQgsGeometry::triangle()
pt1 = QgsPoint( 0, 0 );
QVERIFY( !t11.moveVertex( id, pt1 ) );

//toCurveType
QgsTriangle t12( QgsPoint( 7, 4 ), QgsPoint( 13, 3 ), QgsPoint( 9, 6 ) );
std::unique_ptr< QgsCurvePolygon > curveType( t12.toCurveType() );
QCOMPARE( curveType->wkbType(), QgsWkbTypes::CurvePolygon );
QCOMPARE( curveType->exteriorRing()->numPoints(), 4 );
QCOMPARE( curveType->exteriorRing()->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( 7, 4 ) );
QCOMPARE( curveType->exteriorRing()->vertexAt( QgsVertexId( 0, 0, 1 ) ), QgsPoint( 13, 3 ) );
QCOMPARE( curveType->exteriorRing()->vertexAt( QgsVertexId( 0, 0, 2 ) ), QgsPoint( 9, 6 ) );
QCOMPARE( curveType->exteriorRing()->vertexAt( QgsVertexId( 0, 0, 3 ) ), QgsPoint( 7, 4 ) );
QCOMPARE( curveType->numInteriorRings(), 0 );

// boundary
QVERIFY( !QgsTriangle().boundary() );
std::unique_ptr< QgsCurve > boundary( QgsTriangle( QgsPoint( 7, 4 ), QgsPoint( 13, 3 ), QgsPoint( 9, 6 ) ).boundary() );
QCOMPARE( boundary->wkbType(), QgsWkbTypes::LineString );
QCOMPARE( boundary->numPoints(), 4 );
QCOMPARE( boundary->vertexAt( QgsVertexId( 0, 0, 0 ) ), QgsPoint( 7, 4 ) );
QCOMPARE( boundary->vertexAt( QgsVertexId( 0, 0, 1 ) ), QgsPoint( 13, 3 ) );
QCOMPARE( boundary->vertexAt( QgsVertexId( 0, 0, 2 ) ), QgsPoint( 9, 6 ) );
QCOMPARE( boundary->vertexAt( QgsVertexId( 0, 0, 3 ) ), QgsPoint( 7, 4 ) );
}

void TestQgsGeometry::ellipse()

0 comments on commit 9b6e79c

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