Skip to content
Permalink
Browse files
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 857ae41deeae2b3107f3da9c8a48f8d6410db58c
Showing with 20 additions and 0 deletions.
  1. +4 −0 python/core/qgsgeometry.sip
  2. +12 −0 src/core/qgsgeometry.cpp
  3. +4 −0 src/core/qgsgeometry.h
@@ -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;
@@ -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;
}

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

0 comments on commit 857ae41

Please sign in to comment.