1
0
mirror of https://github.com/qgis/QGIS.git synced 2025-04-17 00:04:02 -04:00

Implement stubbed QgsGeometry methods

This commit is contained in:
Nyall Dawson 2015-06-22 21:26:41 +10:00
parent e9f4530807
commit 6e73c53a1b
6 changed files with 37 additions and 19 deletions

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