From 7b31f8a02f47455bcffddbaea9e69ca642c7c878 Mon Sep 17 00:00:00 2001 From: Marco Hugentobler Date: Thu, 25 Jun 2015 10:45:53 +0200 Subject: [PATCH] Remove python bindings for QgsGeos, move createGeometryEngine() from edit utils to QgsGeometry class --- python/core/core.sip | 1 - python/core/geometry/qgsgeometry.sip | 4 ++ python/core/geometry/qgsgeos.sip | 43 ---------------------- src/core/geometry/qgsgeometry.cpp | 5 +++ src/core/geometry/qgsgeometry.h | 4 ++ src/core/geometry/qgsgeometryeditutils.cpp | 9 +---- src/core/geometry/qgsgeometryeditutils.h | 4 -- 7 files changed, 15 insertions(+), 55 deletions(-) delete mode 100644 python/core/geometry/qgsgeos.sip diff --git a/python/core/core.sip b/python/core/core.sip index 3bb607cbac8..fe916548e13 100644 --- a/python/core/core.sip +++ b/python/core/core.sip @@ -283,7 +283,6 @@ %Include geometry/qgscurvev2.sip %Include geometry/qgsgeometrycollectionv2.sip %Include geometry/qgsgeometryengine.sip -%Include geometry/qgsgeos.sip %Include geometry/qgslinestringv2.sip %Include geometry/qgsmulticurvev2.sip %Include geometry/qgsmultilinestringv2.sip diff --git a/python/core/geometry/qgsgeometry.sip b/python/core/geometry/qgsgeometry.sip index a965c08208a..cc21e9ad23e 100644 --- a/python/core/geometry/qgsgeometry.sip +++ b/python/core/geometry/qgsgeometry.sip @@ -680,5 +680,9 @@ class QgsGeometry QgsPolygon smoothPolygon( const QgsPolygon &polygon, const unsigned int iterations = 1, const double offset = 0.25 ) const; /**Smooths a polyline using the Chaikin algorithm*/ QgsPolyline smoothLine( const QgsPolyline &polyline, const unsigned int iterations = 1, const double offset = 0.25 ) const; + + /** Creates and returns a new geometry engine*/ + static QgsGeometryEngine* createGeometryEngine( const QgsAbstractGeometryV2* geometry ); + }; // class QgsGeometry diff --git a/python/core/geometry/qgsgeos.sip b/python/core/geometry/qgsgeos.sip deleted file mode 100644 index da3235d3e67..00000000000 --- a/python/core/geometry/qgsgeos.sip +++ /dev/null @@ -1,43 +0,0 @@ -class QgsGeos: public QgsGeometryEngine -{ -%TypeHeaderCode -#include -%End - - public: - QgsGeos( const QgsAbstractGeometryV2* geometry ); - ~QgsGeos(); - - /**Removes caches*/ - void geometryChanged(); - void prepareGeometry(); - - QgsAbstractGeometryV2* intersection( const QgsAbstractGeometryV2& geom ) const; - QgsAbstractGeometryV2* difference( const QgsAbstractGeometryV2& geom ) const; - QgsAbstractGeometryV2* combine( const QgsAbstractGeometryV2& geom ) const ; - QgsAbstractGeometryV2* combine( const QList< const QgsAbstractGeometryV2* > ) const; - QgsAbstractGeometryV2* symDifference( const QgsAbstractGeometryV2& geom ) const; - QgsAbstractGeometryV2* buffer( double distance, int segments ) const; - QgsAbstractGeometryV2* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const; - QgsAbstractGeometryV2* simplify( double tolerance ) const; - QgsAbstractGeometryV2* interpolate( double distance ) const; - bool centroid( QgsPointV2& pt ) const; - bool pointOnSurface( QgsPointV2& pt ) const; - QgsAbstractGeometryV2* convexHull() const; - double distance( const QgsAbstractGeometryV2& geom ) const; - bool intersects( const QgsAbstractGeometryV2& geom ) const; - bool touches( const QgsAbstractGeometryV2& geom ) const; - bool crosses( const QgsAbstractGeometryV2& geom ) const; - bool within( const QgsAbstractGeometryV2& geom ) const; - bool overlaps( const QgsAbstractGeometryV2& geom ) const; - bool contains( const QgsAbstractGeometryV2& geom ) const; - bool disjoint( const QgsAbstractGeometryV2& geom ) const; - double area() const; - double length() const; - bool isValid() const; - bool isEqual( const QgsAbstractGeometryV2& geom ) const; - bool isEmpty() const; - - QgsAbstractGeometryV2* offsetCurve( double distance, int segments, int joinStyle, double mitreLimit ) const; - QgsAbstractGeometryV2* reshapeGeometry( const QgsLineStringV2& reshapeWithLine, int* errorCode ) const; -}; diff --git a/src/core/geometry/qgsgeometry.cpp b/src/core/geometry/qgsgeometry.cpp index 802da5298e1..70089b9cf0d 100644 --- a/src/core/geometry/qgsgeometry.cpp +++ b/src/core/geometry/qgsgeometry.cpp @@ -2230,6 +2230,11 @@ QgsGeometry* QgsGeometry::convertToPolygon( bool destMultipart ) const } } +QgsGeometryEngine* QgsGeometry::createGeometryEngine( const QgsAbstractGeometryV2* geometry ) +{ + return new QgsGeos( geometry ); +} + QDataStream& operator<<( QDataStream& out, const QgsGeometry& geometry ) { QByteArray byteArray = QByteArray::fromRawData(( char * )geometry.asWkb(), geometry.wkbSize() ); // does not copy data and does not take ownership diff --git a/src/core/geometry/qgsgeometry.h b/src/core/geometry/qgsgeometry.h index b7b55f216f6..e564e28d621 100644 --- a/src/core/geometry/qgsgeometry.h +++ b/src/core/geometry/qgsgeometry.h @@ -723,6 +723,10 @@ class CORE_EXPORT QgsGeometry /**Smooths a polyline using the Chaikin algorithm*/ QgsPolyline smoothLine( const QgsPolyline &polyline, const unsigned int iterations = 1, const double offset = 0.25 ) const; + /** Creates and returns a new geometry engine + */ + static QgsGeometryEngine* createGeometryEngine( const QgsAbstractGeometryV2* geometry ); + private: QgsGeometryPrivate* d; //implicitely shared data pointer diff --git a/src/core/geometry/qgsgeometryeditutils.cpp b/src/core/geometry/qgsgeometryeditutils.cpp index 02c31de1f30..9a4cb5e9dd9 100644 --- a/src/core/geometry/qgsgeometryeditutils.cpp +++ b/src/core/geometry/qgsgeometryeditutils.cpp @@ -62,7 +62,7 @@ int QgsGeometryEditUtils::addRing( QgsAbstractGeometryV2* geom, QgsCurveV2* ring delete ring; return 3; } - QScopedPointer ringGeom( createGeometryEngine( ring ) ); + QScopedPointer ringGeom( QgsGeometry::createGeometryEngine( ring ) ); ringGeom->prepareGeometry(); //for each polygon, test if inside outer ring and no intersection with other interior ring @@ -215,7 +215,7 @@ bool QgsGeometryEditUtils::deletePart( QgsAbstractGeometryV2* geom, int partNum QgsAbstractGeometryV2* QgsGeometryEditUtils::avoidIntersections( const QgsAbstractGeometryV2& geom, QMap > ignoreFeatures ) { - QScopedPointer geomEngine( createGeometryEngine( &geom ) ); + QScopedPointer geomEngine( QgsGeometry::createGeometryEngine( &geom ) ); if ( geomEngine.isNull() ) { return 0; @@ -285,8 +285,3 @@ QgsAbstractGeometryV2* QgsGeometryEditUtils::avoidIntersections( const QgsAbstra delete combinedGeometries; return diffGeom; } - -QgsGeometryEngine* QgsGeometryEditUtils::createGeometryEngine( const QgsAbstractGeometryV2* geometry ) -{ - return new QgsGeos( geometry ); -} diff --git a/src/core/geometry/qgsgeometryeditutils.h b/src/core/geometry/qgsgeometryeditutils.h index b70346b9a4b..3fcb7d52664 100644 --- a/src/core/geometry/qgsgeometryeditutils.h +++ b/src/core/geometry/qgsgeometryeditutils.h @@ -57,10 +57,6 @@ class QgsGeometryEditUtils * @param ignoreFeatures map of layer to feature id of features to ignore */ static QgsAbstractGeometryV2* avoidIntersections( const QgsAbstractGeometryV2& geom, QMap > ignoreFeatures = ( QMap >() ) ); - - /** Creates and returns a new geometry engine - */ - static QgsGeometryEngine* createGeometryEngine( const QgsAbstractGeometryV2* geometry ); }; #endif // QGSGEOMETRYEDITUTILS_H