Trip log: a trip is a library folder (Trips/<date> <name>) with the planned route and its stops; the car's GNSS recorded into its track there (10 m steps, written every minute and at the end), GET/POST/DELETE /api/trip/log; the Trip menu's Start / End and the line really driven (--route-driven); along-route POI mode for the plugins in TODO
This commit is contained in:
1 parent
809e88ab1a
commit
7d72e9eb63
7 files changed
+279
-1
No files matched your search
@@ -15,6 +15,7 @@ require_relative "lib/maptool/can"
|
||||
require_relative "lib/maptool/can_discovery"
|
||||
require_relative "lib/maptool/gnss_sim"
|
||||
require_relative "lib/maptool/trip"
|
||||
require_relative "lib/maptool/trip_log"
|
||||
require_relative "lib/maptool/updater"
|
||||
require_relative "lib/maptool/sync"
|
||||
require "ipaddr"
|
||||
@@ -414,6 +415,7 @@ module Maptool
|
||||
end
|
||||
return unless fix && fix[:lat] && fix[:lon]
|
||||
|
||||
TRIP_LOG.record(fix[:lon], fix[:lat], fix[:alt], at) if TRIP_LOG.active?
|
||||
# off the shared trip's route: routed again from here (TripStore#follow)
|
||||
|
||||
TRIP_STORE.follow([fix[:lon], fix[:lat]], speed: fix[:speed], hdop: fix[:hdop]) do |locations, vehicle, avoid|
|
||||
@@ -735,6 +737,32 @@ module Maptool
|
||||
# {points: [{lngLat, name, nav}], vehicle, avoid, editing}, routed here.
|
||||
# Logged in only — it's this server's own itinerary.
|
||||
TRIP_STORE = TripStore.new(File.join(DATA_DIR, "trip.json"))
|
||||
# The trip recorded (lib/maptool/trip_log.rb): GET its state (?since=N:
|
||||
# the line's coordinates from N on), POST {"name"} starts it — a
|
||||
# Trips/<date> <name> folder with the planned route and its stops —
|
||||
# DELETE ends it. Every fix goes in meanwhile (App.gnss_update).
|
||||
TRIP_LOG = TripLog.new(File.join(DATA_DIR, "trip_log.json"), library: LIBRARY)
|
||||
|
||||
get "/api/trip/log" do
|
||||
require_login!
|
||||
json TRIP_LOG.status(since: params[:since])
|
||||
end
|
||||
|
||||
post "/api/trip/log" do
|
||||
require_login!
|
||||
name = JSON.parse(request.body.read)["name"].to_s
|
||||
trip = TRIP_STORE.get
|
||||
json folder: TRIP_LOG.start(name, plan: trip[:route], stops: trip[:points])
|
||||
rescue JSON::ParserError
|
||||
halt 400, json(error: "invalid JSON")
|
||||
rescue ArgumentError => e
|
||||
halt 409, json(error: e.message)
|
||||
end
|
||||
|
||||
delete "/api/trip/log" do
|
||||
require_login!
|
||||
json folder: TRIP_LOG.stop
|
||||
end
|
||||
|
||||
get "/api/trip" do
|
||||
require_login!
|
||||
|
||||
Reference in new issue
Block a user