Expand description
Line offset (parallel curve) generation for cartographic styling
This module implements open-curve parallel offset — shifting a polyline
laterally to produce a parallel polyline — distinct from the filled-polygon
buffer in buffer.rs.
§Conventions
A positive distance places the offset curve on the left of the direction of travel (right-hand coordinate system). A negative distance places it on the right.
§Join styles
At interior vertices the two adjacent offset segment directions differ. Three strategies reconcile them:
- Miter – extend both segments to their intersection point. If the
resulting extension ratio exceeds
miter_limit, fall back toBevel. - Bevel – insert two points (one per segment), slicing off the sharp corner.
- Round – interpolate a circular arc between the two offset directions. Arc resolution adapts to the turn angle at approximately 8 segments per π.
§Example
use oxigdal_algorithms::vector::{JoinStyle, OffsetOptions, offset_linestring};
let coords = vec![(0.0_f64, 0.0_f64), (10.0, 0.0)];
let opts = OffsetOptions::default();
let result = offset_linestring(&coords, 1.0, &opts)?;
assert_eq!(result.coords.len(), 2);
assert!((result.coords[0].1 - 1.0).abs() < 1e-10);Structs§
- Offset
Options - Options controlling how the offset curve is generated.
- Offset
Result - Result returned by
offset_linestringand its variants.
Enums§
- Join
Style - Join style used when constructing the offset curve at interior vertices.
Functions§
- offset_
linestring - Compute a parallel offset of an open polyline.
- offset_
polygon_ rings - Compute parallel offset for each ring of a polygon independently.