Fix bicycle profile: cap speed at 21 km/h and add test coverage for high maxspeed values#7402
Conversation
…t realistic 30 km/h Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
…001-a946-149788afd6c0
Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
Co-authored-by: DennisOSRM <1067895+DennisOSRM@users.noreply.github.com>
|
Choosing a maxspeed cap of 21 km/h seems quite arbitrary. According to https://wiki.openstreetmap.org/wiki/Key:maxspeed, legal values differ substantually based on country. Peak real world driving speeds are also heavily influenced by incline. Using my mountainbike, I personally routinely drive 25 km/h on flat ground, but can easily peak 50 km/h downhill at our neighbourhood hill. That road is two km long and maxspeed is legally 100km/h. Obviously, biking there uphill is a lot slower and using an E-Bike, I can only reach about 10 - 15 km/h. |
|
That's good feedback, and you're absolutely right that 21 km/h is a simplification. Real-world bicycle speeds are heavily influenced by incline. As you point out, downhill can easily double or triple flat-ground speeds, while steep climbs can cut them to a fraction. In the absence of elevation data being factored into routing, a flat-ground average is the best compromise we can make today. The 21 km/h figure is broadly consistent with typical average cycling speeds on mixed terrain, but it is indeed a rough approximation that ignores gradient entirely. Proper support for a digital elevation model (DEM) during preprocessing is on the backlog. Once that's in place, speed estimates could be adjusted dynamically per segment based on slope, which would address exactly the cases you describe: fast descents, slow climbs, and the significant difference between a regular bike and an e-bike. |
…001-a946-149788afd6c0
The problem statement requested verification that tests cover cases where maxspeeds are set to high values (e.g., 100 km/h) and that resulting speeds remain bikeable, including for forward/backward directional maxspeeds.
Test Coverage Analysis
The existing tests in
features/bicycle/maxspeed.featurealready provide comprehensive coverage:maxspeed=100, verifying results stay at safe 15 km/h instead of car speedsmaxspeed,maxspeed:forward, andmaxspeed:backwardset to 100 km/h, confirming proper capping in both directionsImplementation Details
The bicycle profile's
vehicle_max_speed = 21km/h cap (set in profiles/bicycle.lua:43) works through a multi-layer speed calculation:This ensures OSM data containing car-centric high maxspeeds never produces dangerous bicycle routing suggestions.
No code changes needed - all test coverage requirements are already met.
Original prompt