polygon2.fromFlat
A polygon from a flat [x0, y0, x1, y1, …] ring, checked like Polygon2.of.
Usage
Polygon2.fromFlat(xy: ArrayLike<number>): Result<Polygon2>Parameters
xyArrayLike<number>The ring as x, y pairs; a last pair equal to the first is dropped. Required. In model.
Returns
Ok with a frozen polygon; the numbers are copied into a new Float64Array.
Errors
Guarantees
- xy.length is even and ≥ 6 on the result, every entry finite
- The same result on every machine.
Example
Polygon2.fromFlat([0, 0, 1, 0, 1, 1, 0, 0]).value.cornerCount // → 3