Skip to content

Commit

Permalink
Remove python bindings for QgsGeos, move createGeometryEngine() from …
Browse files Browse the repository at this point in the history
…edit utils to QgsGeometry class
  • Loading branch information
mhugent committed Jun 25, 2015
1 parent a3441d1 commit 7b31f8a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 55 deletions.
1 change: 0 additions & 1 deletion python/core/core.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions python/core/geometry/qgsgeometry.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Jun 25, 2015

Member

@mhugent Looks good, but should there not be a /Factory/ annotation?

This comment has been minimized.

Copy link
@mhugent

mhugent Jun 25, 2015

Author Contributor

Right, the factory annotation is needed. Thanks for the hint.


}; // class QgsGeometry

43 changes: 0 additions & 43 deletions python/core/geometry/qgsgeos.sip

This file was deleted.

5 changes: 5 additions & 0 deletions src/core/geometry/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/core/geometry/qgsgeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 2 additions & 7 deletions src/core/geometry/qgsgeometryeditutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int QgsGeometryEditUtils::addRing( QgsAbstractGeometryV2* geom, QgsCurveV2* ring
delete ring; return 3;
}

QScopedPointer<QgsGeometryEngine> ringGeom( createGeometryEngine( ring ) );
QScopedPointer<QgsGeometryEngine> ringGeom( QgsGeometry::createGeometryEngine( ring ) );
ringGeom->prepareGeometry();

//for each polygon, test if inside outer ring and no intersection with other interior ring
Expand Down Expand Up @@ -215,7 +215,7 @@ bool QgsGeometryEditUtils::deletePart( QgsAbstractGeometryV2* geom, int partNum

QgsAbstractGeometryV2* QgsGeometryEditUtils::avoidIntersections( const QgsAbstractGeometryV2& geom, QMap<QgsVectorLayer*, QSet<QgsFeatureId> > ignoreFeatures )
{
QScopedPointer<QgsGeometryEngine> geomEngine( createGeometryEngine( &geom ) );
QScopedPointer<QgsGeometryEngine> geomEngine( QgsGeometry::createGeometryEngine( &geom ) );
if ( geomEngine.isNull() )
{
return 0;
Expand Down Expand Up @@ -285,8 +285,3 @@ QgsAbstractGeometryV2* QgsGeometryEditUtils::avoidIntersections( const QgsAbstra
delete combinedGeometries;
return diffGeom;
}

QgsGeometryEngine* QgsGeometryEditUtils::createGeometryEngine( const QgsAbstractGeometryV2* geometry )
{
return new QgsGeos( geometry );
}
4 changes: 0 additions & 4 deletions src/core/geometry/qgsgeometryeditutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QgsVectorLayer*, QSet<QgsFeatureId> > ignoreFeatures = ( QMap<QgsVectorLayer*, QSet<QgsFeatureId> >() ) );

/** Creates and returns a new geometry engine
*/
static QgsGeometryEngine* createGeometryEngine( const QgsAbstractGeometryV2* geometry );
};

#endif // QGSGEOMETRYEDITUTILS_H

0 comments on commit 7b31f8a

Please sign in to comment.