mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 09:44:24 +00:00
Merge tidal inlets
- Sea inlets become tidal reaches on the river pipeline - Recaptures the schema digest for the merged lane
This commit is contained in:
commit
5df42fc49e
82 files changed
+3370
-4647
No files matched your search
@@ -373,7 +373,7 @@ public class HydrologyMetricsTest {
|
||||
}
|
||||
|
||||
private static WindowPlan plan(WindowKey key, List<Reach> reaches, List<Pond> ponds) {
|
||||
return new WindowPlan(key, reaches, ponds, List.of());
|
||||
return new WindowPlan(key, reaches, ponds);
|
||||
}
|
||||
|
||||
private static Reach reach(long id, HydrologyTier tier, long downstream, float catchment, int[] grade, float... coordinates) {
|
||||
|
||||
@@ -57,7 +57,7 @@ public class RiverTransectProbeTest {
|
||||
RiverTransectProbe.Section section = RiverTransectProbe.section(reach, 5,
|
||||
(x, z) -> new RiverTransectProbe.Column(70, 66, Math.abs(z - 100) <= 2 ? 68 : RiverTransectProbe.NO_WATER, WaterRole.CHANNEL));
|
||||
List<String> summary = RiverTransectProbe.summary(new WindowKey(0, 0),
|
||||
new WindowPlan(new WindowKey(0, 0), List.of(reach), List.of(), List.of()), List.of(),
|
||||
new WindowPlan(new WindowKey(0, 0), List.of(reach), List.of()), List.of(),
|
||||
List.of(section), settings);
|
||||
assertEquals("window 0,0 reaches=1 ponds=0 lakes=0 sections=1", summary.get(0));
|
||||
assertTrue(summary.get(1), summary.get(1).startsWith("reach 7 tier=stream length=40 from=0,100@70 to=40,100@60"));
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
package art.arcane.iris.probe;
|
||||
|
||||
import art.arcane.volmlib.nativelib.terrain.NativeBlockState;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class SeaInletChecksTest {
|
||||
@Test
|
||||
public void roofBreachesFailWithTheContainmentSealAndRoofChecks() {
|
||||
SeaInletProbe.Checks breached = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 1939L, 0L, 0L, 0L, 0L, 0L, List.of());
|
||||
assertEquals(1939L, breached.failures());
|
||||
SeaInletProbe.Checks failing = new SeaInletProbe.Checks(3, 1L, 2L, 3L, 4L, 9L, 5L, 6L, 7L, 8L, 0L, List.of());
|
||||
assertEquals(45L, failing.failures());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void looseBedsAreReportedButDoNotFail() {
|
||||
SeaInletProbe.Checks reported = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 952L, List.of());
|
||||
assertEquals(0L, reported.failures());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void theGateFailsOnEveryCheckIncludingOrderSeaLevelAndAddedLeaks() {
|
||||
SeaInletProbe.Checks clean = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 952L, List.of());
|
||||
SeaInletProbe.Gate passing = new SeaInletProbe.Gate(clean, 0, 0, 0);
|
||||
assertEquals(0L, passing.failures());
|
||||
assertTrue(passing.line(), passing.line().startsWith("SEA_INLET_GATE status=PASS failures=0 "));
|
||||
assertEquals(2L, new SeaInletProbe.Gate(clean, 0, 0, 2).failures());
|
||||
assertEquals(1L, new SeaInletProbe.Gate(clean, 1, 0, 0).failures());
|
||||
assertEquals(1L, new SeaInletProbe.Gate(clean, 0, 1, 0).failures());
|
||||
SeaInletProbe.Checks breached = new SeaInletProbe.Checks(3, 0L, 0L, 0L, 0L, 4L, 0L, 0L, 0L, 0L, 0L, List.of());
|
||||
SeaInletProbe.Gate failing = new SeaInletProbe.Gate(breached, 0, 0, 0);
|
||||
assertEquals(4L, failing.failures());
|
||||
assertTrue(failing.line(), failing.line().startsWith("SEA_INLET_GATE status=FAIL failures=4 "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addedLeaksAreTheLeaksMissingWithoutInlets() {
|
||||
long kept = SeaInletProbe.cellKey(10, 300, -20);
|
||||
long removed = SeaInletProbe.cellKey(11, 300, -20);
|
||||
long added = SeaInletProbe.cellKey(10, 301, -20);
|
||||
assertEquals(0, SeaInletProbe.addedLeaks(Set.of(kept), Set.of(kept)));
|
||||
assertEquals("inlets that remove natural leaks do not fail", 0, SeaInletProbe.addedLeaks(Set.of(kept), Set.of(kept, removed)));
|
||||
assertEquals("a leak the inlets move counts although the totals match", 1, SeaInletProbe.addedLeaks(Set.of(kept, added),
|
||||
Set.of(kept, removed)));
|
||||
assertEquals(2, SeaInletProbe.addedLeaks(Set.of(added, removed), Set.of()));
|
||||
assertNotEquals(SeaInletProbe.cellKey(-1, 300, 0), SeaInletProbe.cellKey(0, 300, -1));
|
||||
assertNotEquals(SeaInletProbe.cellKey(5, 0, 5), SeaInletProbe.cellKey(5, 4095, 5));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void inletCellsAreClassifiedAgainstTheDimensionSeaFluid() {
|
||||
assertEquals(SeaInletProbe.classify(state("minecraft:water"), "minecraft:water"), SeaInletProbe.classify(state("minecraft:lava"),
|
||||
"minecraft:lava"));
|
||||
assertEquals(SeaInletProbe.classify(state("minecraft:water[level=8]"), "minecraft:water"),
|
||||
SeaInletProbe.classify(state("minecraft:lava[level=8]"), "minecraft:lava"));
|
||||
assertEquals(SeaInletProbe.classify(state("minecraft:lava"), "minecraft:water"), SeaInletProbe.classify(state("minecraft:water"),
|
||||
"minecraft:lava"));
|
||||
assertNotEquals(SeaInletProbe.classify(state("minecraft:lava"), "minecraft:lava"), SeaInletProbe.classify(state("minecraft:lava"),
|
||||
"minecraft:water"));
|
||||
}
|
||||
|
||||
private static NativeBlockState state(String key) {
|
||||
NativeBlockState state = mock(NativeBlockState.class);
|
||||
when(state.key()).thenReturn(key);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,7 @@ final class SyntheticHydrology implements AutoCloseable {
|
||||
}
|
||||
|
||||
HydrologyProbe.Inputs inputs(UnaryOperator<HydrologyVoxels.ChunkBlocks> edit) {
|
||||
return inputs(edit, (key, plan) -> new HydrologyUnderground.Counts(plan.inlets().size(), 0L, 0, 0L, List.of()));
|
||||
return inputs(edit, (key, plan) -> new HydrologyUnderground.Counts(0, 0L, 0, 0L, List.of()));
|
||||
}
|
||||
|
||||
HydrologyProbe.Inputs inputs(UnaryOperator<HydrologyVoxels.ChunkBlocks> edit, HydrologyUnderground.Source underground) {
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package art.arcane.iris.probe;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class TidalReachMetricsTest {
|
||||
private static float[] line(int points, float step) {
|
||||
float[] values = new float[points];
|
||||
for (int point = 0; point < points; point++) {
|
||||
values[point] = point * step;
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void straightLineRunsItsWholeLengthWithoutTurning() {
|
||||
float[] xs = line(25, 4f);
|
||||
float[] zs = new float[25];
|
||||
assertEquals(1D, TidalReachMetrics.sinuosity(xs, zs), 1e-9D);
|
||||
assertEquals(96D, TidalReachMetrics.straightRun(xs, zs), 1e-9D);
|
||||
assertEquals(0D, TidalReachMetrics.sharpestTurn(xs, zs), 1e-9D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rightAngleShowsAsASharpTurn() {
|
||||
float[] xs = {0f, 40f, 40f};
|
||||
float[] zs = {0f, 0f, 40f};
|
||||
assertEquals(80D / Math.hypot(40D, 40D), TidalReachMetrics.sinuosity(xs, zs), 1e-6D);
|
||||
assertTrue(TidalReachMetrics.sharpestTurn(xs, zs) >= 45D);
|
||||
assertEquals(40D, TidalReachMetrics.straightRun(xs, zs), 4.01D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wavyLineHasShortStraightRunsAndAboveOneSinuosity() {
|
||||
int points = 200;
|
||||
float[] xs = new float[points];
|
||||
float[] zs = new float[points];
|
||||
for (int point = 0; point < points; point++) {
|
||||
xs[point] = point;
|
||||
zs[point] = (float) (6D * Math.sin(point / 8D));
|
||||
}
|
||||
assertTrue(TidalReachMetrics.sinuosity(xs, zs) > 1.1D);
|
||||
assertTrue(TidalReachMetrics.straightRun(xs, zs) < 24D);
|
||||
assertEquals(1D, TidalReachMetrics.percentile(new double[]{0D, 1D, 2D}, 0.5D), 0D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void slotRunFindsWallsOnBothSidesAtOnce() {
|
||||
double[] left = {30D, 30D, 30D, 30D, 2D, 30D};
|
||||
double[] right = {30D, 30D, 30D, 30D, 30D, 2D};
|
||||
assertEquals(8D, TidalReachMetrics.longestSlotRun(left, right, 16D, 2D), 0D);
|
||||
assertEquals(0D, TidalReachMetrics.longestSlotRun(new double[]{30D, 2D}, new double[]{2D, 30D}, 16D, 2D), 0D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void steepestRiseSeesASheerWallNotAGradedBank() {
|
||||
assertEquals(30D, TidalReachMetrics.steepestRise(new int[]{0, 0, 30, 30, 30, 30, 30}, 4), 0D);
|
||||
assertEquals(4D, TidalReachMetrics.steepestRise(new int[]{0, 1, 2, 3, 4, 5, 6}, 4), 0D);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void headWallNeedsTwoAdjacentRays() {
|
||||
assertTrue(TidalReachMetrics.adjacentRaysAtLeast(new int[]{0, 16, 20, 0}, 16));
|
||||
assertTrue(!TidalReachMetrics.adjacentRaysAtLeast(new int[]{16, 0, 20, 0}, 16));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user