Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added QgsGeometry::buffer() function that returns buffer around the g…
…eometry.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7986 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Jan 16, 2008
1 parent 0302dfc commit 857ae41
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/core/qgsgeometry.sip
Expand Up @@ -208,6 +208,10 @@ not disjoint with existing polygons of the feature*/
/** Test for containment of a point (uses GEOS) */
bool contains(QgsPoint* p);

/** Returns a buffer region around this geometry having the given width and with a specified number
of segments used to approximate curves */
QgsGeometry* buffer(double distance, int segments) /Factory/;

/**Creates a geos geometry from this features geometry. Note, that the returned object needs to be deleted*/
// TODO: unsupported class... would be possible to use PyGEOS?
//geos::Geometry* geosGeometry() const;
Expand Down
12 changes: 12 additions & 0 deletions src/core/qgsgeometry.cpp
Expand Up @@ -5511,3 +5511,15 @@ double QgsGeometry::distance(QgsGeometry& geom)

return mGeos->distance(geom.mGeos);
}


QgsGeometry* QgsGeometry::buffer(double distance, int segments)
{
if (mGeos == NULL)
exportWkbToGeos();
GEOS_GEOM::Geometry* geos = mGeos->buffer(distance, segments);
QgsGeometry* g = new QgsGeometry;
g->setGeos(geos);
return g;
}

4 changes: 4 additions & 0 deletions src/core/qgsgeometry.h
Expand Up @@ -278,6 +278,10 @@ not disjoint with existing polygons of the feature*/
/** Test for containment of a point (uses GEOS) */
bool contains(QgsPoint* p);

/** Returns a buffer region around this geometry having the given width and with a specified number
of segments used to approximate curves */
QgsGeometry* buffer(double distance, int segments);

/** Exports the geometry to mWkt
@return true in case of success and false else
*/
Expand Down

0 comments on commit 857ae41

Please sign in to comment.