[FEATURE] Add subways and tunnels
Idea Right now the code skips tunnels and subways. I don't know Rust very well. I think this can be added: If the tag includes tunnel or subway, and terrain is turned on and fill ground is turned on, then respect the layer tag, and render the rails underground. Include one block of air above the rail. Any rail stations can be rendered as grey terracotta or concrete next to the rail line.
Code idea I attempted to add the idea by adding these lines of code, among others. It sometimes works for underground tunnels, but not for overhead flyover lines. Line 44 of railways.rs:
let mut ground_level = ground.level(XZPoint::new(bx, bz));
if let Some(level_str) = element.tags.get("layer") {
if let Ok(level) = level_str.parse::<i32>() {
ground_level += level * 2;
}
}
Then I also added at line 66:
if ground_level<0 {
editor.set_block(AIR, bx, ground_level + 2, bz, None, None);
}
So that there was an air block above the rails.
Here is what I have so far. Rails generate underground, but there is discontinuities where the level tag changes. I think if we add smoothing to the y axis, it should fix it.
Both screenshots taken from NYC, Lower Manhattan with terrain and fill ground on.
Second showing underground station
Let me know if this is a good start to a PR. it's current in my fork: Here
Roads also generate underground now, but right now it's only 1 block tall.
Also, rails on the ground now have the sleepers properly positioned every 4 blocks. Working on that underground too.
Sleepers now generate underground, with the gravel not, because there is usually just the stone between sleepers. Underground roads and paths now generate correctly. This screenshot shows a tunnel between two sides of a subway platform. Not perfect, but the layers show correctly.