Skip to content
Permalink
Browse files

Merge pull request #5209 from nyalldawson/geometry_coverage

[WIP] Extend geometry classes unit test coverage
  • Loading branch information
nyalldawson committed Sep 19, 2017
2 parents 8d34023 + 38cc570 commit 20e1d720070eb3fb367f56e4c8565a23c42b6223
Showing with 5,628 additions and 2,880 deletions.
  1. +5 −5 python/core/geometry/qgsabstractgeometry.sip
  2. +2 −0 python/core/geometry/qgscircle.sip
  3. +2 −1 python/core/geometry/qgscircularstring.sip
  4. +2 −2 python/core/geometry/qgscompoundcurve.sip
  5. +12 −0 python/core/geometry/qgscurve.sip
  6. +36 −5 python/core/geometry/qgscurvepolygon.sip
  7. +2 −0 python/core/geometry/qgsellipse.sip
  8. +33 −5 python/core/geometry/qgsgeometrycollection.sip
  9. +25 −6 python/core/geometry/qgslinestring.sip
  10. +5 −0 python/core/geometry/qgsmulticurve.sip
  11. +5 −2 python/core/geometry/qgsmultilinestring.sip
  12. +7 −0 python/core/geometry/qgsmultipoint.sip
  13. +6 −2 python/core/geometry/qgsmultipolygon.sip
  14. +5 −0 python/core/geometry/qgsmultisurface.sip
  15. +26 −3 python/core/geometry/qgspoint.sip
  16. +7 −8 python/core/geometry/qgspolygon.sip
  17. +5 −6 python/core/geometry/qgsregularpolygon.sip
  18. +7 −2 python/core/geometry/qgstriangle.sip
  19. +0 −6 src/core/geometry/qgsabstractgeometry.cpp
  20. +8 −6 src/core/geometry/qgsabstractgeometry.h
  21. +12 −0 src/core/geometry/qgscircle.cpp
  22. +2 −10 src/core/geometry/qgscircle.h
  23. +56 −33 src/core/geometry/qgscircularstring.cpp
  24. +6 −4 src/core/geometry/qgscircularstring.h
  25. +23 −1 src/core/geometry/qgscompoundcurve.cpp
  26. +4 −4 src/core/geometry/qgscompoundcurve.h
  27. +5 −0 src/core/geometry/qgscurve.cpp
  28. +11 −10 src/core/geometry/qgscurve.h
  29. +96 −30 src/core/geometry/qgscurvepolygon.cpp
  30. +31 −27 src/core/geometry/qgscurvepolygon.h
  31. +2 −0 src/core/geometry/qgsellipse.h
  32. +20 −0 src/core/geometry/qgsgeometrycollection.cpp
  33. +31 −34 src/core/geometry/qgsgeometrycollection.h
  34. +0 −15 src/core/geometry/qgsgeometryfactory.cpp
  35. +0 −2 src/core/geometry/qgsgeometryfactory.h
  36. +6 −2 src/core/geometry/qgsgeometryutils.cpp
  37. +20 −3 src/core/geometry/qgslinestring.cpp
  38. +24 −26 src/core/geometry/qgslinestring.h
  39. +10 −0 src/core/geometry/qgsmulticurve.cpp
  40. +4 −3 src/core/geometry/qgsmulticurve.h
  41. +11 −1 src/core/geometry/qgsmultilinestring.cpp
  42. +4 −4 src/core/geometry/qgsmultilinestring.h
  43. +20 −0 src/core/geometry/qgsmultipoint.cpp
  44. +6 −5 src/core/geometry/qgsmultipoint.h
  45. +11 −1 src/core/geometry/qgsmultipolygon.cpp
  46. +5 −5 src/core/geometry/qgsmultipolygon.h
  47. +10 −0 src/core/geometry/qgsmultisurface.cpp
  48. +4 −3 src/core/geometry/qgsmultisurface.h
  49. +72 −3 src/core/geometry/qgspoint.cpp
  50. +26 −27 src/core/geometry/qgspoint.h
  51. +8 −42 src/core/geometry/qgspolygon.cpp
  52. +6 −9 src/core/geometry/qgspolygon.h
  53. +4 −8 src/core/geometry/qgsregularpolygon.cpp
  54. +5 −5 src/core/geometry/qgsregularpolygon.h
  55. +18 −13 src/core/geometry/qgstriangle.cpp
  56. +6 −6 src/core/geometry/qgstriangle.h
  57. +4,761 −2,483 tests/src/core/testqgsgeometry.cpp
  58. +1 −1 tests/src/python/test_qgsbox3d.py
  59. +87 −1 tests/src/python/test_qgsgeometry.py
  60. BIN tests/testdata/control_images/geometry/expected_circularstring/expected_circularstring.png
  61. BIN ...a/control_images/geometry/expected_circularstring_aspolygon/expected_circularstring_aspolygon.png
  62. BIN tests/testdata/control_images/geometry/expected_linestring/expected_linestring.png
  63. BIN .../testdata/control_images/geometry/expected_linestring_aspolygon/expected_linestring_aspolygon.png
  64. BIN tests/testdata/control_images/geometry/expected_point/expected_point.png
