Planning (the Design canvas' Plan and GridToday, ideas from azedler/roadplanner): a stop's type as its NPS pictogram (marker and list), notes on the trip, its days and stops, + on a leg inserts the next point there; a parking spot per stop (P marker, the route goes there, the walk shown); a link pasted into the search becomes a place (/api/link: the URL's coordinates, else the page's geo meta / JSON-LD / a map link; public addresses only, logged in), added on the leg it lengthens least; avoids for the trip (+ ferries, unpaved) or a day (routed in pieces, joined); Check and Costs folds in the Route panel (no leave time, long days, arriving after sunset, long walks, missing vignettes; fuel from km × consumption × price, stop costs / paid, the budget); Today in drive mode's Menu (stops left, tonight, sunset, Open-Meteo weather, the day's notes, Skip next, Tomorrow). Plugins along the trip's route (Maptool::Corridor, a corridor width; Overpass around:) and plugin settings saved server-side; p4n via a host Firefox's cookies (docs/deployment.adoc). The recording's days (cut where the car stood ≥ 4 h, or by hand) and their export (days, a piece A–B, the whole trip; GPX with times). Track replay in the GNSS simulator. Step advance 5 m past a maneuver. The level gauge (drive mode, from Terrain): lift per wheel to the ramps' steps from roll, pitch, wheelbase and track
This commit is contained in:
1 parent
5e31dfaba9
commit
87d7bd2463
36 files changed
+2047
-123
No files matched your search
+33
-4
@@ -33,16 +33,45 @@ class TripTest < Minitest::Test
|
||||
router = ->(*) { calls += 1; { type: "Feature" } }
|
||||
points = [{ lngLat: [17.1, 48.1] }, { lngLat: [17.2, 48.2] }]
|
||||
store.update(points: points, vehicle: nil, avoid: {}, editing: nil, &router)
|
||||
points[1] = { lngLat: [17.2, 48.2], night: true, stay: "90", note: " call ahead " }
|
||||
trip = store.update(points: points, vehicle: nil, avoid: {}, editing: nil, name: "Alps", start: "2026-12-12T08:00", day_start: "09:30", &router)
|
||||
points[1] = { lngLat: [17.2, 48.2], night: true, stay: "90", note: " call ahead ", type: "campground", day_note: "" }
|
||||
points[0] = { lngLat: [17.1, 48.1], day_note: "leave early" }
|
||||
trip = store.update(points: points, vehicle: nil, avoid: {}, editing: nil, name: "Alps", start: "2026-12-12T08:00", day_start: "09:30", note: " chains ", &router)
|
||||
assert_equal 1, calls # an itinerary change isn't a route change
|
||||
assert_equal({ lngLat: [17.2, 48.2], name: nil, nav: false, passed: false, night: true, stay: 90, note: "call ahead" }.compact, trip[:points][1])
|
||||
assert_equal ["Alps", "2026-12-12T08:00", "09:30"], trip.values_at(:name, :start, :day_start)
|
||||
assert_equal({ lngLat: [17.2, 48.2], name: nil, nav: false, passed: false, night: true, stay: 90, note: "call ahead", type: "campground" }.compact, trip[:points][1])
|
||||
assert_equal "leave early", trip[:points][0][:day_note]
|
||||
assert_equal ["Alps", "2026-12-12T08:00", "09:30", "chains"], trip.values_at(:name, :start, :day_start, :note)
|
||||
assert_raises(ArgumentError) { store.update(points: [{ lngLat: [1, 2], type: "<b>" }], vehicle: nil, avoid: {}, editing: nil, &router) }
|
||||
assert_raises(ArgumentError) { store.update(points: [{ lngLat: [1, 2], cost: "-1" }], vehicle: nil, avoid: {}, editing: nil, &router) }
|
||||
trip = store.update(points: [{ lngLat: [1, 2], cost: "32", paid: "" }], vehicle: nil, avoid: {}, editing: nil, budget: "250", fuel_price: "1.619", &router)
|
||||
assert_equal [32.0, nil, 250.0, 1.62], [trip[:points][0][:cost], trip[:points][0][:paid], trip[:budget], trip[:fuel_price]]
|
||||
# a parking spot: the route goes there instead of the place
|
||||
seen = nil
|
||||
points[1] = points[1].merge(park: { lngLat: [17.21, 48.19], name: "P2" })
|
||||
trip = store.update(points: points, vehicle: nil, avoid: {}, editing: nil) { |locations, *| seen = locations; { type: "Feature" } }
|
||||
assert_equal [[17.1, 48.1], [17.21, 48.19]], seen
|
||||
assert_equal({ lngLat: [17.21, 48.19], name: "P2" }, trip[:points][1][:park])
|
||||
assert_raises(ArgumentError) { store.update(points: [{ lngLat: [1, 2], stay: "-5" }], vehicle: nil, avoid: {}, editing: nil, &router) }
|
||||
assert_raises(ArgumentError) { store.update(points: points, vehicle: nil, avoid: {}, editing: nil, start: "tomorrow", &router) }
|
||||
end
|
||||
end
|
||||
|
||||
# A day with avoids of its own: its legs routed apart, joined into one route.
|
||||
def test_a_days_own_avoids_route_it_apart
|
||||
points = [{ lngLat: [0, 0] }, { lngLat: [1, 0], night: true }, { lngLat: [2, 0], avoid: { highways: true } }, { lngLat: [3, 0] }]
|
||||
assert_equal [[[[0, 0], [1, 0]], { tolls: true }], [[[1, 0], [2, 0], [3, 0]], { highways: true }]], Maptool::TripStore.pieces(points, { tolls: true })
|
||||
assert_equal [[[[0, 0], [1, 0], [2, 0], [3, 0]], {}]], Maptool::TripStore.pieces(points.map { |p| p.except(:avoid) }, {})
|
||||
|
||||
part = ->(from, to) { { type: "Feature", geometry: { coordinates: [[from, 0], [to, 0]] },
|
||||
properties: { distance_km: 10.0, time_s: 600, legs_km: [10.0], legs_s: [600], maneuvers: [{ km: 10 }],
|
||||
roads: [[0.0, "motorway", "AT"]], signals: [[from, 0, 5.0]], countries: [{ code: "AT", km: 10.0, motorway_km: 10.0, toll_km: 0.0 }] } } }
|
||||
route = Maptool::Routing.merge([part.(0, 1), part.(1, 2)])
|
||||
assert_equal [[0, 0], [1, 0], [2, 0]], route[:geometry][:coordinates]
|
||||
assert_equal [20.0, 1200, [10.0, 10.0]], route[:properties].values_at(:distance_km, :time_s, :legs_km)
|
||||
assert_equal [[0.0, "motorway", "AT"], [10.0, "motorway", "AT"]], route[:properties][:roads]
|
||||
assert_equal [[0, 0, 5.0], [1, 0, 15.0]], route[:properties][:signals]
|
||||
assert_equal [{ code: "AT", km: 20.0, motorway_km: 20.0, toll_km: 0.0 }], route[:properties][:countries]
|
||||
end
|
||||
|
||||
# Off the route while driving for 3 fixes: routed again from the position
|
||||
# to the points not reached yet (the first via passed: dropped).
|
||||
def test_following_reroutes_from_the_position_off_the_route
|
||||
|
||||
Reference in new issue
Block a user