Skip to content
Permalink
Browse files

Boost test coverage of geometry classes

  • Loading branch information
nyalldawson committed Sep 18, 2017
1 parent 1956a38 commit 5bb359db90373f97c5f99fd057404b057cf8b87a
@@ -107,6 +107,7 @@ class QgsCircularString: QgsCurve

virtual bool hasCurvedSegments() const;


virtual double vertexAngle( QgsVertexId vertex ) const;

%Docstring
@@ -65,6 +65,11 @@ bool QgsCircularString::operator!=( const QgsCurve &other ) const
return !operator==( other );
}

QString QgsCircularString::geometryType() const
{
return QStringLiteral( "CircularString" );
}

QgsCircularString *QgsCircularString::clone() const
{
return new QgsCircularString( *this );
@@ -580,7 +585,9 @@ void QgsCircularString::addToPainterPath( QPainterPath &path ) const
{
path.lineTo( pt.at( j ).x(), pt.at( j ).y() );
}
#if 0
//arcTo( path, QPointF( mX[i], mY[i] ), QPointF( mX[i + 1], mY[i + 1] ), QPointF( mX[i + 2], mY[i + 2] ) );
#endif
}

//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
}
}

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

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

bool QgsCircularString::hasCurvedSegments() const
{
return true;
}

double QgsCircularString::closestPointOnArc( double x1, double y1, double x2, double y2, double x3, double y3,
const QgsPoint &pt, QgsPoint &segmentPt, QgsVertexId &vertexAfter, bool *leftOf, double epsilon )
{
@@ -38,7 +38,7 @@ class CORE_EXPORT QgsCircularString: public QgsCurve
virtual bool operator==( const QgsCurve &other ) const override;
virtual bool operator!=( const QgsCurve &other ) const override;

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

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

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

#if 0
static void arcTo( QPainterPath &path, QPointF pt1, QPointF pt2, QPointF pt3 );
#endif
//bounding box of a single segment
static QgsRectangle segmentBoundingBox( const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3 );
static QgsPointSequence compassPointsOnSegment( double p1Angle, double p2Angle, double p3Angle, double centerX, double centerY, double radius );
@@ -66,6 +66,11 @@ bool QgsPolygonV2::operator!=( const QgsPolygonV2 &other ) const
return !operator==( other );
}

QString QgsPolygonV2::geometryType() const
{
return QStringLiteral( "Polygon" );
}

QgsPolygonV2 *QgsPolygonV2::clone() const
{
return new QgsPolygonV2( *this );
@@ -35,7 +35,7 @@ class CORE_EXPORT QgsPolygonV2: public QgsCurvePolygon
bool operator==( const QgsPolygonV2 &other ) const;
bool operator!=( const QgsPolygonV2 &other ) const;

virtual QString geometryType() const override { return QStringLiteral( "Polygon" ); }
virtual QString geometryType() const override;
virtual QgsPolygonV2 *clone() const override SIP_FACTORY;
void clear() override;

0 comments on commit 5bb359d

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