Files
TarkovMaps/PLAN.md
T
Claude 6c2bd6d27b Serve tiles with Caddy; fix serve.py falling back to HTTP/1.0
serve.py inherited SimpleHTTPRequestHandler's HTTP/1.0 default, which
closes the socket after every response. A map view pulls ~30 tiles, so
that was ~30 TCP handshakes per pan. Setting HTTP/1.1 more than doubled
loopback throughput on its own.

That still leaves thread-per-connection behind the GIL. Measured over 480
tile requests on reused connections:

  conc  8   serve.py 2,622 req/s p95 4.0ms  |  caddy 6,987 req/s p95 1.9ms
  conc 32   serve.py   462 req/s max 1013ms |  caddy 5,877 req/s max  21ms

serve.py does not merely slow down under load, its throughput falls and
tail latency crosses a second. Caddy stays flat, so it is now the default.

run.ps1 picks Caddy when server/caddy.exe is present and falls back to
serve.py, so a fresh clone still works with nothing installed.
get-caddy.ps1 fetches the binary; it is gitignored.

HTTP/2 is not active: browsers only negotiate h2 over TLS, and trusting a
local CA on every phone is not worth it on a LAN. The gain is Go's I/O.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-08-08 02:20:39 -07:00

12 KiB
Raw Blame History

TarkovMap — Project Plan

Self-hosted, mobile-friendly Escape from Tarkov map viewer on Leaflet. Layered PSDs in, XYZ tile pyramid out, every map placed on one shared pannable canvas.

Status legend: [ ] not started · [~] in progress · [x] done · [!] blocked Every stage lists Owner, Depends on, and Done when. Don't tick [x] until Done when is objectively true.

Revision 2 (2026-08-07) — scope narrowed to base map art only; marker, spawn and label overlays are cut. Architecture changed from "one pyramid per map plus a switcher" to a single shared world canvas holding unrelated maps side by side. Phase 1 is built and running.


1. Goals / Non-goals

Goals

  • Extract only the base map from each PSD. No markers, spawns, extracts, captions, legends or titles.
  • All maps — including ones with no geographic relationship, like Customs and its Dorms floor plans — live on one big canvas you pan across.
  • Adding a map is a config change, never a code change, and never re-tiles existing maps.
  • Fast on a phone over LAN.
  • A flow a teammate can follow from a document without asking questions.

Non-goals

  • Marker / spawn / extract overlays (cut in revision 2 — see §8 backlog).
  • Public internet hosting (licence constrains this — §3).
  • Accounts, editing UI, quest tracking, live player position.

2. Source audit — findings [x]

Measured 2026-08-07 from the two supplied PSDs.

Customs Customs — Dorms
PSD canvas 7832 × 5016 4301 × 4904
PSD size 1.09 GB, 295 layers 198 MB
Base group LOCATION LOCATION
Siblings dropped LEGEND, OVERLAYS, TITLE SECTION OVERLAY, LEGEND, TITLE, Credits
Extra exclusion Map Borders (see §6) none
Crop applied [0, 860, 7832, 3875] → 7832 × 3015 none (art fills canvas)
Scale ≈ 7.39 px/m from the scale bar not marked
Render time 158 s 321 s
Tiles 503 (8.4 MB) 469 (1.4 MB)

Both PSDs use the same top-level convention — LOCATION next to OVERLAY, LEGEND, TITLE. That is what makes "render one group, drop the rest" a general rule rather than a Customs special case. Expect it to hold for other re3mr maps; verify per map at step 1 of the runbook.

Licence in both files: CC BY-NC-SA 4.0, "Made by re3mr.com".


3. Constraints

  • CC BY-NC-SA 4.0. Attribution stays visible in the viewer; non-commercial only; derived map images inherit the licence. LAN use is fine. Sign-off required before public hosting.
  • Source art never enters git. 1.09 GB + 198 MB + a 608 MB archive for one map. .gitignore covers sources/, *.psd, *.7z, build/, web/tiles/.
  • Tooling on the build machine: Python 3.13, Pillow 12, psd-tools 1.18 + scikit-image, Node 22. No ImageMagick / libvips / GDAL needed.

4. Architecture — as built

