@@ -361,120 +361,111 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
361361 node_based_graph.GetEdgeData (intersection[2 ].eid ).annotation_data );
362362 const auto &first_intersection_data = node_data_container.GetAnnotation (
363363 node_based_graph.GetEdgeData (intersection[1 ].eid ).annotation_data );
364- if (first_intersection_data.name_id == EMPTY_NAMEID ||
365- second_intersection_data.name_id == EMPTY_NAMEID)
364+ const auto first_second_same_name =
365+ !util::guidance::requiresNameAnnounced (second_intersection_data.name_id ,
366+ first_intersection_data.name_id ,
367+ name_table,
368+ street_name_suffix_table);
369+
370+ // merging onto a passing highway / or two ramps merging onto the same highway
371+ if (num_valid_turns == 1 )
366372 {
367- return fallback (std::move (intersection));
368- }
369- else
370- {
371- const auto first_second_same_name =
372- !util::guidance::requiresNameAnnounced (second_intersection_data.name_id ,
373- first_intersection_data.name_id ,
374- name_table,
375- street_name_suffix_table);
376-
377- // merging onto a passing highway / or two ramps merging onto the same highway
378- if (num_valid_turns == 1 )
373+ BOOST_ASSERT (!intersection[0 ].entry_allowed );
374+ // check order of highways
375+ // 4
376+ // 5 3
377+ //
378+ // 6 2
379+ //
380+ // 7 1
381+ // 0
382+ const auto &first_intersection_name_empty =
383+ name_table.GetNameForID (first_intersection_data.name_id ).empty ();
384+ const auto &second_intersection_name_empty =
385+ name_table.GetNameForID (second_intersection_data.name_id ).empty ();
386+ if (intersection[1 ].entry_allowed )
379387 {
380- BOOST_ASSERT (!intersection[0 ].entry_allowed );
381- // check order of highways
382- // 4
383- // 5 3
384- //
385- // 6 2
386- //
387- // 7 1
388- // 0
389- const auto &first_intersection_name_empty =
390- name_table.GetNameForID (first_intersection_data.name_id ).empty ();
391- const auto &second_intersection_name_empty =
392- name_table.GetNameForID (second_intersection_data.name_id ).empty ();
393- if (intersection[1 ].entry_allowed )
388+ if (isMotorwayClass (intersection[1 ].eid , node_based_graph) &&
389+ !second_intersection_name_empty && !first_intersection_name_empty &&
390+ first_second_same_name)
394391 {
395- if (isMotorwayClass (intersection[1 ].eid , node_based_graph) &&
396- !second_intersection_name_empty && !first_intersection_name_empty &&
397- first_second_same_name)
398- {
399- // circular order indicates a merge to the left (0-3 onto 4
400- if (angularDeviation (intersection[1 ].angle , STRAIGHT_ANGLE) <
401- 2 * NARROW_TURN_ANGLE)
402- intersection[1 ].instruction = {TurnType::Merge,
403- DirectionModifier::SlightLeft};
404- else // fallback
405- intersection[1 ].instruction = {TurnType::Merge,
406- getTurnDirection (intersection[1 ].angle )};
407- }
408- else // passing by the end of a motorway
409- {
410- intersection[1 ].instruction =
411- getInstructionForObvious (intersection.size (),
412- via_eid,
413- isThroughStreet (1 , intersection),
414- intersection[1 ]);
415- }
392+ // circular order indicates a merge to the left (0-3 onto 4
393+ if (angularDeviation (intersection[1 ].angle , STRAIGHT_ANGLE) <
394+ 2 * NARROW_TURN_ANGLE)
395+ intersection[1 ].instruction = {TurnType::Merge,
396+ DirectionModifier::SlightLeft};
397+ else // fallback
398+ intersection[1 ].instruction = {TurnType::Merge,
399+ getTurnDirection (intersection[1 ].angle )};
416400 }
417- else
401+ else // passing by the end of a motorway
418402 {
419- BOOST_ASSERT (intersection[2 ].entry_allowed );
420- if (isMotorwayClass (intersection[2 ].eid , node_based_graph) &&
421- !second_intersection_name_empty && !first_intersection_name_empty &&
422- first_second_same_name)
423- {
424- // circular order (5-0) onto 4
425- if (angularDeviation (intersection[2 ].angle , STRAIGHT_ANGLE) <
426- 2 * NARROW_TURN_ANGLE)
427- intersection[2 ].instruction = {TurnType::Merge,
428- DirectionModifier::SlightRight};
429- else // fallback
430- intersection[2 ].instruction = {TurnType::Merge,
431- getTurnDirection (intersection[2 ].angle )};
432- }
433- else // passing the end of a highway
434- {
435- intersection[2 ].instruction =
436- getInstructionForObvious (intersection.size (),
437- via_eid,
438- isThroughStreet (2 , intersection),
439- intersection[2 ]);
440- }
403+ intersection[1 ].instruction =
404+ getInstructionForObvious (intersection.size (),
405+ via_eid,
406+ isThroughStreet (1 , intersection),
407+ intersection[1 ]);
441408 }
442409 }
443410 else
444411 {
445- BOOST_ASSERT (num_valid_turns == 2 );
446- // UTurn on ramps is not possible
447- BOOST_ASSERT (!intersection[0 ].entry_allowed );
448- BOOST_ASSERT (intersection[1 ].entry_allowed );
449412 BOOST_ASSERT (intersection[2 ].entry_allowed );
450- // two motorways starting at end of ramp (fork)
451- // M M
452- // \ /
453- // |
413+ if (isMotorwayClass (intersection[2 ].eid , node_based_graph) &&
414+ !second_intersection_name_empty && !first_intersection_name_empty &&
415+ first_second_same_name)
416+ {
417+ // circular order (5-0) onto 4
418+ if (angularDeviation (intersection[2 ].angle , STRAIGHT_ANGLE) <
419+ 2 * NARROW_TURN_ANGLE)
420+ intersection[2 ].instruction = {TurnType::Merge,
421+ DirectionModifier::SlightRight};
422+ else // fallback
423+ intersection[2 ].instruction = {TurnType::Merge,
424+ getTurnDirection (intersection[2 ].angle )};
425+ }
426+ else // passing the end of a highway
427+ {
428+ intersection[2 ].instruction =
429+ getInstructionForObvious (intersection.size (),
430+ via_eid,
431+ isThroughStreet (2 , intersection),
432+ intersection[2 ]);
433+ }
434+ }
435+ }
436+ else
437+ {
438+ BOOST_ASSERT (num_valid_turns == 2 );
439+ // UTurn on ramps is not possible
440+ BOOST_ASSERT (!intersection[0 ].entry_allowed );
441+ BOOST_ASSERT (intersection[1 ].entry_allowed );
442+ BOOST_ASSERT (intersection[2 ].entry_allowed );
443+ // two motorways starting at end of ramp (fork)
444+ // M M
445+ // \ /
446+ // |
447+ // R
448+ if (isMotorwayClass (intersection[1 ].eid , node_based_graph) &&
449+ isMotorwayClass (intersection[2 ].eid , node_based_graph))
450+ {
451+ assignFork (via_eid, intersection[2 ], intersection[1 ]);
452+ }
453+ else
454+ {
455+ // continued ramp passing motorway entry
456+ // M R
457+ // M R
458+ // | /
454459 // R
455- if (isMotorwayClass (intersection[1 ].eid , node_based_graph) &&
456- isMotorwayClass (intersection[2 ].eid , node_based_graph))
460+ if (isMotorwayClass (intersection[1 ].eid , node_based_graph))
457461 {
458- assignFork (via_eid, intersection[2 ], intersection[1 ]);
462+ intersection[1 ].instruction = {TurnType::Turn, DirectionModifier::SlightRight};
463+ intersection[2 ].instruction = {TurnType::Continue,
464+ DirectionModifier::SlightLeft};
459465 }
460466 else
461467 {
462- // continued ramp passing motorway entry
463- // M R
464- // M R
465- // | /
466- // R
467- if (isMotorwayClass (intersection[1 ].eid , node_based_graph))
468- {
469- intersection[1 ].instruction = {TurnType::Turn,
470- DirectionModifier::SlightRight};
471- intersection[2 ].instruction = {TurnType::Continue,
472- DirectionModifier::SlightLeft};
473- }
474- else
475- {
476- assignFork (via_eid, intersection[2 ], intersection[1 ]);
477- }
468+ assignFork (via_eid, intersection[2 ], intersection[1 ]);
478469 }
479470 }
480471 }
0 commit comments