Let a cached file's GeoJSON be downloaded by clicking its tree name

Once a .gpx/.fit is cached, the tree shows it under its converted name
("ride.gpx" -> "ride.gpx.geojson", matching the real cache file next
to it on disk) instead of still reading as un-converted -- the
GeoJSON is what's actually on the map from that point on, and the
original is never deleted, just not re-shown as itself. The name is
now a real link (GET /api/gpx/file/<path>?download=1) instead of
plain text, the only way to get that converted form out of the app.

Verified in a real browser that an <a> nested in a <label> claims its
own click rather than the label forwarding it to the checkbox, so
downloading and toggling visibility don't fight over the same click.
This commit is contained in:
randy committed 2026-09-07 22:56:46 +02:00
1 parent b4f205667b
commit cd92dadf6a
5 files changed
+70 -4

No files matched your search

+17 -1
View File
@@ -285,7 +285,23 @@ A `.geojson` upload skips this path entirely — `geojson` reads and
returns it directly, no cache file, no `Gpx`/`Fit` involved; the file
tree's cached-file icon (`GEOJSON_ICON`, `public/js/icons.js`) always
shows for one, since there's no conversion step it could ever be
waiting on. `Gpx` parses the GPX with REXML: `<wpt>`
waiting on.
+
Once a `.gpx`/`.fit` is cached, the tree shows it under its converted
name instead — `"ride.gpx"` reads as `"ride.gpx.geojson"`, matching
the real cache file sitting next to it on disk — since the GeoJSON,
not the original, is what's actually rendered on the map from that
point on. The original is never deleted or re-parsed once cached, just
not re-shown as itself; the tree's file name is a real link
(`GET /api/gpx/file/<path>?download=1`), the only way to get that
converted form out of the app as an actual file, since the cache is
otherwise an implementation detail with no name of its own to expose.
It's an `<a>`, not a `<span>`, specifically so clicking it downloads
instead of also toggling the row's checkbox — a native `<a>`/`<button>`
nested inside a `<label>` claims its own click instead of the label
forwarding it to the associated control, so the two behaviors don't
fight over the same click. A directly-uploaded `.geojson` keeps its
own name (nothing to convert) and downloads unchanged. `Gpx` parses the GPX with REXML: `<wpt>`
waypoints become `Point` features (with `name`, `desc` and `time`
carried through as properties), each `<trk>` becomes one
`MultiLineString` feature (one line per `<trkseg>`), and each `<rte>`