Function buffer_multi_polygon_rounded

Source
pub fn buffer_multi_polygon_rounded(
    input_multi_polygon: &MultiPolygon,
    distance: f64,
) -> MultiPolygon
Expand description

This function returns the buffered (multi-)polygon of the given multi-polygon, but creates a rounded corners around each convex vertex. Therefore, distance from each point on border of the buffered polygon to the closest points on the given polygon is (approximately) equal.

Click ‘Result’ below to see how this function works.

§Arguments

  • input_multi_polygon: MultiPolygon to buffer.
  • distance: determines how distant from each edge of original polygon to each edge of the result polygon. The sign will be:
    • + to inflate (to add paddings, make bigger) the given polygon, and,
    • - to deflate (to add margins, make smaller) the given polygon.

§Example

use geo_buffer::buffer_polygon;
use geo::{Polygon, MultiPolygon, LineString};

let p1 = Polygon::new(
    LineString::from(vec![(0., 0.), (2., 0.), (2., 2.), (0., 2.)]), vec![],
);
let p2 = Polygon::new(
    LineString::from(vec![(3., 3.), (5., 3.), (5., 5.), (3., 5.)]), vec![],
);
let mp1 = MultiPolygon::new(vec![p1, p2]);
let mp2 = buffer_multi_polygon(&mp1, 1.);
Result