Skip to main content

Crate polyops

Crate polyops 

Source
Expand description

§PolyOps

Boolean operations on polygons via the Martinez-Rueda-Feito sweep-line algorithm. Faithful Rust port of martinez-polygon-clipping.

§Operations

  • intersection — the area covered by both subject and clipping.
  • union — the area covered by either subject or clipping.
  • difference — the area in subject but not in clipping.
  • xor — the area in subject xor clipping (symmetric difference).

All four accept GeoJSON-shaped coordinate arrays: either a Polygon (Vec<Ring>) or a MultiPolygon (Vec<Polygon>), via the Geometry enum.

§Status

Pre-alpha. All algorithm modules are ported; parity against upstream is verified via tests/parity.rs against goldens generated by parity/generate-goldens.ts. Failure modes (if any) get tracked in PLAN.md §14.

Re-exports§

pub use crate::types::BBox;
pub use crate::types::Geometry;
pub use crate::types::MultiPolygon;
pub use crate::types::Polygon;
pub use crate::types::Position;
pub use crate::types::Ring;

Modules§

operation
Boolean operation enum, mirroring upstream src/operation.ts.
types
Coordinate types matching GeoJSON shape, mirroring upstream src/types.ts.

Functions§

difference
subject minus clipping.
intersection
Intersection of subject and clipping.
union
Union of subject and clipping.
xor
Symmetric difference of subject and clipping.