handle access flags for lanes
This commit is contained in:
parent
71d64e8cd9
commit
7d076e9344
@ -1,6 +1,8 @@
|
|||||||
# 5.4.0
|
# 5.4.0
|
||||||
- Profiles
|
- Profiles
|
||||||
- includes library guidance.lua that offers preliminary configuration on guidance.
|
- includes library guidance.lua that offers preliminary configuration on guidance.
|
||||||
|
- Guidance
|
||||||
|
- Handle Access tags for lanes, only considering valid lanes in lane-guidance (think car | car | bike | car)
|
||||||
|
|
||||||
# 5.3.0
|
# 5.3.0
|
||||||
Changes from 5.3.0-rc.3
|
Changes from 5.3.0-rc.3
|
||||||
|
@ -24,6 +24,22 @@ Feature: Turn Lane Guidance
|
|||||||
| c,a | straight,in,in | depart,new name straight,arrive | ,left:false straight:true none:true none:true, |
|
| c,a | straight,in,in | depart,new name straight,arrive | ,left:false straight:true none:true none:true, |
|
||||||
| c,d | straight,right,right | depart,turn left,arrive | ,left:true straight:false none:false none:false, |
|
| c,d | straight,right,right | depart,turn left,arrive | ,left:true straight:false none:false none:false, |
|
||||||
|
|
||||||
|
Scenario: Basic Turn Lane 3-way Turn with designated lane
|
||||||
|
Given the node map
|
||||||
|
| a | | b | | c |
|
||||||
|
| | | d | | |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | turn:lanes | turn:lanes:forward | name | vehicle:lanes:forward |
|
||||||
|
| ab | | through\|through\|right | in | yes\|no\|yes |
|
||||||
|
| bc | | | straight | |
|
||||||
|
| bd | | | right | |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| waypoints | route | turns | lanes |
|
||||||
|
| a,c | in,straight,straight | depart,new name straight,arrive | ,straight:true right:false, |
|
||||||
|
| a,d | in,right,right | depart,turn right,arrive | ,straight:false right:true, |
|
||||||
|
|
||||||
Scenario: Basic Turn Lane 4-Way Turn
|
Scenario: Basic Turn Lane 4-Way Turn
|
||||||
Given the node map
|
Given the node map
|
||||||
| | | e | | |
|
| | | e | | |
|
||||||
|
@ -106,6 +106,13 @@ trimLaneString(std::string lane_string, std::int32_t count_left, std::int32_t co
|
|||||||
{
|
{
|
||||||
return extractor::guidance::trimLaneString(std::move(lane_string), count_left, count_right);
|
return extractor::guidance::trimLaneString(std::move(lane_string), count_left, count_right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string
|
||||||
|
applyAccessTokens(const std::string &lane_string, const std::string &access_tokens)
|
||||||
|
{
|
||||||
|
return extractor::guidance::trimLaneString(lane_string,access_tokens);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <boost/algorithm/string/predicate.hpp>
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
|
#include <boost/tokenizer.hpp>
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
@ -349,6 +350,46 @@ trimLaneString(std::string lane_string, std::int32_t count_left, std::int32_t co
|
|||||||
return lane_string;
|
return lane_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/Project-OSRM/osrm-backend/issues/2638
|
||||||
|
// It can happen that some lanes are not drivable by car. Here we handle this tagging scheme
|
||||||
|
// (vehicle:lanes) to filter out not-allowed roads
|
||||||
|
// lanes=3
|
||||||
|
// turn:lanes=left|through|through|right
|
||||||
|
// vehicle:lanes=yes|yes|no|yes
|
||||||
|
// bicycle:lanes=yes|no|designated|yes
|
||||||
|
|
||||||
|
inline std::string trimLaneString(std::string lane_string, const std::string &access_tokens)
|
||||||
|
{
|
||||||
|
typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
|
||||||
|
boost::char_separator<char> sep("|", "", boost::keep_empty_tokens);
|
||||||
|
tokenizer tokens(lane_string, sep);
|
||||||
|
tokenizer access(access_tokens, sep);
|
||||||
|
|
||||||
|
// strings don't match, don't do anything
|
||||||
|
if (std::distance(std::begin(tokens), std::end(tokens)) !=
|
||||||
|
std::distance(std::begin(access), std::end(access)))
|
||||||
|
return lane_string;
|
||||||
|
|
||||||
|
std::string result_string = "";
|
||||||
|
const static std::string yes = "yes";
|
||||||
|
|
||||||
|
for (auto token_itr = std::begin(tokens), access_itr = std::begin(access);
|
||||||
|
token_itr != std::end(tokens);
|
||||||
|
++token_itr, ++access_itr)
|
||||||
|
{
|
||||||
|
if (*access_itr == yes)
|
||||||
|
{
|
||||||
|
// we have to add this in front, because the next token could be invalid. Doing this on
|
||||||
|
// non-empty strings makes sure that the token string will be valid in the end
|
||||||
|
if (!result_string.empty())
|
||||||
|
result_string += '|';
|
||||||
|
|
||||||
|
result_string += *token_itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result_string;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace guidance
|
} // namespace guidance
|
||||||
} // namespace extractor
|
} // namespace extractor
|
||||||
} // namespace osrm
|
} // namespace osrm
|
||||||
|
@ -90,6 +90,18 @@ local function get_psv_counts(way)
|
|||||||
return fw, bw
|
return fw, bw
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- trims lane string with regard to supported lanes
|
||||||
|
local function process_lanes(turn_lane,vehicle_lane,first_count,second_count)
|
||||||
|
if turn_lane and turn_lane ~= "" then
|
||||||
|
if vehicle_lane and vehicle_lane ~= "" then
|
||||||
|
turn_lane = applyAccessTokens(turn_lane,vehicle_lane)
|
||||||
|
elseif fw_count ~= 0 or bw_count ~= 0 then
|
||||||
|
turn_lane = trimLaneString(turn_lane, first_count, second_count)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return turn_lane;
|
||||||
|
end
|
||||||
|
|
||||||
-- this is broken for left-sided driving. It needs to switch left and right in case of left-sided driving
|
-- this is broken for left-sided driving. It needs to switch left and right in case of left-sided driving
|
||||||
function Guidance.get_turn_lanes(way)
|
function Guidance.get_turn_lanes(way)
|
||||||
local fw_psv = 0
|
local fw_psv = 0
|
||||||
@ -100,12 +112,14 @@ function Guidance.get_turn_lanes(way)
|
|||||||
local turn_lanes_fw = way:get_value_by_key("turn:lanes:forward")
|
local turn_lanes_fw = way:get_value_by_key("turn:lanes:forward")
|
||||||
local turn_lanes_bw = way:get_value_by_key("turn:lanes:backward")
|
local turn_lanes_bw = way:get_value_by_key("turn:lanes:backward")
|
||||||
|
|
||||||
if( fw_psv ~= 0 or bw_psv ~= 0 ) then
|
local vehicle_lanes = way:get_value_by_key("vehicle:lanes");
|
||||||
turn_lanes = trimLaneString(turn_lanes, bw_psv, fw_psv )
|
local vehicle_lanes_fw = way:get_value_by_key("vehicle:lanes:forward");
|
||||||
turn_lanes_fw = trimLaneString(turn_lanes_fw, bw_psv, fw_psv )
|
local vehicle_lanes_bw = way:get_value_by_key("vehicle:lanes:backward");
|
||||||
|
|
||||||
|
turn_lanes = process_lanes(turn_lanes,vehicle_lanes,bw_psv,fw_psv)
|
||||||
|
turn_lanes_fw = process_lanes(turn_lanes_fw,vehicle_lanes_fw,bw_psv,fw_psv)
|
||||||
--backwards turn lanes need to treat bw_psv as fw_psv and vice versa
|
--backwards turn lanes need to treat bw_psv as fw_psv and vice versa
|
||||||
turn_lanes_bw = trimLaneString(turn_lanes_bw, fw_psv, bw_psv )
|
turn_lanes_bw = process_lanes(turn_lanes_bw,vehicle_lanes_bw,fw_psv,bw_psv)
|
||||||
end
|
|
||||||
|
|
||||||
return turn_lanes, turn_lanes_fw, turn_lanes_bw
|
return turn_lanes, turn_lanes_fw, turn_lanes_bw
|
||||||
end
|
end
|
||||||
|
@ -82,6 +82,7 @@ void LuaScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
|||||||
[luabind::def("durationIsValid", durationIsValid),
|
[luabind::def("durationIsValid", durationIsValid),
|
||||||
luabind::def("parseDuration", parseDuration),
|
luabind::def("parseDuration", parseDuration),
|
||||||
luabind::def("trimLaneString", trimLaneString),
|
luabind::def("trimLaneString", trimLaneString),
|
||||||
|
luabind::def("applyAccessTokens", applyAccessTokens),
|
||||||
luabind::class_<TravelMode>("mode").enum_(
|
luabind::class_<TravelMode>("mode").enum_(
|
||||||
"enums")[luabind::value("inaccessible", TRAVEL_MODE_INACCESSIBLE),
|
"enums")[luabind::value("inaccessible", TRAVEL_MODE_INACCESSIBLE),
|
||||||
luabind::value("driving", TRAVEL_MODE_DRIVING),
|
luabind::value("driving", TRAVEL_MODE_DRIVING),
|
||||||
|
15
taginfo.json
15
taginfo.json
@ -205,16 +205,31 @@
|
|||||||
"object_types": [ "way" ],
|
"object_types": [ "way" ],
|
||||||
"description": "Turn Lanes for lane guidance."
|
"description": "Turn Lanes for lane guidance."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"key": "vehicle:lanes",
|
||||||
|
"object_types": [ "way" ],
|
||||||
|
"description": "Access tags for turn lanes."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"key": "turn:lanes:forward",
|
"key": "turn:lanes:forward",
|
||||||
"object_types": [ "way" ],
|
"object_types": [ "way" ],
|
||||||
"description": "Turn Lanes for lane guidance."
|
"description": "Turn Lanes for lane guidance."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"key": "vehicle:lanes:forward",
|
||||||
|
"object_types": [ "way" ],
|
||||||
|
"description": "Access tags for turn lanes."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"key": "turn:lanes:backward",
|
"key": "turn:lanes:backward",
|
||||||
"object_types": [ "way" ],
|
"object_types": [ "way" ],
|
||||||
"description": "Turn Lanes for lane guidance."
|
"description": "Turn Lanes for lane guidance."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"key": "vehicle:lanes:backward",
|
||||||
|
"object_types": [ "way" ],
|
||||||
|
"description": "Access tags for turn lanes."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"key": "lanes:psv",
|
"key": "lanes:psv",
|
||||||
"object_types": [ "way" ],
|
"object_types": [ "way" ],
|
||||||
|
Loading…
Reference in New Issue
Block a user