Return indices instead of points

This commit is contained in:
Patrick Niklaus 2015-02-20 01:13:44 +01:00
parent f46b259384
commit 89460dd39c
2 changed files with 10 additions and 14 deletions

View File

@ -192,10 +192,10 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
for (auto& sub : sub_matchings) for (auto& sub : sub_matchings)
{ {
// classify result // classify result
double trace_length = sub_trace_lengths[sub.end_idx-1] - sub_trace_lengths[sub.begin_idx]; double trace_length = sub_trace_lengths[sub.indices.back()] - sub_trace_lengths[sub.indices.front()];
TraceClassification classification = classify(trace_length, TraceClassification classification = classify(trace_length,
sub.length, sub.length,
(sub.end_idx - sub.begin_idx) - sub.nodes.size()); (sub.indices.back() - sub.indices.front() + 1) - sub.nodes.size());
if (classification.first == ClassifierT::ClassLabel::POSITIVE) if (classification.first == ClassifierT::ClassLabel::POSITIVE)
{ {
sub.confidence = classification.second; sub.confidence = classification.second;
@ -255,18 +255,16 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
descriptor->SetConfig(descriptor_config); descriptor->SetConfig(descriptor_config);
descriptor->Run(raw_route, temp_result); descriptor->Run(raw_route, temp_result);
JSON::Array input_points; JSON::Array indices;
for(const auto& n: sub.nodes) { for (const auto& i : sub.indices)
JSON::Array coord; {
coord.values.emplace_back(n.location.lat / COORDINATE_PRECISION); indices.values.emplace_back(i);
coord.values.emplace_back(n.location.lon / COORDINATE_PRECISION);
input_points.values.push_back(coord);
} }
JSON::Object subtrace; JSON::Object subtrace;
subtrace.values["geometry"] = temp_result.values["route_geometry"]; subtrace.values["geometry"] = temp_result.values["route_geometry"];
subtrace.values["confidence"] = sub.confidence; subtrace.values["confidence"] = sub.confidence;
subtrace.values["input_points"] = input_points; subtrace.values["indices"] = indices;
subtrace.values["matched_points"] = temp_result.values["via_points"]; subtrace.values["matched_points"] = temp_result.values["via_points"];
traces.values.push_back(subtrace); traces.values.push_back(subtrace);

View File

@ -74,8 +74,7 @@ namespace Matching
struct SubMatching struct SubMatching
{ {
std::vector<PhantomNode> nodes; std::vector<PhantomNode> nodes;
unsigned begin_idx; std::vector<unsigned> indices;
unsigned end_idx;
double length; double length;
double confidence; double confidence;
}; };
@ -507,9 +506,6 @@ template <class DataFacadeT> class MapMatching final
continue; continue;
} }
matching.begin_idx = sub_matching_begin;
matching.end_idx = parent_timestamp_index;
// loop through the columns, and only compare the last entry // loop through the columns, and only compare the last entry
auto max_element_iter = std::max_element(model.viterbi[parent_timestamp_index].begin(), auto max_element_iter = std::max_element(model.viterbi[parent_timestamp_index].begin(),
model.viterbi[parent_timestamp_index].end()); model.viterbi[parent_timestamp_index].end());
@ -534,11 +530,13 @@ template <class DataFacadeT> class MapMatching final
matching.length = 0.0f; matching.length = 0.0f;
matching.nodes.resize(reconstructed_indices.size()); matching.nodes.resize(reconstructed_indices.size());
matching.indices.resize(reconstructed_indices.size());
for (auto i = 0u; i < reconstructed_indices.size(); ++i) for (auto i = 0u; i < reconstructed_indices.size(); ++i)
{ {
auto timestamp_index = reconstructed_indices[i].first; auto timestamp_index = reconstructed_indices[i].first;
auto location_index = reconstructed_indices[i].second; auto location_index = reconstructed_indices[i].second;
matching.indices[i] = timestamp_index;
matching.nodes[i] = timestamp_list[timestamp_index][location_index].first; matching.nodes[i] = timestamp_list[timestamp_index][location_index].first;
matching.length += model.path_lengths[timestamp_index][location_index]; matching.length += model.path_lengths[timestamp_index][location_index];