Allow users to specify a class for each way
This adds the ability to mark ways with a user-defined class in the profile. This class information will be included in the response as property of the RouteStep object.
This commit is contained in:
committed by
Patrick Niklaus
parent
d52d530cbe
commit
44739f2dc3
@@ -366,6 +366,9 @@ function way_function(way, result)
|
||||
'handle_maxspeed',
|
||||
'handle_penalties',
|
||||
|
||||
-- compute class labels
|
||||
'handle_classes',
|
||||
|
||||
-- handle turn lanes and road classification, used for guidance
|
||||
'handle_turn_lanes',
|
||||
'handle_classification',
|
||||
|
||||
@@ -277,6 +277,38 @@ function Handlers.handle_speed(way,result,data,profile)
|
||||
end
|
||||
end
|
||||
|
||||
-- add class information
|
||||
function Handlers.handle_classes(way,result,data,profile)
|
||||
local forward_toll, backward_toll = Tags.get_forward_backward_by_key(way, data, "toll")
|
||||
local forward_route, backward_route = Tags.get_forward_backward_by_key(way, data, "route")
|
||||
|
||||
if forward_toll == "yes" then
|
||||
result.forward_classes["toll"] = true
|
||||
end
|
||||
if backward_toll == "yes" then
|
||||
result.backward_classes["toll"] = true
|
||||
end
|
||||
|
||||
if forward_route == "ferry" then
|
||||
result.forward_classes["ferry"] = true
|
||||
end
|
||||
if backward_route == "ferry" then
|
||||
result.backward_classes["ferry"] = true
|
||||
end
|
||||
|
||||
if result.forward_restricted then
|
||||
result.forward_classes["restricted"] = true
|
||||
end
|
||||
if result.backward_restricted then
|
||||
result.backward_classes["restricted"] = true
|
||||
end
|
||||
|
||||
if data.highway == "motorway" or data.highway == "motorway_link" then
|
||||
result.forward_classes["motorway"] = true
|
||||
result.backward_classes["motorway"] = true
|
||||
end
|
||||
end
|
||||
|
||||
-- reduce speed on bad surfaces
|
||||
function Handlers.handle_surface(way,result,data,profile)
|
||||
local surface = way:get_value_by_key("surface")
|
||||
|
||||
Reference in New Issue
Block a user