Skip to content

Commit

Permalink
Mark QgsLineStringV2 as a critical class
Browse files Browse the repository at this point in the history
Now has as close to 100% unit test coverage as possible
  • Loading branch information
nyalldawson committed Nov 27, 2015
1 parent 7eb1133 commit 22af16a
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
97 changes: 97 additions & 0 deletions src/core/geometry/qgslinestringv2.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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 Collaborator

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();
Expand Down Expand Up @@ -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() + ' ';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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() )
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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() );
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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() )
Expand Down Expand Up @@ -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() )
Expand Down Expand Up @@ -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() )
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() )
Expand Down Expand Up @@ -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 ) )
Expand Down
6 changes: 6 additions & 0 deletions src/core/geometry/qgslinestringv2.h
Expand Up @@ -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.
Expand Down

0 comments on commit 22af16a

Please sign in to comment.