Skip to content

Commit

Permalink
added new landcover symbols: ice, sand, rock
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-mooore committed Aug 18, 2023
1 parent 06aae3b commit 006b285
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 9 deletions.
14 changes: 8 additions & 6 deletions src/convert_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
38 changes: 37 additions & 1 deletion src/create_map.r
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(
Expand Down Expand Up @@ -129,13 +159,19 @@ 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,
trees=trees
)
} else { # exclude point symbols
symbols <- list(
ice=ice,
sand=sand,
bare_rock=bare_rock,
canopy=canopy,
contours=contours,
water=water
Expand Down
6 changes: 4 additions & 2 deletions symbols.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,15 @@
}
},
"314": {
"name": "Ice",
"name": "Ice/Snow",
"blocks": {
"ground": [
"ice",
"packed_ice",
"blue_ice",
"frosted_ice"
"frosted_ice",
"snow",
"snow_block"
]
}
},
Expand Down

0 comments on commit 006b285

Please sign in to comment.