adjusted to in/out. only emit one of them for depart/arrive
This commit is contained in:
committed by
Patrick Niklaus
parent
4d9aa65e78
commit
9c8bf820de
@@ -88,13 +88,12 @@ getIntersection(const guidance::Intersection &intersection, bool locate_before,
|
||||
const auto &available_bearings = intersection.bearing_class.getAvailableBearings();
|
||||
for (std::size_t i = 0; i < available_bearings.size(); ++i)
|
||||
{
|
||||
bearings.values.push_back(std::to_string(available_bearings[i]));
|
||||
bearings.values.push_back(available_bearings[i]);
|
||||
entry.values.push_back(intersection.entry_class.allowsEntry(i) ? "true" : "false");
|
||||
}
|
||||
result.values["location"] = detail::coordinateToLonLat(intersection.location);
|
||||
|
||||
bool requires_correction = false;
|
||||
if (locate_before || (!available_bearings.empty() && available_bearings.front()==0))
|
||||
if (locate_before)
|
||||
{
|
||||
// bearings are oriented in the direction of driving. For the in-bearing, we actually need
|
||||
// to
|
||||
@@ -104,31 +103,15 @@ getIntersection(const guidance::Intersection &intersection, bool locate_before,
|
||||
const auto rotated_bearing_before = (intersection.bearing_before >= 180.0)
|
||||
? (intersection.bearing_before - 180.0)
|
||||
: (intersection.bearing_before + 180.0);
|
||||
result.values["bearing_before"] =
|
||||
result.values["in"] =
|
||||
intersection.bearing_class.findMatchingBearing(rotated_bearing_before);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.values["bearing_before"] = available_bearings.size();
|
||||
requires_correction = true;
|
||||
}
|
||||
|
||||
if (locate_after || (!available_bearings.empty() && available_bearings.front()==0))
|
||||
if (locate_after)
|
||||
{
|
||||
result.values["bearing_after"] =
|
||||
result.values["out"] =
|
||||
intersection.bearing_class.findMatchingBearing(intersection.bearing_after);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.values["bearing_after"] = available_bearings.size();
|
||||
requires_correction = true;
|
||||
}
|
||||
|
||||
if (requires_correction)
|
||||
{
|
||||
bearings.values.push_back("0");
|
||||
entry.values.push_back("false");
|
||||
}
|
||||
|
||||
result.values["bearings"] = bearings;
|
||||
result.values["entry"] = entry;
|
||||
|
||||
@@ -45,7 +45,6 @@ void fillInDepart(Intersection &intersection, const LegGeometry &leg_geometry)
|
||||
intersection.bearing_before = 0;
|
||||
intersection.bearing_after =
|
||||
util::coordinate_calculation::bearing(turn_coordinate, post_turn_coordinate);
|
||||
std::cout << "Depart: " << intersection.bearing_before << " " << intersection.bearing_after << std::endl;
|
||||
}
|
||||
|
||||
void fillInArrive(Intersection &intersection, const LegGeometry &leg_geometry)
|
||||
@@ -57,7 +56,6 @@ void fillInArrive(Intersection &intersection, const LegGeometry &leg_geometry)
|
||||
intersection.bearing_before =
|
||||
util::coordinate_calculation::bearing(pre_turn_coordinate, turn_coordinate);
|
||||
intersection.bearing_after = 0;
|
||||
std::cout << "Arrive: " << intersection.bearing_before << " " << intersection.bearing_after << std::endl;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
||||
@@ -201,6 +201,7 @@ void closeOffRoundabout(const bool on_roundabout,
|
||||
// index back to the entering location and prepare the current silent set of instructions for
|
||||
// removal.
|
||||
std::vector<std::size_t> intermediate_steps;
|
||||
BOOST_ASSERT(!steps[step_index].intersections.empty());
|
||||
const auto exit_bearing = steps[step_index].intersections.back().bearing_after;
|
||||
if (step_index > 1)
|
||||
{
|
||||
@@ -245,6 +246,7 @@ void closeOffRoundabout(const bool on_roundabout,
|
||||
// % 360;
|
||||
// All other cases are handled by first rotating both bearings to an
|
||||
// entry_bearing of 0.
|
||||
BOOST_ASSERT(!propagation_step.intersections.empty());
|
||||
const double angle = [](const double entry_bearing, const double exit_bearing) {
|
||||
const double offset = 360 - entry_bearing;
|
||||
const double rotated_exit = [](double bearing, const double offset) {
|
||||
@@ -254,7 +256,7 @@ void closeOffRoundabout(const bool on_roundabout,
|
||||
|
||||
const auto angle = 540 - rotated_exit;
|
||||
return angle > 360 ? angle - 360 : angle;
|
||||
}(propagation_step.intersections.back().bearing_before, exit_bearing);
|
||||
}(propagation_step.intersections.front().bearing_before, exit_bearing);
|
||||
|
||||
propagation_step.maneuver.instruction.direction_modifier =
|
||||
::osrm::util::guidance::getTurnDirection(angle);
|
||||
@@ -335,12 +337,12 @@ void collapseTurnAt(std::vector<RouteStep> &steps,
|
||||
return angularDeviation(bearing_in, bearing_out) > 170;
|
||||
};
|
||||
|
||||
BOOST_ASSERT(!one_back_step.intersections.empty() && !current_step.intersections.empty());
|
||||
const auto isCollapsableInstruction = [](const TurnInstruction instruction) {
|
||||
return instruction.type == TurnType::NewName ||
|
||||
(instruction.type == TurnType::Turn &&
|
||||
instruction.direction_modifier == DirectionModifier::Straight);
|
||||
};
|
||||
|
||||
// Very Short New Name
|
||||
if (isCollapsableInstruction(one_back_step.maneuver.instruction))
|
||||
{
|
||||
@@ -679,7 +681,6 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
|
||||
[](const std::size_t val) { return val - 1; });
|
||||
|
||||
steps.front().maneuver = {TurnInstruction::NO_TURN(), WaypointType::Depart, 0};
|
||||
std::cout << "Removed coordinate: " << std::endl;
|
||||
}
|
||||
|
||||
// and update the leg geometry indices for the removed entry
|
||||
@@ -706,6 +707,7 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
|
||||
geometry.segment_distances.pop_back();
|
||||
|
||||
next_to_last_step.maneuver = {TurnInstruction::NO_TURN(), WaypointType::Arrive, 0};
|
||||
BOOST_ASSERT(!next_to_last_step.intersections.empty());
|
||||
next_to_last_step.intersections.front().bearing_after = 0;
|
||||
steps.pop_back();
|
||||
|
||||
@@ -761,6 +763,7 @@ std::vector<RouteStep> assignRelativeLocations(std::vector<RouteStep> steps,
|
||||
: extractor::guidance::DirectionModifier::UTurn;
|
||||
|
||||
steps.front().maneuver.instruction.direction_modifier = initial_modifier;
|
||||
BOOST_ASSERT(!steps.front().intersections.empty());
|
||||
steps.front().intersections.front().bearing_before = 0;
|
||||
steps.front().intersections.front().bearing_after =
|
||||
util::coordinate_calculation::bearing(leg_geometry.locations[0], leg_geometry.locations[1]);
|
||||
@@ -781,6 +784,7 @@ std::vector<RouteStep> assignRelativeLocations(std::vector<RouteStep> steps,
|
||||
steps.back().maneuver.instruction.direction_modifier = final_modifier;
|
||||
BOOST_ASSERT(steps.back().intersections.size() == 1);
|
||||
|
||||
BOOST_ASSERT(!steps.back().intersections.empty());
|
||||
steps.back().intersections.front().bearing_before = util::coordinate_calculation::bearing(
|
||||
leg_geometry.locations[leg_geometry.locations.size() - 2],
|
||||
leg_geometry.locations[leg_geometry.locations.size() - 1]);
|
||||
|
||||
Reference in New Issue
Block a user