Profiles in a dialog, the chip in the map's bottom-left corner picks one (the Design canvas' Vehicle): a car gains fuel, Euro class, stickers and vignettes / toll units with dates; drive mode's Menu steps through them. Speed limits by country for cars and over 3.5 t (public/js/speed_limits.js, sources in it): the route's roads (km, road class, country), the limit shown the lower of the sign and the profile's; the Route panel's countries with their limits and how the motorways are paid; past a border a card in drive mode (GridBorder). The itinerary in the Route panel (Itinerary): the trip's name, leave time, days start; per stop a night, stay and note, planned times, day headers; another screen's change shown where it happened with Undo
CI / check (push) Successful in 24s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-12-03 19:00:09 +01:00
1 parent a6158f4083
commit 5e31dfaba9
15 files changed
+733 -169

No files matched your search

+29 -3
View File
@@ -10,6 +10,29 @@ module Maptool
# camera. Kept in data/trip.json across restarts.
class TripStore
EMPTY = { version: 0, points: [], vehicle: nil, avoid: {}, editing: nil, route: nil, error: nil }.freeze
# The itinerary: the trip's name, when it starts (local "YYYY-MM-DDTHH:MM")
# and when a day after a night stop starts ("HH:MM"); per point a night
# stop (the day ends there), the stay in minutes and a note.
MAX_STAY_MIN = 7 * 24 * 60
DATE_TIME = /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}\z/
TIME = /\A\d{2}:\d{2}\z/
def self.point(p)
stay = p[:stay].nil? || p[:stay].to_s.empty? ? nil : Integer(p[:stay], exception: false)
raise ArgumentError, "stay must be 0–#{MAX_STAY_MIN} minutes" if stay && !(0..MAX_STAY_MIN).cover?(stay)
note = p[:note].to_s.strip[0, 500]
{ lngLat: p.fetch(:lngLat).map { |v| Float(v) }, name: p[:name], nav: !!p[:nav], passed: !!p[:passed],
night: (true if p[:night]), stay: (stay if stay&.positive?), note: (note unless note.empty?) }.compact
end
def self.itinerary(name:, start:, day_start:)
name = name.to_s.strip[0, 80]
raise ArgumentError, "start must be YYYY-MM-DDTHH:MM" unless start.to_s.empty? || start.to_s.match?(DATE_TIME)
raise ArgumentError, "day_start must be HH:MM" unless day_start.to_s.empty? || day_start.to_s.match?(TIME)
{ name: (name unless name.empty?), start: (start unless start.to_s.empty?), day_start: (day_start unless day_start.to_s.empty?) }
end
def initialize(path)
@path = path
@@ -117,8 +140,9 @@ module Maptool
# changed — the old route stays then. Passed points stay in the trip
# (shown dimmed, still editable: a stop missed out added afterwards),
# just not routed. Last write wins.
def update(points:, vehicle:, avoid:, editing:)
points = points.map { |p| { lngLat: p.fetch(:lngLat).map { |v| Float(v) }, name: p[:name], nav: !!p[:nav], passed: !!p[:passed] } }
def update(points:, vehicle:, avoid:, editing:, name: nil, start: nil, day_start: nil)
points = points.map { |p| self.class.point(p) }
itinerary = self.class.itinerary(name: name, start: start, day_start: day_start)
avoid = (avoid || {}).to_h { |k, v| [k.to_sym, !!v] }
before = get
routed = ->(list) { list.reject { |p| p[:passed] }.map { |p| p[:lngLat] } }
@@ -135,7 +159,9 @@ module Maptool
end
@mutex.synchronize do
@trip = { version: @trip[:version] + 1, points: points, vehicle: vehicle, avoid: avoid, editing: editing,
route: route, error: error, updated_at: Time.now.to_f }
**itinerary, route: route, error: error, updated_at: Time.now.to_f }.compact
@trip[:route] = route # nil kept: the client reads it
@trip[:error] = error
File.write("#{@path}.tmp", JSON.generate(@trip))
File.rename("#{@path}.tmp", @path)
@trip.dup