mirror of
https://github.com/storytold/lightcraft.git
synced 2026-12-05 13:32:52 -05:00
The Map view fetched tiles from its own pool of six threads with no cache policy, no backoff and two User-Agent headers, and offered Esri's ArcGIS tiles by default. The tile core of PR #797 is ported into the engine (crates/engine/src/map/: mercator, source, cache, service; no new crate) and the view now draws from it: - Tile sources are a library preference (prefs.json mapSource, `map.tileSource`): OpenStreetMap (default), OpenTopoMap, a checked https custom template, or Offline (no service, no threads). `map.providers` lists the sources offered; `map.cacheInfo` and `map.clearCache` report and empty the disk cache. - Fetching follows the OSM tile usage policy: only the tiles in view plus one ring, newest view first with stale requests dropped, at most two requests in flight, exponential backoff on errors/429/5xx honouring Retry-After, one distinct `LightCraft/<version> (+https://github.com/storytold/lightcraft)` User-Agent (fetch's `get` no longer adds a second one), no no-cache, size/content/decode checks. One "Loading map tiles" activity row while tiles are queued. - Disk cache in the per-user cache folder (`<cache>/maptiles`, new `config::cache_dir`), one folder per source: Cache-Control/Expires/ETag with conditional refresh (7 days by default), 500 MB LRU cap, atomic writes, damaged entries refetched. HTTP dates go through chrono. - Sessions fetch only when the host asks (`with_default_map_cache`: desktop app, CLI snapshot, MCP), so tests never go online; the test that hit Esri's server is gone. - UI: one texture cache (256, LRU) for the map and the navigator; a missing tile is drawn from a loaded ancestor up to four zooms up; the service gets the union of the tiles drawn this frame and the last, and nothing once no map is drawn. The credit is always painted bottom right. - `LatLon::new` rejects out-of-range positions instead of clamping them (95° was accepted as the pole); `LatLon::wrapped` wraps longitude. - Esri: their terms (docs/map.md, with URLs) allow the layers only with Esri software or an ArcGIS subscription, so they are not offered, `map.tileSource` refuses them, and a library saved with one opens on OpenStreetMap with a one-line notice while prefs.json keeps the choice. No command turns them on; that needs a maintainer decision. docs/map.md is new; control-protocol, the LRC-MAP-VIEW row and gap 16 are updated. Tests: `cargo xtask ci --quick` (fmt, clippy, tests of every package): all map, fetch, geom, config and UI tests pass; the only failures are the pre-existing ones on this machine (13 lightcraft-raw corpus tests, 2 engine corpus tests, 1 GPU out-of-memory test). `cargo xtask layers`, `assets`, `roots`, `parity` and `wasm` pass. The app was run with `--demo --control 18421` and screenshotted: OSM tiles load in the map and the navigator with the credit, Esri is refused, Offline shows the grey map. Co-Authored-By: Jason Baldwin <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>