Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 20e1d72
Show file tree
Hide file tree
Showing 64 changed files with 5,628 additions and 2,880 deletions.
10 changes: 5 additions & 5 deletions python/core/geometry/qgsabstractgeometry.sip
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions python/core/geometry/qgscircle.sip
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion python/core/geometry/qgscircularstring.sip
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions python/core/geometry/qgscompoundcurve.sip
Expand Up @@ -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;

Expand Down
12 changes: 12 additions & 0 deletions python/core/geometry/qgscurve.sip
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -161,6 +172,7 @@ class QgsCurve: QgsAbstractGeometry

virtual void clearCache() const;


};

/************************************************************************
Expand Down
41 changes: 36 additions & 5 deletions python/core/geometry/qgscurvepolygon.sip
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;

Expand All @@ -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;

};

/************************************************************************
Expand Down
2 changes: 2 additions & 0 deletions python/core/geometry/qgsellipse.sip
Expand Up @@ -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.
Expand Down
38 changes: 33 additions & 5 deletions python/core/geometry/qgsgeometrycollection.sip
Expand Up @@ -28,6 +28,7 @@ class QgsGeometryCollection: QgsAbstractGeometry

virtual QgsGeometryCollection *clone() const /Factory/;


int numGeometries() const;
%Docstring
Returns the number of geometries within the collection.
Expand All @@ -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.
Expand All @@ -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;
Expand All @@ -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;


Expand All @@ -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:

Expand All @@ -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;


};

/************************************************************************
Expand Down

0 comments on commit 20e1d72

Please sign in to comment.