Files
TarkovMaps/README.md
T
Claude e656c7c96a Lift the focused map above overlapping neighbours; tilt to 35 degrees
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]>
2026-08-08 11:37:15 -07:00

191 lines
7.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# TarkovMap
Self-hosted, mobile-friendly Escape from Tarkov map viewer. Layered PSDs go in,
a Leaflet tile pyramid comes out, and every map is placed onto one shared world
canvas — the overall satellite map, rotated so north is up.
Zoom out for the whole of Tarkov; zoom into a location and the full-resolution
re3mr map for it fades in over the terrain.
Only the **base map art** is extracted. Markers, spawns, legends, captions and
titles are dropped during the render.
## Quickstart
```bash
python -m pip install -r tools/requirements.txt
```
```bash
python tools/build.py
```
```bash
pwsh server/get-caddy.ps1
```
```bash
pwsh server/run.ps1
```
Open the printed URL. The LAN address works from a phone on the same network.
`run.ps1` uses Caddy when `server/caddy.exe` is present and falls back to
`serve.py` otherwise, so the first step is optional — see [Serving](#serving).
Source PSDs are not in the repo (see `.gitignore`) — get them from the shared
drive and put them under `sources/`.
## Adding a map
See **[docs/adding-a-map.md](docs/adding-a-map.md)**. Short version: run
`tools/psd_tree.py` to find the group holding the art, add an entry to
`maps.json`, run `tools/build.py`. No application code changes.
## Layout
```
maps.json the only thing 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; also writes web/data/world.json
preview.py stitch built tiles into one overview image
place_preview.py gridded base map for positioning maps
retilt.py change world.rotate, keeping placements
common.py config loading + world placement maths
server/serve.py dependency-free static server with sane cache headers
web/ the site: index.html, app.js, style.css, vendored Leaflet
sources/ gitignored — source PSDs
build/ gitignored — intermediate PNGs
web/tiles/ gitignored — generated tiles
```
## How the shared canvas works
The base is `sources/overall/overall.jpeg`, rotated **35°** so north is up.
(An aspect-ratio fit of the Customs zone outline suggested 31°, but the zone
polygon encloses more than the playable strip so that estimate ran low; 35°
lines the maps up better by eye. Adjust with `tools/retilt.py`, which converts
every placement through the old and new angles so geography is preserved.)
World pixels are overall-map pixels × `overallScale` (64), which puts Customs
at almost exactly its native 7832 px. Each map's `place` entry gives its centre
and width in rotated overall-map pixels, and the tiler scales it to match.
Tile grids must stay integral — a map's tile-index offset has to be a whole
number of tiles at every zoom, which only holds when its origin is a multiple
of `tileSize · 2^maxZoom` (131 072 px). Far too coarse to position anything. So
rather than *moving* a map onto the grid, the tiler **pads** it up-and-left to
the nearest cell boundary and only visits tiles containing real content. Exact
placement, integral grid, and the padding costs nothing.
Each map is tiled only down to its **native level** — the deepest zoom still
downscaling its source — and has a `minZoom` below which it doesn't load at
all. So the overview is just the base map, and detail maps appear as you go in.
## No black gaps
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.
## Stacking
Placements are approximate, so map rectangles overlap where the real locations
don't. Baseline order puts the finer map on top (by `maxNativeZoom`, then
smaller footprint), and on top of that **the map whose centre you are viewing
is lifted above all others** — so an overlapping neighbour can never hide the
map you came to see.
## Current maps
Base: `overall.jpeg` 1308 × 1296 → 1816 × 1812 rotated → world 116 160 × 115 968.
| Map | PSD | Base layers |
| --- | --- | --- |
| Customs | 7832 × 5016 | `LOCATION` |
| Customs — Dorms | 4301 × 4904 | `LOCATION` |
| Woods | 7680 × 5168 | `re3mr.com/Map&Art/Map&OverlayArt/{RawMapLayer,WaterDetail}` |
| Interchange | 9600 × 5400 | `3DRENDER` |
| Reserve | 5760 × 3240 | `Day copy` |
| Shoreline | 5760 × 3240 | `Baselayer` |
| Shoreline — Resort | 10694 × 6016 | `BGCOLOR PATTERN`, `BASEMAP+2DLAYERS` |
| Lighthouse | 8259 × 7560 | `Day` |
| Streets of Tarkov | 7605 × 4841 | `Map - 3D map portion…` |
There is **no shared naming convention** between these PSDs — see
[docs/adding-a-map.md](docs/adding-a-map.md).
## Tile resolution and sharpness
World `maxZoom` is 9, set so the whole 116 160 px world fits the pyramid. Each
map is tiled only to its own **native level** — the deepest zoom still
downscaling its source — recorded as `maxNativeZoom` in `world.json`. The base
map is native at z3; detail maps land at z7–z9.
Those ceilings are real: Customs' embedded terrain smart object is exactly
7832 × 3720 placed 1:1, so there is no hidden detail to recover. Past a map's
native level the browser upscales.
Sharpness is therefore about **level selection**, not pyramid depth. Leaflet
picks its level with `Math.round(mapZoom)`, so at zoom 2.25 it takes level 2 and
stretches it 1.19×. On a 150 %-scaled Windows display (`devicePixelRatio` 1.5)
that compounds to a **1.78× upscale** — visibly soft.
`DENSITY_BOOST` in `app.js` fixes it: halve the CSS size of a tile and request
one level deeper, so we downscale a denser level instead of upscaling a coarser
one. Measured at `devicePixelRatio` 1.5, in source pixels delivered per device
pixel (higher is sharper, 1.0 is pixel-perfect):
| View zoom | Before | After |
| --- | --- | --- |
| below native | 0.56 | **1.33** |
| at native | 0.67 | 0.67 |
It costs ~4× the tiles in view (99 at the busiest level on a 1315 px viewport,
~17 KB each). Cached for a week and served by Caddy, that is a fair trade.
Past a map's native level you are beyond its source resolution and the browser
upscales — unavoidable, and `ZOOM_HEADROOM` deliberately allows one level of it.
## Serving
Two options, both driven by `server/run.ps1`:
| | `serve.py` | Caddy |
| --- | --- | --- |
| Dependencies | none (stdlib) | one 47 MB binary |
| conc 8 | 2,622 req/s · p95 4.0 ms | **6,987 req/s** · p95 1.9 ms |
| conc 32 | 462 req/s · max **1,013 ms** | **5,877 req/s** · max 21 ms |
| ETags / compression | no | yes (zstd, gzip) |
Measured on loopback, 480 tile requests over reused connections.
The number that matters is the second row. `serve.py` is thread-per-connection
behind the GIL, so under load it doesn't just slow down — throughput *falls* and
tail latency goes past a second. Caddy stays flat. Use Caddy for anything real;
`serve.py` exists so a fresh clone works with nothing installed.
`serve.py` was also defaulting to **HTTP/1.0**, which closes the socket after
every response — one TCP handshake per tile, ~30 per map view. It now sets
HTTP/1.1, which is most of its improvement above.
Neither runs HTTP/2: browsers only negotiate h2 over TLS, and putting a
trusted cert on every phone isn't worth it on a LAN. The Caddy win is Go's I/O,
not h2.
To reach it from a phone, allow the port once (elevated):
```bash
netsh advfirewall firewall add rule name="TarkovMap 8080" dir=in action=allow protocol=TCP localport=8080
```
## Licence
Map art is by [re3mr.com](https://re3mr.com) under
**CC BY-NC-SA 4.0**. Attribution is shown in the viewer and must stay there.
Use is non-commercial, and derivative map images inherit the same licence.
Local and LAN hosting is fine; get sign-off before hosting publicly.