Skip to content

Commit

Permalink
Implement stubbed QgsGeometry methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 22, 2015
1 parent e9f4530 commit 6e73c53
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 17 deletions.
1 change: 1 addition & 0 deletions python/core/geometry/qgsgeometryengine.sip
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class QgsGeometryEngine
virtual QgsAbstractGeometryV2* combine( const QList< const QgsAbstractGeometryV2* > ) const = 0;
virtual QgsAbstractGeometryV2* symDifference( const QgsAbstractGeometryV2& geom ) const = 0;
virtual QgsAbstractGeometryV2* buffer( double distance, int segments ) const = 0;
virtual QgsAbstractGeometryV2* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const = 0;
virtual QgsAbstractGeometryV2* simplify( double tolerance ) const = 0;
virtual QgsAbstractGeometryV2* interpolate( double distance ) const = 0;
virtual bool centroid( QgsPointV2& pt ) const = 0;
Expand Down
1 change: 1 addition & 0 deletions python/core/geometry/qgsgeos.sip
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class QgsGeos: public QgsGeometryEngine
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;
Expand Down
26 changes: 9 additions & 17 deletions src/core/geometry/qgsgeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1192,26 +1192,18 @@ QgsGeometry* QgsGeometry::buffer( double distance, int segments ) const

QgsGeometry* QgsGeometry::buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const
{
return 0; //todo...

#if 0
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
if ( mDirtyGeos )
exportWkbToGeos();

if ( !mGeos )
if ( !d || !d->geometry )
{
return 0;
}

try
QgsGeos g( d->geometry );
QgsAbstractGeometryV2* geom = g.buffer( distance, segments, endCapStyle, joinStyle, mitreLimit );
if ( !geom )
{
return fromGeosGeom( GEOSBufferWithStyle( mGeos, distance, segments, endCapStyle, joinStyle, mitreLimit ) );
return 0;
}
CATCH_GEOS( 0 )
#else
return 0;
#endif
#endif //0
return new QgsGeometry( geom );
}

QgsGeometry* QgsGeometry::offsetCurve( double distance, int segments, int joinStyle, double mitreLimit ) const
Expand Down Expand Up @@ -1484,7 +1476,7 @@ int QgsGeometry::avoidIntersections( QMap<QgsVectorLayer*, QSet< QgsFeatureId >

void QgsGeometry::validateGeometry( QList<Error> &errors )
{
//todo // QgsGeometryValidator::validateGeometry( this, errors );
QgsGeometryValidator::validateGeometry( this, errors );
}

bool QgsGeometry::isGeosValid() const
Expand Down
1 change: 1 addition & 0 deletions src/core/geometry/qgsgeometryengine.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CORE_EXPORT QgsGeometryEngine
virtual QgsAbstractGeometryV2* combine( const QList< const QgsAbstractGeometryV2* > ) const = 0;
virtual QgsAbstractGeometryV2* symDifference( const QgsAbstractGeometryV2& geom ) const = 0;
virtual QgsAbstractGeometryV2* buffer( double distance, int segments ) const = 0;
virtual QgsAbstractGeometryV2* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const = 0;
virtual QgsAbstractGeometryV2* simplify( double tolerance ) const = 0;
virtual QgsAbstractGeometryV2* interpolate( double distance ) const = 0;
virtual bool centroid( QgsPointV2& pt ) const = 0;
Expand Down
22 changes: 22 additions & 0 deletions src/core/geometry/qgsgeos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,28 @@ QgsAbstractGeometryV2* QgsGeos::buffer( double distance, int segments ) const
return fromGeos( geos );
}

QgsAbstractGeometryV2 *QgsGeos::buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const
{
if ( !mGeos )
{
return 0;
}

#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))

GEOSGeometry* geos = 0;
try
{
geos = GEOSBufferWithStyle_r( geosinit.ctxt, mGeos, distance, segments, endCapStyle, joinStyle, mitreLimit );
}
CATCH_GEOS( 0 );
return fromGeos( geos );
#else
return 0;
#endif //0
}

QgsAbstractGeometryV2* QgsGeos::simplify( double tolerance ) const
{
if ( !mGeos )
Expand Down
1 change: 1 addition & 0 deletions src/core/geometry/qgsgeos.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class CORE_EXPORT QgsGeos: public QgsGeometryEngine
QgsAbstractGeometryV2* combine( const QList< const QgsAbstractGeometryV2* > ) const override;
QgsAbstractGeometryV2* symDifference( const QgsAbstractGeometryV2& geom ) const override;
QgsAbstractGeometryV2* buffer( double distance, int segments ) const override;
QgsAbstractGeometryV2* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const override;
QgsAbstractGeometryV2* simplify( double tolerance ) const override;
QgsAbstractGeometryV2* interpolate( double distance ) const override;
bool centroid( QgsPointV2& pt ) const override;
Expand Down

0 comments on commit 6e73c53

Please sign in to comment.