Dashboard overlay (Overlays → Live → Dashboard): one inclinometer (compass ring, roll and pitch), speed, the speed limit with an over-limit warning and, on the route, the next limit change, traffic signal, maneuver and its lanes; /api/route gains speed_limits, signals and lanes, POST /api/road gives the driven road's limit; GNSS simulation (random trips over Valhalla) for trying it without the car; the HMC5883L heading in can.json
CI / check (push) Successful in 24s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-11-30 18:30:21 +01:00
1 parent 5958ffd153
commit 190a8ad334
13 files changed
+713 -27

No files matched your search

+16 -5
View File
@@ -145,18 +145,29 @@ class RoutingTest < Minitest::Test
def test_a_route_sums_motorway_and_toll_km_per_country_and_can_avoid_tolls
route = JSON.generate(trip: { summary: { length: 3, time: 90 }, legs: [{ shape: "wdg|xA{ubdQc@w@", maneuvers: [] }] })
attributes = JSON.generate(admins: [{ country_code: "AT" }, { country_code: "SK" }],
edges: [{ length: 1.0, road_class: "motorway", toll: false, end_node: { admin_index: 0 } },
{ length: 0.5, road_class: "primary", toll: false, end_node: { admin_index: 0 } },
{ length: 1.5, road_class: "motorway", toll: true, end_node: { admin_index: 1 } }])
edges: [{ length: 1.0, road_class: "motorway", toll: false, speed_limit: 130, end_shape_index: 0, end_node: { admin_index: 0 } },
{ length: 0.5, road_class: "primary", toll: false, speed_limit: 0, end_shape_index: 1, end_node: { admin_index: 0, traffic_signal: true } },
{ length: 1.5, road_class: "motorway", toll: true, speed_limit: 130, end_shape_index: 1, end_node: { admin_index: 1 } }])
ok = ->(body) { "HTTP/1.1 200 OK\r\nContent-Length: #{body.bytesize}\r\n\r\n#{body}" }
request = serve_once(ok.(route), ok.(attributes)) do |url|
countries = Maptool::Routing.route(url, [[1, 2], [3, 4]], { id: "car" }, { "tolls" => true })[:properties][:countries]
assert_equal [{ code: "AT", km: 1.5, motorway_km: 1.0, toll_km: 0.0 }, { code: "SK", km: 1.5, motorway_km: 1.5, toll_km: 1.5 }], countries
properties = Maptool::Routing.route(url, [[1, 2], [3, 4]], { id: "car" }, { "tolls" => true })[:properties]
assert_equal [{ code: "AT", km: 1.5, motorway_km: 1.0, toll_km: 0.0 }, { code: "SK", km: 1.5, motorway_km: 1.5, toll_km: 1.5 }], properties[:countries]
assert_equal [[0.0, 130], [1.0, nil], [1.5, 130]], properties[:speed_limits]
assert_equal [[9.521034, 47.140974, 1.5]], properties[:signals]
end
assert_includes request, %("costing_options":{"auto":{"use_tolls":0.0}})
assert_includes request, "/trace_attributes"
end
def test_the_road_driven_is_the_last_matched_edge
reply = JSON.generate(edges: [{ names: ["A"], road_class: "primary", speed_limit: 90 }, { names: ["B"], road_class: "motorway", speed_limit: "unlimited" }])
request = serve_once("HTTP/1.1 200 OK\r\nContent-Length: #{reply.bytesize}\r\n\r\n#{reply}") do |url|
assert_equal({ name: "B", road_class: "motorway", speed_limit: "unlimited" }, Maptool::Routing.road(url, [[17.1, 48.1], [17.2, 48.2]]))
end
assert_includes request, %("shape_match":"map_snap")
assert_raises(Maptool::Routing::RouteError) { Maptool::Routing.road("http://x", [[17.1, 48.1]]) }
end
def test_bicycle_and_foot_use_their_own_costing_without_the_country_lookup
reply = JSON.generate(trip: { summary: { length: 1.5, time: 90 }, legs: [{ shape: "wdg|xA{ubdQc@w@", maneuvers: [] }] })
request = serve_once("HTTP/1.1 200 OK\r\nContent-Length: #{reply.bytesize}\r\n\r\n#{reply}") do |url|