# Decision Notes
A1 Leaflet + custom CRS.Simple, XYZ pyramid LatLng is (y, x) in world pixels at native resolution
A2 256 px tiles, zoom 0–5, 1:1 at z5 ~500 tiles per map; z0 is a whole-cell thumbnail
A3 WebP q82, transparent padding on edge tiles 9.8 MB for both maps combined
A4 Chrome cropped away, not rebuilt Scope is base art only, so there is no legend to rebuild
A5 Shared world canvas on an 8192 px grid See below — this is the core of revision 2
A6 maps.json in, web/data/world.json out The app hard-codes nothing about any map
A7 Dependency-free static server, long cache on tiles Caddy/nginx drop-in later if wanted
A8 Pure-Python pipeline (psd-tools + Pillow) No native binaries to install on three machines
A9 excludeLayers escape hatch Needed because psd-tools fills stroke-only vector shapes
A10 Coarse underlay layer per map at underlayZoom (2) Whole world = 17 tiles / 134 KB, on screen in ~120 ms; detail tiles draw over it, so loading gaps never show black

The world grid (A5)

Each map is tiled independently, numbered from its own top-left corner. A map in grid cell (gx, gy) sits at world pixel (gx · cellSize, gy · cellSize) where

cellSize = tileSize · 2^maxZoom = 256 · 32 = 8192

At that cell size the tile-index shift is exactly gx · 2^z at every zoom — always an integer. So getTileUrl converts world tile coords to a map's local ones with integer arithmetic and no resampling.

Consequences, and the reason this design was chosen:

  • Adding a map never re-tiles another map.
  • Unrelated maps share one continuous, pannable canvas.
  • A map must fit one cell (8192²). maxZoom + 1 doubles the cell.

Current layout: Customs (0,0), Customs — Dorms (1,0).


5. Repository layout

maps.json          the only file you edit to add or change a map
tools/
  psd_tree.py      inspect a PSD's layer tree
  export_base.py   PSD -> build/<id>/base.png   (base group only)
  tile.py          base.png -> web/tiles/<id>/{z}/{x}/{y}.webp
  build.py         orchestrator; writes web/data/world.json
  preview.py       stitch built tiles into one overview image
  common.py        config loading + world-grid maths
server/serve.py    static server, LAN-reachable, cache headers
web/               index.html, app.js, style.css, vendored Leaflet 1.9.4
docs/adding-a-map.md
sources/ build/ web/tiles/     gitignored

6. Known issues

Issue Impact Status
psd-tools fills stroke-only vector shape layers as solid colour Customs rendered white over the whole playable area until Map Borders was excluded Worked around via excludeLayers; documented as a check in the runbook
Excluding Map Borders also removes the playable-area boundary outline Customs no longer shows the dotted play-area edge; the out-of-bounds grey-out still marks it Accepted. Revisit only if the boundary is missed
No retina / DPR-2 tiles Slightly soft on high-DPI phones at 1:1 Stage 7
flyToBounds depends on requestAnimationFrame Picker doesn't move the view in a non-compositing tab Cosmetic; not seen in a real browser
Dorms has no scale bar No px/m for that map Fine — pxPerMeter is optional

7. Stages

Phase 1 — pipeline and viewer ✅ complete

Stage 0 — Repo foundations [x]

  • git init, .gitignore covering sources, build output and tiles
  • Directory skeleton, tools/requirements.txt
  • README.md with quickstart
  • Sources moved to sources/customs/
  • Verified nothing large is tracked — 0.43 MB staged
  • Decide where master PSDs live for the team (shared drive / NAS / Syncthing) and record the path in the README

Stage 1 — Source audit [x]

  • Dimensions, layer trees, blend modes, masks for both PSDs
  • Identified the shared LOCATION convention
  • Derived 7.39 px/m for Customs
  • Confirmed CC BY-NC-SA 4.0

Stage 2 — Contracts [x]

  • maps.json schema — the single input contract
  • web/data/world.json — the single output contract the app reads
  • Tile URL scheme tiles/{id}/{z}/{x}/{y}.webp, XYZ, y-down
  • Coordinate spec: LatLng = (y, x) in world pixels; grid maths in common.py
  • docs/adding-a-map.md written as the runbook

Stage 3 — Extraction [x]

  • psd_tree.py for onboarding inspection
  • export_base.py renders one named group, drops all siblings
  • excludeLayers escape hatch for the shape-fill bug
  • Warns loudly when an excludeLayers entry matches nothing
  • Both maps verified by eye — no markers, labels, legends or titles survive

