Add permanent trims and semantic map layers

This commit is contained in:
lucio committed 2026-08-08 18:47:56 -07:00
1 parent 3abdc95500
commit e71447da5d
13 files changed
+1929 -114

No files matched your search

+51 -4
View File
@@ -300,15 +300,23 @@ around 8 GB for the largest PSDs.
| `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 |
| `trim` | no | `{points, outsideTransparency}` playable-area polygon; see below |
| `parent` | no | parent map id for grouped navigation and dropdown ordering |
`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.
Detail layers default to `minZoom: 0`, keeping main location maps visible in
the overview. An explicit `minZoom` delays a nested detail layer until a closer
zoom, and cannot be set above its native tile level.
`trim.points` is a list of `[x, y]` vertices normalized to the map rectangle,
where both axes run from 0 to 1. Normalization keeps the boundary attached when
the map is moved or stretched. `outsideTransparency` runs from 0 (unchanged)
to 1 (fully transparent). Saving generates `build/<id>/trimmed.png` and a
separate `web/tiles-trimmed/<id>/` pyramid; `base.png` and the original tile
pyramid remain available and unchanged.
**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
@@ -354,6 +362,21 @@ of the map's geometry, zoom range and source file stamp — see §11.
## 8. The viewer
### Semantic PSD markers
`tools/extract_markers.py` reads PSD layer metadata only; it never composites
marker pixels. Visible leaves in on-map overlay/marker groups are classified,
normalized against the configured crop, and deduplicated when a PSD icon and
text component share the same point. Legends, credits, titles, compass art and
large region overlays are excluded. The generated `web/data/markers.json`
contains `{mapId, x, y, category, label, source}` records.
The viewer converts normalized coordinates through each map's current
`origin`/`size`, so placement and stretch changes also move the marker layer.
One **Markers** control toggles the complete layer. Focus limits rendering to
the active parent/sub-map family, while consistent CSS category symbols remain
visible at broad zooms and labels appear from zoom 6.
`web/app.js`, 179 lines, no build step, no framework, vendored Leaflet.
### Layers
@@ -425,12 +448,36 @@ 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.
Placement editing temporarily hides any trim overlay and renders the complete
selected map at exactly 50% opacity, making underlying satellite landmarks
visible during alignment.
**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.
### Trim editor
**Trim area** authors a single playable-area polygon. Map clicks append points;
points are draggable, and Undo/Clear support correction. The outside
transparency slider previews the result immediately.
While editing, the untouched tile pane and a clipped duplicate provide an
immediate preview without rebuilding on every drag. **Save trim** posts the
normalized points and transparency to `/api/trim`; the server writes
`maps.json`, bakes the outside alpha into `build/<id>/trimmed.png`, and creates
a separately versioned `web/tiles-trimmed/<id>/` pyramid. The normal viewer
then uses those already-rasterized tiles with no dynamic CSS mask. Clearing and
saving a trim returns the viewer to the original tiles. The trim-only build
leaves both `base.png` and `web/tiles/<id>/` untouched.
The original rectangle remains the raster/tile coordinate frame so alignment
does not move. The viewer separately derives a viewable bounding box and exact
point-in-polygon hit area from `trim.points`; map-button focusing and automatic
active-map selection therefore follow the saved playable zone.
---
## 9. Serving