Cache parsed GPX/FIT GeoJSON to fix large POI-export loads
CI / check (push) Successful in 42s
CI / deploy (push) Successful in 14s

A several-thousand-waypoint park4night area export re-parses the
whole file with REXML on every toggle — ~2.4s for a 5k-waypoint/3.6MB
sample, so tens of seconds for a 50k-waypoint one, likely the actual
cause behind a "Could not load" report on a 41.5MB export. MapLibre
already clusters the waypoint layer client-side, so the bottleneck was
never rendering — cache the GeoJSON conversion alongside the source
file (invalidated by mtime) instead of a bigger bbox/tiling rework.
This commit is contained in:
randy committed 2026-09-07 22:21:00 +02:00
1 parent b6a9c1546e
commit ddf2ee4990
4 files changed
+94 -9

No files matched your search

+6 -7
View File
@@ -193,18 +193,17 @@ module Maptool
get "/api/gpx/file/*" do
begin
path = GPX_STORE.resolve_file(params[:splat].first)
body = GPX_STORE.geojson(params[:splat].first)
rescue GpxStore::InvalidPath
halt 400
end
halt 404 unless File.file?(path)
begin
geojson = path.downcase.end_with?(".fit") ? Fit.to_geojson(path) : Gpx.to_geojson(path)
json geojson
rescue Errno::ENOENT
halt 404
rescue Gpx::ParseError, Fit::ParseError
halt 422, json(error: "could not parse file")
end
content_type :json
body
end
post "/api/gpx/folder" do