Upgrade clang-format to version 15 (#6859)
This commit is contained in:
@@ -40,10 +40,10 @@ class BaseAPI
|
||||
util::json::Array waypoints;
|
||||
waypoints.values.resize(parameters.coordinates.size());
|
||||
|
||||
boost::range::transform(
|
||||
waypoint_candidates,
|
||||
waypoints.values.begin(),
|
||||
[this](const PhantomNodeCandidates &candidates) { return MakeWaypoint(candidates); });
|
||||
boost::range::transform(waypoint_candidates,
|
||||
waypoints.values.begin(),
|
||||
[this](const PhantomNodeCandidates &candidates)
|
||||
{ return MakeWaypoint(candidates); });
|
||||
return waypoints;
|
||||
}
|
||||
|
||||
@@ -104,9 +104,8 @@ class BaseAPI
|
||||
std::transform(waypoint_candidates.begin(),
|
||||
waypoint_candidates.end(),
|
||||
waypoints.begin(),
|
||||
[this, builder](const PhantomNodeCandidates &candidates) {
|
||||
return MakeWaypoint(builder, candidates)->Finish();
|
||||
});
|
||||
[this, builder](const PhantomNodeCandidates &candidates)
|
||||
{ return MakeWaypoint(builder, candidates)->Finish(); });
|
||||
return builder->CreateVector(waypoints);
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,8 @@ struct BaseParameters
|
||||
(approaches.empty() || approaches.size() == coordinates.size()) &&
|
||||
std::all_of(bearings.begin(),
|
||||
bearings.end(),
|
||||
[](const boost::optional<Bearing> &bearing_and_range) {
|
||||
[](const boost::optional<Bearing> &bearing_and_range)
|
||||
{
|
||||
if (bearing_and_range)
|
||||
{
|
||||
return bearing_and_range->IsValid();
|
||||
|
||||
@@ -52,9 +52,10 @@ class MatchAPI final : public RouteAPI
|
||||
data_version_string = fb_result.CreateString(data_timestamp);
|
||||
}
|
||||
|
||||
auto response = MakeFBResponse(sub_routes, fb_result, [this, &fb_result, &sub_matchings]() {
|
||||
return MakeTracepoints(fb_result, sub_matchings);
|
||||
});
|
||||
auto response = MakeFBResponse(sub_routes,
|
||||
fb_result,
|
||||
[this, &fb_result, &sub_matchings]()
|
||||
{ return MakeTracepoints(fb_result, sub_matchings); });
|
||||
|
||||
if (!data_timestamp.empty())
|
||||
{
|
||||
|
||||
@@ -67,7 +67,7 @@ struct MatchParameters : public RouteParameters
|
||||
MatchParameters(const std::vector<unsigned> ×tamps_,
|
||||
GapsType gaps_,
|
||||
bool tidy_,
|
||||
Args &&... args_)
|
||||
Args &&...args_)
|
||||
: MatchParameters(timestamps_, gaps_, tidy_, {}, std::forward<Args>(args_)...)
|
||||
{
|
||||
}
|
||||
@@ -77,7 +77,7 @@ struct MatchParameters : public RouteParameters
|
||||
GapsType gaps_,
|
||||
bool tidy_,
|
||||
const std::vector<std::size_t> &waypoints_,
|
||||
Args &&... args_)
|
||||
Args &&...args_)
|
||||
: RouteParameters{std::forward<Args>(args_)..., waypoints_}, timestamps{std::move(
|
||||
timestamps_)},
|
||||
gaps(gaps_), tidy(tidy_)
|
||||
|
||||
@@ -57,20 +57,20 @@ class NearestAPI final : public BaseAPI
|
||||
{
|
||||
std::vector<flatbuffers::Offset<fbresult::Waypoint>> waypoints;
|
||||
waypoints.resize(phantom_nodes.front().size());
|
||||
std::transform(
|
||||
phantom_nodes.front().begin(),
|
||||
phantom_nodes.front().end(),
|
||||
waypoints.begin(),
|
||||
[this, &fb_result](const PhantomNodeWithDistance &phantom_with_distance) {
|
||||
auto &phantom_node = phantom_with_distance.phantom_node;
|
||||
std::transform(phantom_nodes.front().begin(),
|
||||
phantom_nodes.front().end(),
|
||||
waypoints.begin(),
|
||||
[this, &fb_result](const PhantomNodeWithDistance &phantom_with_distance)
|
||||
{
|
||||
auto &phantom_node = phantom_with_distance.phantom_node;
|
||||
|
||||
auto node_values = MakeNodes(phantom_node);
|
||||
fbresult::Uint64Pair nodes{node_values.first, node_values.second};
|
||||
auto node_values = MakeNodes(phantom_node);
|
||||
fbresult::Uint64Pair nodes{node_values.first, node_values.second};
|
||||
|
||||
auto waypoint = MakeWaypoint(&fb_result, {phantom_node});
|
||||
waypoint->add_nodes(&nodes);
|
||||
return waypoint->Finish();
|
||||
});
|
||||
auto waypoint = MakeWaypoint(&fb_result, {phantom_node});
|
||||
waypoint->add_nodes(&nodes);
|
||||
return waypoint->Finish();
|
||||
});
|
||||
|
||||
waypoints_vector = fb_result.CreateVector(waypoints);
|
||||
}
|
||||
@@ -94,7 +94,8 @@ class NearestAPI final : public BaseAPI
|
||||
std::transform(phantom_nodes.front().begin(),
|
||||
phantom_nodes.front().end(),
|
||||
waypoints.values.begin(),
|
||||
[this](const PhantomNodeWithDistance &phantom_with_distance) {
|
||||
[this](const PhantomNodeWithDistance &phantom_with_distance)
|
||||
{
|
||||
auto &phantom_node = phantom_with_distance.phantom_node;
|
||||
auto waypoint = MakeWaypoint({phantom_node});
|
||||
|
||||
|
||||
@@ -77,9 +77,10 @@ class RouteAPI : public BaseAPI
|
||||
}
|
||||
|
||||
auto response =
|
||||
MakeFBResponse(raw_routes, fb_result, [this, &waypoint_candidates, &fb_result]() {
|
||||
return BaseAPI::MakeWaypoints(&fb_result, waypoint_candidates);
|
||||
});
|
||||
MakeFBResponse(raw_routes,
|
||||
fb_result,
|
||||
[this, &waypoint_candidates, &fb_result]()
|
||||
{ return BaseAPI::MakeWaypoints(&fb_result, waypoint_candidates); });
|
||||
|
||||
if (!data_timestamp.empty())
|
||||
{
|
||||
@@ -171,10 +172,15 @@ class RouteAPI : public BaseAPI
|
||||
}
|
||||
std::vector<fbresult::Position> coordinates;
|
||||
coordinates.resize(std::distance(begin, end));
|
||||
std::transform(begin, end, coordinates.begin(), [](const Coordinate &c) {
|
||||
return fbresult::Position{static_cast<float>(util::toFloating(c.lon).__value),
|
||||
static_cast<float>(util::toFloating(c.lat).__value)};
|
||||
});
|
||||
std::transform(begin,
|
||||
end,
|
||||
coordinates.begin(),
|
||||
[](const Coordinate &c)
|
||||
{
|
||||
return fbresult::Position{
|
||||
static_cast<float>(util::toFloating(c.lon).__value),
|
||||
static_cast<float>(util::toFloating(c.lat).__value)};
|
||||
});
|
||||
return builder.CreateVectorOfStructs(coordinates);
|
||||
}
|
||||
|
||||
@@ -354,9 +360,8 @@ class RouteAPI : public BaseAPI
|
||||
std::transform(leg.steps.begin(),
|
||||
leg.steps.end(),
|
||||
legSteps.begin(),
|
||||
[this, &fb_result, &leg_geometry](auto &step) {
|
||||
return this->MakeFBStep(fb_result, leg_geometry, step);
|
||||
});
|
||||
[this, &fb_result, &leg_geometry](auto &step)
|
||||
{ return this->MakeFBStep(fb_result, leg_geometry, step); });
|
||||
}
|
||||
auto steps_vector = fb_result.CreateVector(legSteps);
|
||||
|
||||
@@ -441,7 +446,8 @@ class RouteAPI : public BaseAPI
|
||||
speed =
|
||||
GetAnnotations<float>(fb_result,
|
||||
leg_geometry,
|
||||
[&prev_speed](const guidance::LegGeometry::Annotation &anno) {
|
||||
[&prev_speed](const guidance::LegGeometry::Annotation &anno)
|
||||
{
|
||||
if (anno.duration < std::numeric_limits<float>::min())
|
||||
{
|
||||
return prev_speed;
|
||||
@@ -459,37 +465,37 @@ class RouteAPI : public BaseAPI
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint32_t>> duration;
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Duration)
|
||||
{
|
||||
duration = GetAnnotations<uint32_t>(
|
||||
fb_result, leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||
return anno.duration;
|
||||
});
|
||||
duration = GetAnnotations<uint32_t>(fb_result,
|
||||
leg_geometry,
|
||||
[](const guidance::LegGeometry::Annotation &anno)
|
||||
{ return anno.duration; });
|
||||
}
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint32_t>> distance;
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Distance)
|
||||
{
|
||||
distance = GetAnnotations<uint32_t>(
|
||||
fb_result, leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||
return anno.distance;
|
||||
});
|
||||
distance = GetAnnotations<uint32_t>(fb_result,
|
||||
leg_geometry,
|
||||
[](const guidance::LegGeometry::Annotation &anno)
|
||||
{ return anno.distance; });
|
||||
}
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint32_t>> weight;
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Weight)
|
||||
{
|
||||
weight = GetAnnotations<uint32_t>(
|
||||
fb_result, leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||
return anno.weight;
|
||||
});
|
||||
weight = GetAnnotations<uint32_t>(fb_result,
|
||||
leg_geometry,
|
||||
[](const guidance::LegGeometry::Annotation &anno)
|
||||
{ return anno.weight; });
|
||||
}
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint32_t>> datasources;
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Datasources)
|
||||
{
|
||||
datasources = GetAnnotations<uint32_t>(
|
||||
fb_result, leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||
return anno.datasource;
|
||||
});
|
||||
datasources = GetAnnotations<uint32_t>(fb_result,
|
||||
leg_geometry,
|
||||
[](const guidance::LegGeometry::Annotation &anno)
|
||||
{ return anno.datasource; });
|
||||
}
|
||||
std::vector<uint32_t> nodes;
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Nodes)
|
||||
@@ -653,7 +659,8 @@ class RouteAPI : public BaseAPI
|
||||
step.intersections.begin(),
|
||||
step.intersections.end(),
|
||||
intersections.begin(),
|
||||
[&fb_result, this](const guidance::IntermediateIntersection &intersection) {
|
||||
[&fb_result, this](const guidance::IntermediateIntersection &intersection)
|
||||
{
|
||||
std::vector<flatbuffers::Offset<fbresult::Lane>> lanes;
|
||||
if (json::detail::hasValidLanes(intersection))
|
||||
{
|
||||
@@ -681,11 +688,11 @@ class RouteAPI : public BaseAPI
|
||||
auto bearings_vector = fb_result.CreateVector(intersection.bearings);
|
||||
std::vector<flatbuffers::Offset<flatbuffers::String>> classes;
|
||||
classes.resize(intersection.classes.size());
|
||||
std::transform(
|
||||
intersection.classes.begin(),
|
||||
intersection.classes.end(),
|
||||
classes.begin(),
|
||||
[&fb_result](const std::string &cls) { return fb_result.CreateString(cls); });
|
||||
std::transform(intersection.classes.begin(),
|
||||
intersection.classes.end(),
|
||||
classes.begin(),
|
||||
[&fb_result](const std::string &cls)
|
||||
{ return fb_result.CreateString(cls); });
|
||||
auto classes_vector = fb_result.CreateVector(classes);
|
||||
auto entry_vector = fb_result.CreateVector(intersection.entry);
|
||||
|
||||
@@ -720,9 +727,10 @@ class RouteAPI : public BaseAPI
|
||||
|
||||
std::vector<util::json::Value> step_geometries;
|
||||
const auto total_step_count =
|
||||
std::accumulate(legs.begin(), legs.end(), 0, [](const auto &v, const auto &leg) {
|
||||
return v + leg.steps.size();
|
||||
});
|
||||
std::accumulate(legs.begin(),
|
||||
legs.end(),
|
||||
0,
|
||||
[](const auto &v, const auto &leg) { return v + leg.steps.size(); });
|
||||
step_geometries.reserve(total_step_count);
|
||||
|
||||
for (const auto idx : util::irange<std::size_t>(0UL, legs.size()))
|
||||
@@ -733,7 +741,8 @@ class RouteAPI : public BaseAPI
|
||||
legs[idx].steps.begin(),
|
||||
legs[idx].steps.end(),
|
||||
std::back_inserter(step_geometries),
|
||||
[this, &leg_geometry](const guidance::RouteStep &step) {
|
||||
[this, &leg_geometry](const guidance::RouteStep &step)
|
||||
{
|
||||
if (parameters.geometries == RouteParameters::GeometriesType::Polyline)
|
||||
{
|
||||
return static_cast<util::json::Value>(json::makePolyline<100000>(
|
||||
@@ -778,7 +787,9 @@ class RouteAPI : public BaseAPI
|
||||
{
|
||||
double prev_speed = 0;
|
||||
annotation.values["speed"] = GetAnnotations(
|
||||
leg_geometry, [&prev_speed](const guidance::LegGeometry::Annotation &anno) {
|
||||
leg_geometry,
|
||||
[&prev_speed](const guidance::LegGeometry::Annotation &anno)
|
||||
{
|
||||
if (anno.duration < std::numeric_limits<double>::min())
|
||||
{
|
||||
return prev_speed;
|
||||
@@ -794,17 +805,17 @@ class RouteAPI : public BaseAPI
|
||||
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Duration)
|
||||
{
|
||||
annotation.values["duration"] = GetAnnotations(
|
||||
leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||
return anno.duration;
|
||||
});
|
||||
annotation.values["duration"] =
|
||||
GetAnnotations(leg_geometry,
|
||||
[](const guidance::LegGeometry::Annotation &anno)
|
||||
{ return anno.duration; });
|
||||
}
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Distance)
|
||||
{
|
||||
annotation.values["distance"] = GetAnnotations(
|
||||
leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||
return anno.distance;
|
||||
});
|
||||
annotation.values["distance"] =
|
||||
GetAnnotations(leg_geometry,
|
||||
[](const guidance::LegGeometry::Annotation &anno)
|
||||
{ return anno.distance; });
|
||||
}
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Weight)
|
||||
{
|
||||
@@ -814,10 +825,10 @@ class RouteAPI : public BaseAPI
|
||||
}
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Datasources)
|
||||
{
|
||||
annotation.values["datasources"] = GetAnnotations(
|
||||
leg_geometry, [](const guidance::LegGeometry::Annotation &anno) {
|
||||
return anno.datasource;
|
||||
});
|
||||
annotation.values["datasources"] =
|
||||
GetAnnotations(leg_geometry,
|
||||
[](const guidance::LegGeometry::Annotation &anno)
|
||||
{ return anno.datasource; });
|
||||
}
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Nodes)
|
||||
{
|
||||
|
||||
@@ -83,7 +83,7 @@ struct RouteParameters : public BaseParameters
|
||||
const GeometriesType geometries_,
|
||||
const OverviewType overview_,
|
||||
const boost::optional<bool> continue_straight_,
|
||||
Args &&... args_)
|
||||
Args &&...args_)
|
||||
// Once we perfectly-forward `args` (see #2990) this constructor can delegate to the one
|
||||
// below.
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
|
||||
@@ -101,7 +101,7 @@ struct RouteParameters : public BaseParameters
|
||||
const GeometriesType geometries_,
|
||||
const OverviewType overview_,
|
||||
const boost::optional<bool> continue_straight_,
|
||||
Args &&... args_)
|
||||
Args &&...args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
|
||||
number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{annotations_},
|
||||
annotations_type{annotations_ ? AnnotationsType::All : AnnotationsType::None},
|
||||
@@ -119,7 +119,7 @@ struct RouteParameters : public BaseParameters
|
||||
const GeometriesType geometries_,
|
||||
const OverviewType overview_,
|
||||
const boost::optional<bool> continue_straight_,
|
||||
Args &&... args_)
|
||||
Args &&...args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
|
||||
number_of_alternatives{alternatives_ ? 1u : 0u},
|
||||
annotations{annotations_ != AnnotationsType::None}, annotations_type{annotations_},
|
||||
@@ -137,7 +137,7 @@ struct RouteParameters : public BaseParameters
|
||||
const OverviewType overview_,
|
||||
const boost::optional<bool> continue_straight_,
|
||||
std::vector<std::size_t> waypoints_,
|
||||
const Args &&... args_)
|
||||
const Args &&...args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
|
||||
number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{annotations_},
|
||||
annotations_type{annotations_ ? AnnotationsType::All : AnnotationsType::None},
|
||||
@@ -155,7 +155,7 @@ struct RouteParameters : public BaseParameters
|
||||
const OverviewType overview_,
|
||||
const boost::optional<bool> continue_straight_,
|
||||
std::vector<std::size_t> waypoints_,
|
||||
Args &&... args_)
|
||||
Args &&...args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
|
||||
number_of_alternatives{alternatives_ ? 1u : 0u}, annotations{annotations_ !=
|
||||
AnnotationsType::None},
|
||||
@@ -180,9 +180,9 @@ struct RouteParameters : public BaseParameters
|
||||
const auto coordinates_ok = coordinates.size() >= 2;
|
||||
const auto base_params_ok = BaseParameters::IsValid();
|
||||
const auto valid_waypoints =
|
||||
std::all_of(waypoints.begin(), waypoints.end(), [this](const auto &w) {
|
||||
return w < coordinates.size();
|
||||
});
|
||||
std::all_of(waypoints.begin(),
|
||||
waypoints.end(),
|
||||
[this](const auto &w) { return w < coordinates.size(); });
|
||||
return coordinates_ok && base_params_ok && valid_waypoints;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -245,9 +245,8 @@ class TableAPI final : public BaseAPI
|
||||
|
||||
boost::range::transform(candidates,
|
||||
std::back_inserter(waypoints),
|
||||
[this, &builder](const PhantomNodeCandidates &candidates) {
|
||||
return BaseAPI::MakeWaypoint(&builder, candidates)->Finish();
|
||||
});
|
||||
[this, &builder](const PhantomNodeCandidates &candidates)
|
||||
{ return BaseAPI::MakeWaypoint(&builder, candidates)->Finish(); });
|
||||
return builder.CreateVector(waypoints);
|
||||
}
|
||||
|
||||
@@ -261,7 +260,8 @@ class TableAPI final : public BaseAPI
|
||||
boost::range::transform(
|
||||
indices,
|
||||
std::back_inserter(waypoints),
|
||||
[this, &builder, &candidates](const std::size_t idx) {
|
||||
[this, &builder, &candidates](const std::size_t idx)
|
||||
{
|
||||
BOOST_ASSERT(idx < candidates.size());
|
||||
return BaseAPI::MakeWaypoint(&builder, candidates[idx])->Finish();
|
||||
});
|
||||
@@ -274,14 +274,17 @@ class TableAPI final : public BaseAPI
|
||||
{
|
||||
std::vector<float> distance_table;
|
||||
distance_table.resize(values.size());
|
||||
std::transform(
|
||||
values.begin(), values.end(), distance_table.begin(), [](const EdgeDuration duration) {
|
||||
if (duration == MAXIMAL_EDGE_DURATION)
|
||||
{
|
||||
return 0.;
|
||||
}
|
||||
return from_alias<double>(duration) / 10.;
|
||||
});
|
||||
std::transform(values.begin(),
|
||||
values.end(),
|
||||
distance_table.begin(),
|
||||
[](const EdgeDuration duration)
|
||||
{
|
||||
if (duration == MAXIMAL_EDGE_DURATION)
|
||||
{
|
||||
return 0.;
|
||||
}
|
||||
return from_alias<double>(duration) / 10.;
|
||||
});
|
||||
return builder.CreateVector(distance_table);
|
||||
}
|
||||
|
||||
@@ -291,14 +294,17 @@ class TableAPI final : public BaseAPI
|
||||
{
|
||||
std::vector<float> duration_table;
|
||||
duration_table.resize(values.size());
|
||||
std::transform(
|
||||
values.begin(), values.end(), duration_table.begin(), [](const EdgeDistance distance) {
|
||||
if (distance == INVALID_EDGE_DISTANCE)
|
||||
{
|
||||
return 0.;
|
||||
}
|
||||
return std::round(from_alias<double>(distance) * 10) / 10.;
|
||||
});
|
||||
std::transform(values.begin(),
|
||||
values.end(),
|
||||
duration_table.begin(),
|
||||
[](const EdgeDistance distance)
|
||||
{
|
||||
if (distance == INVALID_EDGE_DISTANCE)
|
||||
{
|
||||
return 0.;
|
||||
}
|
||||
return std::round(from_alias<double>(distance) * 10) / 10.;
|
||||
});
|
||||
return builder.CreateVector(duration_table);
|
||||
}
|
||||
|
||||
@@ -308,11 +314,13 @@ class TableAPI final : public BaseAPI
|
||||
{
|
||||
std::vector<uint32_t> fb_table;
|
||||
fb_table.reserve(fallback_speed_cells.size());
|
||||
std::for_each(
|
||||
fallback_speed_cells.begin(), fallback_speed_cells.end(), [&](const auto &cell) {
|
||||
fb_table.push_back(cell.row);
|
||||
fb_table.push_back(cell.column);
|
||||
});
|
||||
std::for_each(fallback_speed_cells.begin(),
|
||||
fallback_speed_cells.end(),
|
||||
[&](const auto &cell)
|
||||
{
|
||||
fb_table.push_back(cell.row);
|
||||
fb_table.push_back(cell.column);
|
||||
});
|
||||
return builder.CreateVector(fb_table);
|
||||
}
|
||||
|
||||
@@ -325,9 +333,8 @@ class TableAPI final : public BaseAPI
|
||||
|
||||
boost::range::transform(candidates,
|
||||
std::back_inserter(json_waypoints.values),
|
||||
[this](const PhantomNodeCandidates &candidates) {
|
||||
return BaseAPI::MakeWaypoint(candidates);
|
||||
});
|
||||
[this](const PhantomNodeCandidates &candidates)
|
||||
{ return BaseAPI::MakeWaypoint(candidates); });
|
||||
return json_waypoints;
|
||||
}
|
||||
|
||||
@@ -338,7 +345,8 @@ class TableAPI final : public BaseAPI
|
||||
json_waypoints.values.reserve(indices.size());
|
||||
boost::range::transform(indices,
|
||||
std::back_inserter(json_waypoints.values),
|
||||
[this, &candidates](const std::size_t idx) {
|
||||
[this, &candidates](const std::size_t idx)
|
||||
{
|
||||
BOOST_ASSERT(idx < candidates.size());
|
||||
return BaseAPI::MakeWaypoint(candidates[idx]);
|
||||
});
|
||||
@@ -359,7 +367,8 @@ class TableAPI final : public BaseAPI
|
||||
std::transform(row_begin_iterator,
|
||||
row_end_iterator,
|
||||
json_row.values.begin(),
|
||||
[](const EdgeDuration duration) {
|
||||
[](const EdgeDuration duration)
|
||||
{
|
||||
if (duration == MAXIMAL_EDGE_DURATION)
|
||||
{
|
||||
return util::json::Value(util::json::Null());
|
||||
@@ -387,7 +396,8 @@ class TableAPI final : public BaseAPI
|
||||
std::transform(row_begin_iterator,
|
||||
row_end_iterator,
|
||||
json_row.values.begin(),
|
||||
[](const EdgeDistance distance) {
|
||||
[](const EdgeDistance distance)
|
||||
{
|
||||
if (distance == INVALID_EDGE_DISTANCE)
|
||||
{
|
||||
return util::json::Value(util::json::Null());
|
||||
@@ -405,13 +415,15 @@ class TableAPI final : public BaseAPI
|
||||
MakeEstimatesTable(const std::vector<TableCellRef> &fallback_speed_cells) const
|
||||
{
|
||||
util::json::Array json_table;
|
||||
std::for_each(
|
||||
fallback_speed_cells.begin(), fallback_speed_cells.end(), [&](const auto &cell) {
|
||||
util::json::Array row;
|
||||
row.values.push_back(util::json::Number(cell.row));
|
||||
row.values.push_back(util::json::Number(cell.column));
|
||||
json_table.values.push_back(std::move(row));
|
||||
});
|
||||
std::for_each(fallback_speed_cells.begin(),
|
||||
fallback_speed_cells.end(),
|
||||
[&](const auto &cell)
|
||||
{
|
||||
util::json::Array row;
|
||||
row.values.push_back(util::json::Number(cell.row));
|
||||
row.values.push_back(util::json::Number(cell.column));
|
||||
json_table.values.push_back(std::move(row));
|
||||
});
|
||||
return json_table;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ struct TableParameters : public BaseParameters
|
||||
template <typename... Args>
|
||||
TableParameters(std::vector<std::size_t> sources_,
|
||||
std::vector<std::size_t> destinations_,
|
||||
Args &&... args_)
|
||||
Args &&...args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, sources{std::move(sources_)},
|
||||
destinations{std::move(destinations_)}
|
||||
{
|
||||
@@ -91,7 +91,7 @@ struct TableParameters : public BaseParameters
|
||||
TableParameters(std::vector<std::size_t> sources_,
|
||||
std::vector<std::size_t> destinations_,
|
||||
const AnnotationsType annotations_,
|
||||
Args &&... args_)
|
||||
Args &&...args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, sources{std::move(sources_)},
|
||||
destinations{std::move(destinations_)}, annotations{annotations_}
|
||||
{
|
||||
@@ -104,7 +104,7 @@ struct TableParameters : public BaseParameters
|
||||
double fallback_speed_,
|
||||
FallbackCoordinateType fallback_coordinate_type_,
|
||||
double scale_factor_,
|
||||
Args &&... args_)
|
||||
Args &&...args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, sources{std::move(sources_)},
|
||||
destinations{std::move(destinations_)}, fallback_speed{fallback_speed_},
|
||||
fallback_coordinate_type{fallback_coordinate_type_}, annotations{annotations_},
|
||||
|
||||
@@ -50,10 +50,10 @@ class TripAPI final : public RouteAPI
|
||||
data_version_string = fb_result.CreateString(data_timestamp);
|
||||
}
|
||||
|
||||
auto response =
|
||||
MakeFBResponse(sub_routes, fb_result, [this, &fb_result, &sub_trips, &candidates]() {
|
||||
return MakeWaypoints(fb_result, sub_trips, candidates);
|
||||
});
|
||||
auto response = MakeFBResponse(sub_routes,
|
||||
fb_result,
|
||||
[this, &fb_result, &sub_trips, &candidates]()
|
||||
{ return MakeWaypoints(fb_result, sub_trips, candidates); });
|
||||
|
||||
if (!data_timestamp.empty())
|
||||
{
|
||||
|
||||
@@ -60,7 +60,7 @@ struct TripParameters : public RouteParameters
|
||||
TripParameters(SourceType source_,
|
||||
DestinationType destination_,
|
||||
bool roundtrip_,
|
||||
Args &&... args_)
|
||||
Args &&...args_)
|
||||
: RouteParameters{std::forward<Args>(args_)...}, source{source_},
|
||||
destination{destination_}, roundtrip{roundtrip_}
|
||||
{
|
||||
|
||||
@@ -440,9 +440,11 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
{
|
||||
auto indexes = extractor::getClassIndexes(class_data);
|
||||
std::vector<std::string> classes(indexes.size());
|
||||
std::transform(indexes.begin(), indexes.end(), classes.begin(), [this](const auto index) {
|
||||
return m_profile_properties->GetClassName(index);
|
||||
});
|
||||
std::transform(indexes.begin(),
|
||||
indexes.end(),
|
||||
classes.begin(),
|
||||
[this](const auto index)
|
||||
{ return m_profile_properties->GetClassName(index); });
|
||||
|
||||
return classes;
|
||||
}
|
||||
@@ -600,15 +602,19 @@ class ContiguousInternalMemoryDataFacadeBase : public BaseDataFacade
|
||||
auto found_range = std::equal_range(
|
||||
m_maneuver_overrides.begin(), m_maneuver_overrides.end(), edge_based_node_id, Comp{});
|
||||
|
||||
std::for_each(found_range.first, found_range.second, [&](const auto &override) {
|
||||
std::vector<NodeID> sequence(
|
||||
m_maneuver_override_node_sequences.begin() + override.node_sequence_offset_begin,
|
||||
m_maneuver_override_node_sequences.begin() + override.node_sequence_offset_end);
|
||||
results.push_back(extractor::ManeuverOverride{std::move(sequence),
|
||||
override.instruction_node,
|
||||
override.override_type,
|
||||
override.direction});
|
||||
});
|
||||
std::for_each(found_range.first,
|
||||
found_range.second,
|
||||
[&](const auto &override)
|
||||
{
|
||||
std::vector<NodeID> sequence(m_maneuver_override_node_sequences.begin() +
|
||||
override.node_sequence_offset_begin,
|
||||
m_maneuver_override_node_sequences.begin() +
|
||||
override.node_sequence_offset_end);
|
||||
results.push_back(extractor::ManeuverOverride{std::move(sequence),
|
||||
override.instruction_node,
|
||||
override.override_type,
|
||||
override.direction});
|
||||
});
|
||||
return results;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -60,7 +60,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
auto results = rtree.Nearest(
|
||||
input_coordinate,
|
||||
[this, approach, &input_coordinate, &bearing_with_range, &use_all_edges](
|
||||
const CandidateSegment &segment) {
|
||||
const CandidateSegment &segment)
|
||||
{
|
||||
auto valid = CheckSegmentExclude(segment) &&
|
||||
CheckApproach(input_coordinate, segment, approach) &&
|
||||
(use_all_edges ? HasValidEdge(segment, *use_all_edges)
|
||||
@@ -70,7 +71,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
return valid;
|
||||
},
|
||||
[this, &max_distance, &max_results, input_coordinate](const std::size_t num_results,
|
||||
const CandidateSegment &segment) {
|
||||
const CandidateSegment &segment)
|
||||
{
|
||||
return (max_results && num_results >= *max_results) ||
|
||||
(max_distance && max_distance != -1.0 &&
|
||||
CheckSegmentDistance(input_coordinate, segment, *max_distance));
|
||||
@@ -107,7 +109,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
&big_component_coord,
|
||||
&big_component_distance,
|
||||
&use_all_edges,
|
||||
&bearing_with_range](const CandidateSegment &segment) {
|
||||
&bearing_with_range](const CandidateSegment &segment)
|
||||
{
|
||||
auto is_big_component = !IsTinyComponent(segment);
|
||||
auto not_nearest =
|
||||
has_nearest && segment.fixed_projected_coordinate != nearest_coord;
|
||||
@@ -159,7 +162,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
return use_candidate;
|
||||
},
|
||||
[this, &has_big_component, &max_distance, input_coordinate, &big_component_distance](
|
||||
const std::size_t /*num_results*/, const CandidateSegment &segment) {
|
||||
const std::size_t /*num_results*/, const CandidateSegment &segment)
|
||||
{
|
||||
auto distance = GetSegmentDistance(input_coordinate, segment);
|
||||
auto further_than_big_component = distance > big_component_distance;
|
||||
auto no_more_candidates = has_big_component && further_than_big_component;
|
||||
@@ -190,13 +194,17 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
PhantomNodeCandidates nearest_phantoms;
|
||||
PhantomNodeCandidates big_component_phantoms;
|
||||
|
||||
const auto add_to_candidates = [this, &input_coordinate](PhantomNodeCandidates &candidates,
|
||||
const EdgeData data) {
|
||||
const auto add_to_candidates =
|
||||
[this, &input_coordinate](PhantomNodeCandidates &candidates, const EdgeData data)
|
||||
{
|
||||
auto candidate_it =
|
||||
std::find_if(candidates.begin(), candidates.end(), [&](const PhantomNode &node) {
|
||||
return data.forward_segment_id.id == node.forward_segment_id.id &&
|
||||
data.reverse_segment_id.id == node.reverse_segment_id.id;
|
||||
});
|
||||
std::find_if(candidates.begin(),
|
||||
candidates.end(),
|
||||
[&](const PhantomNode &node)
|
||||
{
|
||||
return data.forward_segment_id.id == node.forward_segment_id.id &&
|
||||
data.reverse_segment_id.id == node.reverse_segment_id.id;
|
||||
});
|
||||
if (candidate_it == candidates.end())
|
||||
{
|
||||
// First candidate from this segment
|
||||
@@ -259,17 +267,20 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
}
|
||||
};
|
||||
|
||||
std::for_each(results.begin(), results.end(), [&](const CandidateSegment &segment) {
|
||||
if (segment.fixed_projected_coordinate == nearest_coord)
|
||||
{
|
||||
add_to_candidates(nearest_phantoms, segment.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Can only be from a big component for the alternative candidates
|
||||
add_to_candidates(big_component_phantoms, segment.data);
|
||||
}
|
||||
});
|
||||
std::for_each(results.begin(),
|
||||
results.end(),
|
||||
[&](const CandidateSegment &segment)
|
||||
{
|
||||
if (segment.fixed_projected_coordinate == nearest_coord)
|
||||
{
|
||||
add_to_candidates(nearest_phantoms, segment.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Can only be from a big component for the alternative candidates
|
||||
add_to_candidates(big_component_phantoms, segment.data);
|
||||
}
|
||||
});
|
||||
return std::make_pair(std::move(nearest_phantoms), std::move(big_component_phantoms));
|
||||
}
|
||||
|
||||
@@ -281,9 +292,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
std::transform(results.begin(),
|
||||
results.end(),
|
||||
distance_and_phantoms.begin(),
|
||||
[this, &input_coordinate](const CandidateSegment &segment) {
|
||||
return MakePhantomNode(input_coordinate, segment.data);
|
||||
});
|
||||
[this, &input_coordinate](const CandidateSegment &segment)
|
||||
{ return MakePhantomNode(input_coordinate, segment.data); });
|
||||
return distance_and_phantoms;
|
||||
}
|
||||
|
||||
@@ -400,9 +410,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
}
|
||||
|
||||
// check phantom node segments validity
|
||||
auto areSegmentsValid = [](auto first, auto last) -> bool {
|
||||
return std::find(first, last, INVALID_SEGMENT_WEIGHT) == last;
|
||||
};
|
||||
auto areSegmentsValid = [](auto first, auto last) -> bool
|
||||
{ return std::find(first, last, INVALID_SEGMENT_WEIGHT) == last; };
|
||||
bool is_forward_valid_source =
|
||||
areSegmentsValid(forward_weights.begin(), forward_weights.end());
|
||||
bool is_forward_valid_target = areSegmentsValid(
|
||||
|
||||
@@ -43,7 +43,8 @@ std::array<std::uint32_t, SegmentNumber> summarizeRoute(const datafacade::BaseDa
|
||||
const bool target_traversed_in_reverse)
|
||||
{
|
||||
// merges segments with same name id
|
||||
const auto collapse_segments = [](std::vector<NamedSegment> &segments) {
|
||||
const auto collapse_segments = [](std::vector<NamedSegment> &segments)
|
||||
{
|
||||
auto out = segments.begin();
|
||||
auto end = segments.end();
|
||||
|
||||
@@ -75,7 +76,8 @@ std::array<std::uint32_t, SegmentNumber> summarizeRoute(const datafacade::BaseDa
|
||||
std::transform(route_data.begin(),
|
||||
route_data.end(),
|
||||
segments.begin(),
|
||||
[&index, &facade](const PathData &point) {
|
||||
[&index, &facade](const PathData &point)
|
||||
{
|
||||
return NamedSegment{point.duration_until_turn,
|
||||
index++,
|
||||
facade.GetNameIndex(point.from_edge_based_node)};
|
||||
@@ -87,33 +89,37 @@ std::array<std::uint32_t, SegmentNumber> summarizeRoute(const datafacade::BaseDa
|
||||
if (target_duration > EdgeDuration{1})
|
||||
segments.push_back({target_duration, index++, facade.GetNameIndex(target_node_id)});
|
||||
// this makes sure that the segment with the lowest position comes first
|
||||
std::sort(
|
||||
segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) {
|
||||
return lhs.name_id < rhs.name_id ||
|
||||
(lhs.name_id == rhs.name_id && lhs.position < rhs.position);
|
||||
});
|
||||
std::sort(segments.begin(),
|
||||
segments.end(),
|
||||
[](const NamedSegment &lhs, const NamedSegment &rhs)
|
||||
{
|
||||
return lhs.name_id < rhs.name_id ||
|
||||
(lhs.name_id == rhs.name_id && lhs.position < rhs.position);
|
||||
});
|
||||
auto new_end = collapse_segments(segments);
|
||||
segments.resize(new_end - segments.begin());
|
||||
|
||||
// Filter out segments with an empty name (name_id == 0)
|
||||
new_end = std::remove_if(segments.begin(), segments.end(), [](const NamedSegment &segment) {
|
||||
return segment.name_id == 0;
|
||||
});
|
||||
new_end = std::remove_if(segments.begin(),
|
||||
segments.end(),
|
||||
[](const NamedSegment &segment) { return segment.name_id == 0; });
|
||||
segments.resize(new_end - segments.begin());
|
||||
|
||||
// sort descending
|
||||
std::sort(
|
||||
segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) {
|
||||
return lhs.duration > rhs.duration ||
|
||||
(lhs.duration == rhs.duration && lhs.position < rhs.position);
|
||||
});
|
||||
std::sort(segments.begin(),
|
||||
segments.end(),
|
||||
[](const NamedSegment &lhs, const NamedSegment &rhs)
|
||||
{
|
||||
return lhs.duration > rhs.duration ||
|
||||
(lhs.duration == rhs.duration && lhs.position < rhs.position);
|
||||
});
|
||||
|
||||
// make sure the segments are sorted by position
|
||||
segments.resize(std::min(segments.size(), SegmentNumber));
|
||||
std::sort(
|
||||
segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) {
|
||||
return lhs.position < rhs.position;
|
||||
});
|
||||
std::sort(segments.begin(),
|
||||
segments.end(),
|
||||
[](const NamedSegment &lhs, const NamedSegment &rhs)
|
||||
{ return lhs.position < rhs.position; });
|
||||
|
||||
std::array<std::uint32_t, SegmentNumber> summary;
|
||||
std::fill(summary.begin(), summary.end(), EMPTY_NAMEID);
|
||||
@@ -138,7 +144,8 @@ inline std::string assembleSummary(const datafacade::BaseDataFacade &facade,
|
||||
|
||||
// transform a name_id into a string containing either the name, or -if the name is empty-
|
||||
// the reference.
|
||||
const auto name_id_to_string = [&](const NameID name_id) {
|
||||
const auto name_id_to_string = [&](const NameID name_id)
|
||||
{
|
||||
const auto name = facade.GetNameForID(name_id);
|
||||
if (!name.empty())
|
||||
return std::string(name);
|
||||
@@ -178,14 +185,16 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
|
||||
const auto target_weight =
|
||||
(target_traversed_in_reverse ? target_node.reverse_weight : target_node.forward_weight);
|
||||
|
||||
auto duration = std::accumulate(
|
||||
route_data.begin(), route_data.end(), 0, [](const double sum, const PathData &data) {
|
||||
return sum + from_alias<double>(data.duration_until_turn);
|
||||
});
|
||||
auto weight = std::accumulate(
|
||||
route_data.begin(), route_data.end(), 0, [](const double sum, const PathData &data) {
|
||||
return sum + from_alias<double>(data.weight_until_turn);
|
||||
});
|
||||
auto duration = std::accumulate(route_data.begin(),
|
||||
route_data.end(),
|
||||
0,
|
||||
[](const double sum, const PathData &data)
|
||||
{ return sum + from_alias<double>(data.duration_until_turn); });
|
||||
auto weight = std::accumulate(route_data.begin(),
|
||||
route_data.end(),
|
||||
0,
|
||||
[](const double sum, const PathData &data)
|
||||
{ return sum + from_alias<double>(data.weight_until_turn); });
|
||||
|
||||
// s
|
||||
// |
|
||||
|
||||
@@ -16,7 +16,7 @@ bool basicCollapsePreconditions(const RouteStepIterator first,
|
||||
|
||||
// Staggered intersection are very short zig-zags of a few meters.
|
||||
// We do not want to announce these short left-rights or right-lefts:
|
||||
//
|
||||
//
|
||||
// * -> b a -> *
|
||||
// | or | becomes a -> b
|
||||
// a -> * * -> b
|
||||
@@ -26,7 +26,7 @@ bool isStaggeredIntersection(const RouteStepIterator step_prior_to_intersection,
|
||||
|
||||
// Two two turns following close after another, we can announce them as a U-Turn if both end up
|
||||
// involving the same (segregated) road.
|
||||
//
|
||||
//
|
||||
// b < - y
|
||||
// | will be represented by at x, turn around instead of turn left at x, turn left at y
|
||||
// a - > x
|
||||
@@ -42,11 +42,11 @@ bool isNameOszillation(const RouteStepIterator step_prior_to_intersection,
|
||||
|
||||
// Sometimes, segments names don't match the perceived turns. We try to detect these additional
|
||||
// name changes and issue a combined turn.
|
||||
//
|
||||
//
|
||||
// | e |
|
||||
// a - b - c
|
||||
// d
|
||||
//
|
||||
//
|
||||
// can have `a-b` as one name, `b-c-d` as a second. At `b` we would issue a new name, even though
|
||||
// the road turns right after. The offset would only be there due to the broad road at `e`
|
||||
bool maneuverPreceededByNameChange(const RouteStepIterator step_prior_to_intersection,
|
||||
@@ -73,11 +73,11 @@ bool doubleChoiceless(const RouteStepIterator step_entering_intersection,
|
||||
|
||||
// Due to obvious detection, sometimes we can have straight turns followed by a different turn right
|
||||
// next to each other. We combine both turns into one, if the second turn is without choice
|
||||
//
|
||||
// e
|
||||
//
|
||||
// e
|
||||
// a - b - c
|
||||
// ' d
|
||||
//
|
||||
//
|
||||
// with a main road `abd`, the turn `continue straight` at `b` and `turn left at `c` will become a
|
||||
// `turn left` at `b`
|
||||
bool straightTurnFollowedByChoiceless(const RouteStepIterator step_entering_intersection,
|
||||
|
||||
@@ -122,9 +122,8 @@ inline bool haveSameMode(const RouteStep &first, const RouteStep &second, const
|
||||
// alias for readability
|
||||
inline bool haveSameName(const RouteStep &lhs, const RouteStep &rhs)
|
||||
{
|
||||
const auto has_name_or_ref = [](auto const &step) {
|
||||
return !step.name.empty() || !step.ref.empty();
|
||||
};
|
||||
const auto has_name_or_ref = [](auto const &step)
|
||||
{ return !step.name.empty() || !step.ref.empty(); };
|
||||
|
||||
// make sure empty is not involved
|
||||
if (!has_name_or_ref(lhs) || !has_name_or_ref(rhs))
|
||||
@@ -151,12 +150,14 @@ inline bool haveSameName(const RouteStep &lhs, const RouteStep &rhs)
|
||||
// alias for readability, both turn right | left
|
||||
inline bool areSameSide(const RouteStep &lhs, const RouteStep &rhs)
|
||||
{
|
||||
const auto is_left = [](const RouteStep &step) {
|
||||
const auto is_left = [](const RouteStep &step)
|
||||
{
|
||||
return hasModifier(step, osrm::guidance::DirectionModifier::Straight) ||
|
||||
hasLeftModifier(step.maneuver.instruction);
|
||||
};
|
||||
|
||||
const auto is_right = [](const RouteStep &step) {
|
||||
const auto is_right = [](const RouteStep &step)
|
||||
{
|
||||
return hasModifier(step, osrm::guidance::DirectionModifier::Straight) ||
|
||||
hasRightModifier(step.maneuver.instruction);
|
||||
};
|
||||
@@ -174,7 +175,8 @@ inline std::vector<RouteStep> removeNoTurnInstructions(std::vector<RouteStep> st
|
||||
// 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) {
|
||||
const auto not_is_valid = [](const RouteStep &step)
|
||||
{
|
||||
return step.maneuver.instruction == osrm::guidance::TurnInstruction::NO_TURN() &&
|
||||
step.maneuver.waypoint_type == WaypointType::None;
|
||||
};
|
||||
@@ -225,7 +227,8 @@ inline double totalTurnAngle(const RouteStep &entry_step, const RouteStep &exit_
|
||||
inline bool bearingsAreReversed(const double bearing_in, const double bearing_out)
|
||||
{
|
||||
// Nearly perfectly reversed angles have a difference close to 180 degrees (straight)
|
||||
const double left_turn_angle = [&]() {
|
||||
const double left_turn_angle = [&]()
|
||||
{
|
||||
if (0 <= bearing_out && bearing_out <= bearing_in)
|
||||
return bearing_in - bearing_out;
|
||||
return bearing_in + 360 - bearing_out;
|
||||
|
||||
@@ -20,14 +20,16 @@ template <typename Iter, typename Fn> inline Fn forEachRoundabout(Iter first, It
|
||||
{
|
||||
while (first != last)
|
||||
{
|
||||
const auto enter = std::find_if(first, last, [](const RouteStep &step) {
|
||||
return entersRoundabout(step.maneuver.instruction);
|
||||
});
|
||||
const auto enter = std::find_if(first,
|
||||
last,
|
||||
[](const RouteStep &step)
|
||||
{ return entersRoundabout(step.maneuver.instruction); });
|
||||
|
||||
// enter has to come before leave, otherwise: faulty data / partial roundabout, skip those
|
||||
const auto leave = std::find_if(enter, last, [](const RouteStep &step) {
|
||||
return leavesRoundabout(step.maneuver.instruction);
|
||||
});
|
||||
const auto leave = std::find_if(enter,
|
||||
last,
|
||||
[](const RouteStep &step)
|
||||
{ return leavesRoundabout(step.maneuver.instruction); });
|
||||
|
||||
// No roundabouts, or partial one (like start / end inside a roundabout)
|
||||
if (enter == last || leave == last)
|
||||
|
||||
@@ -259,10 +259,10 @@ inline util::Coordinate candidatesInputLocation(const PhantomNodeCandidates &can
|
||||
|
||||
inline bool candidatesHaveComponent(const PhantomNodeCandidates &candidates, uint32_t component_id)
|
||||
{
|
||||
return std::any_of(
|
||||
candidates.begin(), candidates.end(), [component_id](const PhantomNode &node) {
|
||||
return node.component.id == component_id;
|
||||
});
|
||||
return std::any_of(candidates.begin(),
|
||||
candidates.end(),
|
||||
[component_id](const PhantomNode &node)
|
||||
{ return node.component.id == component_id; });
|
||||
}
|
||||
|
||||
struct PhantomEndpoints
|
||||
|
||||
@@ -33,10 +33,10 @@ class BasePlugin
|
||||
|
||||
bool CheckAllCoordinates(const std::vector<util::Coordinate> &coordinates) const
|
||||
{
|
||||
return !std::any_of(
|
||||
std::begin(coordinates), std::end(coordinates), [](const util::Coordinate coordinate) {
|
||||
return !coordinate.IsValid();
|
||||
});
|
||||
return !std::any_of(std::begin(coordinates),
|
||||
std::end(coordinates),
|
||||
[](const util::Coordinate coordinate)
|
||||
{ return !coordinate.IsValid(); });
|
||||
}
|
||||
|
||||
bool CheckAlgorithms(const api::BaseParameters ¶ms,
|
||||
@@ -105,45 +105,45 @@ class BasePlugin
|
||||
{
|
||||
// are all phantoms from a tiny cc?
|
||||
const auto all_in_same_tiny_component =
|
||||
[](const std::vector<PhantomCandidateAlternatives> &alts_list) {
|
||||
return std::any_of(
|
||||
alts_list.front().first.begin(),
|
||||
alts_list.front().first.end(),
|
||||
// For each of the first possible phantoms, check if all other
|
||||
// positions in the list have a phantom from the same small component.
|
||||
[&](const PhantomNode &phantom) {
|
||||
if (!phantom.component.is_tiny)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const auto component_id = phantom.component.id;
|
||||
return std::all_of(
|
||||
std::next(alts_list.begin()),
|
||||
std::end(alts_list),
|
||||
[component_id](const PhantomCandidateAlternatives &alternatives) {
|
||||
return candidatesHaveComponent(alternatives.first, component_id);
|
||||
});
|
||||
});
|
||||
};
|
||||
[](const std::vector<PhantomCandidateAlternatives> &alts_list)
|
||||
{
|
||||
return std::any_of(
|
||||
alts_list.front().first.begin(),
|
||||
alts_list.front().first.end(),
|
||||
// For each of the first possible phantoms, check if all other
|
||||
// positions in the list have a phantom from the same small component.
|
||||
[&](const PhantomNode &phantom)
|
||||
{
|
||||
if (!phantom.component.is_tiny)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
const auto component_id = phantom.component.id;
|
||||
return std::all_of(
|
||||
std::next(alts_list.begin()),
|
||||
std::end(alts_list),
|
||||
[component_id](const PhantomCandidateAlternatives &alternatives)
|
||||
{ return candidatesHaveComponent(alternatives.first, component_id); });
|
||||
});
|
||||
};
|
||||
|
||||
// Move the alternative into the final list
|
||||
const auto fallback_to_big_component = [](PhantomCandidateAlternatives &alternatives) {
|
||||
const auto fallback_to_big_component = [](PhantomCandidateAlternatives &alternatives)
|
||||
{
|
||||
auto no_big_alternative = alternatives.second.empty();
|
||||
return no_big_alternative ? std::move(alternatives.first)
|
||||
: std::move(alternatives.second);
|
||||
};
|
||||
|
||||
// Move the alternative into the final list
|
||||
const auto use_closed_phantom = [](PhantomCandidateAlternatives &alternatives) {
|
||||
return std::move(alternatives.first);
|
||||
};
|
||||
const auto use_closed_phantom = [](PhantomCandidateAlternatives &alternatives)
|
||||
{ return std::move(alternatives.first); };
|
||||
|
||||
const auto no_alternatives =
|
||||
std::all_of(alternatives_list.begin(),
|
||||
alternatives_list.end(),
|
||||
[](const PhantomCandidateAlternatives &alternatives) {
|
||||
return alternatives.second.empty();
|
||||
});
|
||||
[](const PhantomCandidateAlternatives &alternatives)
|
||||
{ return alternatives.second.empty(); });
|
||||
|
||||
std::vector<PhantomNodeCandidates> snapped_phantoms;
|
||||
snapped_phantoms.reserve(alternatives_list.size());
|
||||
@@ -313,12 +313,12 @@ class BasePlugin
|
||||
alternatives.end(),
|
||||
coordinates.begin(),
|
||||
coordinates.end(),
|
||||
[](const auto &candidates_pair, const auto &coordinate) {
|
||||
[](const auto &candidates_pair, const auto &coordinate)
|
||||
{
|
||||
return std::any_of(candidates_pair.first.begin(),
|
||||
candidates_pair.first.end(),
|
||||
[&](const auto &phantom) {
|
||||
return phantom.input_location == coordinate;
|
||||
});
|
||||
[&](const auto &phantom)
|
||||
{ return phantom.input_location == coordinate; });
|
||||
});
|
||||
std::size_t missing_index = std::distance(alternatives.begin(), mismatch.first);
|
||||
return std::string("Could not find a matching segment for coordinate ") +
|
||||
|
||||
@@ -39,7 +39,8 @@ std::string encodePolyline(CoordVectorForwardIter begin, CoordVectorForwardIter
|
||||
begin,
|
||||
end,
|
||||
[&delta_numbers, ¤t_lat, ¤t_lon, coordinate_to_polyline](
|
||||
const util::Coordinate loc) {
|
||||
const util::Coordinate loc)
|
||||
{
|
||||
const int lat_diff =
|
||||
std::round(static_cast<int>(loc.lat) * coordinate_to_polyline) - current_lat;
|
||||
const int lon_diff =
|
||||
|
||||
@@ -190,8 +190,10 @@ void annotatePath(const FacadeT &facade,
|
||||
std::vector<SegmentDuration> duration_vector;
|
||||
std::vector<DatasourceID> datasource_vector;
|
||||
|
||||
const auto get_segment_geometry = [&](const auto geometry_index) {
|
||||
const auto copy = [](auto &vector, const auto range) {
|
||||
const auto get_segment_geometry = [&](const auto geometry_index)
|
||||
{
|
||||
const auto copy = [](auto &vector, const auto range)
|
||||
{
|
||||
vector.resize(range.size());
|
||||
std::copy(range.begin(), range.end(), vector.begin());
|
||||
};
|
||||
|
||||
@@ -294,9 +294,9 @@ EdgeDistance calculateEBGNodeAnnotations(const DataFacade<Algorithm> &facade,
|
||||
|
||||
// Look for an edge on the forward CH graph (.forward)
|
||||
EdgeID smaller_edge_id =
|
||||
facade.FindSmallestEdge(std::get<0>(edge), std::get<1>(edge), [](const auto &data) {
|
||||
return data.forward;
|
||||
});
|
||||
facade.FindSmallestEdge(std::get<0>(edge),
|
||||
std::get<1>(edge),
|
||||
[](const auto &data) { return data.forward; });
|
||||
|
||||
// If we didn't find one there, the we might be looking at a part of the path that
|
||||
// was found using the backward search. Here, we flip the node order (.second,
|
||||
@@ -381,7 +381,8 @@ void unpackPath(const FacadeT &facade,
|
||||
unpackPath(facade,
|
||||
packed_path_begin,
|
||||
packed_path_end,
|
||||
[&](std::pair<NodeID, NodeID> &edge, const auto &edge_id) {
|
||||
[&](std::pair<NodeID, NodeID> &edge, const auto &edge_id)
|
||||
{
|
||||
BOOST_ASSERT(edge.first == unpacked_nodes.back());
|
||||
unpacked_nodes.push_back(edge.second);
|
||||
unpacked_edges.push_back(edge_id);
|
||||
|
||||
@@ -30,7 +30,8 @@ inline LevelID getNodeQueryLevel(const MultiLevelPartition &partition,
|
||||
const PhantomNode &source,
|
||||
const PhantomNode &target)
|
||||
{
|
||||
auto level = [&partition, node](const SegmentID &source, const SegmentID &target) {
|
||||
auto level = [&partition, node](const SegmentID &source, const SegmentID &target)
|
||||
{
|
||||
if (source.enabled && target.enabled)
|
||||
return partition.GetQueryLevel(source.id, target.id, node);
|
||||
return INVALID_LEVEL_ID;
|
||||
@@ -59,7 +60,8 @@ inline LevelID getNodeQueryLevel(const MultiLevelPartition &partition,
|
||||
endpoint_candidates.source_phantoms.begin(),
|
||||
endpoint_candidates.source_phantoms.end(),
|
||||
INVALID_LEVEL_ID,
|
||||
[&](LevelID current_level, const PhantomNode &source) {
|
||||
[&](LevelID current_level, const PhantomNode &source)
|
||||
{
|
||||
return std::min(
|
||||
current_level,
|
||||
getNodeQueryLevel(partition, node, source, endpoint_candidates.target_phantom));
|
||||
@@ -76,7 +78,8 @@ inline LevelID getNodeQueryLevel(const MultiLevelPartition &partition,
|
||||
endpoint_candidates.source_phantoms.begin(),
|
||||
endpoint_candidates.source_phantoms.end(),
|
||||
INVALID_LEVEL_ID,
|
||||
[&](LevelID level_1, const PhantomNode &source) {
|
||||
[&](LevelID level_1, const PhantomNode &source)
|
||||
{
|
||||
return std::min(
|
||||
level_1,
|
||||
std::accumulate(endpoint_candidates.target_phantoms.begin(),
|
||||
@@ -119,7 +122,8 @@ inline LevelID getNodeQueryLevel(const MultiLevelPartition &partition,
|
||||
const NodeID node,
|
||||
const PhantomNodeCandidates &candidates)
|
||||
{
|
||||
auto highest_different_level = [&partition, node](const SegmentID &segment) {
|
||||
auto highest_different_level = [&partition, node](const SegmentID &segment)
|
||||
{
|
||||
return segment.enabled ? partition.GetHighestDifferentLevel(segment.id, node)
|
||||
: INVALID_LEVEL_ID;
|
||||
};
|
||||
@@ -128,7 +132,8 @@ inline LevelID getNodeQueryLevel(const MultiLevelPartition &partition,
|
||||
std::accumulate(candidates.begin(),
|
||||
candidates.end(),
|
||||
INVALID_LEVEL_ID,
|
||||
[&](LevelID current_level, const PhantomNode &phantom_node) {
|
||||
[&](LevelID current_level, const PhantomNode &phantom_node)
|
||||
{
|
||||
auto highest_level =
|
||||
std::min(highest_different_level(phantom_node.forward_segment_id),
|
||||
highest_different_level(phantom_node.reverse_segment_id));
|
||||
@@ -151,9 +156,11 @@ inline LevelID getNodeQueryLevel(const MultiLevelPartition &partition,
|
||||
// This is equivalent to min_{∀ source, target} partition.GetQueryLevel(source, node, target)
|
||||
auto init = getNodeQueryLevel(partition, node, candidates_list[phantom_index]);
|
||||
auto result = std::accumulate(
|
||||
phantom_indices.begin(), phantom_indices.end(), init, [&](LevelID level, size_t index) {
|
||||
return std::min(level, getNodeQueryLevel(partition, node, candidates_list[index]));
|
||||
});
|
||||
phantom_indices.begin(),
|
||||
phantom_indices.end(),
|
||||
init,
|
||||
[&](LevelID level, size_t index)
|
||||
{ return std::min(level, getNodeQueryLevel(partition, node, candidates_list[index])); });
|
||||
return result;
|
||||
}
|
||||
} // namespace
|
||||
@@ -266,7 +273,7 @@ template <bool DIRECTION, typename Algorithm, typename... Args>
|
||||
void relaxOutgoingEdges(const DataFacade<Algorithm> &facade,
|
||||
typename SearchEngineData<Algorithm>::QueryHeap &forward_heap,
|
||||
const typename SearchEngineData<Algorithm>::QueryHeap::HeapNode &heapNode,
|
||||
const Args &... args)
|
||||
const Args &...args)
|
||||
{
|
||||
const auto &partition = facade.GetMultiLevelPartition();
|
||||
const auto &cells = facade.GetCellStorage();
|
||||
@@ -384,7 +391,7 @@ void routingStep(const DataFacade<Algorithm> &facade,
|
||||
EdgeWeight &path_upper_bound,
|
||||
const std::vector<NodeID> &force_loop_forward_nodes,
|
||||
const std::vector<NodeID> &force_loop_reverse_nodes,
|
||||
const Args &... args)
|
||||
const Args &...args)
|
||||
{
|
||||
const auto heapNode = forward_heap.DeleteMinGetHeapNode();
|
||||
const auto weight = heapNode.weight;
|
||||
@@ -434,7 +441,7 @@ UnpackedPath search(SearchEngineData<Algorithm> &engine_working_data,
|
||||
const std::vector<NodeID> &force_loop_forward_nodes,
|
||||
const std::vector<NodeID> &force_loop_reverse_nodes,
|
||||
EdgeWeight weight_upper_bound,
|
||||
const Args &... args)
|
||||
const Args &...args)
|
||||
{
|
||||
if (forward_heap.Empty() || reverse_heap.Empty())
|
||||
{
|
||||
@@ -601,7 +608,8 @@ void unpackPath(const FacadeT &facade,
|
||||
util::for_each_pair(
|
||||
packed_path_begin,
|
||||
packed_path_end,
|
||||
[&facade, &unpacked_nodes, &unpacked_edges](const auto from, const auto to) {
|
||||
[&facade, &unpacked_nodes, &unpacked_edges](const auto from, const auto to)
|
||||
{
|
||||
unpacked_nodes.push_back(to);
|
||||
unpacked_edges.push_back(facade.FindEdge(from, to));
|
||||
});
|
||||
|
||||
@@ -247,7 +247,8 @@ constructRouteResult(const DataFacade<Algorithm> &facade,
|
||||
auto source_it =
|
||||
std::find_if(source_candidates.begin(),
|
||||
source_candidates.end(),
|
||||
[&start_node](const auto &source_phantom) {
|
||||
[&start_node](const auto &source_phantom)
|
||||
{
|
||||
return (start_node == source_phantom.forward_segment_id.id ||
|
||||
start_node == source_phantom.reverse_segment_id.id);
|
||||
});
|
||||
@@ -256,7 +257,8 @@ constructRouteResult(const DataFacade<Algorithm> &facade,
|
||||
auto target_it =
|
||||
std::find_if(target_candidates.begin(),
|
||||
target_candidates.end(),
|
||||
[&end_node](const auto &target_phantom) {
|
||||
[&end_node](const auto &target_phantom)
|
||||
{
|
||||
return (end_node == target_phantom.forward_segment_id.id ||
|
||||
end_node == target_phantom.reverse_segment_id.id);
|
||||
});
|
||||
@@ -464,16 +466,16 @@ struct route_state
|
||||
last.total_weight_to_forward.resize(init_candidates.size(), {0});
|
||||
last.total_weight_to_reverse.resize(init_candidates.size(), {0});
|
||||
// Initialize routability from source validity.
|
||||
std::transform(
|
||||
init_candidates.begin(),
|
||||
init_candidates.end(),
|
||||
std::back_inserter(last.reached_forward_node_target),
|
||||
[](const PhantomNode &phantom_node) { return phantom_node.IsValidForwardSource(); });
|
||||
std::transform(
|
||||
init_candidates.begin(),
|
||||
init_candidates.end(),
|
||||
std::back_inserter(last.reached_reverse_node_target),
|
||||
[](const PhantomNode &phantom_node) { return phantom_node.IsValidReverseSource(); });
|
||||
std::transform(init_candidates.begin(),
|
||||
init_candidates.end(),
|
||||
std::back_inserter(last.reached_forward_node_target),
|
||||
[](const PhantomNode &phantom_node)
|
||||
{ return phantom_node.IsValidForwardSource(); });
|
||||
std::transform(init_candidates.begin(),
|
||||
init_candidates.end(),
|
||||
std::back_inserter(last.reached_reverse_node_target),
|
||||
[](const PhantomNode &phantom_node)
|
||||
{ return phantom_node.IsValidReverseSource(); });
|
||||
}
|
||||
|
||||
bool completeLeg()
|
||||
@@ -611,15 +613,21 @@ struct route_state
|
||||
{
|
||||
// Find the segment from final leg with the shortest path
|
||||
auto forward_range = util::irange<std::size_t>(0UL, last.total_weight_to_forward.size());
|
||||
auto forward_min =
|
||||
std::min_element(forward_range.begin(), forward_range.end(), [&](size_t a, size_t b) {
|
||||
auto forward_min = std::min_element(
|
||||
forward_range.begin(),
|
||||
forward_range.end(),
|
||||
[&](size_t a, size_t b)
|
||||
{
|
||||
return (last.total_weight_to_forward[a] < last.total_weight_to_forward[b] ||
|
||||
(last.total_weight_to_forward[a] == last.total_weight_to_forward[b] &&
|
||||
last.total_nodes_to_forward[a] < last.total_nodes_to_forward[b]));
|
||||
});
|
||||
auto reverse_range = util::irange<std::size_t>(0UL, last.total_weight_to_reverse.size());
|
||||
auto reverse_min =
|
||||
std::min_element(reverse_range.begin(), reverse_range.end(), [&](size_t a, size_t b) {
|
||||
auto reverse_min = std::min_element(
|
||||
reverse_range.begin(),
|
||||
reverse_range.end(),
|
||||
[&](size_t a, size_t b)
|
||||
{
|
||||
return (last.total_weight_to_reverse[a] < last.total_weight_to_reverse[b] ||
|
||||
(last.total_weight_to_reverse[a] == last.total_weight_to_reverse[b] &&
|
||||
last.total_nodes_to_reverse[a] < last.total_nodes_to_reverse[b]));
|
||||
|
||||
Reference in New Issue
Block a user