Parameters
- geometry
- Specifies the input geometry.
- distance
- The distance (in the unit of the geometry's spatial reference) to buffer the geometry.
Return Value
The polygon that represents the buffered area.
Exception | Description |
---|---|
System.ArgumentNullException | Geometry is null or empty. |
System.NotImplementedException | The method is not implemented for GeometryBag. |
System.ArgumentException | The buffer distance must be a valid floating point number. |
If the distance is less than or equal to zero and the input geometry is not a polygon or an envelope, then an empty polygon is returned.
//Create a point var pt = MapPointBuilderEx.CreateMapPoint(x, y, SpatialReferenceBuilder.CreateSpatialReference(4326)); //Buffer it - for purpose of zoom var poly = GeometryEngine.Instance.Buffer(pt, buffer_size); //do we need to project the buffer polygon? if (!MapView.Active.Map.SpatialReference.IsEqual(poly.SpatialReference)) { //project the polygon poly = GeometryEngine.Instance.Project(poly, MapView.Active.Map.SpatialReference); } // Must run on MCT. QueuedTask.Run(() => { //Zoom - add in a delay for animation effect MapView.Active.ZoomTo(poly, new TimeSpan(0, 0, 0, 3)); });
// buffer a point MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84); Geometry ptBuffer = GeometryEngine.Instance.Buffer(pt, 5.0); Polygon buffer = ptBuffer as Polygon;
// create the circular arc MapPoint fromPt = MapPointBuilderEx.CreateMapPoint(2, 1); MapPoint toPt = MapPointBuilderEx.CreateMapPoint(1, 2); Coordinate2D interiorPt = new Coordinate2D(1 + Math.Sqrt(2) / 2, 1 + Math.Sqrt(2) / 2); EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromPt, toPt, interiorPt); // buffer the arc Polyline polyline = PolylineBuilderEx.CreatePolyline(circularArc); Geometry lineBuffer = GeometryEngine.Instance.Buffer(polyline, 10);
Target Platforms: Windows 11, Windows 10, Windows 8.1