diff --git a/server/src/atlas/drainage.rs b/server/src/atlas/drainage.rs index 6e48eebcd..2f7d47c20 100644 --- a/server/src/atlas/drainage.rs +++ b/server/src/atlas/drainage.rs @@ -569,7 +569,13 @@ fn build_basins(labels: &[i32], w: usize, h: usize) -> Vec { /// `start` (a row-major cell index), clockwise, via Moore-neighbour tracing. /// Produces an ordered, 8-connected, non-self-crossing perimeter. The grid edge is /// treated as background (no x-wrap) — this is for atlas visualization, not flow. -fn trace_outer_boundary(labels: &[i32], w: usize, h: usize, basin_id: i32, start: usize) -> Vec<(u16, u16)> { +fn trace_outer_boundary( + labels: &[i32], + w: usize, + h: usize, + basin_id: i32, + start: usize, +) -> Vec<(u16, u16)> { // Moore-neighbourhood offsets in clockwise order: N, NE, E, SE, S, SW, W, NW. const DIRS: [(i32, i32); 8] = [ (-1, 0), @@ -588,7 +594,8 @@ fn trace_outer_boundary(labels: &[i32], w: usize, h: usize, basin_id: i32, start && c < w as i32 && labels[r as usize * w + c as usize] == basin_id }; - let dir_index = |dr: i32, dc: i32| -> usize { DIRS.iter().position(|&o| o == (dr, dc)).unwrap_or(0) }; + let dir_index = + |dr: i32, dc: i32| -> usize { DIRS.iter().position(|&o| o == (dr, dc)).unwrap_or(0) }; let sr = (start / w) as i32; let sc = (start % w) as i32; @@ -660,7 +667,10 @@ mod tests { 1, 1, 1, 1, // ]; let boundary = trace_outer_boundary(&labels, 4, 4, 1, 0); - assert!(boundary.len() >= 8, "expected a real perimeter, got {boundary:?}"); + assert!( + boundary.len() >= 8, + "expected a real perimeter, got {boundary:?}" + ); // The defining property the angle-sort violated: consecutive boundary // points are 8-adjacent (a genuine contour walk, not crossing chords). for w in boundary.windows(2) {