pub fn unflatten_polygon_coordinates(coords: &[f32]) -> Vec<Vec<(f32, f32)>>Expand description
Unflatten coordinates with NaN separators back to nested polygon structure.
Converts flat list of coordinates with NaN separators back to nested polygon structure (inverse of flatten_polygon_coordinates):
- Input: [x1, y1, x2, y2, NaN, x3, y3]
- Output: [[(x1, y1), (x2, y2)], [(x3, y3)]]
This function is used when parsing Arrow files to reconstruct the nested polygon format required by the EdgeFirst Studio API.
ยงExamples
use edgefirst_client::unflatten_polygon_coordinates;
let coords = vec![1.0, 2.0, 3.0, 4.0, f32::NAN, 5.0, 6.0];
let polygons = unflatten_polygon_coordinates(&coords);
assert_eq!(polygons.len(), 2);
assert_eq!(polygons[0], vec![(1.0, 2.0), (3.0, 4.0)]);
assert_eq!(polygons[1], vec![(5.0, 6.0)]);