Files
lightcraft/docs/map.md
T
f6524ed1c6 LRC-MAP-GEOTAG: drag filmstrip photos onto the Map view to geotag them; filmstrip and selection on the map
The Map view had no filmstrip: only Detail and Compare draw it, and in the Map view the
bottom bar fell into the grid branch, showing a thumbnail-size slider that did nothing
and no filmstrip toggle. So photos could not be dragged onto the map, and the map did not
show which photos were selected beyond a pin colour.

- The Map view draws the shared filmstrip under the map when it is on (View > Filmstrip,
  `/`, F6), as Detail does, and shrinks the map above it (not in full screen, not when the
  window is too short). In the Map view the bottom bar shows the Filmstrip toggle instead
  of the thumbnail size.
- Photos carried from the filmstrip (the drag the filmstrip and grid already start: the
  selection, or the photo alone when it is not selected) draw a pin with their count at
  the pointer over the map, and the drag label says "Set the location of N photos". A
  release over the map gives all of them that point's position, overwriting one they had,
  as one undo step (`photo.setGps`). A release over the map's toolbar or filter bar, or
  outside the map, changes nothing. The longitude wraps around the world and the latitude
  stays inside Web Mercator's 85.05 degrees.
- Selection both ways: a cluster holding selected photos is yellow and carries a bubble
  with how many are selected; a click on a pin selects its photo and a click on a cluster
  selects all its photos (the first active; Cmd/Ctrl adds), so the filmstrip shows them
  and scrolls to the active one. Pins are not hovered or clicked while photos are carried.
- `map.state` (UI command) reports the view, the canvas, whether the filmstrip is drawn,
  each pin drawn last frame with its ids, count and selected count, and a drop in
  progress; it is cleared each frame so it reports nothing once the map is gone.
- `photo.setGps` is extended rather than duplicated: it names its photos explicitly,
  wraps the longitude into -180..180 (it refused 190), refuses ids the library doesn't
  have (it skipped them silently, so a drop of photos deleted meanwhile reported success),
  and its undo step and label are "Set GPS Coordinates"; it now also returns lat/lon.
  This validation follows PR #810 (geotag); the drop itself is written for this branch's
  map view, since #810 builds on #797's cluster and viewport code.

New strings are in every locale catalog. docs/map.md gains "Map view" and "Geotagging"
sections; control-protocol, the LRC-MAP-VIEW and LRC-MAP-GEOTAG rows (geotag stays
partial: no pin move, Lock Markers, Remove GPS menu or sidecar fix yet) and gap 16 are
updated.

Tests: new `ui-egui tests::map_filmstrip` (filmstrip drawn and toggled in the Map view,
bottom bar toggle and no slider; filmstrip drag sets GPS for two photos in one undo
step; a drop on the toolbar or of missing photos changes nothing; selected counts per
pin and a cluster click selecting in the filmstrip) and two engine tests (one undo step
and restore for several photos; longitude wrap and hostile values). Each failed with its
change reverted (filmstrip not drawn; bottom bar branch, drop handler and cluster
selection disabled; old `photo.setGps`). `cargo xtask ci --quick` (fmt, clippy, tests of
every package): all pass except the known failures on this machine (13 lightcraft-raw
corpus tests, 2 engine corpus tests; the GPU out-of-memory test failed in one run and
passed in the other, and ui-egui find_similar::stopping_leaves_the_view_alone... failed
once and passed three times alone). `cargo xtask layers`, `assets`, `roots`, `parity`
and `wasm` pass. The app was run with `--demo --control 18421` and a headless snapshot:
filmstrip under the map, a drag from it dropped two photos at the pointer, selected
counts on the clusters, a cluster click selecting its photos in the filmstrip.

Co-Authored-By: Jason Baldwin <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 00:05:17 -05:00

9.0 KiB
Raw Blame History

Map

