mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Inland hollow box cap
- Treat an inland hollow as open when its basin box would pass 2^20 cells, decided from the whole hollow - Mark a classified hollow's cells inside the window as seen so its other pieces are not classified again - Test a long diagonal trench classified open from two windows without sampling its basin box
This commit is contained in:
1 parent
e108bd3c58
commit
06b7001132
3 files changed
+81
-25
No files matched your search
@@ -22,6 +22,11 @@ public class InlandHollowsTest {
|
||||
private static final double PIT_RADIUS = 100D;
|
||||
private static final double PIT_DEPTH = 64D;
|
||||
private static final int LAKE_STEP = 16;
|
||||
private static final double TRENCH_FROM = 128D;
|
||||
private static final double TRENCH_TO = 7800D;
|
||||
private static final double TRENCH_HALF_WIDTH = 16D;
|
||||
private static final int TRENCH_WINDOW_CELL = 500;
|
||||
private static final long MAX_HOLLOW_SAMPLES = 200_000L;
|
||||
|
||||
@Test
|
||||
public void hollowCutByTheGridEdgeIsClassifiedLikeAWholeOne() {
|
||||
@@ -78,6 +83,26 @@ public class InlandHollowsTest {
|
||||
assertEquals("and its basin keeps the trunk", 0, held.basins().cardinality());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hollowTooLongForItsBasinBoxIsOpenFromEveryWindow() {
|
||||
SyntheticTerrain terrain = SyntheticTerrain.diagonalTrench(TRENCH_FROM, TRENCH_TO, TRENCH_HALF_WIDTH, SEA_LEVEL - 20D);
|
||||
HeightLattice fine = new HeightLattice(terrain, WindowPlanner.FINE_CELL, false, 1 << 20);
|
||||
for (int cell : new int[]{0, TRENCH_WINDOW_CELL}) {
|
||||
Window window = new Window(fine, cell, cell);
|
||||
int below = 0;
|
||||
for (float height : window.natural.values()) {
|
||||
below += Math.round(height) < SEA_LEVEL ? 1 : 0;
|
||||
}
|
||||
assertTrue("the trench crosses the window at cell " + cell + ": " + below, below > 20);
|
||||
long before = terrain.naturalSamples();
|
||||
InlandHollows.Hollows hollows = window.classify();
|
||||
long sampled = terrain.naturalSamples() - before;
|
||||
assertEquals("the trench is open from the window at cell " + cell, 0, hollows.inland().cardinality());
|
||||
assertEquals("and has no basin there", 0, hollows.basins().cardinality());
|
||||
assertTrue("ground sampled to classify the trench from the window at cell " + cell + ": " + sampled, sampled < MAX_HOLLOW_SAMPLES);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class Window {
|
||||
private final HeightLattice fine;
|
||||
private final DemGrid natural;
|
||||
|
||||
@@ -303,6 +303,15 @@ final class SyntheticTerrain implements HydrologyTerrainSource {
|
||||
});
|
||||
}
|
||||
|
||||
static SyntheticTerrain diagonalTrench(double from, double to, double halfWidth, double floor) {
|
||||
double land = SEA_LEVEL + 20D;
|
||||
return new SyntheticTerrain((x, z) -> {
|
||||
double along = 0.5D * (x + z);
|
||||
double across = Math.abs(x - z) / Math.sqrt(2D);
|
||||
return along >= from && along <= to && across <= halfWidth ? floor : land;
|
||||
}).withLand((x, z) -> true);
|
||||
}
|
||||
|
||||
private static double valleySlope(double x, double z) {
|
||||
return 100D - 0.03D * x + 0.05D * Math.abs(z - VALLEY_AXIS);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user