Skip to content

Commit 6e73c53

Browse files
committedJun 22, 2015
Implement stubbed QgsGeometry methods
1 parent e9f4530 commit 6e73c53

File tree

6 files changed

+35
-17
lines changed

6 files changed

+35
-17
lines changed
 

‎python/core/geometry/qgsgeometryengine.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class QgsGeometryEngine
1717
virtual QgsAbstractGeometryV2* combine( const QList< const QgsAbstractGeometryV2* > ) const = 0;
1818
virtual QgsAbstractGeometryV2* symDifference( const QgsAbstractGeometryV2& geom ) const = 0;
1919
virtual QgsAbstractGeometryV2* buffer( double distance, int segments ) const = 0;
20+
virtual QgsAbstractGeometryV2* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const = 0;
2021
virtual QgsAbstractGeometryV2* simplify( double tolerance ) const = 0;
2122
virtual QgsAbstractGeometryV2* interpolate( double distance ) const = 0;
2223
virtual bool centroid( QgsPointV2& pt ) const = 0;

‎python/core/geometry/qgsgeos.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class QgsGeos: public QgsGeometryEngine
1818
QgsAbstractGeometryV2* combine( const QList< const QgsAbstractGeometryV2* > ) const;
1919
QgsAbstractGeometryV2* symDifference( const QgsAbstractGeometryV2& geom ) const;
2020
QgsAbstractGeometryV2* buffer( double distance, int segments ) const;
21+
QgsAbstractGeometryV2* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const;
2122
QgsAbstractGeometryV2* simplify( double tolerance ) const;
2223
QgsAbstractGeometryV2* interpolate( double distance ) const;
2324
bool centroid( QgsPointV2& pt ) const;

‎src/core/geometry/qgsgeometry.cpp

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,26 +1192,18 @@ QgsGeometry* QgsGeometry::buffer( double distance, int segments ) const
11921192

11931193
QgsGeometry* QgsGeometry::buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const
11941194
{
1195-
return 0; //todo...
1196-
1197-
#if 0
1198-
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
1199-
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
1200-
if ( mDirtyGeos )
1201-
exportWkbToGeos();
1202-
1203-
if ( !mGeos )
1195+
if ( !d || !d->geometry )
1196+
{
12041197
return 0;
1198+
}
12051199

1206-
try
1200+
QgsGeos g( d->geometry );
1201+
QgsAbstractGeometryV2* geom = g.buffer( distance, segments, endCapStyle, joinStyle, mitreLimit );
1202+
if ( !geom )
12071203
{
1208-
return fromGeosGeom( GEOSBufferWithStyle( mGeos, distance, segments, endCapStyle, joinStyle, mitreLimit ) );
1204+
return 0;
12091205
}
1210-
CATCH_GEOS( 0 )
1211-
#else
1212-
return 0;
1213-
#endif
1214-
#endif //0
1206+
return new QgsGeometry( geom );
12151207
}
12161208

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

14851477
void QgsGeometry::validateGeometry( QList<Error> &errors )
14861478
{
1487-
//todo // QgsGeometryValidator::validateGeometry( this, errors );
1479+
QgsGeometryValidator::validateGeometry( this, errors );
14881480
}
14891481

14901482
bool QgsGeometry::isGeosValid() const

‎src/core/geometry/qgsgeometryengine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class CORE_EXPORT QgsGeometryEngine
3838
virtual QgsAbstractGeometryV2* combine( const QList< const QgsAbstractGeometryV2* > ) const = 0;
3939
virtual QgsAbstractGeometryV2* symDifference( const QgsAbstractGeometryV2& geom ) const = 0;
4040
virtual QgsAbstractGeometryV2* buffer( double distance, int segments ) const = 0;
41+
virtual QgsAbstractGeometryV2* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const = 0;
4142
virtual QgsAbstractGeometryV2* simplify( double tolerance ) const = 0;
4243
virtual QgsAbstractGeometryV2* interpolate( double distance ) const = 0;
4344
virtual bool centroid( QgsPointV2& pt ) const = 0;

‎src/core/geometry/qgsgeos.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,6 +1184,28 @@ QgsAbstractGeometryV2* QgsGeos::buffer( double distance, int segments ) const
11841184
return fromGeos( geos );
11851185
}
11861186

1187+
QgsAbstractGeometryV2 *QgsGeos::buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const
1188+
{
1189+
if ( !mGeos )
1190+
{
1191+
return 0;
1192+
}
1193+
1194+
#if defined(GEOS_VERSION_MAJOR) && defined(GEOS_VERSION_MINOR) && \
1195+
((GEOS_VERSION_MAJOR>3) || ((GEOS_VERSION_MAJOR==3) && (GEOS_VERSION_MINOR>=3)))
1196+
1197+
GEOSGeometry* geos = 0;
1198+
try
1199+
{
1200+
geos = GEOSBufferWithStyle_r( geosinit.ctxt, mGeos, distance, segments, endCapStyle, joinStyle, mitreLimit );
1201+
}
1202+
CATCH_GEOS( 0 );
1203+
return fromGeos( geos );
1204+
#else
1205+
return 0;
1206+
#endif //0
1207+
}
1208+
11871209
QgsAbstractGeometryV2* QgsGeos::simplify( double tolerance ) const
11881210
{
11891211
if ( !mGeos )

‎src/core/geometry/qgsgeos.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class CORE_EXPORT QgsGeos: public QgsGeometryEngine
4040
QgsAbstractGeometryV2* combine( const QList< const QgsAbstractGeometryV2* > ) const override;
4141
QgsAbstractGeometryV2* symDifference( const QgsAbstractGeometryV2& geom ) const override;
4242
QgsAbstractGeometryV2* buffer( double distance, int segments ) const override;
43+
QgsAbstractGeometryV2* buffer( double distance, int segments, int endCapStyle, int joinStyle, double mitreLimit ) const override;
4344
QgsAbstractGeometryV2* simplify( double tolerance ) const override;
4445
QgsAbstractGeometryV2* interpolate( double distance ) const override;
4546
bool centroid( QgsPointV2& pt ) const override;

0 commit comments

Comments
 (0)
Please sign in to comment.