The Map view (View ▸ Map, ⌘⌥3 / Ctrl+Alt+3) shows the photos that have a GPS position on a slippy map. This page describes where the map's tiles come from, what is sent over the network, and the commands behind it. Later sections (pins and clusters, the Info panel map, geotagging, the location filter, saved locations, track logs, keys and menus) are filled in as those parts land.

Map view

The filmstrip runs under the map, as in Detail: View ▸ Filmstrip, / (F6), or the Filmstrip button at the right of the bottom bar, which in the Map view takes the place of the grid's thumbnail size. It shows the same photos as the grid. The selection shows both ways:

  • Selected photos' pins are yellow. A cluster holding selected photos is yellow and carries a small blue bubble with how many of its photos are selected.
  • A click on a pin selects its photo; a click on a cluster selects all its photos, the first one active. The filmstrip shows them selected and scrolls to the active one. ⌘-click (Ctrl-click) adds them to the selection instead. A double-click on a pin opens Detail; on a cluster it zooms in.

map.state reports the view (lat, lon, zoom), the map canvas, whether the filmstrip is drawn, every pin or cluster drawn in the last frame (ids, count, selected, screen x / y) and a drop in progress.

Geotagging

Drag photos from the filmstrip onto the map to set where they were taken. The drag carries the selection, or only the photo dragged when it isn't selected. While they are over the map a pin with their count follows the pointer; release to give every one of them that point's position, overwriting a position they had. That is one undo step, "Set GPS Coordinates" (photo.setGps). A release over the map's toolbar or location filter bar, or outside the map, changes nothing. Drops are limited to the map's ±85.05° latitude (the edge of the Web Mercator projection); the longitude of a drop on the world's repeat at low zoom is wrapped into −180…180.

Not yet: moving a pin by dragging it, Lock Markers stopping that, and Remove GPS Coordinates in the Photo menu and a pin's menu (photo.clearGps removes a position today).

Tile sources and cache

The tiles are raster images in the Web Mercator projection (256 px, zoom 0–19). Where they come from is a library preference (prefs.json → mapSource), set with the Map Style list at the bottom of the map or the map.tileSource command:

Source Id Tiles Max zoom Credit shown on the map
OpenStreetMap (default) osm https://tile.openstreetmap.org/{z}/{x}/{y}.png 19 © OpenStreetMap contributors
OpenTopoMap opentopomap https://tile.opentopomap.org/{z}/{x}/{y}.png 17 Map data: © OpenStreetMap contributors, SRTM | Map style: © OpenTopoMap (CC-BY-SA)
Offline offline none: a grey map, nothing is fetched and no tile service runs 19 —
Custom your id an https://…/{z}/{x}/{y}… template you give, with its credit 0–24 the credit you give (required)

The credit of the source in use is always painted at the bottom right of the map, never behind a toggle. A stored source is checked again when the library opens: one that is damaged or not https:// falls back to OpenStreetMap and the rest of prefs.json is kept.

Cache. Tiles are cached on disk in the per-user cache folder: ~/Library/Caches/LightCraft/maptiles on macOS, %LOCALAPPDATA%\LightCraft\Cache\maptiles on Windows, $XDG_CACHE_HOME/lightcraft/maptiles (else ~/.cache/lightcraft/maptiles) elsewhere, <exe dir>/LightCraftData/Cache/maptiles in portable mode, or $LIGHTCRAFT_MAP_CACHE when set. Each source has its own subfolder. The cache follows the server's Cache-Control / Expires headers (7 days when there are none), refreshes an expired tile with a conditional request (If-None-Match / If-Modified-Since; a 304 only renews it) while still showing it, writes atomically (a temporary file renamed into place), deletes and fetches again an entry that is damaged, and stays under 500 MB by deleting the least recently used tiles. map.cacheInfo reports its size; map.clearCache empties it.

On screen, up to 256 tile textures are kept (least recently used dropped first); a tile that is not loaded yet is drawn from a loaded tile up to four zoom levels above it, else the map's grey shows.

OpenStreetMap tile usage policy

