Implement track export for bluemap, ignore for mapcrafter
All checks were successful
Build maps / build-mapcrafter (push) Successful in 28s
Build maps / build-bluemap (push) Successful in 29s

This commit is contained in:
2025-12-17 01:36:07 +09:00
parent 1b3a7d0e90
commit be638b2ade
2 changed files with 27 additions and 6 deletions

View File

@@ -1,10 +1,10 @@
import json
from pathlib import Path
from textwrap import indent
from typing import Any
from pathlib import Path
from lib_marker import Point, Track
from marker_sets import WORLDS
from lib_marker import Point
def generate_bluemap_output(output_dir: Path):
@@ -43,6 +43,7 @@ def convert_data_to_bluemap_structure() -> dict:
for marker in marker_set.markers:
if isinstance(marker, Point):
# https://bluemap.bluecolored.de/wiki/customization/Markers.html#poi-markers
result[world_name][slug(marker_set.name)][slug(marker.name)] = {
"type": "poi",
"label": marker.name,
@@ -52,6 +53,21 @@ def convert_data_to_bluemap_structure() -> dict:
"z": marker.z,
},
}
elif isinstance(marker, Track):
# https://bluemap.bluecolored.de/wiki/customization/Markers.html#line-markers
result[world_name][slug(marker_set.name)][slug(marker.name)] = {
"type": "line",
# TODO: Calculate the median point of the track for the label position
"position": {
"x": marker.points[0][0],
"y": marker.points[0][1],
"z": marker.points[0][2],
},
"label": marker.name,
"line": [
{"x": p[0], "y": p[1], "z": p[2]} for p in marker.points
],
}
else:
raise NotImplementedError(f"Unknown marker type: {marker}")
@@ -72,7 +88,7 @@ def to_hocon(x: Any) -> str:
return f"[\n{'\n'.join(items)}\n]"
elif isinstance(x, dict):
items = [
f' "{k}": {indent(to_hocon(v), ' ').removeprefix(' ')}'
f' "{k}": {indent(to_hocon(v), " ").removeprefix(" ")}'
for k, v in x.items()
]
return f"{{\n{'\n'.join(items)}\n}}"

View File

@@ -1,8 +1,8 @@
import json
from pathlib import Path
from lib_marker import Area, Point, Track
from marker_sets import WORLDS
from lib_marker import Point, Track, Area
def generate_mapcrafter_output(output_dir: Path):
@@ -30,6 +30,7 @@ def convert_data_to_mapcrafter_structure() -> dict:
for world_name, world_marker_sets in WORLDS.items():
for marker_set in world_marker_sets:
# https://mapcrafter.readthedocs.io/en/latest/markers.html#manually-specifying-markers
if marker_set.name not in result:
result[marker_set.name] = {
"id": marker_set.name.lower().replace(" ", "-"),
@@ -46,10 +47,14 @@ def convert_data_to_mapcrafter_structure() -> dict:
)
elif isinstance(marker, Track):
raise NotImplementedError("Track markers are not supported")
print(
f"Track markers are not natively supported in Mapcrafter, skipping '{marker.name}'..."
)
elif isinstance(marker, Area):
raise NotImplementedError("Area markers are not supported")
print(
f"Area markers are not natively supported in Mapcrafter, skipping '{marker.name}'..."
)
else:
raise ValueError(f"Unknown marker type: {marker}")