Simulation along the trip's route ("Simulate driving the route" when there is one, POST /api/sim/gnss {"trip": true}), random trips after it
CI / check (push) Successful in 21s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-12-01 01:45:38 +01:00
1 parent 07a4d363ec
commit 7fcac61c99
5 files changed
+38 -9

No files matched your search

+8 -3
View File
@@ -1341,8 +1341,13 @@ module Maptool
post "/api/sim/gnss" do
require_login!
lon, lat = JSON.parse(request.body.read)["start"]
if lon.nil?
body = JSON.parse(request.body.read)
lon, lat = body["start"]
# {"trip": true}: along the shared trip's route (to try the navigation)
route = TRIP_STORE.get[:route] if body["trip"]
halt 422, json(error: "the trip has no route") if body["trip"] && !route
if route then nil
elsif lon.nil?
codes = (PmtilesBuilder.offline_meta(DATA_DIR) || {}).fetch("sources", []).map { |source| source["code"] }
bboxes = codes.filter_map { |code| PmtilesBuilder.country_bbox(code) }
halt 422, json(error: "no offline countries to start in") if bboxes.empty?
@@ -1351,7 +1356,7 @@ module Maptool
end
CAN_STORE.override_prefix = "gnss."
GNSS_SIM.start(lon, lat, bboxes: bboxes) do |fix|
GNSS_SIM.start(lon, lat, bboxes: bboxes, route: route) do |fix|
CAN_STORE.put(fix.transform_keys { |key| "gnss.#{key}" })
App.gnss_update(fix)
end