Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Mark QgsLineStringV2 as a critical class
Now has as close to 100% unit test coverage as possible
- Loading branch information
1 parent
7eb1133
commit 22af16a
Showing
2 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nyalldawson
Author
Collaborator
|
||
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 ) ) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
why is this repeated, repeated, repeated?