Placements are approximate, so map rectangles overlap where the real locations do not -- Reserve clips Customs, Lighthouse clipped Shoreline. Sampling the rendered tiles showed the stacking was technically fine (finer map always on top) but that did not help: an overlapping neighbour still covered the map you had navigated to. Stacking is now explicit. Baseline order is by maxNativeZoom then footprint so the finer map wins, and whichever map the view is centred on is lifted above everything else. Verified for Shoreline, Lighthouse, Customs, Reserve and Woods: each becomes topmost when centred. Tilt raised 31 -> 35 degrees. The original 31 came from fitting the Customs zone outline's aspect ratio, but that polygon encloses more than the playable strip so the estimate ran low; attempts to register the two polygons directly failed because the dashed outline will not flood-fill. 35 aligns better by eye. `place` lives in the rotated frame, so retilt.py converts every placement through the old and new angles -- changing the tilt no longer scatters the maps. Lighthouse's box also tightened; its PSD is nearly square while the zone is a coastal strip, so it overhung into the sea. Verified zoom 0-9: 620 tiles, zero broken. Co-Authored-By: Claude Opus 5 <[email protected]>
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
"""Change world.rotate without losing every map's position.
|
|
|
|
python tools/retilt.py 35
|
|
|
|
`place` coordinates live in the ROTATED frame, so changing the tilt would
|
|
otherwise move every map. This converts each `place` back through the old
|
|
rotation and forward through the new one, then writes both the new angle and
|
|
the converted coordinates to maps.json. Geography is preserved; only the tilt
|
|
changes.
|
|
|
|
Re-run `tools/place_preview.py` afterwards to check, then
|
|
`tools/build.py --tiles-only` to retile.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import sys
|
|
|
|
from common import CONFIG, load_config, rotate_point, unrotate_point
|
|
|
|
|
|
def main() -> None:
|
|
if len(sys.argv) != 2:
|
|
raise SystemExit(__doc__)
|
|
new_deg = float(sys.argv[1])
|
|
|
|
cfg = load_config()
|
|
old_deg = cfg.rotate
|
|
bw, bh = cfg.base_size()
|
|
if abs(new_deg - old_deg) < 1e-9:
|
|
print(f"rotate is already {old_deg}; nothing to do")
|
|
return
|
|
|
|
raw = json.loads(CONFIG.read_text(encoding="utf-8"))
|
|
print(f"rotate {old_deg} -> {new_deg} (base {bw}x{bh})\n")
|
|
print(f"{'map':<18} {'old cx,cy':>14} {'new cx,cy':>14}")
|
|
for m in raw["maps"]:
|
|
p = m.get("place")
|
|
if not p:
|
|
continue
|
|
sx, sy = unrotate_point(p["cx"], p["cy"], bw, bh, old_deg)
|
|
nx, ny = rotate_point(sx, sy, bw, bh, new_deg)
|
|
print(f"{m['id']:<18} {p['cx']:>6.0f},{p['cy']:>6.0f} {nx:>6.0f},{ny:>6.0f}")
|
|
p["cx"], p["cy"] = round(nx), round(ny)
|
|
|
|
raw["world"]["rotate"] = new_deg
|
|
CONFIG.write_text(json.dumps(raw, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
|
|
print(f"\nwrote {CONFIG.name}; now run place_preview.py and build.py --tiles-only")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|