Stage 4 — Tiler [x]

  • Crop, Lanczos pyramid, 256 px WebP tiles, z0–z5
  • Edge tiles padded to square with alpha; fully-empty tiles skipped
  • Rejects a map too large for its grid cell with an actionable message
  • build.py orchestrates and emits world.json; skips the slow render when base.png is current
  • Partial builds keep other maps in world.json

Stage 5 — Viewer [x]

  • Vendored Leaflet 1.9.4 (no CDN — must work offline on LAN)
  • Custom CRS, world grid, per-map OffsetTileLayer with bounds
  • Map picker, URL hash state, non-dismissible attribution
  • Minimal dark UI, maxNativeZoom over-zoom, transparent errorTileUrl
  • Verified in-browser: 972 tiles, zero 404s, zero broken tiles, correct cross-map offsets

Stage 6 — Serving [~]

  • server/serve.py — dependency-free, binds 0.0.0.0, prints the LAN URL
  • image/webp MIME, tiles cached 7 days, app shell uncached
  • Fixed serve.py defaulting to HTTP/1.0 (a TCP handshake per tile); now HTTP/1.1 keep-alive
  • Benchmarked and added Caddy as the default engine — serve.py collapses to 462 req/s at concurrency 32 while Caddy holds 5,877
  • run.ps1 picks Caddy when present, falls back to serve.py; get-caddy.ps1 fetches the binary
  • Verified through Caddy: immutable + ETag on tiles, no-cache + zstd on the shell, bare 404 for missing tiles
  • Windows Firewall rule for the port
  • Confirm from a phone on the LAN and record the URL in the README

Phase 2 — verification and hardening ← next

Stage 7 — Mobile pass

Owner: __ · Depends on: 6

  • Viewport meta with viewport-fit=cover, safe-area insets, 44 px touch targets
  • Collapsible picker; zoom buttons hidden under 640 px in favour of pinch
  • Test on a real iOS Safari and a real Android Chrome over LAN — nothing here is proven until this happens
  • Check pinch, double-tap and inertial pan don't fight page scroll
  • Decide on retina: one extra zoom level vs. @2x tiles vs. accept
  • First-paint budget on LAN (target ~2 s)

Stage 8 — Third map by someone else

Owner: __ · Depends on: 2

The real test of the runbook is a person who has not seen the pipeline.

  • Pick a third map (Factory is the fastest loop; Woods/Streets stress size)
  • A teammate adds it using only docs/adding-a-map.md
  • Every question they have to ask is a documentation bug — fix the doc
  • Confirm the LOCATION convention holds; if it doesn't, note the variant
  • Confirm no map needs more than one grid cell

Stage 9 — Grid ergonomics

Owner: __ · Depends on: 8

  • Decide grid layout policy as map count grows (gridCols is currently 4)
  • Consider labelling each map on the canvas at low zoom, so the overview is readable
  • Consider per-map maxBounds snapping so panning between maps feels deliberate

Phase 3 — backlog (only if wanted)

  • Measure tool using pxPerMeter (Customs has it; Dorms doesn't)
  • PWA / offline tile caching for phones that leave the LAN
  • PMTiles single-file archives instead of loose tiles — revisit around 5+ maps
  • Marker/overlay layers — cut in revision 2. The PSDs make this cheap to revive: every marker is its own layer with a known bbox, so positions can be extracted programmatically rather than hand-placed
  • Restore the Customs playable-area boundary, if its absence turns out to matter

8. Parallelisation

Phase 1 is done, so the tracks are narrower now:

Track Stages Skills
Mobile / frontend 7 JS, Leaflet, touch CSS, real devices
Content 8 Photoshop-adjacent; mostly following the runbook
Ops 6 tail Windows networking, firewall

Stages 7 and 8 are fully independent — run them in parallel.


9. Open questions

  1. Where do master PSDs live so every contributor can reach them? (blocks Stage 0's last item)
  2. Which maps next, and in what order?
  3. Is public hosting ever intended? Changes the licence conversation entirely.
  4. Does the missing Customs play-area boundary matter enough to restore?

Last updated: 2026-08-07 · Phase 1 complete and verified; Phase 2 next.