diff --git a/src/convert_world.py b/src/convert_world.py index 303e389..46f9845 100644 --- a/src/convert_world.py +++ b/src/convert_world.py @@ -167,15 +167,15 @@ def chunk_at(region, cx, cz): max_height = int(chunk.heightmap[bz_in_c, bx_in_c]) if chunk.heightmap.any() else 255 min_height = 0 - tree_so_far = False - for by in range(max_height, min_height, -1): + tree_so_far = 0 + for by in range(max_height + 1, min_height, -1): block = chunk.get_block(bx_in_c, by, bz_in_c) # -- surface processes: dem and landcover -- if block.id in surface_blocks: data["dem"][entry] = by data["landcover"][entry] = surface_blocks.index(block.id) - if tree_so_far: + if tree_so_far == 2: data["trees"][entry] = 1 break @@ -198,9 +198,11 @@ def chunk_at(region, cx, cz): # -- other processes: trees -- if block.id in symbol_data["418"]["blocks"]["canopy"]: - tree_so_far = True - elif not block.id in symbol_data["418"]["blocks"]["trunk"]: - tree_so_far = False + tree_so_far = 1 + elif block.id in symbol_data["418"]["blocks"]["trunk"]: + tree_so_far = 2 if tree_so_far else 0 + else: + tree_so_far = 0 logging.info("Writing data...") try: diff --git a/src/create_map.r b/src/create_map.r index 73cc247..299ed96 100644 --- a/src/create_map.r +++ b/src/create_map.r @@ -91,7 +91,7 @@ contours <- list( log_info("Creating water...") water <- data$landcover -water[data$landcover != (match(symbol_data$`301`$blocks$ground, surface_blocks) - 1)] <- NA +water[!(data$landcover %in%(match(symbol_data$`301`$blocks$ground, surface_blocks) - 1))] <- NA water <- list( feature=water |> terra::as.polygons(), @@ -102,6 +102,36 @@ water <- list( smoothing=3 ) +log_info("Creating ice...") +ice <- data$landcover +ice[!(data$landcover %in%(match(symbol_data$`314`$blocks$ground, surface_blocks) - 1))] <- NA +ice <- list( + feature=ice |> + terra::as.polygons(), + render=list(tm_fill(col = "#BFFFFF")), + smoothing=3 +) + +log_info("Creating bare rock...") +bare_rock <- data$landcover +bare_rock[!(data$landcover %in%(match(symbol_data$`214`$blocks$ground, surface_blocks) - 1))] <- NA +bare_rock <- list( + feature=bare_rock |> + terra::as.polygons(), + render=list(tm_fill(col = "#B3B3B3")), + smoothing=3 +) + +log_info("Creating sand...") +sand <- data$landcover +sand[!(data$landcover %in%(match(symbol_data$`213`$blocks$ground, surface_blocks) - 1))] <- NA +sand <- list( + feature=sand |> + terra::as.polygons(), + render=list(tm_fill(col = "#FFFF80")), + smoothing=3 +) + log_info("Creating canopy...") data$canopy[data$canopy == 0] <- NA canopy <- list( @@ -129,6 +159,9 @@ if (resolution == 1) { if (resolution == 1) { # include point symbols symbols <- list( + ice=ice, + sand=sand, + bare_rock=bare_rock, canopy=canopy, contours=contours, water=water, @@ -136,6 +169,9 @@ if (resolution == 1) { # include point symbols ) } else { # exclude point symbols symbols <- list( + ice=ice, + sand=sand, + bare_rock=bare_rock, canopy=canopy, contours=contours, water=water diff --git a/symbols.json b/symbols.json index af9bc97..1cfcc18 100644 --- a/symbols.json +++ b/symbols.json @@ -59,13 +59,15 @@ } }, "314": { - "name": "Ice", + "name": "Ice/Snow", "blocks": { "ground": [ "ice", "packed_ice", "blue_ice", - "frosted_ice" + "frosted_ice", + "snow", + "snow_block" ] } },