Skip to main content

buffer_polygon_pooled

Function buffer_polygon_pooled 

Source
pub fn buffer_polygon_pooled(
    polygon: &Polygon,
    distance: f64,
    options: &BufferOptions,
) -> Result<PoolGuard<'static, Polygon>>
Expand description

Generates a buffer around a polygon using object pooling

This is the pooled version of buffer_polygon that reuses allocated polygons from a thread-local pool.

§Arguments

  • polygon - The polygon to buffer
  • distance - Buffer distance (positive for expansion, negative for erosion)
  • options - Buffer options

§Returns

A PoolGuard<Polygon> that automatically returns the polygon to the pool when dropped.

§Errors

Returns error if polygon is invalid

§Example

use oxigdal_algorithms::vector::{buffer_polygon_pooled, Polygon, LineString, Coordinate, BufferOptions};

let exterior = LineString::new(vec![
    Coordinate::new_2d(0.0, 0.0),
    Coordinate::new_2d(10.0, 0.0),
    Coordinate::new_2d(10.0, 10.0),
    Coordinate::new_2d(0.0, 10.0),
    Coordinate::new_2d(0.0, 0.0),
])?;
let polygon = Polygon::new(exterior, vec![])?;
let options = BufferOptions::default();
let buffered = buffer_polygon_pooled(&polygon, 2.0, &options)?;