refactor route step / intermediate intersections
rename intersection (engine version) to IntermediateIntersection follow coding convention for existing functions, move invalidate into routeStep moved elongate into route step move forward-step-signage into route step replace post-processings `forwardInto` with `RouteStep` functionality. Don't change maneuver in step separete declaration and implementation
This commit is contained in:
@@ -302,16 +302,16 @@ class GraphContractor
|
||||
|
||||
util::UnbufferedLog log;
|
||||
log << "initializing elimination PQ ...";
|
||||
tbb::parallel_for(
|
||||
tbb::blocked_range<NodeID>(0, number_of_nodes, PQGrainSize),
|
||||
[this, &node_priorities, &node_depth, &thread_data_list](
|
||||
const tbb::blocked_range<NodeID> &range) {
|
||||
ContractorThreadData *data = thread_data_list.GetThreadData();
|
||||
for (auto x = range.begin(), end = range.end(); x != end; ++x)
|
||||
{
|
||||
node_priorities[x] = this->EvaluateNodePriority(data, node_depth[x], x);
|
||||
}
|
||||
});
|
||||
tbb::parallel_for(tbb::blocked_range<NodeID>(0, number_of_nodes, PQGrainSize),
|
||||
[this, &node_priorities, &node_depth, &thread_data_list](
|
||||
const tbb::blocked_range<NodeID> &range) {
|
||||
ContractorThreadData *data = thread_data_list.GetThreadData();
|
||||
for (auto x = range.begin(), end = range.end(); x != end; ++x)
|
||||
{
|
||||
node_priorities[x] =
|
||||
this->EvaluateNodePriority(data, node_depth[x], x);
|
||||
}
|
||||
});
|
||||
log << "ok";
|
||||
}
|
||||
BOOST_ASSERT(node_priorities.size() == number_of_nodes);
|
||||
@@ -552,8 +552,7 @@ class GraphContractor
|
||||
[this, &node_priorities, &remaining_nodes, &node_depth, &thread_data_list](
|
||||
const tbb::blocked_range<NodeID> &range) {
|
||||
ContractorThreadData *data = thread_data_list.GetThreadData();
|
||||
for (auto position = range.begin(), end = range.end();
|
||||
position != end;
|
||||
for (auto position = range.begin(), end = range.end(); position != end;
|
||||
++position)
|
||||
{
|
||||
NodeID x = remaining_nodes[position].id;
|
||||
|
||||
@@ -70,13 +70,13 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
|
||||
WaypointType::Depart,
|
||||
0};
|
||||
|
||||
Intersection intersection{source_node.location,
|
||||
std::vector<short>({bearings.second}),
|
||||
std::vector<bool>({true}),
|
||||
Intersection::NO_INDEX,
|
||||
0,
|
||||
util::guidance::LaneTuple(),
|
||||
{}};
|
||||
IntermediateIntersection intersection{source_node.location,
|
||||
std::vector<short>({bearings.second}),
|
||||
std::vector<bool>({true}),
|
||||
IntermediateIntersection::NO_INDEX,
|
||||
0,
|
||||
util::guidance::LaneTuple(),
|
||||
{}};
|
||||
|
||||
if (leg_data.size() > 0)
|
||||
{
|
||||
@@ -218,7 +218,7 @@ inline std::vector<RouteStep> assembleSteps(const datafacade::BaseDataFacade &fa
|
||||
std::vector<short>({static_cast<short>(util::reverseBearing(bearings.first))}),
|
||||
std::vector<bool>({true}),
|
||||
0,
|
||||
Intersection::NO_INDEX,
|
||||
IntermediateIntersection::NO_INDEX,
|
||||
util::guidance::LaneTuple(),
|
||||
{}};
|
||||
|
||||
|
||||
@@ -30,10 +30,6 @@ std::vector<RouteStep> collapseTurns(std::vector<RouteStep> steps);
|
||||
// maneuvers that can, in some form, be seen as one. Lookahead of one step.
|
||||
bool collapsable(const RouteStep &step, const RouteStep &next);
|
||||
|
||||
// Elongate a step by another. the data is added either at the front, or the back
|
||||
OSRM_ATTR_WARN_UNUSED
|
||||
RouteStep elongate(RouteStep step, const RouteStep &by_step);
|
||||
|
||||
// trim initial/final segment of very short length.
|
||||
// This function uses in/out parameter passing to modify both steps and geometry in place.
|
||||
// We use this method since both steps and geometry are closely coupled logically but
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace guidance
|
||||
// Arrive: a --> b --> t. The segment (b,t) is already covered by the previous segment.
|
||||
|
||||
// A representation of intermediate intersections
|
||||
struct Intersection
|
||||
struct IntermediateIntersection
|
||||
{
|
||||
static const constexpr std::size_t NO_INDEX = std::numeric_limits<std::size_t>::max();
|
||||
util::Coordinate location;
|
||||
@@ -44,13 +44,13 @@ struct Intersection
|
||||
extractor::guidance::TurnLaneDescription lane_description;
|
||||
};
|
||||
|
||||
inline Intersection getInvalidIntersection()
|
||||
inline IntermediateIntersection getInvalidIntersection()
|
||||
{
|
||||
return {util::Coordinate{util::FloatLongitude{0.0}, util::FloatLatitude{0.0}},
|
||||
{},
|
||||
{},
|
||||
Intersection::NO_INDEX,
|
||||
Intersection::NO_INDEX,
|
||||
IntermediateIntersection::NO_INDEX,
|
||||
IntermediateIntersection::NO_INDEX,
|
||||
util::guidance::LaneTuple(),
|
||||
{}};
|
||||
}
|
||||
@@ -71,55 +71,135 @@ struct RouteStep
|
||||
// indices into the locations array stored the LegGeometry
|
||||
std::size_t geometry_begin;
|
||||
std::size_t geometry_end;
|
||||
std::vector<Intersection> intersections;
|
||||
std::vector<IntermediateIntersection> intersections;
|
||||
|
||||
LaneID numLanesToTheRight() const
|
||||
{
|
||||
return intersections.front().lanes.first_lane_from_the_right;
|
||||
}
|
||||
// remove all information from the route step, marking it as invalid (used to indicate empty
|
||||
// steps to be removed).
|
||||
void Invalidate();
|
||||
|
||||
LaneID numLanesToTheLeft() const
|
||||
{
|
||||
LaneID const total = intersections.front().lane_description.size();
|
||||
return total - (intersections.front().lanes.lanes_in_turn +
|
||||
intersections.front().lanes.first_lane_from_the_right);
|
||||
}
|
||||
// Elongate by another step in front
|
||||
RouteStep &AddInFront(const RouteStep &preceeding_step);
|
||||
|
||||
auto lanesToTheLeft() const
|
||||
{
|
||||
const auto &description = intersections.front().lane_description;
|
||||
LaneID num_lanes_left = numLanesToTheLeft();
|
||||
return boost::make_iterator_range(description.begin(),
|
||||
description.begin() + num_lanes_left);
|
||||
}
|
||||
// Elongate by another step in back
|
||||
RouteStep &ElongateBy(const RouteStep &following_step);
|
||||
|
||||
auto lanesToTheRight() const
|
||||
{
|
||||
const auto &description = intersections.front().lane_description;
|
||||
LaneID num_lanes_right = numLanesToTheRight();
|
||||
return boost::make_iterator_range(description.end() - num_lanes_right, description.end());
|
||||
}
|
||||
/* Elongate without prior knowledge of in front, or in back, convenience function if you
|
||||
* don't know if step is augmented in front or at the back */
|
||||
RouteStep &MergeWith(const RouteStep &by_step);
|
||||
|
||||
// copy all strings from origin into the step, apart from rotary names
|
||||
RouteStep &AdaptStepSignage(const RouteStep &origin);
|
||||
|
||||
LaneID NumLanesToTheRight() const;
|
||||
|
||||
LaneID NumLanesToTheLeft() const;
|
||||
|
||||
auto LanesToTheLeft() const;
|
||||
|
||||
auto LanesToTheRight() const;
|
||||
};
|
||||
|
||||
inline RouteStep getInvalidRouteStep()
|
||||
inline void RouteStep::Invalidate()
|
||||
{
|
||||
return {0,
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
0,
|
||||
TRAVEL_MODE_INACCESSIBLE,
|
||||
getInvalidStepManeuver(),
|
||||
0,
|
||||
0,
|
||||
{getInvalidIntersection()}};
|
||||
}
|
||||
}
|
||||
}
|
||||
name_id = EMPTY_NAMEID;
|
||||
name.clear();
|
||||
ref.clear();
|
||||
pronunciation.clear();
|
||||
destinations.clear();
|
||||
rotary_name.clear();
|
||||
rotary_pronunciation.clear();
|
||||
duration = 0;
|
||||
distance = 0;
|
||||
mode = TRAVEL_MODE_INACCESSIBLE;
|
||||
maneuver = getInvalidStepManeuver();
|
||||
geometry_begin = 0;
|
||||
geometry_end = 0;
|
||||
intersections.clear();
|
||||
intersections.push_back(getInvalidIntersection());
|
||||
}
|
||||
|
||||
// Elongate by another step in front
|
||||
inline RouteStep &RouteStep::AddInFront(const RouteStep &preceeding_step)
|
||||
{
|
||||
BOOST_ASSERT(preceeding_step.geometry_end == geometry_begin + 1);
|
||||
BOOST_ASSERT(mode == preceeding_step.mode);
|
||||
duration += preceeding_step.duration;
|
||||
distance += preceeding_step.distance;
|
||||
|
||||
geometry_begin = preceeding_step.geometry_begin;
|
||||
intersections.insert(intersections.begin(),
|
||||
preceeding_step.intersections.begin(),
|
||||
preceeding_step.intersections.end());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Elongate by another step in back
|
||||
inline RouteStep &RouteStep::ElongateBy(const RouteStep &following_step)
|
||||
{
|
||||
BOOST_ASSERT(geometry_end == following_step.geometry_begin + 1);
|
||||
BOOST_ASSERT(mode == following_step.mode);
|
||||
duration += following_step.duration;
|
||||
distance += following_step.distance;
|
||||
|
||||
geometry_end = following_step.geometry_end;
|
||||
intersections.insert(intersections.end(),
|
||||
following_step.intersections.begin(),
|
||||
following_step.intersections.end());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Elongate without prior knowledge of in front, or in back.
|
||||
inline RouteStep &RouteStep::MergeWith(const RouteStep &by_step)
|
||||
{
|
||||
// if our own geometry ends, where the next begins, we elongate by
|
||||
if (geometry_end == by_step.geometry_begin + 1)
|
||||
return AddInFront(by_step);
|
||||
else
|
||||
return ElongateBy(by_step);
|
||||
}
|
||||
|
||||
// copy all strings from origin into the step, apart from rotary names
|
||||
inline RouteStep &RouteStep::AdaptStepSignage(const RouteStep &origin)
|
||||
{
|
||||
name_id = origin.name_id;
|
||||
name = origin.name;
|
||||
pronunciation = origin.pronunciation;
|
||||
destinations = origin.destinations;
|
||||
ref = origin.ref;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline LaneID RouteStep::NumLanesToTheRight() const
|
||||
{
|
||||
return intersections.front().lanes.first_lane_from_the_right;
|
||||
}
|
||||
|
||||
inline LaneID RouteStep::NumLanesToTheLeft() const
|
||||
{
|
||||
LaneID const total = intersections.front().lane_description.size();
|
||||
return total - (intersections.front().lanes.lanes_in_turn +
|
||||
intersections.front().lanes.first_lane_from_the_right);
|
||||
}
|
||||
|
||||
inline auto RouteStep::LanesToTheLeft() const
|
||||
{
|
||||
const auto &description = intersections.front().lane_description;
|
||||
LaneID num_lanes_left = NumLanesToTheLeft();
|
||||
return boost::make_iterator_range(description.begin(), description.begin() + num_lanes_left);
|
||||
}
|
||||
|
||||
inline auto RouteStep::LanesToTheRight() const
|
||||
{
|
||||
const auto &description = intersections.front().lane_description;
|
||||
LaneID num_lanes_right = NumLanesToTheRight();
|
||||
return boost::make_iterator_range(description.end() - num_lanes_right, description.end());
|
||||
}
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace engine
|
||||
} // namespace osrm
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user