Skip to content

Commit 5bb359d

Browse files
committedSep 19, 2017
Boost test coverage of geometry classes
1 parent 1956a38 commit 5bb359d

File tree

9 files changed

+4540
-2345
lines changed

9 files changed

+4540
-2345
lines changed
 

‎python/core/geometry/qgscircularstring.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class QgsCircularString: QgsCurve
107107

108108
virtual bool hasCurvedSegments() const;
109109

110+
110111
virtual double vertexAngle( QgsVertexId vertex ) const;
111112

112113
%Docstring

‎src/core/geometry/qgscircularstring.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ bool QgsCircularString::operator!=( const QgsCurve &other ) const
6565
return !operator==( other );
6666
}
6767

68+
QString QgsCircularString::geometryType() const
69+
{
70+
return QStringLiteral( "CircularString" );
71+
}
72+
6873
QgsCircularString *QgsCircularString::clone() const
6974
{
7075
return new QgsCircularString( *this );
@@ -580,7 +585,9 @@ void QgsCircularString::addToPainterPath( QPainterPath &path ) const
580585
{
581586
path.lineTo( pt.at( j ).x(), pt.at( j ).y() );
582587
}
588+
#if 0
583589
//arcTo( path, QPointF( mX[i], mY[i] ), QPointF( mX[i + 1], mY[i + 1] ), QPointF( mX[i + 2], mY[i + 2] ) );
590+
#endif
584591
}
585592

586593
//if number of points is even, connect to last point with straight line (even though the circular string is not valid)
@@ -590,6 +597,7 @@ void QgsCircularString::addToPainterPath( QPainterPath &path ) const
590597
}
591598
}
592599

600+
#if 0
593601
void QgsCircularString::arcTo( QPainterPath &path, QPointF pt1, QPointF pt2, QPointF pt3 )
594602
{
595603
double centerX, centerY, radius;
@@ -602,6 +610,7 @@ void QgsCircularString::arcTo( QPainterPath &path, QPointF pt1, QPointF pt2, QPo
602610
double diameter = 2 * radius;
603611
path.arcTo( centerX - radius, centerY - radius, diameter, diameter, p1Angle, sweepAngle );
604612
}
613+
#endif
605614

606615
void QgsCircularString::drawAsPolygon( QPainter &p ) const
607616
{
@@ -816,6 +825,11 @@ void QgsCircularString::sumUpArea( double &sum ) const
816825
}
817826
}
818827

828+
bool QgsCircularString::hasCurvedSegments() const
829+
{
830+
return true;
831+
}
832+
819833
double QgsCircularString::closestPointOnArc( double x1, double y1, double x2, double y2, double x3, double y3,
820834
const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon )
821835
{

‎src/core/geometry/qgscircularstring.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class CORE_EXPORT QgsCircularString: public QgsCurve
3838
virtual bool operator==( const QgsCurve &other ) const override;
3939
virtual bool operator!=( const QgsCurve &other ) const override;
4040

41-
virtual QString geometryType() const override { return QStringLiteral( "CircularString" ); }
41+
virtual QString geometryType() const override;
4242
virtual int dimension() const override { return 1; }
4343
virtual QgsCircularString *clone() const override SIP_FACTORY;
4444
virtual void clear() override;
@@ -97,7 +97,7 @@ class CORE_EXPORT QgsCircularString: public QgsCurve
9797

9898
bool pointAt( int node, QgsPoint &point, QgsVertexId::VertexType &type ) const override;
9999
void sumUpArea( double &sum SIP_OUT ) const override;
100-
bool hasCurvedSegments() const override { return true; }
100+
bool hasCurvedSegments() const override;
101101

102102
/** Returns approximate rotation angle for a vertex. Usually average angle between adjacent segments.
103103
\param vertex the vertex id
@@ -141,7 +141,9 @@ class CORE_EXPORT QgsCircularString: public QgsCurve
141141
QVector<double> mZ;
142142
QVector<double> mM;
143143

144+
#if 0
144145
static void arcTo( QPainterPath &path, QPointF pt1, QPointF pt2, QPointF pt3 );
146+
#endif
145147
//bounding box of a single segment
146148
static QgsRectangle segmentBoundingBox( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3 );
147149
static QgsPointSequence compassPointsOnSegment( double p1Angle, double p2Angle, double p3Angle, double centerX, double centerY, double radius );

‎src/core/geometry/qgspolygon.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ bool QgsPolygonV2::operator!=( const QgsPolygonV2 &other ) const
6666
return !operator==( other );
6767
}
6868

69+
QString QgsPolygonV2::geometryType() const
70+
{
71+
return QStringLiteral( "Polygon" );
72+
}
73+
6974
QgsPolygonV2 *QgsPolygonV2::clone() const
7075
{
7176
return new QgsPolygonV2( *this );

‎src/core/geometry/qgspolygon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CORE_EXPORT QgsPolygonV2: public QgsCurvePolygon
3535
bool operator==( const QgsPolygonV2 &other ) const;
3636
bool operator!=( const QgsPolygonV2 &other ) const;
3737

38-
virtual QString geometryType() const override { return QStringLiteral( "Polygon" ); }
38+
virtual QString geometryType() const override;
3939
virtual QgsPolygonV2 *clone() const override SIP_FACTORY;
4040
void clear() override;
4141

0 commit comments

Comments
 (0)
Please sign in to comment.