Adapt test to returning ref, Take Pronunciation into Account, Fixes name change heuristic usage in UTurn check
This commit is contained in:
committed by
Daniel J. H
parent
ccdebccde1
commit
6ac9617d49
@@ -127,9 +127,9 @@ double turn_angle(const double entry_bearing, const double exit_bearing)
|
||||
// Treats e.g. "Name (Ref)" -> "Name" changes still as same name.
|
||||
bool isNoticeableNameChange(const RouteStep &lhs, const RouteStep &rhs)
|
||||
{
|
||||
// TODO: at some point we might want to think about pronunciation here.
|
||||
// Also rotary_name is not handled at the moment.
|
||||
return util::guidance::requiresNameAnnounced(lhs.name, lhs.ref, rhs.name, rhs.ref);
|
||||
// TODO: rotary_name is not handled at the moment.
|
||||
return util::guidance::requiresNameAnnounced(
|
||||
lhs.name, lhs.ref, lhs.pronunciation, rhs.name, rhs.ref, rhs.pronunciation);
|
||||
}
|
||||
|
||||
double nameSegmentLength(std::size_t at, const std::vector<RouteStep> &steps)
|
||||
@@ -372,10 +372,10 @@ bool isLinkroad(const RouteStep &step)
|
||||
|
||||
bool isUTurn(const RouteStep &in_step, const RouteStep &out_step, const RouteStep &pre_in_step)
|
||||
{
|
||||
const bool is_possible_candidate = in_step.distance <= MAX_COLLAPSE_DISTANCE ||
|
||||
choiceless(out_step, in_step) ||
|
||||
(isLinkroad(in_step) && out_step.name_id != EMPTY_NAMEID &&
|
||||
pre_in_step.name_id == out_step.name_id);
|
||||
const bool is_possible_candidate =
|
||||
in_step.distance <= MAX_COLLAPSE_DISTANCE || choiceless(out_step, in_step) ||
|
||||
(isLinkroad(in_step) && out_step.name_id != EMPTY_NAMEID &&
|
||||
pre_in_step.name_id != EMPTY_NAMEID && !isNoticeableNameChange(pre_in_step, out_step));
|
||||
const bool takes_u_turn = bearingsAreReversed(
|
||||
util::bearing::reverseBearing(
|
||||
in_step.intersections.front().bearings[in_step.intersections.front().in]),
|
||||
|
||||
@@ -229,11 +229,8 @@ bool IntersectionGenerator::CanMerge(const NodeID node_at_intersection,
|
||||
|
||||
// need to be same name
|
||||
if (second_data.name_id != EMPTY_NAMEID &&
|
||||
util::guidance::requiresNameAnnounced(name_table.GetNameForID(first_data.name_id),
|
||||
name_table.GetRefForID(first_data.name_id),
|
||||
name_table.GetNameForID(second_data.name_id),
|
||||
name_table.GetRefForID(second_data.name_id),
|
||||
street_name_suffix_table))
|
||||
util::guidance::requiresNameAnnounced(
|
||||
first_data.name_id, second_data.name_id, name_table, street_name_suffix_table))
|
||||
return false;
|
||||
|
||||
// compatibility is required
|
||||
@@ -341,11 +338,8 @@ bool IntersectionGenerator::CanMerge(const NodeID node_at_intersection,
|
||||
const auto &third_data = node_based_graph.GetEdgeData(intersection[third_index].eid);
|
||||
|
||||
if (third_data.name_id != EMPTY_NAMEID &&
|
||||
util::guidance::requiresNameAnnounced(name_table.GetNameForID(third_data.name_id),
|
||||
name_table.GetRefForID(third_data.name_id),
|
||||
name_table.GetNameForID(first_data.name_id),
|
||||
name_table.GetRefForID(first_data.name_id),
|
||||
street_name_suffix_table))
|
||||
util::guidance::requiresNameAnnounced(
|
||||
third_data.name_id, first_data.name_id, name_table, street_name_suffix_table))
|
||||
return false;
|
||||
|
||||
// we only allow collapsing of a Y like fork. So the angle to the third index has to be
|
||||
|
||||
@@ -59,12 +59,8 @@ TurnType::Enum IntersectionHandler::findBasicTurnType(const EdgeID via_edge,
|
||||
if (!on_ramp && onto_ramp)
|
||||
return TurnType::OnRamp;
|
||||
|
||||
const auto same_name =
|
||||
!util::guidance::requiresNameAnnounced(name_table.GetNameForID(in_data.name_id),
|
||||
name_table.GetRefForID(in_data.name_id),
|
||||
name_table.GetNameForID(out_data.name_id),
|
||||
name_table.GetRefForID(out_data.name_id),
|
||||
street_name_suffix_table);
|
||||
const auto same_name = !util::guidance::requiresNameAnnounced(
|
||||
in_data.name_id, out_data.name_id, name_table, street_name_suffix_table);
|
||||
|
||||
if (in_data.name_id != EMPTY_NAMEID && out_data.name_id != EMPTY_NAMEID && same_name)
|
||||
{
|
||||
@@ -97,11 +93,8 @@ TurnInstruction IntersectionHandler::getInstructionForObvious(const std::size_t
|
||||
const auto &in_data = node_based_graph.GetEdgeData(via_edge);
|
||||
const auto &out_data = node_based_graph.GetEdgeData(road.eid);
|
||||
|
||||
if (util::guidance::requiresNameAnnounced(name_table.GetNameForID(in_data.name_id),
|
||||
name_table.GetRefForID(in_data.name_id),
|
||||
name_table.GetNameForID(out_data.name_id),
|
||||
name_table.GetRefForID(out_data.name_id),
|
||||
street_name_suffix_table))
|
||||
if (util::guidance::requiresNameAnnounced(
|
||||
in_data.name_id, out_data.name_id, name_table, street_name_suffix_table))
|
||||
{
|
||||
// obvious turn onto a through street is a merge
|
||||
if (through_street)
|
||||
@@ -367,11 +360,8 @@ bool IntersectionHandler::isThroughStreet(const std::size_t index,
|
||||
|
||||
const bool have_same_name =
|
||||
road_data.name_id != EMPTY_NAMEID &&
|
||||
!util::guidance::requiresNameAnnounced(name_table.GetNameForID(data_at_index.name_id),
|
||||
name_table.GetRefForID(data_at_index.name_id),
|
||||
name_table.GetNameForID(road_data.name_id),
|
||||
name_table.GetRefForID(road_data.name_id),
|
||||
street_name_suffix_table);
|
||||
!util::guidance::requiresNameAnnounced(
|
||||
data_at_index.name_id, road_data.name_id, name_table, street_name_suffix_table);
|
||||
|
||||
const bool have_same_category =
|
||||
data_at_index.road_classification == road_data.road_classification;
|
||||
@@ -413,12 +403,8 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
const auto continue_class =
|
||||
node_based_graph.GetEdgeData(intersection[best_continue].eid).road_classification;
|
||||
|
||||
const auto same_name =
|
||||
!util::guidance::requiresNameAnnounced(name_table.GetNameForID(in_data.name_id),
|
||||
name_table.GetRefForID(in_data.name_id),
|
||||
name_table.GetNameForID(out_data.name_id),
|
||||
name_table.GetRefForID(out_data.name_id),
|
||||
street_name_suffix_table);
|
||||
const auto same_name = !util::guidance::requiresNameAnnounced(
|
||||
in_data.name_id, out_data.name_id, name_table, street_name_suffix_table);
|
||||
|
||||
if (same_name && (best_continue == 0 || (continue_class.GetPriority() >
|
||||
out_data.road_classification.GetPriority() &&
|
||||
@@ -476,11 +462,7 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
const auto &road_data = node_based_graph.GetEdgeData(road.eid);
|
||||
|
||||
const auto same_name = !util::guidance::requiresNameAnnounced(
|
||||
name_table.GetNameForID(in_data.name_id),
|
||||
name_table.GetRefForID(in_data.name_id),
|
||||
name_table.GetNameForID(road_data.name_id),
|
||||
name_table.GetRefForID(road_data.name_id),
|
||||
street_name_suffix_table);
|
||||
in_data.name_id, road_data.name_id, name_table, street_name_suffix_table);
|
||||
|
||||
if (same_name)
|
||||
{
|
||||
@@ -511,12 +493,11 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
return std::count_if(
|
||||
intersection.begin() + 1, intersection.end(), [&](const ConnectedRoad &road) {
|
||||
const auto &road_data = node_based_graph.GetEdgeData(road.eid);
|
||||
const auto same_name = !util::guidance::requiresNameAnnounced(
|
||||
name_table.GetNameForID(in_data.name_id),
|
||||
name_table.GetRefForID(in_data.name_id),
|
||||
name_table.GetNameForID(road_data.name_id),
|
||||
name_table.GetRefForID(road_data.name_id),
|
||||
street_name_suffix_table);
|
||||
const auto same_name =
|
||||
!util::guidance::requiresNameAnnounced(in_data.name_id,
|
||||
road_data.name_id,
|
||||
name_table,
|
||||
street_name_suffix_table);
|
||||
|
||||
return same_name &&
|
||||
angularDeviation(road.angle, STRAIGHT_ANGLE) < NARROW_TURN_ANGLE;
|
||||
@@ -725,11 +706,7 @@ std::size_t IntersectionHandler::findObviousTurn(const EdgeID via_edge,
|
||||
*/
|
||||
|
||||
const auto same_name = !util::guidance::requiresNameAnnounced(
|
||||
name_table.GetNameForID(turn_data.name_id),
|
||||
name_table.GetRefForID(turn_data.name_id),
|
||||
name_table.GetNameForID(continue_data.name_id),
|
||||
name_table.GetRefForID(continue_data.name_id),
|
||||
street_name_suffix_table);
|
||||
turn_data.name_id, continue_data.name_id, name_table, street_name_suffix_table);
|
||||
|
||||
if (same_name && deviation_ratio < 1.5 * DISTINCTION_RATIO)
|
||||
return 0;
|
||||
|
||||
@@ -121,12 +121,8 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
{
|
||||
const auto &out_data = node_based_graph.GetEdgeData(road.eid);
|
||||
|
||||
const auto same_name =
|
||||
!util::guidance::requiresNameAnnounced(name_table.GetNameForID(in_data.name_id),
|
||||
name_table.GetRefForID(in_data.name_id),
|
||||
name_table.GetNameForID(out_data.name_id),
|
||||
name_table.GetRefForID(out_data.name_id),
|
||||
street_name_suffix_table);
|
||||
const auto same_name = !util::guidance::requiresNameAnnounced(
|
||||
in_data.name_id, out_data.name_id, name_table, street_name_suffix_table);
|
||||
|
||||
if (road.angle != 0 && in_data.name_id != EMPTY_NAMEID &&
|
||||
out_data.name_id != EMPTY_NAMEID && same_name &&
|
||||
@@ -361,16 +357,13 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
|
||||
}
|
||||
else if (intersection.size() == 3)
|
||||
{
|
||||
const auto &second_intersection_data =
|
||||
node_based_graph.GetEdgeData(intersection[2].eid);
|
||||
const auto &first_intersection_data =
|
||||
node_based_graph.GetEdgeData(intersection[1].eid);
|
||||
const auto first_second_same_name = !util::guidance::requiresNameAnnounced(
|
||||
name_table.GetNameForID(second_intersection_data.name_id),
|
||||
name_table.GetRefForID(second_intersection_data.name_id),
|
||||
name_table.GetNameForID(first_intersection_data.name_id),
|
||||
name_table.GetRefForID(first_intersection_data.name_id),
|
||||
street_name_suffix_table);
|
||||
const auto &second_intersection_data = node_based_graph.GetEdgeData(intersection[2].eid);
|
||||
const auto &first_intersection_data = node_based_graph.GetEdgeData(intersection[1].eid);
|
||||
const auto first_second_same_name =
|
||||
!util::guidance::requiresNameAnnounced(second_intersection_data.name_id,
|
||||
first_intersection_data.name_id,
|
||||
name_table,
|
||||
street_name_suffix_table);
|
||||
|
||||
// merging onto a passing highway / or two ramps merging onto the same highway
|
||||
if (num_valid_turns == 1)
|
||||
|
||||
@@ -242,11 +242,7 @@ RoundaboutType RoundaboutHandler::getRoundaboutType(const NodeID nid) const
|
||||
|
||||
const auto announce = [&](unsigned id) {
|
||||
return util::guidance::requiresNameAnnounced(
|
||||
name_table.GetNameForID(id),
|
||||
name_table.GetRefForID(id),
|
||||
name_table.GetNameForID(edge_data.name_id),
|
||||
name_table.GetRefForID(edge_data.name_id),
|
||||
street_name_suffix_table);
|
||||
id, edge_data.name_id, name_table, street_name_suffix_table);
|
||||
};
|
||||
|
||||
if (std::all_of(begin(roundabout_name_ids), end(roundabout_name_ids), announce))
|
||||
|
||||
@@ -154,11 +154,7 @@ operator()(const NodeID, const EdgeID source_edge_id, Intersection intersection)
|
||||
// Test to see if the source edge and the one we're looking at are the same road
|
||||
|
||||
const auto same_name = !util::guidance::requiresNameAnnounced(
|
||||
name_table.GetNameForID(road_edge_data.name_id),
|
||||
name_table.GetRefForID(road_edge_data.name_id),
|
||||
name_table.GetNameForID(source_edge_data.name_id),
|
||||
name_table.GetRefForID(source_edge_data.name_id),
|
||||
street_name_suffix_table);
|
||||
road_edge_data.name_id, source_edge_data.name_id, name_table, street_name_suffix_table);
|
||||
|
||||
return road_edge_data.road_classification == source_edge_data.road_classification &&
|
||||
road_edge_data.name_id != EMPTY_NAMEID && source_edge_data.name_id != EMPTY_NAMEID &&
|
||||
@@ -229,10 +225,9 @@ operator()(const NodeID, const EdgeID source_edge_id, Intersection intersection)
|
||||
const auto same_name =
|
||||
road_edge_data.name_id != EMPTY_NAMEID &&
|
||||
!util::guidance::requiresNameAnnounced(
|
||||
name_table.GetNameForID(road_edge_data.name_id),
|
||||
name_table.GetRefForID(road_edge_data.name_id),
|
||||
name_table.GetNameForID(link_data.name_id),
|
||||
name_table.GetRefForID(link_data.name_id),
|
||||
road_edge_data.name_id,
|
||||
link_data.name_id,
|
||||
name_table,
|
||||
street_name_suffix_table);
|
||||
|
||||
return same_name;
|
||||
@@ -274,14 +269,10 @@ operator()(const NodeID, const EdgeID source_edge_id, Intersection intersection)
|
||||
{
|
||||
const auto &next_data = node_based_graph.GetEdgeData(next_road.eid);
|
||||
|
||||
const auto same_name = next_data.name_id != EMPTY_NAMEID &&
|
||||
source_edge_data.name_id != EMPTY_NAMEID &&
|
||||
!util::guidance::requiresNameAnnounced(
|
||||
name_table.GetNameForID(next_data.name_id),
|
||||
name_table.GetRefForID(next_data.name_id),
|
||||
name_table.GetNameForID(source_edge_data.name_id),
|
||||
name_table.GetRefForID(source_edge_data.name_id),
|
||||
street_name_suffix_table);
|
||||
const auto same_name =
|
||||
next_data.name_id != EMPTY_NAMEID && source_edge_data.name_id != EMPTY_NAMEID &&
|
||||
!util::guidance::requiresNameAnnounced(
|
||||
next_data.name_id, source_edge_data.name_id, name_table, street_name_suffix_table);
|
||||
|
||||
if (same_name)
|
||||
{
|
||||
|
||||
@@ -112,12 +112,8 @@ bool TurnHandler::isObviousOfTwo(const EdgeID via_edge,
|
||||
|
||||
const auto &road_data = node_based_graph.GetEdgeData(road.eid);
|
||||
|
||||
const auto same_name =
|
||||
!util::guidance::requiresNameAnnounced(name_table.GetNameForID(in_data.name_id),
|
||||
name_table.GetRefForID(in_data.name_id),
|
||||
name_table.GetNameForID(road_data.name_id),
|
||||
name_table.GetRefForID(road_data.name_id),
|
||||
street_name_suffix_table);
|
||||
const auto same_name = !util::guidance::requiresNameAnnounced(
|
||||
in_data.name_id, road_data.name_id, name_table, street_name_suffix_table);
|
||||
|
||||
if (turn_is_perfectly_straight && in_data.name_id != EMPTY_NAMEID &&
|
||||
road_data.name_id != EMPTY_NAMEID && same_name)
|
||||
|
||||
@@ -85,5 +85,22 @@ std::string NameTable::GetRefForID(const unsigned name_id) const
|
||||
return GetNameForID(name_id + OFFSET_REF);
|
||||
}
|
||||
|
||||
std::string NameTable::GetPronunciationForID(const unsigned name_id) const
|
||||
{
|
||||
// Way string data is stored in blocks based on `name_id` as follows:
|
||||
//
|
||||
// | name | destination | pronunciation | ref |
|
||||
// ^ ^
|
||||
// [range)
|
||||
// ^ name_id + 2
|
||||
//
|
||||
// `name_id + offset` gives us the range of chars.
|
||||
//
|
||||
// Offset 0 is name, 1 is destination, 2 is pronunciation, 3 is ref.
|
||||
// See datafacades and extractor callbacks for details.
|
||||
const constexpr auto OFFSET_PRONUNCIATION = 2u;
|
||||
return GetNameForID(name_id + OFFSET_PRONUNCIATION);
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
} // namespace osrm
|
||||
|
||||
Reference in New Issue
Block a user