[][src]Function offset_polygon::offset_polygon

pub fn offset_polygon<N>(
    polygon: &LineString<N>,
    offset: N,
    arcdetail: N
) -> Result<Vec<LineString<N>>, CombinatorialExplosionError> where
    N: Num + Copy + NumCast + PartialOrd + Float + FloatConst + FromPrimitive + AddAssign + SubAssign

The core function of this crate. Expands or shrinks the given polygon by the offset. It support f32 and f64 for its calculations and input/output.

Arguments

  • polygon - A polygon to shrink or expand. It has to be closed (the last coordinate has to be the same as the first coordinate)
  • offset - A positive number expands the polygon, a negative number shrinks it.
  • arcdetail - Defines how many points should be added in a sharp corner. This number is the number of vertices inserted if it's a full circle. The actual number inserted depends on the angle of the corner.

Returns a vector of polygons (if the polygon is shrunk more than its thinnest section, multiple polygons will be generated). The error occurs when there are too many intersections during the operation and should never happen. It's there to avoid infinite loops (which the author did experience with certain edge cases).