@@ -275,7 +275,7 @@ class QgsAbstractGeometry

virtual double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt /Out/,
QgsVertexId &vertexAfter /Out/,
bool *leftOf /Out/, double epsilon ) const = 0;
bool *leftOf /Out/ = 0, double epsilon = 4 * DBL_EPSILON ) const = 0;
%Docstring
Searches for the closest segment of the geometry to a given point.
\param pt specifies the point to find closest segment to
@@ -372,12 +372,12 @@ Returns the centroid of the geometry
:rtype: QgsAbstractGeometry
%End

virtual QgsAbstractGeometry *toCurveType() const /Factory/;
virtual QgsAbstractGeometry *toCurveType() const = 0 /Factory/;
%Docstring
Returns the geometry converted to the more generic curve type.
E.g. QgsLineString -> QgsCompoundCurve, QgsPolygonV2 -> QgsCurvePolygon,
QgsMultiLineString -> QgsMultiCurve, QgsMultiPolygonV2 -> QgsMultiSurface
:return: the converted geometry. Caller takes ownership*
E.g. QgsLineString -> QgsCompoundCurve, QgsPolygonV2 -> QgsCurvePolygon,
QgsMultiLineString -> QgsMultiCurve, QgsMultiPolygonV2 -> QgsMultiSurface
:return: the converted geometry. Caller takes ownership
:rtype: QgsAbstractGeometry
%End

@@ -133,13 +133,15 @@ class QgsCircle : QgsEllipse


virtual void setSemiMajorAxis( const double semiMajorAxis );

%Docstring
Inherited method. Use setRadius instead.
.. seealso:: radius()
.. seealso:: setRadius()
%End

virtual void setSemiMinorAxis( const double semiMinorAxis );

%Docstring
Inherited method. Use setRadius instead.
.. seealso:: radius()
@@ -99,14 +99,15 @@ class QgsCircularString: QgsCurve

virtual double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt /Out/,
QgsVertexId &vertexAfter /Out/,
bool *leftOf /Out/, double epsilon ) const;
bool *leftOf /Out/ = 0, double epsilon = 4 * DBL_EPSILON ) const;

virtual bool pointAt( int node, QgsPoint &point, QgsVertexId::VertexType &type ) const;

virtual void sumUpArea( double &sum /Out/ ) const;

virtual bool hasCurvedSegments() const;


virtual double vertexAngle( QgsVertexId vertex ) const;

%Docstring
@@ -107,8 +107,8 @@ class QgsCompoundCurve: QgsCurve
virtual bool deleteVertex( QgsVertexId position );

virtual double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt /Out/,
QgsVertexId &vertexAfter /Out/, bool *leftOf /Out/,
double epsilon ) const;
QgsVertexId &vertexAfter /Out/, bool *leftOf /Out/ = 0,
double epsilon = 4 * DBL_EPSILON ) const;

