Commit Graph
9 Commits
Author SHA1 Message Date
8bd02083fe LR-MAP-MODULE: the Map view's keys, Hide Pins, View > Map and Settings > Map tile source and cache
- Keys in the Map view only (shortcuts::grid_key_command, the rule that
  already gave the map \ and Cmd+K): H hides / shows the pins, O the saved
  locations list, = / - and Cmd+= / Cmd+- zoom the map, Cmd+0 fits it; the +
  alias zooms there too. Elsewhere the keys keep Remove, the mask overlay,
  the grid's thumbnail size and the photo zoom; the Masking panel's H
  override stays out of the Map view.
- Hide Pins: MapUi.show_pins (saved in ui.json), the bottom toolbar's Hide
  Pins, map.showPins {on?}; hidden pins can't be clicked, hovered or dragged;
  saved locations and the track log stay. map.showLocations {on?} (the
  navigator panel holding the list), map.settings (Settings > Map).
- View > Map (after PR #921's map menu): Fit, Zoom In / Out, Map Pins, Lock
  Markers, Location Filter Bar, Location Filter > 4 modes, Saved Locations >
  New Location... / Saved Locations List, Tracklog > Load / Auto-Tag / Set
  Offset / Fit / Clear, Map Tiles...; greyed outside the Map view. Window >
  Map keeps the panel toggles.
- Settings > Map: the tile source (built-in sources usable now, the Esri
  styles only with a key, Offline), a custom server applied on Apply or
  Return only (a refused one shows why and changes nothing), the tile cache's
  size with Clear Cache, what a tile server sees, a link to docs/map.md, then
  the ArcGIS key. The offline note says "Map tiles are off (Settings > Map)".
- Tests: tests/map_keys.rs (each key in and out of the Map view, hidden pins
  not clickable, the menu and its states, Settings source / bad server /
  custom on Apply / Esri with a key).
- Docs: map.md "Keys and menus", library-shortcuts.md, control protocol;
  LR-MAP-MODULE 0 -> partial, MENU-VIEW-MAP added; strings in all 17 catalogs.

After PR #921 by Jason Baldwin.

Co-Authored-By: Jason Baldwin <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 21:02:55 -05:00
1127a17ab3 LRC-MAP-TRACKLOG: track logs drawn on the Map view, the Tracklog menu, loading off the UI thread
- crates/engine/src/map/track.rs (ported from PR #916): TrackShape projects a
  track's segments once, cuts them at ±180°, ranks points for Douglas-Peucker
  (ends kept, ~0.6 pt error), builds a level per zoom in chunks clipped to the
  view. 2 million points (release): 370 ms to build, 1-29 ms per zoom level,
  a frame's clipped lines under 1 ms (big_track_cost, ignored by default).
- crates/engine/src/tracklog.rs: map.trackLog (load path / gpx, active track,
  camera time zone offset, clear; session only; 50 MB, 2 million timed
  points; a refused file keeps the loaded log); photo.autoTagTracklog
  {loaded: true} tags from the active track with its offset. Files are read
  through read_file::read_regular under the byte cap (#3703's rule).
- The GPX parser's track indexes, names and caps already come from
  craft-metadata.
- Map view (panels/map/tracks.rs): a Tracklog button in the bottom toolbar
  with its menu (tracks, start / end / duration on the camera clock, Set Time
  Zone Offset…, Auto-Tag N Selected Photos, Fit Map to Tracklog, Load
  Another…, Clear); tracks drawn under the pins (others dimmed); the selected
  photos marked where Auto-Tag puts them. Load Tracklog… reads the file on a
  worker thread with an activity row ("Loading tracklog <file>") and fits the
  map when it lands. UI commands map.loadTrackLog, map.trackLog.autoTag,
  .setOffset, .fit; map.state.trackLog.
- The tile credit moves above the toolbar (the longer toolbar made it cover
  Lock Markers) and the legend above the credit.
- Tests: engine tests/tracklog.rs and map/tests_track.rs (ported); UI
  tests/map_tracks.rs (load and fit, track pick, ticks and auto-tag in one
  undo step, bad files / hostile tracks / tiny window, the worker thread's
  activity row).
- Docs: map.md "Track logs", control protocol, LRC-MAP-TRACKLOG row; strings
  in all 17 catalogs.

Ported from PR #916 by Jason Baldwin.

Co-Authored-By: Jason Baldwin <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 20:00:42 -05:00
6776fad691 LRC-MAP-LOCATIONS: saved locations in locations.json, with counts, private exports and handles on the map
- crates/engine/src/locations.rs (ported from PR #906): named circles, 1 m to
  1000 km, great-circle (across ±180° and the poles), a private flag, checked
  on every change; a latitude-sorted index for counts.
- Kept per library in locations.json (atomic; a damaged file or bad entries
  set aside as locations.json.corrupt-<time> with a warning; a file that can't
  be read is never overwritten). Older prefs.json savedLocations are written
  there once, read back to confirm, and only then left out of prefs.json;
  while unconfirmed (or with locations.json damaged) prefs.json keeps them.
- Commands map.locations, map.location.add (or fromSelection), .update,
  .remove, .photos; app: map.location.show, .select, .new. The older
  map.savedLocations.list/create/delete stay as aliases (numeric ids now).
- Private locations: photos inside them export without GPS or place fields
  (the export's remove-location switch, per photo); the Info panel hides their
  map until Show Map.
- Map view (panels/map/locations.rs): every location in view drawn with its
  name; the active one has centre and radius handles (Lock Markers keeps
  them); the navigator list shows counts of photos in view, a checkbox
  selecting them, Go To, Rename…, Private, Delete… with a confirmation; +
  around the selected photos or at the map's centre.
- GPS Radius smart-rule field (catalog, from #906), with its editor.
- Tests: engine tests/saved_locations.rs (ported, plus migration: old prefs
  only, both files, a damaged locations.json); the private-export test fails
  with the strip turned off; ported catalog circle tests; UI
  tests/map_locations.rs.
- Docs: map.md "Saved locations", control protocol, LRC-MAP-LOCATIONS row;
  strings in all 17 catalogs.

Ported from PR #906 by Jason Baldwin.

Co-Authored-By: Jason Baldwin <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 01:19:57 -05:00
e895981e5a LRC-MAP-FILTER: the location filter narrows the filmstrip, with counts, over the library's filter
- Smart-rule fields (crates/catalog/src/rules.rs): GPS Area (gpsArea, is
  inside / is outside {south, west, north, east}; east < west wraps across
  ±180°; edges inside; no position is neither) and Has GPS counting only a
  valid position. library.filter, album.createSmart and album.setRules refuse
  missing edges, text, NaN, out-of-range values and south north of north;
  album.ruleFields reports kind "area"; the rule editor shows four numbers and
  never rewrites a stored out-of-range edge.
- Session::narrow: a view's own rules over source, filter and sort, never
  saved or shown as the filter; visible_base_shared gives the list before it.
- The Map view's bar counts Visible on Map, Tagged, Untagged and None, and
  narrows the filmstrip, selection and keys while the Map view is shown;
  leaving it restores exactly the grid's list (sync_location_filter, every
  frame). Visible on Map follows the view once it rests 250 ms (commands at
  once). Pins come from the list before it; Untagged hides them with a note.
- map.locationFilter {mode?} → {mode, visible, tagged, untagged, all, area,
  countMs, shown}; map.state.locationFilter.
- Tests: the ported catalog rule tests (areas, antimeridian, checks, Has GPS
  on corrupt positions, smart albums following tagging), engine
  tests/location.rs (library.filter, smart albums, narrowing over the filter,
  empty library, 50,000 photos narrowed in 9 ms release, 20,000 counted in
  0.1 ms), UI tests/map_filter.rs.
- Docs: map.md "Location filter", control protocol, LRC-MAP-FILTER row; 11
  strings in all 17 catalogs.

Ported from PR #819 by Jason Baldwin.

Co-Authored-By: Jason Baldwin <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-16 00:10:24 -05:00
d3e4b8ed28 LR-MAP-INFO: a map of the active photo's place in the Info panel
- Under the location fields: the fields' width, 160 pt, zoom 14 (or the
  source's max), the photo's pin (kept on the map near the poles) and the tile
  credit. The active photo's place with several selected; no map without a
  valid position. A click opens the Map view centred there.
- Show on Map becomes Open in Browser (same widget id, still openstreetmap.org).
- It draws with the Map view's tile service and textures (tiles::draw, ring 0)
  and only while on screen: with the Info panel closed or the map below the
  panel's fold, nothing is wanted, so nothing is fetched for it. Offline: grey,
  the pin, "Map tiles are off" (now at the top of a short map).
- The tile texture store moves from a process-wide static into the egui
  context's memory, so each window (and each headless test) has its own;
  parallel tests no longer roll each other's wanted tiles.
- map.state reports miniMap {photo, lat, lon, zoom, rect, pin, tiles};
  widgets info:miniMap, info:miniMapAttribution.
- Tests (tests/map_info.rs, fake tile server): pin and credit, active photo
  with several selected, no GPS, near the pole, a click to the Map view with
  no tile fetched twice, nothing wanted off screen or below the fold, offline,
  and keep_on_map on tiny and non-finite input.
- Docs: map.md "Info panel map", control protocol, LR-MAP-INFO ✅; two strings
  in all 17 catalogs.

Ported in spirit from PR #804 by Jason Baldwin.

Co-Authored-By: Jason Baldwin <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 22:43:17 -05:00
6838cb5a42 LRC-MAP-VIEW: world-anchored pin clusters, view commands, pin moves and Lock Markers
Phase 2 of the map work, and the Map view half of the geotag work (pin moves,
the lock and the pin menu share the canvas's input handling, so they came
with the rewrite):

- Clustering moves to the engine (map/cluster.rs, ported from PR #797):
  positions are projected once per change of the photo list, then grouped in
  world-anchored ~60 pt cells, so panning never regroups the pins and zooming
  in only splits them. 50,000 photos cluster in 1.7 ms (release).
- The view uses the engine's Viewport for pan, wheel zoom and positions.
  Fit to Photos (toolbar, map.fit, and the first showing in a session),
  map.setView {lat?, lon?, zoom?} (hostile values refused), map.zoomIn /
  map.zoomOut. "N photos without GPS" on the map; hovering a pin shows its
  photo's thumbnail; double-click opens Detail or zooms into a cluster.
- A drag that starts on a single photo's pin moves it (photo.setGps, one undo
  step; let go off the map, nothing changes); a cluster's drag pans. Lock
  Markers (toolbar, map.lockMarkers {on?}, Cmd/Ctrl+K in the Map view, saved
  in ui.json) stops pin moves. A pin's right-click menu removes its photos'
  GPS (photo.removeGps); Photo > Remove GPS Coordinates in the menu bar.
- map.state gains maxZoom, source, offline, attribution, pins' lat/lon,
  clusterCount, clusterMs, withGps/withoutGps, lockMarkers, movingPin, hovered.
- Tests: tests/map_geotag.rs (pin move and undo, cluster pans, Lock Markers,
  pin menu and Photo menu, groups kept on pan and split on zoom, view
  commands and hostile values, first-showing fit, without-GPS count, hover
  thumbnail, empty library) and the ported engine cluster tests.
- Docs: map.md (Map view, Geotagging, commands), control protocol, parity
  rows (LRC-MAP-GEOTAG ✅, MENU-PHOTO-REMOVEGPS), gaps; strings in all 17
  catalogs.

Ported in part from PRs #797 and #810 by Jason Baldwin.

Co-Authored-By: Jason Baldwin <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 19:56:59 -05:00
Bruno D.andClaude Opus 5.5 1e0e814657 LRC-MAP-VIEW: Esri map styles with the user's own ArcGIS API key
- Esri Streets and Esri Outdoor (topographic) come from the ArcGIS Location
  Platform static basemap tiles service with the user's key (Settings > Map,
  map.setEsriKey); without a key they are not offered and map.tileSource
  refuses them, saying where to get one. The keyless arcgisonline endpoints
  are gone; World Imagery is dropped (no raster imagery style there).
- Esri's 512 px tiles are cut into the four 256 px tiles they hold; one
  request serves all four.
- The key is a secret: kept in the config folder (map-keys.json, 0600 on
  Unix), never journaled, logged, reported (esriKeySet only), used as a cache
  key or shown in errors ([key]); ApiKey's Debug hides it.
- The map's credit is "Powered by Esri" plus the style's copyrightText from
  its metadata (bounded, plain text), else a fixed fallback.
- docs/map.md records the endpoints, what was read and what could not be
  verified (attribution guide, platform agreement).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-15 18:14:32 -05:00
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
7cbfd8c5ba LRC-MAP-VIEW: map tiles under the OSM tile policy from an engine tile service; Esri layers off
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]>
2026-11-14 22:18:05 -05:00