A side_road tag support for the OSRM car profile.

This commit is contained in:
Lev Dragunov 2015-12-15 12:52:28 +03:00
parent 158267a8b8
commit 6a2926850d
3 changed files with 34 additions and 2 deletions

View file

@ -141,6 +141,7 @@ local min = math.min
local max = math.max
local speed_reduction = 0.8
local side_road_speed_multiplier = 0.8
--modes
local mode_normal = 1
@ -327,6 +328,14 @@ function way_function (way, result)
return
end
-- reduce speed on special side roads
local sideway = way:get_value_by_key("side_road")
if "yes" == sideway or
"rotary" == sideway then
result.forward_speed = result.forward_speed * side_road_speed_multiplier
result.backward_speed = result.backward_speed * side_road_speed_multiplier
end
-- reduce speed on bad surfaces
local surface = way:get_value_by_key("surface")
local tracktype = way:get_value_by_key("tracktype")

View file

@ -141,6 +141,7 @@ local min = math.min
local max = math.max
local speed_reduction = 0.8
local side_road_speed_multiplier = 0.8
--modes
local mode_normal = 1
@ -310,8 +311,8 @@ function way_function (way, result)
end
else
-- Set the avg speed on ways that are marked accessible
-- OMIM does not support non highway classes
--if access_tag_whitelist[access] and "yes" ~= access then
-- OMIM does not support not highway classes
-- if access_tag_whitelist[access] and "yes" ~= access then
-- result.forward_speed = speed_profile["default"]
-- result.backward_speed = speed_profile["default"]
--end
@ -327,6 +328,14 @@ function way_function (way, result)
return
end
-- reduce speed on special side roads
local sideway = way:get_value_by_key("side_road")
if "yes" == sideway or
"rotary" == sideway then
result.forward_speed = result.forward_speed * side_road_speed_multiplier
result.backward_speed = result.backward_speed * side_road_speed_multiplier
end
-- reduce speed on bad surfaces
local surface = way:get_value_by_key("surface")
local tracktype = way:get_value_by_key("tracktype")

View file

@ -32,6 +32,20 @@ UNIT_TEST(RussiaMoscowNagatinoUturnTurnTest)
integration::TestRouteLength(route, 561.);
}
UNIT_TEST(StPetersburgSideRoadPenaltyTest)
{
TRouteResult const routeResult = integration::CalculateRoute(
integration::GetOsrmComponents(),
MercatorBounds::FromLatLon(59.85157, 30.28033), {0., 0.},
MercatorBounds::FromLatLon(59.84268, 30.27589));
Route const & route = *routeResult.first;
IRouter::ResultCode const result = routeResult.second;
TEST_EQUAL(result, IRouter::NoError, ());
integration::TestTurnCount(route, 0);
}
UNIT_TEST(RussiaMoscowLenigradskiy39UturnTurnTest)
{
TRouteResult const routeResult = integration::CalculateRoute(