virtual bool pointAt( int node, QgsPoint &point, QgsVertexId::VertexType &type ) const;

@@ -31,6 +31,7 @@ class QgsCurve: QgsAbstractGeometry

virtual QgsCurve *clone() const = 0 /Factory/;


virtual QgsPoint startPoint() const = 0;
%Docstring
Returns the starting point of the curve.
@@ -94,8 +95,10 @@ class QgsCurve: QgsAbstractGeometry
%End

virtual QgsCoordinateSequence coordinateSequence() const;

virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex /Out/ ) const;


virtual bool pointAt( int node, QgsPoint &point /Out/, QgsVertexId::VertexType &type /Out/ ) const = 0;
%Docstring
Returns the point and vertex id of a point within the curve.
@@ -115,6 +118,7 @@ class QgsCurve: QgsAbstractGeometry

virtual QgsAbstractGeometry *boundary() const /Factory/;


virtual QgsCurve *segmentize( double tolerance = M_PI_2 / 90, SegmentationToleranceType toleranceType = MaximumAngle ) const /Factory/;

%Docstring
@@ -125,12 +129,19 @@ class QgsCurve: QgsAbstractGeometry
%End

virtual int vertexCount( int part = 0, int ring = 0 ) const;

virtual int ringCount( int part = 0 ) const;

virtual int partCount() const;

virtual QgsPoint vertexAt( QgsVertexId id ) const;

virtual QgsCurve *toCurveType() const /Factory/;


virtual QgsRectangle boundingBox() const;


virtual double xAt( int index ) const = 0;
%Docstring
Returns the x-coordinate of the specified node in the line string.
@@ -161,6 +172,7 @@ class QgsCurve: QgsAbstractGeometry

virtual void clearCache() const;


};

/************************************************************************
@@ -23,17 +23,29 @@ class QgsCurvePolygon: QgsSurface
public:
QgsCurvePolygon();
QgsCurvePolygon( const QgsCurvePolygon &p );

bool operator==( const QgsCurvePolygon &other ) const;
bool operator!=( const QgsCurvePolygon &other ) const;
%Docstring
:rtype: bool
%End

~QgsCurvePolygon();

virtual QString geometryType() const;

virtual int dimension() const;

virtual QgsCurvePolygon *clone() const /Factory/;

virtual void clear();


virtual bool fromWkb( QgsConstWkbPtr &wkb );

virtual bool fromWkt( const QString &wkt );


virtual QByteArray asWkb() const;

virtual QString asWkt( int precision = 17 ) const;
@@ -46,11 +58,14 @@ class QgsCurvePolygon: QgsSurface


virtual double area() const;

virtual double perimeter() const;

virtual QgsPolygonV2 *surfaceToPolygon() const /Factory/;

virtual QgsAbstractGeometry *boundary() const /Factory/;


int numInteriorRings() const;
%Docstring
:rtype: int
@@ -111,22 +126,27 @@ Adds an interior ring to the geometry (takes ownership)
%End

virtual void draw( QPainter &p ) const;

virtual void transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform,
bool transformZ = false );
virtual void transform( const QTransform &t );


virtual bool insertVertex( QgsVertexId position, const QgsPoint &vertex );

virtual bool moveVertex( QgsVertexId position, const QgsPoint &newPos );

virtual bool deleteVertex( QgsVertexId position );


virtual QgsCoordinateSequence coordinateSequence() const;

virtual int nCoordinates() const;

virtual bool isEmpty() const;

virtual double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt /Out/,
QgsVertexId &vertexAfter /Out/, bool *leftOf /Out/,
double epsilon ) const;
virtual double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt /Out/, QgsVertexId &vertexAfter /Out/, bool *leftOf /Out/ = 0, double epsilon = 4 * DBL_EPSILON ) const;


virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex /Out/ ) const;

@@ -152,20 +172,31 @@ Adds an interior ring to the geometry (takes ownership)
:rtype: float
%End

virtual int vertexCount( int /*part*/ = 0, int ring = 0 ) const;
virtual int ringCount( int /*part*/ = 0 ) const;
virtual int vertexCount( int part = 0, int ring = 0 ) const;

