Skip to main content

buffer_point_pooled

Function buffer_point_pooled 

Source
pub fn buffer_point_pooled(
    center: &Point,
    radius: f64,
    options: &BufferOptions,
) -> Result<PoolGuard<'static, Polygon>>
Expand description

Generates a circular buffer around a point using object pooling

This is the pooled version of buffer_point that reuses allocated polygons from a thread-local pool, reducing allocation overhead for batch operations.

§Arguments

  • center - The center point
  • radius - Buffer radius (must be positive)
  • options - Buffer options controlling segment count and other parameters

§Returns

A PoolGuard<Polygon> that automatically returns the polygon to the pool when dropped. Use .into_inner() to take ownership without returning to pool.

§Errors

Returns error if radius is negative or non-finite

§Performance

For batch operations, this can reduce allocations by 2-3x compared to the non-pooled version.

§Example

use oxigdal_algorithms::vector::{buffer_point_pooled, Point, BufferOptions};

let point = Point::new(0.0, 0.0);
let options = BufferOptions::default();
let buffered = buffer_point_pooled(&point, 10.0, &options)?;
// Use buffered polygon...
// Automatically returned to pool when buffered drops