Fix endless loop
This commit is contained in:
parent
8b8a19c75d
commit
70bb082973
@ -96,6 +96,7 @@ template <class CandidateLists> struct HiddenMarkovModel
|
|||||||
path_lengths.resize(candidates_list.size());
|
path_lengths.resize(candidates_list.size());
|
||||||
suspicious.resize(candidates_list.size());
|
suspicious.resize(candidates_list.size());
|
||||||
pruned.resize(candidates_list.size());
|
pruned.resize(candidates_list.size());
|
||||||
|
breakage.resize(candidates_list.size());
|
||||||
for (const auto i : osrm::irange<std::size_t>(0u, candidates_list.size()))
|
for (const auto i : osrm::irange<std::size_t>(0u, candidates_list.size()))
|
||||||
{
|
{
|
||||||
const auto& num_candidates = candidates_list[i].size();
|
const auto& num_candidates = candidates_list[i].size();
|
||||||
|
@ -301,14 +301,17 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
|||||||
{
|
{
|
||||||
osrm::matching::SubMatching matching;
|
osrm::matching::SubMatching matching;
|
||||||
|
|
||||||
// find real end of trace
|
|
||||||
// not sure if this is really needed
|
|
||||||
std::size_t parent_timestamp_index = sub_matching_end - 1;
|
std::size_t parent_timestamp_index = sub_matching_end - 1;
|
||||||
while (parent_timestamp_index >= sub_matching_begin &&
|
while (parent_timestamp_index >= sub_matching_begin &&
|
||||||
model.breakage[parent_timestamp_index])
|
model.breakage[parent_timestamp_index])
|
||||||
{
|
{
|
||||||
--parent_timestamp_index;
|
--parent_timestamp_index;
|
||||||
}
|
}
|
||||||
|
while (sub_matching_begin < sub_matching_end &&
|
||||||
|
model.breakage[sub_matching_begin])
|
||||||
|
{
|
||||||
|
++sub_matching_begin;
|
||||||
|
}
|
||||||
|
|
||||||
// matchings that only consist of one candidate are invalid
|
// matchings that only consist of one candidate are invalid
|
||||||
if (parent_timestamp_index - sub_matching_begin + 1 < 2)
|
if (parent_timestamp_index - sub_matching_begin + 1 < 2)
|
||||||
@ -335,6 +338,11 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
|||||||
|
|
||||||
reconstructed_indices.emplace_front(parent_timestamp_index, parent_candidate_index);
|
reconstructed_indices.emplace_front(parent_timestamp_index, parent_candidate_index);
|
||||||
const auto &next = model.parents[parent_timestamp_index][parent_candidate_index];
|
const auto &next = model.parents[parent_timestamp_index][parent_candidate_index];
|
||||||
|
// make sure we can never get stuck in this loop
|
||||||
|
if (parent_timestamp_index == next.first)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
parent_timestamp_index = next.first;
|
parent_timestamp_index = next.first;
|
||||||
parent_candidate_index = next.second;
|
parent_candidate_index = next.second;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user