Skip to content
Permalink
Browse files

Implement stubbed QgsGeometry methods

  • Loading branch information
nyalldawson committed Jun 22, 2015
1 parent e9f4530 commit 6e73c53a1b87e599c65ab8dc9ffc4444e10cecf7
@@ -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;
@@ -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;
@@ -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
@@ -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
@@ -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;
@@ -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 )
@@ -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;

0 comments on commit 6e73c53

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