Version tile URLs so rebuilt maps cannot serve a previous build
Tile paths are stable across rebuilds but their contents are not: moving a map's `place` makes tiles/<id>/6/17/33.webp different imagery at the same URL. Combined with the immutable week-long cache added earlier, a browser that had seen an older build blended the two and drew duplicated, offset terrain -- visible as a second copy of Lighthouse. Each map now carries a `version` in world.json, hashed from its geometry, zoom range and source file stamp, and appended to every tile URL as ?v=. Re-tiled maps get fresh URLs; identical rebuilds keep the same version so nothing is re-fetched needlessly. Also corrects the runbook's base-layer table, which still listed the pre-correction layers for Woods, Reserve, Interchange and Streets. Verified: 733 tiles across seven map views, all carrying ?v=, zero broken, and the focused map topmost in every case. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
1 parent
e656c7c96a
commit
f49a00bc98
4 files changed
+50
-10
No files matched your search
@@ -91,6 +91,18 @@ The base map is the backdrop. It is 85 tiles / 0.3 MB, always resident, and
|
||||
Leaflet upscales it past its native z3 — so any gap while detail tiles load
|
||||
shows blurry terrain rather than the page background.
|
||||
|
||||
## Cache busting
|
||||
|
||||
Tile paths are stable across rebuilds but their contents are not — move a map's
|
||||
`place` and `tiles/<id>/6/17/33.webp` becomes different imagery. Tiles are
|
||||
served `immutable` for a week, so a browser that saw the old build would blend
|
||||
it with the new one and show duplicated, offset terrain.
|
||||
|
||||
Each map therefore carries a `version` in `world.json` — a hash of its
|
||||
geometry, zoom range and source file stamp — appended to every tile URL as
|
||||
`?v=`. Re-tile a map and it simply gets fresh URLs. Identical rebuilds keep the
|
||||
same version, so nothing is re-downloaded needlessly.
|
||||
|
||||
## Stacking
|
||||
|
||||
Placements are approximate, so map rectangles overlap where the real locations
|
||||
|
||||
+19
-9
@@ -30,16 +30,22 @@ you have to look each time:
|
||||
| Map | Base layers |
|
||||
| --- | --- |
|
||||
| Customs, Customs Dorms | `LOCATION` |
|
||||
| Woods | `re3mr.com/Map&Art` (nested inside a wrapper group) |
|
||||
| Woods | `re3mr.com/Map&Art/Map&OverlayArt/{RawMapLayer,WaterDetail}` |
|
||||
| Lighthouse | `Day` (there is also a hidden `Night`) |
|
||||
| Shoreline | `Baselayer` |
|
||||
| Shoreline Resort | `BGCOLOR PATTERN`, `BASEMAP+2DLAYERS` |
|
||||
| Interchange | `Background`, `3DRENDER` |
|
||||
| Reserve | `Day copy`, `Color Fill 1`, `Group 5` |
|
||||
| Streets | `Layer 1`, `Map - 3D map portion…` |
|
||||
| Interchange | `3DRENDER` |
|
||||
| Reserve | `Day copy` |
|
||||
| Streets | `Map - 3D map portion…` |
|
||||
|
||||
Note the two shapes this takes: several maps need **more than one** top-level
|
||||
layer, and some bury the art **inside a wrapper group** (use a slash path).
|
||||
Note the shapes this takes: several maps need **more than one** top-level
|
||||
layer, and some bury the art **inside wrapper groups** (use a slash path —
|
||||
Woods is three deep).
|
||||
|
||||
Watch for layers that are really just plates. Interchange's `Background` and
|
||||
Reserve's `Color Fill 1` are solid white; Woods' `MapBlackout` and Streets'
|
||||
`Layer 1` are solid black. Including them hides the terrain underneath, so
|
||||
leave them out.
|
||||
|
||||
Also note any `shape` layers — psd-tools renders stroke-only vector shapes as
|
||||
solid fills, so they may need `excludeLayers`.
|
||||
@@ -53,10 +59,10 @@ solid fills, so they may need `excludeLayers`.
|
||||
"id": "woods",
|
||||
"name": "Woods",
|
||||
"psd": "sources/woods/woods.psd",
|
||||
"baseLayers": ["re3mr.com/Map&Art"],
|
||||
"baseLayers": ["re3mr.com/Map&Art/Map&OverlayArt/RawMapLayer"],
|
||||
"excludeLayers": [],
|
||||
"crop": null,
|
||||
"place": { "cx": 818, "cy": 652, "w": 380 }
|
||||
"place": { "cx": 814, "cy": 672, "w": 380 }
|
||||
}
|
||||
```
|
||||
|
||||
@@ -92,7 +98,7 @@ A failed map no longer aborts the batch; check the summary at the end.
|
||||
## 4. Position it on the world map
|
||||
|
||||
The base of the canvas is `sources/overall/overall.jpeg`, rotated by
|
||||
`world.rotate` (31°) so north is up. `place` is in **rotated overall-map
|
||||
`world.rotate` (35°) so north is up. `place` is in **rotated overall-map
|
||||
pixels** — the north-up image you actually look at.
|
||||
|
||||
```bash
|
||||
@@ -156,6 +162,10 @@ python tools/build.py --force-export # re-render even if base.png is current
|
||||
`build.py` skips the PSD render when `base.png` is newer than the PSD, so
|
||||
iterating on `place` and `crop` is seconds, not minutes.
|
||||
|
||||
Retiling a map changes its `version` in `world.json`, which is appended to its
|
||||
tile URLs as `?v=`. That is what stops a browser mixing a previous build's
|
||||
tiles with the new ones — you do not need to hard-reload after a rebuild.
|
||||
|
||||
---
|
||||
|
||||
## How placement works
|
||||
|
||||
@@ -18,6 +18,7 @@ identical to upscaling here but without storing the tiles.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import math
|
||||
import shutil
|
||||
import sys
|
||||
@@ -108,6 +109,19 @@ def tile_map(cfg: Config, m: dict) -> dict:
|
||||
f"@({round(x0)},{round(y0)}) z{min_zoom}-{native_level} "
|
||||
f"{written} tiles ({skipped} empty), {size_mb:.1f} MB")
|
||||
|
||||
# Tile URLs are stable across rebuilds but their *contents* are not: move a
|
||||
# map's `place` and tiles/<id>/6/17/33.webp is suddenly different imagery.
|
||||
# Since tiles are served immutable for a week, a browser that saw the old
|
||||
# build would blend it with the new one. This version stamp goes into the
|
||||
# URL so a rebuilt map simply gets fresh URLs.
|
||||
stamp = f"{x0:.1f},{y0:.1f},{tw:.1f},{th:.1f},{min_zoom},{native_level},{written}"
|
||||
if m["id"] != WORLD_ID:
|
||||
st = (BUILD / m["id"] / "base.png").stat()
|
||||
stamp += f",{int(st.st_mtime)},{st.st_size}"
|
||||
else:
|
||||
st = cfg.base_image_path().stat()
|
||||
stamp += f",{int(st.st_mtime)},{st.st_size},{cfg.rotate},{cfg.overall_scale}"
|
||||
|
||||
return {
|
||||
"id": m["id"],
|
||||
"name": m["name"],
|
||||
@@ -117,6 +131,7 @@ def tile_map(cfg: Config, m: dict) -> dict:
|
||||
"minZoom": min_zoom,
|
||||
"maxNativeZoom": native_level,
|
||||
"base": m["id"] == WORLD_ID,
|
||||
"version": hashlib.sha1(stamp.encode()).hexdigest()[:8],
|
||||
"pxPerMeter": m.get("pxPerMeter"),
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -23,11 +23,13 @@ const OffsetTileLayer = L.TileLayer.extend({
|
||||
getTileUrl(coords) {
|
||||
const o = this.options;
|
||||
const perCell = (o.baseTileSize * 2 ** coords.z) / o.tileSize;
|
||||
// ?v= busts the week-long immutable cache when a map is re-tiled; the same
|
||||
// URL would otherwise serve a previous build's imagery.
|
||||
return L.Util.template(this._url, {
|
||||
z: coords.z + o.zoomOffset,
|
||||
x: coords.x - o.cell[0] * perCell,
|
||||
y: coords.y - o.cell[1] * perCell,
|
||||
});
|
||||
}) + (o.version ? `?v=${o.version}` : '');
|
||||
},
|
||||
});
|
||||
|
||||
@@ -110,6 +112,7 @@ async function main() {
|
||||
const layer = new OffsetTileLayer(`tiles/${m.id}/{z}/{x}/{y}.webp`, {
|
||||
cell: m.cell,
|
||||
bounds: rectOf(m),
|
||||
version: m.version,
|
||||
baseTileSize: world.tileSize,
|
||||
tileSize: world.tileSize / 2 ** boost,
|
||||
zoomOffset: boost,
|
||||
|
||||
Reference in new issue
Block a user