Bearing calculation on matching short segments fix.
This commit is contained in:
parent
e34f2db4db
commit
7922a6172a
@ -25,7 +25,7 @@ std::pair<short, short> getDepartBearings(const LegGeometry &leg_geometry,
|
|||||||
const auto turn_coordinate = leg_geometry.locations.front();
|
const auto turn_coordinate = leg_geometry.locations.front();
|
||||||
const auto post_turn_coordinate = *(leg_geometry.locations.begin() + 1);
|
const auto post_turn_coordinate = *(leg_geometry.locations.begin() + 1);
|
||||||
|
|
||||||
if (turn_coordinate == post_turn_coordinate)
|
if (util::coordinate_calculation::haversineDistance(turn_coordinate, post_turn_coordinate) <= 1)
|
||||||
{
|
{
|
||||||
return std::make_pair<short, short>(0, source_node.GetBearing(traversed_in_reverse));
|
return std::make_pair<short, short>(0, source_node.GetBearing(traversed_in_reverse));
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ std::pair<short, short> getArriveBearings(const LegGeometry &leg_geometry,
|
|||||||
BOOST_ASSERT(leg_geometry.locations.size() >= 2);
|
BOOST_ASSERT(leg_geometry.locations.size() >= 2);
|
||||||
const auto turn_coordinate = leg_geometry.locations.back();
|
const auto turn_coordinate = leg_geometry.locations.back();
|
||||||
const auto pre_turn_coordinate = *(leg_geometry.locations.end() - 2);
|
const auto pre_turn_coordinate = *(leg_geometry.locations.end() - 2);
|
||||||
if (turn_coordinate == pre_turn_coordinate)
|
if (util::coordinate_calculation::haversineDistance(turn_coordinate, pre_turn_coordinate) <= 1)
|
||||||
{
|
{
|
||||||
return std::make_pair<short, short>(target_node.GetBearing(traversed_in_reverse), 0);
|
return std::make_pair<short, short>(target_node.GetBearing(traversed_in_reverse), 0);
|
||||||
}
|
}
|
||||||
|
@ -283,6 +283,7 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
|
|||||||
geometry.osm_node_ids.begin() + offset);
|
geometry.osm_node_ids.begin() + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto const first_bearing = steps.front().maneuver.bearing_after;
|
||||||
// We have to adjust the first step both for its name and the bearings
|
// We have to adjust the first step both for its name and the bearings
|
||||||
if (zero_length_step)
|
if (zero_length_step)
|
||||||
{
|
{
|
||||||
@ -339,10 +340,14 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
|
|||||||
});
|
});
|
||||||
|
|
||||||
auto &first_step = steps.front();
|
auto &first_step = steps.front();
|
||||||
|
auto bearing = first_bearing;
|
||||||
// we changed the geometry, we need to recalculate the bearing
|
// we changed the geometry, we need to recalculate the bearing
|
||||||
auto bearing = std::round(util::coordinate_calculation::bearing(
|
if (geometry.locations[first_step.geometry_begin] != geometry.locations[first_step.geometry_begin + 1])
|
||||||
|
{
|
||||||
|
bearing = std::round(util::coordinate_calculation::bearing(
|
||||||
geometry.locations[first_step.geometry_begin],
|
geometry.locations[first_step.geometry_begin],
|
||||||
geometry.locations[first_step.geometry_begin + 1]));
|
geometry.locations[first_step.geometry_begin + 1]));
|
||||||
|
}
|
||||||
first_step.maneuver.bearing_after = bearing;
|
first_step.maneuver.bearing_after = bearing;
|
||||||
first_step.intersections.front().bearings.front() = bearing;
|
first_step.intersections.front().bearings.front() = bearing;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user