virtual int ringCount( int part = 0 ) const;

virtual int partCount() const;

virtual QgsPoint vertexAt( QgsVertexId id ) const;


virtual bool addZValue( double zValue = 0 );

virtual bool addMValue( double mValue = 0 );

virtual bool dropZValue();

virtual bool dropMValue();


virtual QgsCurvePolygon *toCurveType() const /Factory/;

protected:


virtual QgsRectangle calculateBoundingBox() const;

};

/************************************************************************
@@ -27,6 +27,8 @@ class QgsEllipse
public:
QgsEllipse();

virtual ~QgsEllipse();

QgsEllipse( const QgsPoint &center, const double semiMajorAxis, const double semiMinorAxis, const double azimuth = 90 );
%Docstring
Constructs an ellipse by defining all the members.
@@ -28,6 +28,7 @@ class QgsGeometryCollection: QgsAbstractGeometry

virtual QgsGeometryCollection *clone() const /Factory/;


int numGeometries() const;
%Docstring
Returns the number of geometries within the collection.
@@ -45,10 +46,14 @@ class QgsGeometryCollection: QgsAbstractGeometry
virtual bool isEmpty() const;

virtual int dimension() const;

virtual QString geometryType() const;

virtual void clear();

virtual QgsAbstractGeometry *boundary() const /Factory/;


virtual bool addGeometry( QgsAbstractGeometry *g /Transfer/ );
%Docstring
Adds a geometry and takes ownership. Returns true in case of success.
@@ -71,15 +76,18 @@ Adds a geometry and takes ownership. Returns true in case of success.
:rtype: bool
%End

virtual void transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform,
bool transformZ = false );
virtual void transform( const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d = QgsCoordinateTransform::ForwardTransform,
bool transformZ = false );
virtual void transform( const QTransform &t );


virtual void draw( QPainter &p ) const;


virtual bool fromWkb( QgsConstWkbPtr &wkb );

virtual bool fromWkt( const QString &wkt );

virtual QByteArray asWkb() const;

virtual QString asWkt( int precision = 17 ) const;
@@ -93,23 +101,31 @@ Adds a geometry and takes ownership. Returns true in case of success.

virtual QgsRectangle boundingBox() const;


virtual QgsCoordinateSequence coordinateSequence() const;

virtual int nCoordinates() const;

virtual double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt /Out/,
QgsVertexId &vertexAfter /Out/, bool *leftOf /Out/,
double epsilon ) const;

virtual double closestSegment( const QgsPoint &pt, QgsPoint &segmentPt /Out/, QgsVertexId &vertexAfter /Out/, bool *leftOf /Out/ = 0, double epsilon = 4 * DBL_EPSILON ) const;

virtual bool nextVertex( QgsVertexId &id, QgsPoint &vertex /Out/ ) const;


virtual bool insertVertex( QgsVertexId position, const QgsPoint &vertex );

virtual bool moveVertex( QgsVertexId position, const QgsPoint &newPos );

virtual bool deleteVertex( QgsVertexId position );


virtual double length() const;

virtual double area() const;

virtual double perimeter() const;


virtual bool hasCurvedSegments() const;


@@ -132,15 +148,25 @@ Adds a geometry and takes ownership. Returns true in case of success.
%End

virtual int vertexCount( int part = 0, int ring = 0 ) const;

virtual int ringCount( int part = 0 ) const;

virtual int partCount() const;

virtual QgsPoint vertexAt( QgsVertexId id ) const;


virtual bool addZValue( double zValue = 0 );

virtual bool addMValue( double mValue = 0 );

virtual bool dropZValue();

virtual bool dropMValue();

virtual QgsGeometryCollection *toCurveType() const /Factory/;



protected:

@@ -158,8 +184,10 @@ Adds a geometry and takes ownership. Returns true in case of success.
%End

virtual QgsRectangle calculateBoundingBox() const;

virtual void clearCache() const;


};

/************************************************************************

0 comments on commit 20e1d72

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