Bicycle and foot route profiles (Valhalla bicycle/pedestrian costing); hiking trail colours in the elevation profile; power, splits and best efforts in the profile; TCX import; FIT course export
CI / check (push) Successful in 19s
CI / deploy (push) Successful in 18s

This commit is contained in:
randy committed 2026-11-16 12:18:06 +01:00
1 parent 4c704045c5
commit f8755ea65a
21 files changed
+634 -40

No files matched your search

+23 -3
View File
@@ -95,13 +95,19 @@ class RoutingTest < Minitest::Test
end
def test_vehicle_profiles_are_validated_and_stored
assert_equal %w[car camper], Maptool::Routing.vehicles(@data).map { |v| v[:id] }
assert_equal %w[car camper bike mtb run hike], Maptool::Routing.vehicles(@data).map { |v| v[:id] }
assert_equal "Car", Maptool::Routing.vehicle(@data, "nope")[:name]
Maptool::Routing.save_vehicles(@data, [{ "id" => "car", "name" => "Car", "height" => "" },
{ "id" => "van", "name" => "Van", "height" => "3.4", "weight" => "4.2" }])
assert_equal({ id: "van", name: "Van", height: 3.4, weight: 4.2 }, Maptool::Routing.vehicle(@data, "van"))
assert_equal({ id: "car", name: "Car" }, Maptool::Routing.vehicle(@data, "car"))
assert_equal({ id: "van", name: "Van", type: "car", height: 3.4, weight: 4.2 }, Maptool::Routing.vehicle(@data, "van"))
assert_equal({ id: "car", name: "Car", type: "car" }, Maptool::Routing.vehicle(@data, "car"))
assert_equal %w[car van], Maptool::Routing.vehicles(@data).map { |v| v[:id] } # deleted bike/foot stay deleted
Maptool::Routing.save_vehicles(@data, [{ "id" => "b", "name" => "B", "type" => "bicycle", "bicycle_type" => "Road", "speed" => "28", "height" => "" }])
assert_equal({ id: "b", name: "B", type: "bicycle", bicycle_type: "Road", speed: 28.0 }, Maptool::Routing.vehicle(@data))
assert_raises(ArgumentError) { Maptool::Routing.save_vehicles(@data, [{ "id" => "x", "name" => "X", "type" => "boat" }]) }
assert_raises(ArgumentError) { Maptool::Routing.save_vehicles(@data, [{ "id" => "x", "name" => "X", "type" => "bicycle", "bicycle_type" => "Tandem" }]) }
assert_raises(ArgumentError) { Maptool::Routing.save_vehicles(@data, [{ "id" => "x", "name" => "X", "type" => "foot", "sac" => "7" }]) }
assert_raises(ArgumentError) { Maptool::Routing.save_vehicles(@data, [{ "id" => "x", "name" => "X", "height" => "30" }]) }
assert_raises(ArgumentError) { Maptool::Routing.save_vehicles(@data, [{ "id" => "x", "name" => "" }]) }
assert_raises(ArgumentError) { Maptool::Routing.save_vehicles(@data, []) }
@@ -151,6 +157,20 @@ class RoutingTest < Minitest::Test
assert_includes request, "/trace_attributes"
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|
route = Maptool::Routing.route(url, [[1, 2], [3, 4]], Maptool::Routing::ACTIVE_VEHICLES[2], { "tolls" => true })
assert_nil route[:properties][:countries]
end
assert_includes request, %("costing_options":{"pedestrian":{"walking_speed":10.0,"max_hiking_difficulty":2}})
request = serve_once("HTTP/1.1 200 OK\r\nContent-Length: #{reply.bytesize}\r\n\r\n#{reply}") do |url|
Maptool::Routing.route(url, [[1, 2], [3, 4]], Maptool::Routing::ACTIVE_VEHICLES[1])
end
assert_includes request, %("costing_options":{"bicycle":{"bicycle_type":"Mountain"}})
end
def test_isochrone_asks_valhalla_for_each_time_and_checks_them
reply = JSON.generate(type: "FeatureCollection", features: [])
request = serve_once("HTTP/1.1 200 OK\r\nContent-Length: #{reply.bytesize}\r\n\r\n#{reply}") do |url|