Move splitting candidates to plugin

This commit is contained in:
Patrick Niklaus
2015-02-09 00:55:12 +01:00
parent 0637215b85
commit 66d7a073d3
2 changed files with 53 additions and 58 deletions
+1 -41
View File
@@ -247,47 +247,11 @@ template <class DataFacadeT> class MapMatching final
{
}
// TODO optimize: a lot of copying that could probably be avoided
void expandCandidates(const Matching::CandidateLists &candidates_lists,
Matching::CandidateLists &expanded_lists,
const std::vector<bool>& uturn_indicators) const
{
// expand list of PhantomNodes to be single-directional
expanded_lists.resize(candidates_lists.size());
for (const auto i : osrm::irange(0lu, candidates_lists.size()))
{
for (const auto& candidate : candidates_lists[i])
{
// bi-directional edge, split phantom node if we don't expect a uturn
if (!uturn_indicators[i] && candidate.first.forward_node_id != SPECIAL_NODEID && candidate.first.reverse_node_id != SPECIAL_NODEID)
{
PhantomNode forward_node(candidate.first);
PhantomNode reverse_node(candidate.first);
forward_node.reverse_node_id = SPECIAL_NODEID;
reverse_node.forward_node_id = SPECIAL_NODEID;
expanded_lists[i].emplace_back(forward_node, candidate.second);
expanded_lists[i].emplace_back(reverse_node, candidate.second);
}
else
{
expanded_lists[i].push_back(candidate);
}
}
}
}
void operator()(const Matching::CandidateLists &candidates_lists,
void operator()(const Matching::CandidateLists &timestamp_list,
const std::vector<FixedPointCoordinate> coordinate_list,
const std::vector<bool>& uturn_indicators,
std::vector<PhantomNode>& matched_nodes,
JSON::Object& _debug_info) const
{
BOOST_ASSERT(candidates_lists.size() == coordinate_list.size());
BOOST_ASSERT(candidates_lists.size() == uturn_indicators.size());
Matching::CandidateLists timestamp_list;
expandCandidates(candidates_lists, timestamp_list, uturn_indicators);
std::vector<bool> breakage(timestamp_list.size(), true);
BOOST_ASSERT(timestamp_list.size() > 0);
@@ -462,10 +426,6 @@ template <class DataFacadeT> class MapMatching final
matched_nodes[i] = timestamp_list[timestamp_index][location_index].first;
}
unsigned removed = candidates_lists.size() - matched_nodes.size();
if (removed > 10)
SimpleLogger().Write(logWARNING) << "Warning: removed " << removed << " candiates.";
JSON::Array _debug_chosen_candidates;
auto _debug_candidate_iter = reconstructed_indices.begin();
for (auto i = 0u; i < timestamp_list.size(); ++i)