mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Land inlet searches near mouths
- Offer tidal reach points in the half toward the sea, short of the open sea - Keep tidal reaches out of river mouth searches
This commit is contained in:
2 files changed
+21
-2
No files matched your search
+13
-2
@@ -40,6 +40,8 @@ final class HydrologyFeatureSearch {
|
||||
private static final Set<HydrologyFeatureType> WINDOW_TYPES = EnumSet.of(HydrologyFeatureType.STREAM, HydrologyFeatureType.RIVER,
|
||||
HydrologyFeatureType.MAJOR_RIVER, HydrologyFeatureType.CASCADE, HydrologyFeatureType.WATERFALL, HydrologyFeatureType.MOUTH,
|
||||
HydrologyFeatureType.POND, HydrologyFeatureType.DAM, HydrologyFeatureType.SEA_INLET);
|
||||
private static final double TIDAL_LANDING_FROM = 0.5D;
|
||||
private static final double TIDAL_LANDING_TO = 0.9D;
|
||||
private static final long POLL_NANOS = TimeUnit.MILLISECONDS.toNanos(50L);
|
||||
static final String OFF = "hydrology is off";
|
||||
private static final String PONDS_OFF = "hydrology.ponds.natural and hydrology.ponds.seeded are disabled";
|
||||
@@ -251,8 +253,17 @@ final class HydrologyFeatureSearch {
|
||||
}
|
||||
|
||||
private void tidal(Reach reach) {
|
||||
for (int index = 0; index < reach.xs().length; index++) {
|
||||
offer(reach.id(), HydrologyFeatureType.SEA_INLET, (int) Math.floor(reach.xs()[index]), reach.grade()[index], (int) Math.floor(reach.zs()[index]));
|
||||
float[] xs = reach.xs();
|
||||
float[] zs = reach.zs();
|
||||
double[] along = new double[xs.length];
|
||||
for (int index = 1; index < xs.length; index++) {
|
||||
along[index] = along[index - 1] + Math.hypot(xs[index] - xs[index - 1], zs[index] - zs[index - 1]);
|
||||
}
|
||||
double total = along[xs.length - 1];
|
||||
for (int index = 0; index < xs.length; index++) {
|
||||
if (along[index] >= TIDAL_LANDING_FROM * total && along[index] <= TIDAL_LANDING_TO * total) {
|
||||
offer(reach.id(), HydrologyFeatureType.SEA_INLET, (int) Math.floor(xs[index]), reach.grade()[index], (int) Math.floor(zs[index]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
@@ -335,6 +335,14 @@ public class HydrologyRuntimeTest {
|
||||
HydrologyFeatureRef nearest = runtime.nearestFeature(1050, 405, HydrologyFeatureQuery.of(HydrologyFeatureType.SEA_INLET), 512, ANY,
|
||||
RUNNING).orElseThrow();
|
||||
assertEquals(new HydrologyFeatureRef(INLET, HydrologyFeatureType.SEA_INLET, 1048, 40, 400), nearest);
|
||||
HydrologyFeatureRef fromInland = runtime.nearestFeature(960, 400, HydrologyFeatureQuery.of(HydrologyFeatureType.SEA_INLET), 512, ANY,
|
||||
RUNNING).orElseThrow();
|
||||
assertEquals("a search lands in the half of the arm toward the sea", new HydrologyFeatureRef(INLET, HydrologyFeatureType.SEA_INLET, 1040, 40, 400), fromInland);
|
||||
HydrologyFeatureRef fromTheSea = runtime.nearestFeature(1200, 400, HydrologyFeatureQuery.of(HydrologyFeatureType.SEA_INLET), 512, ANY,
|
||||
RUNNING).orElseThrow();
|
||||
assertEquals("a search lands short of the open sea", new HydrologyFeatureRef(INLET, HydrologyFeatureType.SEA_INLET, 1072, 40, 400), fromTheSea);
|
||||
assertEquals("a tidal reach is not a river mouth", Optional.empty(),
|
||||
runtime.nearestFeature(1050, 405, HydrologyFeatureQuery.of(HydrologyFeatureType.MOUTH), 128, ANY, RUNNING));
|
||||
assertEquals(Optional.empty(),
|
||||
runtime.nearestFeature(0, 0, HydrologyFeatureQuery.of(HydrologyFeatureType.SEA_INLET), 64, ANY, RUNNING));
|
||||
assertEquals(List.of(INLET), runtime.planPreview(900, 300, 1100, 500).reaches().stream().map(Reach::id).filter(id -> id == INLET).toList());
|
||||
|
||||
Reference in new issue
Block a user