Sea head review fixes

- The mouth sea-level check covers only the trailing mouth run of reaches that end in the ocean
- Ocean-flagged points inside a reach no longer fail planning closed
- Reach checks are split into a below-sea pass and a trailing-mouth pass with one failure message builder
- Reflooded ponds stop lowering at the sea surface and drop instead of standing below it
- A sea-strip slope fixture reproduces mid-reach mouth points above sea
This commit is contained in:
Brian Neumann-Fopiano committed 2026-11-01 20:12:45 -05:00
1 parent d341e114b5
commit de62c76807
5 files changed
+84 -12

No files matched your search

@@ -330,12 +330,16 @@ public final class WindowPlanner {
}
for (Reach reach : plan.reaches()) {
for (int point = 0; point < reach.grade().length; point++) {
int grade = reach.grade()[point];
boolean mouth = reach.style()[point] == ReachStyle.MOUTH;
if (grade < seaLevel || mouth && grade != seaLevel) {
throw new IllegalStateException("Window " + plan.key() + " reach " + reach.id() + " " + reach.style()[point] + " point "
+ point + " at " + reach.xs()[point] + "," + reach.zs()[point] + " is graded " + grade
+ (mouth ? ", not at sea level " : ", below sea level ") + seaLevel);
if (reach.grade()[point] < seaLevel) {
throw offSea(plan.key(), reach, point, ", below sea level " + seaLevel);
}
}
if (reach.downstreamId() != 0L) {
continue;
}
for (int point = reach.grade().length - 1; point >= 0 && reach.style()[point] == ReachStyle.MOUTH; point--) {
if (reach.grade()[point] != seaLevel) {
throw offSea(plan.key(), reach, point, ", but the mouth must meet the sea at sea level " + seaLevel);
}
}
}
@@ -347,6 +351,11 @@ public final class WindowPlanner {
}
}
private static IllegalStateException offSea(WindowKey key, Reach reach, int point, String rule) {
return new IllegalStateException("Window " + key + " reach " + reach.id() + " " + reach.style()[point] + " point " + point + " at "
+ reach.xs()[point] + "," + reach.zs()[point] + " is graded " + reach.grade()[point] + rule);
}
private record Drainage(float[] filled, List<Basin> basins, DemGrid surface, int[] receivers, float[] accumulation, BitSet channels) {
}
}
@@ -142,7 +142,8 @@ public final class PondPlanner {
floor = node;
}
}
for (int level = pond.level(); floor >= 0 && ground[floor] < level; level--) {
int seaFloor = Math.max(settings.minY() + 1, settings.seaLevel());
for (int level = pond.level(); level >= seaFloor && floor >= 0 && ground[floor] < level; level--) {
boolean[] wet = floodWithin(box, ground, inside, floor, level);
if (pond.damRaise() > 0 || contained(box, ground, wet, level)) {
float lowest = Float.POSITIVE_INFINITY;