Add interactive map placement and sizing editor

This commit is contained in:
lucio committed 2026-08-08 16:40:09 -07:00
1 parent 9e7ff82280
commit 3abdc95500
14 files changed
+647 -81

No files matched your search

+42 -21
View File
@@ -109,13 +109,13 @@ expressed here.
internally; you never author in this space.
**3. Overall-map pixels (rotated)** — the same image after
`rotate(world.rotate, expand=True)`, currently 1816 × 1812 at 35°. **This is
`rotate(world.rotate, expand=True)`, currently 1842 × 1842 at 45°. **This is
where `place` lives**, because it is the north-up image you actually look at.
`tools/place_preview.py` draws a 100 px grid over it so you can read
coordinates directly.
**4. World pixels** — rotated overall-map pixels × `world.overallScale` (64).
The world is 116 160 × 115 968. Tiles, origins and Leaflet coordinates all use
The world is 117 824 × 117 824. Tiles, origins and Leaflet coordinates all use
this space.
In the viewer, a Leaflet `LatLng` is `(y, x)` in world pixels at native
@@ -157,7 +157,7 @@ every zoom level. That holds only when the origin is a multiple of
cellSize = tileSize · 2^maxZoom = 256 · 2^9 = 131 072 world pixels
```
131 072 px is larger than the entire world (116 160 px). Useless for
131 072 px is larger than the entire world (117 824 px). Useless for
positioning — every map would land at (0, 0).
**The fix is to pad, not to snap.** The tiler:
@@ -284,7 +284,7 @@ around 8 GB for the largest PSDs.
| `maxZoom` | 9 | World zoom depth; sets `cellSize = tileSize · 2^maxZoom` |
| `attribution` | HTML | Shown in the viewer; **must** keep the re3mr credit |
| `world.image` | path | The base map |
| `world.rotate` | 35 | Degrees counter-clockwise to put north up |
| `world.rotate` | 45 | Degrees counter-clockwise to put north up |
| `world.overallScale` | 64 | World pixels per overall-map pixel |
### Per map
@@ -297,11 +297,18 @@ around 8 GB for the largest PSDs.
| `baseLayers` | yes | Slash-paths from the document root; everything else hidden |
| `excludeLayers` | no | Layer names to hide anywhere inside the kept set |
| `crop` | no | `[x0, y0, x1, y1]` in PSD pixels, or `null` |
| `place` | yes | `{cx, cy, w}` in **rotated** overall-map pixels |
| `minZoom` | no | Raise the automatically derived zoom at which a nested detail layer appears |
| `place` | yes | `{cx, cy, w, h?}`: center anchor and dimensions in **rotated** overall-map pixels |
| `pxPerMeter` | no | From the map's scale bar; recorded for future use |
`place.w` is the map's width in overall-map pixels; height follows from the
source aspect ratio.
`place.w` is the map's width in overall-map pixels. Height follows from the
source aspect ratio unless optional `place.h` is set, in which case width and
height can be tuned independently.
`minZoom` is normally derived from placed size so a layer does not load while
it would be a speck. An explicit value is a lower visibility bound: it can
delay a nested detail layer until a closer zoom, but cannot force it to appear
earlier than the automatic threshold or above its native tile level.
**Changing `world.rotate` by hand will move every map**, because `place` lives
in the rotated frame. Use `python tools/retilt.py <deg>`, which converts each
@@ -318,9 +325,9 @@ a map is a data change.
{
"tileSize": 256,
"maxZoom": 9,
"worldSize": [116160, 115968],
"worldSize": [117824, 117824],
"cellSize": 131072,
"rotate": 35.0,
"rotate": 45.0,
"overallScale": 64.0,
"attribution": "Maps by <a href=\"https://re3mr.com\">re3mr.com</a> · CC BY-NC-SA 4.0",
"maps": [
@@ -410,6 +417,20 @@ LAN. The boost switches itself off on a 1:1 display with integer zoom.
- Mobile: `viewport-fit=cover`, safe-area insets, 44 px touch targets,
collapsible picker, zoom buttons hidden under 640 px in favour of pinch.
### Placement editor
Each detail map's `place.cx/cy` is its center anchor in rotated overall-map
pixels. Select a map and choose **Edit placement** to expose that anchor. A
drag or numeric X/Y edit translates the map's dedicated Leaflet pane live.
Width and Height scale the same pane independently around the anchor, providing
horizontal and vertical stretch with a live aspect-ratio readout.
**Save & rebuild** posts the new center and dimensions to `server/serve.py`.
The server writes `maps.json` atomically, runs a tiles-only build for that map,
and returns only after `world.json` contains its new origin, size and
cache-busting version. Use
`pwsh server/run.ps1 -Editable`; the Caddy-only mode remains read-only.
---
## 9. Serving
@@ -547,7 +568,7 @@ Two attempts failed:
filled region came out at 2 % coverage with elongation 1.24 against the
PSD's 3.73.
The current **35°** is a visual judgement, not a measurement. `retilt.py` makes
The current **45°** is a visual judgement, not a measurement. `retilt.py` makes
it a one-number change.
### PowerShell here-strings in Bash
@@ -612,21 +633,21 @@ whose tiles were deleted. Re-run `build.py`.
## 14. Current state
World 116 160 × 115 968 px, `maxZoom` 9, rotated 35°. Ten layers, **6096 tiles,
World 117 824 × 117 824 px, `maxZoom` 9, rotated 45°. Ten layers, **6101 tiles,
45.1 MB**.
| Layer | Origin | World size | Zooms | Tiles | Size |
| --- | --- | --- | --- | --- | --- |
| overall (base) | 0, 0 | 116160 × 115968 | z0–3 | 85 | 0.3 MB |
| woods | 39936, 34825 | 24320 × 16365 | z2–7 | 466 | 4.2 MB |
| shoreline | 37184, 72904 | 24320 × 13680 | z2–7 | 506 | 3.1 MB |
| lighthouse | 27360, 61385 | 17600 × 16110 | z3–8 | 1580 | 16.2 MB |
| customs | 53600, 58752 | 16960 × 6529 | z3–8 | 646 | 9.3 MB |
| reserve | 46208, 64296 | 8960 × 5040 | z4–8 | 277 | 1.7 MB |
| shoreline-resort | 40192, 74716 | 8320 × 4680 | z4–9 | 924 | 2.4 MB |
| streets | 67584, 26111 | 7040 × 4481 | z4–9 | 713 | 2.8 MB |
| interchange | 70112, 54098 | 6080 × 3420 | z4–9 | 392 | 3.3 MB |
| customs-dorms | 63040, 61190 | 4480 × 5108 | z5–9 | 507 | 1.9 MB |
| overall (base) | 0, 0 | 117824 × 117824 | z0–3 | 85 | 0.2 MB |
| woods | 38272, 37001 | 24320 × 16365 | z2–7 | 486 | 4.2 MB |
| shoreline | 41920, 75016 | 24320 × 13680 | z2–7 | 498 | 3.1 MB |
| lighthouse | 30560, 65929 | 17600 × 16110 | z3–8 | 1639 | 16.2 MB |
| customs | 55072, 58944 | 16960 × 6529 | z3–8 | 623 | 9.3 MB |
| reserve | 48704, 66408 | 8960 × 5040 | z4–8 | 287 | 1.7 MB |
| shoreline-resort | 44544, 77724 | 8320 × 4680 | z6–9 | 871 | 2.4 MB |
| streets | 63104, 25215 | 7040 × 4481 | z4–9 | 707 | 2.8 MB |
| interchange | 70368, 52434 | 6080 × 3420 | z6–9 | 375 | 3.3 MB |
| customs-dorms | 64768, 60806 | 4480 × 5108 | z6–9 | 530 | 1.9 MB |
Verified across zoom 0–9: zero broken tiles; every tile carries `?v=`; the
focused map is topmost in all seven tested cases.