From f7478ba80f04ee6777556661f93edff5bef85c90 Mon Sep 17 00:00:00 2001 From: Matt Riggott Date: Thu, 3 Jun 2021 16:56:57 +0000 Subject: [PATCH] Process maxspeed tag before surface, smoothness, and tracktype tags (#6002) * Handle maxspeed tags before surface and smoothness tags Let's say we have a tertiary road with the following tags: highway=tertiary maxspeed=60 surface=gravel smoothness=intermediate While the maxspeed tag tells us the legal speed limit, the surface and smoothness tags have much more effect on the real-world speed of a car. We should process the maxspeed tags first, and then update the road's forwards/backwards speeds according to any surface and smoothness tags. For our hypothetical road the process in the car.lua profile now goes like this: 1. Get default speed from profile (tertiary = 40 on line 150 of car.lua) 2. Change speed to 60 using maxspeed tag (WayHandlers.maxspeed function in way_handlers.lua, lines 434-447) 3. Change speed to 40 using surface tag (WayHandlers.surface function in way_handlers.lua, lines 360-363) 4. Check speed according to smoothness tag --- but because it's higher than the speed according to the surface tag, leave the speed unchanged (WayHandlers.surface function again, lines 368-371) Note in step 3 above the speed's only changed from 60kph to 40kph because it's a lower value. If the surface speed was higher than than the previous value, the speed would remain unchanged. Another example: highway=tertiary maxspeed=60 surface=compacted smoothness=intermediate Here, although the profile's speed for compacted is 80, it would stay at the lower value of 60 (see way_handlers.lua, lines 360-363). --- profiles/car.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiles/car.lua b/profiles/car.lua index 401f4bf45..fddae14d7 100644 --- a/profiles/car.lua +++ b/profiles/car.lua @@ -432,8 +432,8 @@ function process_way(profile, way, result, relations) -- compute speed taking into account way type, maxspeed tags, etc. WayHandlers.speed, - WayHandlers.surface, WayHandlers.maxspeed, + WayHandlers.surface, WayHandlers.penalties, -- compute class labels