LightCraft uses OpenStreetMap's tile server under its tile usage policy (https://operations.osmfoundation.org/policies/tiles/, read 2026-11-14):

  • Only what is in view. The tiles requested are those drawn plus at most one ring around them, at the zoom drawn. There is no prefetching, no "download area" and no offline download. When the view moves, queued requests that left it are dropped before they start, and the newest view's tiles nearest the centre go first. When no map is on screen for two frames, the queue is emptied.
  • Gently. At most two requests at a time. After an error, a 429 or a 5xx the host is left alone with exponential backoff (1 s doubling up to 5 min, at least its Retry-After), then asked one request at a time until it answers. A tile the server refuses (404, not an image) is not asked for again for 10 min.
  • Identified. Every request carries User-Agent: LightCraft/<version> (+https://github.com/storytold/lightcraft), and nothing about you. Requests never send Cache-Control: no-cache or Pragma.
  • Cached as described above, honouring the server's headers.
  • Checked. A response over 2 MiB, one that is not a PNG, JPEG or WebP image of at most 1024 px a side, or one that does not decode is an error for that tile, never a crash, and is not cached.
  • Visible. While tiles are queued or loading, one "Loading map tiles" row is on the activity stack.

Sessions that a host has not put online (tests, the web build) never fetch tiles.

Esri layers (off)

Earlier builds of this branch offered Esri's World Imagery, World Street Map, World Topographic Map and a Hybrid layer, fetched from server.arcgisonline.com without an account. They are off and cannot be turned on in this build: the Map Style list does not offer them, map.tileSource refuses them with an error naming this page, and nothing is ever fetched from Esri. A library saved with an Esri layer opens on OpenStreetMap with a one-line notice; prefs.json keeps the Esri choice.

Why: Esri's terms for these layers do not allow this use. Each layer's ArcGIS Online item (e.g. https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9 for World Imagery) says it is "licensed under the Esri Master License Agreement" and links its terms. The terms summary (https://www.esri.com/content/dam/arcgisonline/docs/tou_summary.pdf, "Last Updated: April 21, 2025", read 2026-11-14) lists as conditions "Use with Esri software and comply with its terms of use. If you do not have Esri software, you must purchase an ArcGIS Online subscription", and among what you may not do, "Systematically harvest basemap tiles through any method other than using Esri Content Packages" and "Use content from ArcGIS Living Atlas for commercial use in your application or product". LightCraft is not Esri software and has no ArcGIS subscription. The full terms are the Esri Master Agreement (https://www.esri.com/en-us/legal/terms/master-agreement). The layers' required credits, kept in the code for when this changes, come from each item's accessInformation (https://www.arcgis.com/sharing/rest/content/items/10df2279f9684e4a9f6a7f08febac2a9?f=json).

Turning them on would need a maintainer decision, for example a user-supplied ArcGIS key through Esri's token-based basemap service, with the privacy note that Esri's server then sees which places you look at.

Privacy

The tile server sees which tiles you look at (so roughly which places), your IP address and the User-Agent above. Nothing else leaves the machine: no photo, place name or coordinate is sent except as the tile z/x/y in the URL. Reverse geocoding (place names from GPS) is offline (metadata.reverseGeocode, GeoNames). Choose Offline to fetch nothing.

Commands

Command What it does
map.tileSource {} reports the source; {id: "osm" | "opentopomap" | "offline"}, {offline: true | false}, or {urlTemplate, attribution, maxZoom?, id?} sets it (saved in prefs.json)
map.providers The sources offered now, with credit and max zoom
map.cacheInfo {bytes, tiles, capBytes, dir} of the tile cache
map.clearCache Deletes every cached tile
map.state The view, the pins drawn (with how many of their photos are selected) and a drop in progress (app only)
photo.setGps {ids?, lat, lon}: sets the position of the photos (default: the selection), one undo step; lat −90…90, lon wrapped into −180…180; unknown ids are refused
photo.clearGps {ids?}: removes the position of the photos, one undo step

The tile core (Web Mercator maths, source checks, cache, fetch queue) is ported from PR #797 by Jason Baldwin.