Skip to content

Carve route corridors only between adjacent decomposed cells - #135

Merged
SteveMacenski merged 2 commits into
open-navigation:mainfrom
u33549:Feature/umutc/f2c-enhancements-main/decomp-route-corridors
Jul 24, 2026
Merged

SteveMacenski merged 2 commits into
open-navigation:mainfrom
u33549:Feature/umutc/f2c-enhancements-main/decomp-route-corridors

Conversation

@u33549

@u33549 u33549 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a double-headland gap between decomposed cells. Behavior-preserving unless
the field is decomposed with a headland.

The bug: when a field is decomposed with a headland, the headland was being
applied twice. The field headland is already removed once before decomposing;
then applying generateHeadlands to every sub-cell insets a headland on all
of that cell's borders again — including the borders shared with a neighbor. Two
adjacent cells each carving a headland on the same shared edge leaves a
double-width gap between them, and outer edges get a redundant second headland
stacked on the one already removed at the field level.

The fix: generateHeadlandsBetweenCells carves a corridor only on the
borders two cells actually share. An edge is carved only when both its endpoints
and its midpoint lie on a neighbor cell's border, so shared borders get exactly
one corridor and edges facing the outer boundary or a void keep their single,
already-correct headland. route_headland_width (default 0.0 = operation
width) sets the corridor width.

generateHeadlands per sub-cell (before)      generateHeadlandsBetweenCells (after)
headland inset on EVERY border               corridor ONLY on the shared A│B border

 ┌─────────────┐ ┌─────────────┐              ┌─────────────┬───┬─────────────┐
 │▒▒▒▒▒▒▒▒▒▒▒▒▒│ │▒▒▒▒▒▒▒▒▒▒▒▒▒│              │             │░░░│             │
 │▒┌─────────┐▒│ │▒┌─────────┐▒│              │             │░░░│             │
 │▒│    A    │▒│ │▒│    B    │▒│              │      A      │░░░│      B      │
 │▒│         │▒│ │▒│         │▒│              │             │░░░│             │
 │▒└─────────┘▒│ │▒└─────────┘▒│              │             │░░░│             │
 │▒▒▒▒▒▒▒▒▒▒▒▒▒│ │▒▒▒▒▒▒▒▒▒▒▒▒▒│              │             │░░░│             │
 └─────────────┘ └─────────────┘              └─────────────┴───┴─────────────┘
   double headland on the shared edge           one corridor where cells meet;
   + redundant outer headland                   outer boundary left untouched

Decomposition removes the field headland once before decomposing; the
per-sub-cell second headland is dropped so swaths reach the outer field
headland instead of leaving a double-wide gap. A new route_headland_width
goal field (0 = operation width) sets the corridor carved strictly on the
borders that two cells actually share: an edge is carved only when both
endpoints and its midpoint lie on a neighbor's border, so edges facing a
concave void or the outer boundary keep their single headland.

The corridor is built by buffering the shared edge as a line (numerically
robust) and differencing it out; sub-cells below a minimum area are dropped
so degenerate slivers never reach F2C's unchecked OGR casts.
Copilot AI review requested due to automatic review settings July 21, 2026 22:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@u33549

u33549 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author
image

The image compares the behavior of route generation before and after the fix:

  • Before (generateHeadlands per sub-cell):
    When generateHeadlands is applied individually to every sub-cell, a headland inset is carved around all borders of each cell. As a result, adjacent cells carving headlands along their shared boundary produce a double-width gap (double-headland) between them. Additionally, outer boundaries end up with a redundant, second headland stacked on top of the initial field-level headland.

  • After (generateHeadlandsBetweenCells):
    With generateHeadlandsBetweenCells, a corridor is carved only along the borders that two cells actually share. Outer boundaries and edges facing voids remain untouched (retaining their single, correct field-level headland), eliminating the redundant gaps and double-insets.

Note: The generated route in the "After" image appears slightly distorted/crooked; this routing issue will be fixed in the next PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants