Implement re-enabling of PhantomNode directions after bearing filtering

This commit is contained in:
Patrick Niklaus
2016-03-28 17:06:51 +02:00
parent 5829bbe22d
commit fda4656630
16 changed files with 302 additions and 280 deletions
+10 -10
View File
@@ -56,10 +56,10 @@ void filterCandidates(const std::vector<util::Coordinate> &coordinates,
candidates.begin(), candidates.end(),
[](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs)
{
return lhs.phantom_node.forward_node_id < rhs.phantom_node.forward_node_id ||
(lhs.phantom_node.forward_node_id == rhs.phantom_node.forward_node_id &&
(lhs.phantom_node.reverse_node_id < rhs.phantom_node.reverse_node_id ||
(lhs.phantom_node.reverse_node_id == rhs.phantom_node.reverse_node_id &&
return lhs.phantom_node.forward_segment_id.id < rhs.phantom_node.forward_segment_id.id ||
(lhs.phantom_node.forward_segment_id.id == rhs.phantom_node.forward_segment_id.id &&
(lhs.phantom_node.reverse_segment_id.id < rhs.phantom_node.reverse_segment_id.id ||
(lhs.phantom_node.reverse_segment_id.id == rhs.phantom_node.reverse_segment_id.id &&
lhs.distance < rhs.distance)));
});
@@ -67,8 +67,8 @@ void filterCandidates(const std::vector<util::Coordinate> &coordinates,
candidates.begin(), candidates.end(),
[](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs)
{
return lhs.phantom_node.forward_node_id == rhs.phantom_node.forward_node_id &&
lhs.phantom_node.reverse_node_id == rhs.phantom_node.reverse_node_id;
return lhs.phantom_node.forward_segment_id.id == rhs.phantom_node.forward_segment_id.id &&
lhs.phantom_node.reverse_segment_id.id == rhs.phantom_node.reverse_segment_id.id;
});
candidates.resize(new_end - candidates.begin());
@@ -78,15 +78,15 @@ void filterCandidates(const std::vector<util::Coordinate> &coordinates,
for (const auto i : util::irange<std::size_t>(0, compact_size))
{
// Split edge if it is bidirectional and append reverse direction to end of list
if (candidates[i].phantom_node.forward_node_id != SPECIAL_NODEID &&
candidates[i].phantom_node.reverse_node_id != SPECIAL_NODEID)
if (candidates[i].phantom_node.forward_segment_id.enabled &&
candidates[i].phantom_node.reverse_segment_id.enabled)
{
PhantomNode reverse_node(candidates[i].phantom_node);
reverse_node.forward_node_id = SPECIAL_NODEID;
reverse_node.forward_segment_id.enabled = false;
candidates.push_back(
PhantomNodeWithDistance{reverse_node, candidates[i].distance});
candidates[i].phantom_node.reverse_node_id = SPECIAL_NODEID;
candidates[i].phantom_node.reverse_segment_id.enabled = false;
}
}
}
+2 -2
View File
@@ -364,7 +364,7 @@ Status TilePlugin::HandleRequest(const api::TileParameters &parameters, std::str
};
// If this is a valid forward edge, go ahead and add it to the tile
if (forward_weight != 0 && edge.forward_edge_based_node_id != SPECIAL_NODEID)
if (forward_weight != 0 && edge.forward_segment_id.enabled)
{
std::int32_t start_x = 0;
std::int32_t start_y = 0;
@@ -383,7 +383,7 @@ Status TilePlugin::HandleRequest(const api::TileParameters &parameters, std::str
// Repeat the above for the coordinates reversed and using the `reverse`
// properties
if (reverse_weight != 0 && edge.reverse_edge_based_node_id != SPECIAL_NODEID)
if (reverse_weight != 0 && edge.reverse_segment_id.enabled)
{
std::int32_t start_x = 0;
std::int32_t start_y = 0;
+18 -5
View File
@@ -50,20 +50,33 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter
auto phantom_node_pairs = GetPhantomNodes(route_parameters);
if (phantom_node_pairs.size() != route_parameters.coordinates.size())
{
return Error("NoSegment",
std::string("Could not find a matching segment for coordinate ") +
std::to_string(phantom_node_pairs.size()),
return Error("NoSegment", std::string("Could not find a matching segment for coordinate ") +
std::to_string(phantom_node_pairs.size()),
json_result);
}
BOOST_ASSERT(phantom_node_pairs.size() == route_parameters.coordinates.size());
auto snapped_phantoms = SnapPhantomNodes(phantom_node_pairs);
const bool allow_u_turn_at_via =
route_parameters.uturns ? *route_parameters.uturns : facade.GetUTurnsDefault();
InternalRouteResult raw_route;
auto build_phantom_pairs = [&raw_route](const PhantomNode &first_node,
const PhantomNode &second_node)
auto build_phantom_pairs = [&raw_route, allow_u_turn_at_via](const PhantomNode &first_node,
const PhantomNode &second_node)
{
raw_route.segment_end_coordinates.push_back(PhantomNodes{first_node, second_node});
auto &last_inserted = raw_route.segment_end_coordinates.back();
// enable forward direction if possible
if (last_inserted.source_phantom.forward_segment_id.id != SPECIAL_SEGMENTID)
{
last_inserted.source_phantom.forward_segment_id.enabled |= allow_u_turn_at_via;
}
// enable reverse direction if possible
if (last_inserted.source_phantom.reverse_segment_id.id != SPECIAL_SEGMENTID)
{
last_inserted.source_phantom.reverse_segment_id.enabled |= allow_u_turn_at_via;
}
};
util::for_each_pair(snapped_phantoms, build_phantom_pairs);