Skip to content
Permalink
Browse files

Mark QgsLineStringV2 as a critical class

Now has as close to 100% unit test coverage as possible
  • Loading branch information
nyalldawson committed Nov 27, 2015
1 parent 7eb1133 commit 22af16a1fb6bef71f8bccaf8cd71c2768789c526
Showing with 103 additions and 0 deletions.
  1. +97 −0 src/core/geometry/qgslinestringv2.cpp
  2. +6 −0 src/core/geometry/qgslinestringv2.h
@@ -26,6 +26,13 @@
#include <QDomDocument>
#include <QtCore/qmath.h>


/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

QgsLineStringV2::QgsLineStringV2(): QgsCurveV2()
{
mWkbType = QgsWKBTypes::LineString;
@@ -72,6 +79,12 @@ void QgsLineStringV2::fromWkbPoints( QgsWKBTypes::Type type, const QgsConstWkbPt
importVerticesFromWkb( wkb );
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

This comment has been minimized.

Copy link
@jef-n

jef-n Nov 27, 2015

Member

why is this repeated, repeated, repeated?

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Nov 29, 2015

Author Contributor

Just wanted to make it easier for new contributors/devs unaware of QEP 17 that this class requires unit tests. If it's just a single note at the top of the file, it's likely to be overlooked.

bool QgsLineStringV2::fromWkt( const QString& wkt )
{
clear();
@@ -106,6 +119,12 @@ unsigned char* QgsLineStringV2::asWkb( int& binarySize ) const
return geomPtr;
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

QString QgsLineStringV2::asWkt( int precision ) const
{
QString wkt = wktTypeStr() + ' ';
@@ -149,6 +168,12 @@ QString QgsLineStringV2::asJSON( int precision ) const
return "{\"type\": \"LineString\", \"coordinates\": " + QgsGeometryUtils::pointsToJSON( pts, precision ) + '}';
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

double QgsLineStringV2::length() const
{
double length = 0;
@@ -181,6 +206,12 @@ QgsPointV2 QgsLineStringV2::endPoint() const
return pointN( numPoints() - 1 );
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

QgsLineStringV2* QgsLineStringV2::curveToLine() const
{
return static_cast<QgsLineStringV2*>( clone() );
@@ -234,6 +265,12 @@ QgsPointV2 QgsLineStringV2::pointN( int i ) const
return QgsPointV2( t, x, y, z, m );
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

double QgsLineStringV2::xAt( int index ) const
{
if ( index >= 0 && index < mX.size() )
@@ -292,6 +329,12 @@ void QgsLineStringV2::setMAt( int index, double m )
mM[ index ] = m;
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

void QgsLineStringV2::points( QList<QgsPointV2>& pts ) const
{
pts.clear();
@@ -353,6 +396,12 @@ void QgsLineStringV2::setPoints( const QList<QgsPointV2>& points )
}
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

void QgsLineStringV2::append( const QgsLineStringV2* line )
{
if ( !line )
@@ -407,6 +456,12 @@ QgsLineStringV2* QgsLineStringV2::reversed() const
return copy;
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

void QgsLineStringV2::draw( QPainter& p ) const
{
p.drawPolyline( asQPolygonF() );
@@ -446,6 +501,12 @@ QPolygonF QgsLineStringV2::asQPolygonF() const
return points;
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

void QgsLineStringV2::transform( const QgsCoordinateTransform& ct, QgsCoordinateTransform::TransformDirection d )
{
double* zArray = mZ.data();
@@ -480,6 +541,12 @@ void QgsLineStringV2::transform( const QTransform& t )
mBoundingBox = QgsRectangle();
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

bool QgsLineStringV2::insertVertex( const QgsVertexId& position, const QgsPointV2& vertex )
{
if ( position.vertex < 0 || position.vertex > mX.size() )
@@ -547,6 +614,12 @@ bool QgsLineStringV2::deleteVertex( const QgsVertexId& position )
return true;
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

void QgsLineStringV2::addVertex( const QgsPointV2& pt )
{
if ( mWkbType == QgsWKBTypes::Unknown || mX.isEmpty() )
@@ -607,6 +680,12 @@ double QgsLineStringV2::closestSegment( const QgsPointV2& pt, QgsPointV2& segmen
return sqrDist;
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

bool QgsLineStringV2::pointAt( int node, QgsPointV2& point, QgsVertexId::VertexType& type ) const
{
if ( node < 0 || node >= numPoints() )
@@ -656,6 +735,12 @@ QgsPointV2 QgsLineStringV2::centroid() const

}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

void QgsLineStringV2::sumUpArea( double& sum ) const
{
int maxIndex = numPoints() - 1;
@@ -694,6 +779,12 @@ void QgsLineStringV2::importVerticesFromWkb( const QgsConstWkbPtr& wkb )
mBoundingBox = QgsRectangle(); //set bounding box invalid
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

void QgsLineStringV2::close()
{
if ( numPoints() < 1 || isClosed() )
@@ -746,6 +837,12 @@ double QgsLineStringV2::vertexAngle( const QgsVertexId& vertex ) const
}
}

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests.
* See details in QEP #17
****************************************************************************/

bool QgsLineStringV2::addZValue( double zValue )
{
if ( QgsWKBTypes::hasZ( mWkbType ) )
@@ -22,6 +22,12 @@
#include "qgswkbptr.h"
#include <QPolygonF>

/***************************************************************************
* This class is considered CRITICAL and any change MUST be accompanied with
* full unit tests in testqgsgeometry.cpp.
* See details in QEP #17
****************************************************************************/

/** \ingroup core
* \class QgsLineStringV2
* \brief Line string geometry type, with support for z-dimension and m-values.

0 comments on commit 22af16a

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