Skip to content

Commit 857ae41

Browse files
author
wonder
committedJan 16, 2008
Added QgsGeometry::buffer() function that returns buffer around the geometry.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7986 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed
 

‎python/core/qgsgeometry.sip

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ not disjoint with existing polygons of the feature*/
208208
/** Test for containment of a point (uses GEOS) */
209209
bool contains(QgsPoint* p);
210210

211+
/** Returns a buffer region around this geometry having the given width and with a specified number
212+
of segments used to approximate curves */
213+
QgsGeometry* buffer(double distance, int segments) /Factory/;
214+
211215
/**Creates a geos geometry from this features geometry. Note, that the returned object needs to be deleted*/
212216
// TODO: unsupported class... would be possible to use PyGEOS?
213217
//geos::Geometry* geosGeometry() const;

‎src/core/qgsgeometry.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5511,3 +5511,15 @@ double QgsGeometry::distance(QgsGeometry& geom)
55115511

55125512
return mGeos->distance(geom.mGeos);
55135513
}
5514+
5515+
5516+
QgsGeometry* QgsGeometry::buffer(double distance, int segments)
5517+
{
5518+
if (mGeos == NULL)
5519+
exportWkbToGeos();
5520+
GEOS_GEOM::Geometry* geos = mGeos->buffer(distance, segments);
5521+
QgsGeometry* g = new QgsGeometry;
5522+
g->setGeos(geos);
5523+
return g;
5524+
}
5525+

‎src/core/qgsgeometry.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ not disjoint with existing polygons of the feature*/
278278
/** Test for containment of a point (uses GEOS) */
279279
bool contains(QgsPoint* p);
280280

281+
/** Returns a buffer region around this geometry having the given width and with a specified number
282+
of segments used to approximate curves */
283+
QgsGeometry* buffer(double distance, int segments);
284+
281285
/** Exports the geometry to mWkt
282286
@return true in case of success and false else
283287
*/

0 commit comments

Comments
 (0)
Please sign in to comment.