From 22af16a1fb6bef71f8bccaf8cd71c2768789c526 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 27 Nov 2015 16:32:57 +1100 Subject: [PATCH] Mark QgsLineStringV2 as a critical class Now has as close to 100% unit test coverage as possible --- src/core/geometry/qgslinestringv2.cpp | 97 +++++++++++++++++++++++++++ src/core/geometry/qgslinestringv2.h | 6 ++ 2 files changed, 103 insertions(+) diff --git a/src/core/geometry/qgslinestringv2.cpp b/src/core/geometry/qgslinestringv2.cpp index f4cc6db6840..8e52150afd1 100644 --- a/src/core/geometry/qgslinestringv2.cpp +++ b/src/core/geometry/qgslinestringv2.cpp @@ -26,6 +26,13 @@ #include #include + +/*************************************************************************** + * 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 + ****************************************************************************/ + 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( 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& pts ) const { pts.clear(); @@ -353,6 +396,12 @@ void QgsLineStringV2::setPoints( const QList& 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 ) ) diff --git a/src/core/geometry/qgslinestringv2.h b/src/core/geometry/qgslinestringv2.h index a64efd50a30..aec8d0a1c20 100644 --- a/src/core/geometry/qgslinestringv2.h +++ b/src/core/geometry/qgslinestringv2.h @@ -22,6 +22,12 @@ #include "qgswkbptr.h" #include +/*************************************************************************** + * 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.