added list of intersections to the step-maneuver, not in api so far
This commit is contained in:
parent
f3ea86b611
commit
83e6679d61
@ -43,7 +43,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
|||||||
const bool source_traversed_in_reverse,
|
const bool source_traversed_in_reverse,
|
||||||
const bool target_traversed_in_reverse)
|
const bool target_traversed_in_reverse)
|
||||||
{
|
{
|
||||||
const double constexpr ZERO_DURACTION = 0., ZERO_DISTANCE = 0.;
|
const double constexpr ZERO_DURATION = 0., ZERO_DISTANCE = 0.;
|
||||||
const EdgeWeight source_duration =
|
const EdgeWeight source_duration =
|
||||||
source_traversed_in_reverse ? source_node.reverse_weight : source_node.forward_weight;
|
source_traversed_in_reverse ? source_node.reverse_weight : source_node.forward_weight;
|
||||||
const auto source_mode = source_traversed_in_reverse ? source_node.backward_travel_mode
|
const auto source_mode = source_traversed_in_reverse ? source_node.backward_travel_mode
|
||||||
@ -167,7 +167,7 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
|
|||||||
WaypointType::Arrive, leg_geometry);
|
WaypointType::Arrive, leg_geometry);
|
||||||
steps.push_back(RouteStep{target_node.name_id,
|
steps.push_back(RouteStep{target_node.name_id,
|
||||||
facade.GetNameForID(target_node.name_id),
|
facade.GetNameForID(target_node.name_id),
|
||||||
ZERO_DURACTION,
|
ZERO_DURATION,
|
||||||
ZERO_DISTANCE,
|
ZERO_DISTANCE,
|
||||||
target_mode,
|
target_mode,
|
||||||
final_maneuver,
|
final_maneuver,
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "extractor/guidance/turn_instruction.hpp"
|
#include "extractor/guidance/turn_instruction.hpp"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
@ -20,6 +21,14 @@ enum class WaypointType : std::uint8_t
|
|||||||
Depart,
|
Depart,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//A represenetation of intermediate intersections
|
||||||
|
struct IntermediateIntersection
|
||||||
|
{
|
||||||
|
double duration;
|
||||||
|
double distance;
|
||||||
|
util::Coordinate location;
|
||||||
|
};
|
||||||
|
|
||||||
struct StepManeuver
|
struct StepManeuver
|
||||||
{
|
{
|
||||||
util::Coordinate location;
|
util::Coordinate location;
|
||||||
@ -28,7 +37,7 @@ struct StepManeuver
|
|||||||
extractor::guidance::TurnInstruction instruction;
|
extractor::guidance::TurnInstruction instruction;
|
||||||
WaypointType waypoint_type;
|
WaypointType waypoint_type;
|
||||||
unsigned exit;
|
unsigned exit;
|
||||||
unsigned intersection;
|
std::vector<IntermediateIntersection> intersections;
|
||||||
};
|
};
|
||||||
} // namespace guidance
|
} // namespace guidance
|
||||||
} // namespace engine
|
} // namespace engine
|
||||||
|
@ -153,8 +153,8 @@ util::json::Object makeStepManeuver(const guidance::StepManeuver &maneuver)
|
|||||||
//TODO currently we need this to comply with the api.
|
//TODO currently we need this to comply with the api.
|
||||||
//We should move this to an additional entry, the moment we
|
//We should move this to an additional entry, the moment we
|
||||||
//actually compute the correct locations of the intersections
|
//actually compute the correct locations of the intersections
|
||||||
if (maneuver.intersection != 0 && maneuver.exit == 0 )
|
if (!maneuver.intersections.empty() && maneuver.exit == 0 )
|
||||||
step_maneuver.values["exit"] = maneuver.intersection;
|
step_maneuver.values["exit"] = maneuver.intersections.size();
|
||||||
return step_maneuver;
|
return step_maneuver;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,13 +37,15 @@ StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instr
|
|||||||
pre_turn_bearing =
|
pre_turn_bearing =
|
||||||
util::coordinate_calculation::bearing(pre_turn_coordinate, turn_coordinate);
|
util::coordinate_calculation::bearing(pre_turn_coordinate, turn_coordinate);
|
||||||
}
|
}
|
||||||
return StepManeuver{turn_coordinate,
|
return StepManeuver{
|
||||||
|
std::move(turn_coordinate),
|
||||||
pre_turn_bearing,
|
pre_turn_bearing,
|
||||||
post_turn_bearing,
|
post_turn_bearing,
|
||||||
instruction,
|
std::move(instruction),
|
||||||
waypoint_type,
|
waypoint_type,
|
||||||
INVALID_EXIT_NR,
|
INVALID_EXIT_NR,
|
||||||
INVALID_EXIT_NR};
|
{} // no intermediate intersections
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
|
StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instruction,
|
||||||
@ -64,13 +66,15 @@ StepManeuver stepManeuverFromGeometry(extractor::guidance::TurnInstruction instr
|
|||||||
const double post_turn_bearing =
|
const double post_turn_bearing =
|
||||||
util::coordinate_calculation::bearing(turn_coordinate, post_turn_coordinate);
|
util::coordinate_calculation::bearing(turn_coordinate, post_turn_coordinate);
|
||||||
|
|
||||||
return StepManeuver{turn_coordinate,
|
return StepManeuver{
|
||||||
|
std::move(turn_coordinate),
|
||||||
pre_turn_bearing,
|
pre_turn_bearing,
|
||||||
post_turn_bearing,
|
post_turn_bearing,
|
||||||
instruction,
|
std::move(instruction),
|
||||||
WaypointType::None,
|
WaypointType::None,
|
||||||
INVALID_EXIT_NR,
|
INVALID_EXIT_NR,
|
||||||
INVALID_EXIT_NR};
|
{} // no intermediate intersections
|
||||||
|
};
|
||||||
}
|
}
|
||||||
} // ns detail
|
} // ns detail
|
||||||
} // ns engine
|
} // ns engine
|
||||||
|
@ -4,8 +4,11 @@
|
|||||||
#include "engine/guidance/toolkit.hpp"
|
#include "engine/guidance/toolkit.hpp"
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
#include <boost/range/algorithm_ext/erase.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <vector>
|
#include <cstddef>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using TurnInstruction = osrm::extractor::guidance::TurnInstruction;
|
using TurnInstruction = osrm::extractor::guidance::TurnInstruction;
|
||||||
using TurnType = osrm::extractor::guidance::TurnType;
|
using TurnType = osrm::extractor::guidance::TurnType;
|
||||||
@ -32,67 +35,41 @@ RouteStep forwardInto(RouteStep destination, const RouteStep &source)
|
|||||||
// Overwrites turn instruction and increases exit NR
|
// Overwrites turn instruction and increases exit NR
|
||||||
destination.duration += source.duration;
|
destination.duration += source.duration;
|
||||||
destination.distance += source.distance;
|
destination.distance += source.distance;
|
||||||
destination.geometry_begin = std::min( destination.geometry_begin, source.geometry_begin );
|
destination.geometry_begin = std::min(destination.geometry_begin, source.geometry_begin);
|
||||||
destination.geometry_end = std::max( destination.geometry_end, source.geometry_end );
|
destination.geometry_end = std::max(destination.geometry_end, source.geometry_end);
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace detail
|
void fixFinalRoundabout(std::vector<RouteStep> &steps)
|
||||||
|
|
||||||
void print(const std::vector<RouteStep> &steps)
|
|
||||||
{
|
{
|
||||||
std::cout << "Path\n";
|
for (std::size_t propagation_index = steps.size() - 1; propagation_index > 0;
|
||||||
int segment = 0;
|
--propagation_index)
|
||||||
for (const auto &step : steps)
|
|
||||||
{
|
{
|
||||||
const auto type = static_cast<int>(step.maneuver.instruction.type);
|
auto &propagation_step = steps[propagation_index];
|
||||||
const auto modifier = static_cast<int>(step.maneuver.instruction.direction_modifier);
|
if (entersRoundabout(propagation_step.maneuver.instruction))
|
||||||
|
{
|
||||||
std::cout << "\t[" << ++segment << "]: " << type << " " << modifier
|
propagation_step.maneuver.exit = 0;
|
||||||
<< " Duration: " << step.duration << " Distance: " << step.distance
|
propagation_step.geometry_end = steps.back().geometry_begin;
|
||||||
<< " Geometry: " << step.geometry_begin << " " << step.geometry_end
|
break;
|
||||||
<< " exit: " << step.maneuver.exit << " Intersection: " << step.maneuver.intersection << " name[" << step.name_id
|
}
|
||||||
<< "]: " << step.name << std::endl;
|
else if (propagation_step.maneuver.instruction.type == TurnType::StayOnRoundabout)
|
||||||
|
{
|
||||||
|
//TODO this operates on the data that is in the instructions.
|
||||||
|
//We are missing out on the final segment after the last stay-on-roundabout
|
||||||
|
//instruction though. it is not contained somewhere until now
|
||||||
|
steps[propagation_index - 1] =
|
||||||
|
forwardInto(std::move(steps[propagation_index - 1]), propagation_step);
|
||||||
|
propagation_step.maneuver.instruction =
|
||||||
|
TurnInstruction::NO_TURN(); // mark intermediate instructions invalid
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Every Step Maneuver consists of the information until the turn.
|
bool setUpRoundabout(RouteStep &step)
|
||||||
// This list contains a set of instructions, called silent, which should
|
|
||||||
// not be part of the final output.
|
|
||||||
// They are required for maintenance purposes. We can calculate the number
|
|
||||||
// of exits to pass in a roundabout and the number of intersections
|
|
||||||
// that we come across.
|
|
||||||
|
|
||||||
std::vector<RouteStep> postProcess(std::vector<RouteStep> steps)
|
|
||||||
{
|
{
|
||||||
// the steps should always include the first/last step in form of a location
|
|
||||||
BOOST_ASSERT(steps.size() >= 2);
|
|
||||||
if (steps.size() == 2)
|
|
||||||
return steps;
|
|
||||||
|
|
||||||
#define PRINT_DEBUG 0
|
|
||||||
#if PRINT_DEBUG
|
|
||||||
std::cout << "[POSTPROCESSING ITERATION]" << std::endl;
|
|
||||||
std::cout << "Input\n";
|
|
||||||
print(steps);
|
|
||||||
#endif
|
|
||||||
// Count Street Exits forward
|
|
||||||
bool on_roundabout = false;
|
|
||||||
|
|
||||||
// count the exits forward. if enter/exit roundabout happen both, no further treatment is
|
|
||||||
// required. We might end up with only one of them (e.g. starting within a roundabout)
|
|
||||||
// or having a via-point in the roundabout.
|
|
||||||
// In this case, exits are numbered from the start of the lag.
|
|
||||||
std::size_t last_valid_instruction = 0;
|
|
||||||
for (std::size_t step_index = 0; step_index < steps.size(); ++step_index)
|
|
||||||
{
|
|
||||||
auto &step = steps[step_index];
|
|
||||||
const auto instruction = step.maneuver.instruction;
|
|
||||||
if (entersRoundabout(instruction))
|
|
||||||
{
|
|
||||||
last_valid_instruction = step_index;
|
|
||||||
// basic entry into a roundabout
|
// basic entry into a roundabout
|
||||||
// Special case handling, if an entry is directly tied to an exit
|
// Special case handling, if an entry is directly tied to an exit
|
||||||
|
const auto instruction = step.maneuver.instruction;
|
||||||
if (instruction.type == TurnType::EnterRotaryAtExit ||
|
if (instruction.type == TurnType::EnterRotaryAtExit ||
|
||||||
instruction.type == TurnType::EnterRoundaboutAtExit)
|
instruction.type == TurnType::EnterRoundaboutAtExit)
|
||||||
{
|
{
|
||||||
@ -111,24 +88,19 @@ std::vector<RouteStep> postProcess(std::vector<RouteStep> steps)
|
|||||||
step.maneuver.instruction = TurnType::EnterRotary;
|
step.maneuver.instruction = TurnType::EnterRotary;
|
||||||
else
|
else
|
||||||
step.maneuver.instruction = TurnType::EnterRoundabout;
|
step.maneuver.instruction = TurnType::EnterRoundabout;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
on_roundabout = true;
|
return true;
|
||||||
if (step_index + 1 < steps.size())
|
|
||||||
steps[step_index + 1].maneuver.exit = step.maneuver.exit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (instruction.type == TurnType::StayOnRoundabout)
|
|
||||||
{
|
void closeOffRoundabout(const bool on_roundabout,
|
||||||
// increase the exit number we require passing the exit
|
std::vector<RouteStep> &steps,
|
||||||
step.maneuver.exit += 1;
|
const std::size_t step_index)
|
||||||
if (step_index + 1 < steps.size())
|
{
|
||||||
steps[step_index + 1].maneuver.exit = step.maneuver.exit;
|
auto &step = steps[step_index];
|
||||||
}
|
|
||||||
else if (leavesRoundabout(instruction))
|
|
||||||
{
|
|
||||||
// count the exit (0 based vs 1 based counting)
|
|
||||||
step.maneuver.exit += 1;
|
step.maneuver.exit += 1;
|
||||||
if (!on_roundabout)
|
if (!on_roundabout)
|
||||||
{
|
{
|
||||||
@ -144,13 +116,9 @@ std::vector<RouteStep> postProcess(std::vector<RouteStep> steps)
|
|||||||
steps[1] = detail::forwardInto(steps[1], steps[0]);
|
steps[1] = detail::forwardInto(steps[1], steps[0]);
|
||||||
steps[0].duration = 0;
|
steps[0].duration = 0;
|
||||||
steps[0].distance = 0;
|
steps[0].distance = 0;
|
||||||
steps[1].maneuver.instruction.type =
|
steps[1].maneuver.instruction.type = step.maneuver.instruction.type == TurnType::ExitRotary
|
||||||
step.maneuver.instruction.type == TurnType::ExitRotary
|
|
||||||
? TurnType::EnterRotary
|
? TurnType::EnterRotary
|
||||||
: TurnType::EnterRoundabout;
|
: TurnType::EnterRoundabout;
|
||||||
|
|
||||||
//remember the now enter-instruction as valid
|
|
||||||
last_valid_instruction = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normal exit from the roundabout, or exit from a previously fixed roundabout.
|
// Normal exit from the roundabout, or exit from a previously fixed roundabout.
|
||||||
@ -164,8 +132,7 @@ std::vector<RouteStep> postProcess(std::vector<RouteStep> steps)
|
|||||||
--propagation_index)
|
--propagation_index)
|
||||||
{
|
{
|
||||||
auto &propagation_step = steps[propagation_index];
|
auto &propagation_step = steps[propagation_index];
|
||||||
propagation_step =
|
propagation_step = detail::forwardInto(propagation_step, steps[propagation_index + 1]);
|
||||||
detail::forwardInto(propagation_step, steps[propagation_index + 1]);
|
|
||||||
if (entersRoundabout(propagation_step.maneuver.instruction))
|
if (entersRoundabout(propagation_step.maneuver.instruction))
|
||||||
{
|
{
|
||||||
// TODO at this point, we can remember the additional name for a rotary
|
// TODO at this point, we can remember the additional name for a rotary
|
||||||
@ -187,18 +154,110 @@ std::vector<RouteStep> postProcess(std::vector<RouteStep> steps)
|
|||||||
// remove exit
|
// remove exit
|
||||||
step.maneuver.instruction = TurnInstruction::NO_TURN();
|
step.maneuver.instruction = TurnInstruction::NO_TURN();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
void print(const std::vector<RouteStep> &steps)
|
||||||
|
{
|
||||||
|
std::cout << "Path\n";
|
||||||
|
int segment = 0;
|
||||||
|
for (const auto &step : steps)
|
||||||
|
{
|
||||||
|
const auto type = static_cast<int>(step.maneuver.instruction.type);
|
||||||
|
const auto modifier = static_cast<int>(step.maneuver.instruction.direction_modifier);
|
||||||
|
|
||||||
|
std::cout << "\t[" << ++segment << "]: " << type << " " << modifier
|
||||||
|
<< " Duration: " << step.duration << " Distance: " << step.distance
|
||||||
|
<< " Geometry: " << step.geometry_begin << " " << step.geometry_end
|
||||||
|
<< " exit: " << step.maneuver.exit
|
||||||
|
<< " Intersections: " << step.maneuver.intersections.size() << " [";
|
||||||
|
|
||||||
|
for (auto intersection : step.maneuver.intersections)
|
||||||
|
std::cout << "(" << intersection.duration << " " << intersection.distance << ")";
|
||||||
|
|
||||||
|
std::cout << "] name[" << step.name_id << "]: " << step.name << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Every Step Maneuver consists of the information until the turn.
|
||||||
|
// This list contains a set of instructions, called silent, which should
|
||||||
|
// not be part of the final output.
|
||||||
|
// They are required for maintenance purposes. We can calculate the number
|
||||||
|
// of exits to pass in a roundabout and the number of intersections
|
||||||
|
// that we come across.
|
||||||
|
|
||||||
|
std::vector<RouteStep> postProcess(std::vector<RouteStep> steps)
|
||||||
|
{
|
||||||
|
// the steps should always include the first/last step in form of a location
|
||||||
|
BOOST_ASSERT(steps.size() >= 2);
|
||||||
|
if (steps.size() == 2)
|
||||||
|
return steps;
|
||||||
|
|
||||||
|
#define OSRM_POST_PROCESSING_PRINT_DEBUG 0
|
||||||
|
#if OSRM_POST_PROCESSING_PRINT_DEBUG
|
||||||
|
std::cout << "[POSTPROCESSING ITERATION]" << std::endl;
|
||||||
|
std::cout << "Input\n";
|
||||||
|
print(steps);
|
||||||
|
#endif
|
||||||
|
// Count Street Exits forward
|
||||||
|
bool on_roundabout = false;
|
||||||
|
|
||||||
|
// adds an intersection to the initial route step
|
||||||
|
// It includes the length of the last step, until the intersection
|
||||||
|
// Also updates the length of the respective segment
|
||||||
|
auto addIntersection =
|
||||||
|
[](RouteStep into, const RouteStep &last_step, const RouteStep &intersection)
|
||||||
|
{
|
||||||
|
into.maneuver.intersections.push_back(
|
||||||
|
{last_step.duration, last_step.distance, intersection.maneuver.location});
|
||||||
|
|
||||||
|
return detail::forwardInto(std::move(into), intersection);
|
||||||
|
};
|
||||||
|
|
||||||
|
// count the exits forward. if enter/exit roundabout happen both, no further treatment is
|
||||||
|
// required. We might end up with only one of them (e.g. starting within a roundabout)
|
||||||
|
// or having a via-point in the roundabout.
|
||||||
|
// In this case, exits are numbered from the start of the lag.
|
||||||
|
std::size_t last_valid_instruction = 0;
|
||||||
|
for (std::size_t step_index = 0; step_index < steps.size(); ++step_index)
|
||||||
|
{
|
||||||
|
auto &step = steps[step_index];
|
||||||
|
const auto instruction = step.maneuver.instruction;
|
||||||
|
if (entersRoundabout(instruction))
|
||||||
|
{
|
||||||
|
last_valid_instruction = step_index;
|
||||||
|
on_roundabout = detail::setUpRoundabout(step);
|
||||||
|
if (on_roundabout && step_index + 1 < steps.size())
|
||||||
|
steps[step_index + 1].maneuver.exit = step.maneuver.exit;
|
||||||
|
}
|
||||||
|
else if (instruction.type == TurnType::StayOnRoundabout)
|
||||||
|
{
|
||||||
|
// increase the exit number we require passing the exit
|
||||||
|
step.maneuver.exit += 1;
|
||||||
|
if (step_index + 1 < steps.size())
|
||||||
|
steps[step_index + 1].maneuver.exit = step.maneuver.exit;
|
||||||
|
}
|
||||||
|
else if (leavesRoundabout(instruction))
|
||||||
|
{
|
||||||
|
if (!on_roundabout)
|
||||||
|
{
|
||||||
|
// in case the we are not on a roundabout, the very first instruction
|
||||||
|
// after the depart will be transformed into a roundabout and become
|
||||||
|
// the first valid instruction
|
||||||
|
last_valid_instruction = 1;
|
||||||
|
}
|
||||||
|
detail::closeOffRoundabout(on_roundabout, steps, step_index);
|
||||||
on_roundabout = false;
|
on_roundabout = false;
|
||||||
}
|
}
|
||||||
else if (instruction.type == TurnType::Suppressed)
|
else if (instruction.type == TurnType::Suppressed)
|
||||||
{
|
{
|
||||||
// count intersections. We cannot use exit, since intersections can follow directly after a roundabout
|
// count intersections. We cannot use exit, since intersections can follow directly
|
||||||
steps[last_valid_instruction].maneuver.intersection += 1;
|
// after a roundabout
|
||||||
|
steps[last_valid_instruction] = addIntersection(
|
||||||
steps[last_valid_instruction] =
|
std::move(steps[last_valid_instruction]), steps[step_index - 1], step);
|
||||||
detail::forwardInto(steps[last_valid_instruction], step);
|
|
||||||
step.maneuver.instruction = TurnInstruction::NO_TURN();
|
step.maneuver.instruction = TurnInstruction::NO_TURN();
|
||||||
}
|
}
|
||||||
else if( !isSilent(instruction) )
|
else if (!isSilent(instruction))
|
||||||
{
|
{
|
||||||
// Remember the last non silent instruction
|
// Remember the last non silent instruction
|
||||||
last_valid_instruction = step_index;
|
last_valid_instruction = step_index;
|
||||||
@ -209,38 +268,24 @@ std::vector<RouteStep> postProcess(std::vector<RouteStep> steps)
|
|||||||
// A roundabout without exit translates to enter-roundabout.
|
// A roundabout without exit translates to enter-roundabout.
|
||||||
if (on_roundabout)
|
if (on_roundabout)
|
||||||
{
|
{
|
||||||
for (std::size_t propagation_index = steps.size() - 1; propagation_index > 0;
|
detail::fixFinalRoundabout(steps);
|
||||||
--propagation_index)
|
|
||||||
{
|
|
||||||
auto &propagation_step = steps[propagation_index];
|
|
||||||
if (entersRoundabout(propagation_step.maneuver.instruction))
|
|
||||||
{
|
|
||||||
propagation_step.maneuver.exit = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if (propagation_step.maneuver.instruction == TurnType::StayOnRoundabout)
|
|
||||||
{
|
|
||||||
propagation_step.maneuver.instruction =
|
|
||||||
TurnInstruction::NO_TURN(); // mark intermediate instructions invalid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally clean up the post-processed instructions.
|
// finally clean up the post-processed instructions.
|
||||||
// Remove all, now NO_TURN instructions for the set of steps
|
// Remove all invalid instructions from the set of instructions.
|
||||||
auto pos = steps.begin();
|
// An instruction is invalid, if its NO_TURN and has WaypointType::None.
|
||||||
for (auto check = steps.begin(); check != steps.end(); ++check)
|
// Two valid NO_TURNs exist in each leg in the form of Depart/Arrive
|
||||||
|
|
||||||
|
// keep valid instructions
|
||||||
|
const auto not_is_valid = [](const RouteStep &step)
|
||||||
{
|
{
|
||||||
// keep valid instrucstions
|
return step.maneuver.instruction == TurnInstruction::NO_TURN() &&
|
||||||
if (check->maneuver.instruction != TurnInstruction::NO_TURN() ||
|
step.maneuver.waypoint_type == WaypointType::None;
|
||||||
check->maneuver.waypoint_type != WaypointType::None)
|
};
|
||||||
{
|
|
||||||
*pos = *check;
|
boost::remove_erase_if(steps, not_is_valid);
|
||||||
++pos;
|
|
||||||
}
|
#if OSRM_POST_PROCESSING_PRINT_DEBUG
|
||||||
}
|
|
||||||
steps.erase(pos, steps.end());
|
|
||||||
#if PRINT_DEBUG
|
|
||||||
std::cout << "Merged\n";
|
std::cout << "Merged\n";
|
||||||
print(steps);
|
print(steps);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user