Skip to content
Permalink
Browse files

Make QgsAbstractGeometry::toCurveType pure virtual, and implement

for all geometry types

Previously this method would return nullptrs for many geometry
types
  • Loading branch information
nyalldawson committed Sep 19, 2017
1 parent bb3170f commit 54c988f9188343a639c951683f5b102ba57a1def
Showing with 331 additions and 183 deletions.
  1. +4 −4 python/core/geometry/qgsabstractgeometry.sip
  2. +12 −0 python/core/geometry/qgscurve.sip
  3. +23 −3 python/core/geometry/qgscurvepolygon.sip
  4. +31 −5 python/core/geometry/qgsgeometrycollection.sip
  5. +20 −3 python/core/geometry/qgslinestring.sip
  6. +4 −0 python/core/geometry/qgsmulticurve.sip
  7. +3 −2 python/core/geometry/qgsmultilinestring.sip
  8. +4 −0 python/core/geometry/qgsmultipoint.sip
  9. +4 −2 python/core/geometry/qgsmultipolygon.sip
  10. +4 −0 python/core/geometry/qgsmultisurface.sip
  11. +14 −3 python/core/geometry/qgspoint.sip
  12. +5 −0 python/core/geometry/qgspolygon.sip
  13. +4 −0 python/core/geometry/qgstriangle.sip
  14. +0 −6 src/core/geometry/qgsabstractgeometry.cpp
  15. +7 −5 src/core/geometry/qgsabstractgeometry.h
  16. +5 −0 src/core/geometry/qgscircularstring.cpp
  17. +1 −1 src/core/geometry/qgscircularstring.h
  18. +5 −0 src/core/geometry/qgscurve.cpp
  19. +11 −10 src/core/geometry/qgscurve.h
  20. +5 −0 src/core/geometry/qgscurvepolygon.cpp
  21. +25 −26 src/core/geometry/qgscurvepolygon.h
  22. +10 −0 src/core/geometry/qgsgeometrycollection.cpp
  23. +31 −34 src/core/geometry/qgsgeometrycollection.h
  24. +22 −24 src/core/geometry/qgslinestring.h
  25. +5 −0 src/core/geometry/qgsmulticurve.cpp
  26. +4 −3 src/core/geometry/qgsmulticurve.h
  27. +1 −1 src/core/geometry/qgsmultilinestring.cpp
  28. +4 −4 src/core/geometry/qgsmultilinestring.h
  29. +5 −0 src/core/geometry/qgsmultipoint.cpp
  30. +6 −5 src/core/geometry/qgsmultipoint.h
  31. +1 −1 src/core/geometry/qgsmultipolygon.cpp
  32. +5 −5 src/core/geometry/qgsmultipolygon.h
  33. +5 −0 src/core/geometry/qgsmultisurface.cpp
  34. +4 −3 src/core/geometry/qgsmultisurface.h
  35. +5 −0 src/core/geometry/qgspoint.cpp
  36. +22 −23 src/core/geometry/qgspoint.h
  37. +5 −5 src/core/geometry/qgspolygon.h
  38. +5 −5 src/core/geometry/qgstriangle.h
@@ -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

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


};

/************************************************************************
@@ -28,12 +28,15 @@ class QgsCurvePolygon: QgsSurface
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 +49,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 +117,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/, double epsilon ) const;


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

@@ -153,19 +164,28 @@ Adds an interior ring to the geometry (takes ownership)
%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 QgsCurvePolygon *toCurveType() const /Factory/;

protected:


virtual QgsRectangle calculateBoundingBox() const;

};

/************************************************************************
@@ -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/, double 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,23 @@ 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 +182,10 @@ Adds a geometry and takes ownership. Returns true in case of success.
%End

virtual QgsRectangle calculateBoundingBox() const;

virtual void clearCache() const;


};

/************************************************************************
@@ -170,13 +170,17 @@ Closes the line string by appending the first point to the end of the line, if i
virtual QString geometryType() const;
virtual int dimension() const;
virtual QgsLineString *clone() const /Factory/;

virtual void clear();

virtual bool isEmpty() const;


virtual bool fromWkb( QgsConstWkbPtr &wkb );

virtual bool fromWkt( const QString &wkt );


virtual QByteArray asWkb() const;

virtual QString asWkt( int precision = 17 ) const;
@@ -189,10 +193,14 @@ Closes the line string by appending the first point to the end of the line, if i


virtual double length() const;

virtual QgsPoint startPoint() const;

virtual QgsPoint endPoint() const;


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

%Docstring
Returns a new line string geometry corresponding to a segmentized approximation
of the curve.
@@ -221,37 +229,46 @@ Closes the line string by appending the first point to the end of the line, if i


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

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

virtual bool deleteVertex( QgsVertexId position );


virtual QgsLineString *reversed() const /Factory/;

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/, double epsilon ) const;

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


virtual QgsPoint centroid() const;


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

virtual double vertexAngle( QgsVertexId vertex ) const;


virtual bool addZValue( double zValue = 0 );

virtual bool addMValue( double mValue = 0 );


virtual bool dropZValue();

virtual bool dropMValue();


virtual bool convertTo( QgsWkbTypes::Type type );


protected:

virtual QgsRectangle calculateBoundingBox() const;


};

/************************************************************************
@@ -23,6 +23,8 @@ class QgsMultiCurve: QgsGeometryCollection
virtual QString geometryType() const;
virtual QgsMultiCurve *clone() const /Factory/;

virtual QgsMultiCurve *toCurveType() const /Factory/;


virtual bool fromWkt( const QString &wkt );

@@ -35,6 +37,7 @@ class QgsMultiCurve: QgsGeometryCollection


virtual bool addGeometry( QgsAbstractGeometry *g /Transfer/ );

%Docstring
Adds a geometry and takes ownership. Returns true in case of success
:rtype: bool
@@ -50,6 +53,7 @@ Adds a geometry and takes ownership. Returns true in case of success
virtual QgsAbstractGeometry *boundary() const /Factory/;



};

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

0 comments on commit 54c988f

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