Added QgsGeometry::buffer() function that returns buffer around the geometry.

git-svn-id: http://svn.osgeo.org/qgis/trunk@7986 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
wonder 2008-01-16 22:39:57 +00:00
parent 764ee5d0a7
commit be72a7a663
3 changed files with 20 additions and 0 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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
*/