From 2fab696bb3ebcb206515409b44c2e23e30aa35fc Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Mon, 20 Mar 2017 13:30:24 +0300 Subject: [PATCH] New tidying and gaps parameters. --- docs/http.md | 3 ++- include/engine/api/match_parameters.hpp | 17 ++++++------ include/engine/routing_algorithms.hpp | 8 +++--- .../routing_algorithms/map_matching.hpp | 4 +-- .../server/api/match_parameter_grammar.hpp | 15 ++++++----- src/engine/plugins/match.cpp | 26 +++++++++---------- .../routing_algorithms/map_matching.cpp | 12 ++++----- 7 files changed, 44 insertions(+), 41 deletions(-) diff --git a/docs/http.md b/docs/http.md index 6ea272443..f84535dad 100644 --- a/docs/http.md +++ b/docs/http.md @@ -274,12 +274,13 @@ In addition to the [general options](#general-options) the following options are |Option |Values |Description | |------------|------------------------------------------------|------------------------------------------------------------------------------------------| |steps |`true`, `false` (default) |Return route steps for each route | -|preprocess |`full`, `simple` (default), `false` |Allows the input track modification to obtain better matching quality for noisy tracks. | |geometries |`polyline` (default), `polyline6`, `geojson` |Returned route geometry format (influences overview and per step) | |annotations |`true`, `false` (default), `nodes`, `distance`, `duration`, `datasources`, `weight`, `speed` |Returns additional metadata for each coordinate along the route geometry. | |overview |`simplified` (default), `full`, `false` |Add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all.| |timestamps |`{timestamp};{timestamp}[;{timestamp} ...]` |Timestamps for the input locations in seconds since UNIX epoch. Timestamps need to be monotonically increasing. | |radiuses |`{radius};{radius}[;{radius} ...]` |Standard deviation of GPS precision used for map matching. If applicable use GPS accuracy.| +|gaps |`split` (default), `ignore` |Allows the input track splitting based on huge timestamp gaps between points. | +|tidying |`true`, `false` (default) |Allows the input track modification to obtain better matching quality for noisy tracks. | |Parameter |Values | |------------|-----------------------------------| diff --git a/include/engine/api/match_parameters.hpp b/include/engine/api/match_parameters.hpp index cfb275edc..37938e980 100644 --- a/include/engine/api/match_parameters.hpp +++ b/include/engine/api/match_parameters.hpp @@ -50,11 +50,10 @@ namespace api */ struct MatchParameters : public RouteParameters { - enum class PreprocessingType + enum class GapsType { - False, - Simple, - Full + Split, + Ignore }; MatchParameters() @@ -64,21 +63,23 @@ struct MatchParameters : public RouteParameters RouteParameters::GeometriesType::Polyline, RouteParameters::OverviewType::Simplified, {}), - track_preprocessing(PreprocessingType::Simple) + gaps_processing(GapsType::Split), use_tidying(false) { } template MatchParameters(std::vector timestamps_, - PreprocessingType track_preprocessing_, + GapsType gaps_processing_, + bool use_tidying_, Args... args_) : RouteParameters{std::forward(args_)...}, timestamps{std::move(timestamps_)}, - track_preprocessing(track_preprocessing_) + gaps_processing(gaps_processing_), use_tidying(use_tidying_) { } std::vector timestamps; - PreprocessingType track_preprocessing; + GapsType gaps_processing; + bool use_tidying; bool IsValid() const { diff --git a/include/engine/routing_algorithms.hpp b/include/engine/routing_algorithms.hpp index 20ac3faee..4096e3a8a 100644 --- a/include/engine/routing_algorithms.hpp +++ b/include/engine/routing_algorithms.hpp @@ -39,7 +39,7 @@ class RoutingAlgorithmsInterface const std::vector &trace_coordinates, const std::vector &trace_timestamps, const std::vector> &trace_gps_precision, - const bool use_tidying) const = 0; + const bool allow_splitting) const = 0; virtual std::vector GetTileTurns(const std::vector &edges, @@ -85,7 +85,7 @@ template class RoutingAlgorithms final : public RoutingAlg const std::vector &trace_coordinates, const std::vector &trace_timestamps, const std::vector> &trace_gps_precision, - const bool use_tidying) const final override; + const bool allow_splitting) const final override; std::vector GetTileTurns(const std::vector &edges, @@ -166,7 +166,7 @@ inline routing_algorithms::SubMatchingList RoutingAlgorithms::MapMat const std::vector &trace_coordinates, const std::vector &trace_timestamps, const std::vector> &trace_gps_precision, - const bool use_tidying) const + const bool allow_splitting) const { return routing_algorithms::mapMatching(heaps, facade, @@ -174,7 +174,7 @@ inline routing_algorithms::SubMatchingList RoutingAlgorithms::MapMat trace_coordinates, trace_timestamps, trace_gps_precision, - use_tidying); + allow_splitting); } template diff --git a/include/engine/routing_algorithms/map_matching.hpp b/include/engine/routing_algorithms/map_matching.hpp index 1bc5ebea4..499ce1937 100644 --- a/include/engine/routing_algorithms/map_matching.hpp +++ b/include/engine/routing_algorithms/map_matching.hpp @@ -29,7 +29,7 @@ mapMatching(SearchEngineData &engine_working_data, const std::vector &trace_coordinates, const std::vector &trace_timestamps, const std::vector> &trace_gps_precision, - const bool use_tidying); + const bool allow_splitting); SubMatchingList mapMatching(SearchEngineData &engine_working_data, @@ -38,7 +38,7 @@ mapMatching(SearchEngineData &engine_working_data, const std::vector &trace_coordinates, const std::vector &trace_timestamps, const std::vector> &trace_gps_precision, - const bool use_tidying); + const bool allow_splitting); } } } diff --git a/include/server/api/match_parameter_grammar.hpp b/include/server/api/match_parameter_grammar.hpp index e89264f21..5a62622e2 100644 --- a/include/server/api/match_parameter_grammar.hpp +++ b/include/server/api/match_parameter_grammar.hpp @@ -33,17 +33,18 @@ struct MatchParametersGrammar final : public RouteParametersGrammar -qi::lit(".json") > -('?' > (timestamps_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1) | - (qi::lit("preprocess=") > - preprocessing_type[ph::bind(&engine::api::MatchParameters::track_preprocessing, - qi::_r1) = qi::_1])) % + (qi::lit("gaps=") > + gaps_type[ph::bind(&engine::api::MatchParameters::gaps_processing, qi::_r1) = + qi::_1]) | + (qi::lit("tidying=") > qi::bool_[ph::bind(&engine::api::MatchParameters::use_tidying, + qi::_r1) = qi::_1])) % '&'); } @@ -51,7 +52,7 @@ struct MatchParametersGrammar final : public RouteParametersGrammar root_rule; qi::rule timestamps_rule; - qi::symbols preprocessing_type; + qi::symbols gaps_type; }; } } diff --git a/src/engine/plugins/match.cpp b/src/engine/plugins/match.cpp index cb84079f6..d3f54d6b0 100644 --- a/src/engine/plugins/match.cpp +++ b/src/engine/plugins/match.cpp @@ -175,7 +175,7 @@ Status MatchPlugin::HandleRequest(const datafacade::ContiguousInternalMemoryData } SubMatchingList sub_matchings; - if (parameters.track_preprocessing == api::MatchParameters::PreprocessingType::Full) + if (parameters.use_tidying) { // Transparently tidy match parameters, do map matching on tidied parameters. // Then use the mapping to restore the original <-> tidied relationship. @@ -197,12 +197,12 @@ Status MatchPlugin::HandleRequest(const datafacade::ContiguousInternalMemoryData } // call the actual map matching - sub_matchings = algorithms.MapMatching( - candidates_lists, - tidied.parameters.coordinates, - tidied.parameters.timestamps, - tidied.parameters.radiuses, - !(parameters.track_preprocessing == api::MatchParameters::PreprocessingType::False)); + sub_matchings = algorithms.MapMatching(candidates_lists, + tidied.parameters.coordinates, + tidied.parameters.timestamps, + tidied.parameters.radiuses, + parameters.gaps_processing == + api::MatchParameters::GapsType::Split); } else { @@ -222,12 +222,12 @@ Status MatchPlugin::HandleRequest(const datafacade::ContiguousInternalMemoryData } // call the actual map matching - sub_matchings = algorithms.MapMatching( - candidates_lists, - parameters.coordinates, - parameters.timestamps, - parameters.radiuses, - !(parameters.track_preprocessing == api::MatchParameters::PreprocessingType::False)); + sub_matchings = algorithms.MapMatching(candidates_lists, + parameters.coordinates, + parameters.timestamps, + parameters.radiuses, + parameters.gaps_processing == + api::MatchParameters::GapsType::Split); } if (sub_matchings.size() == 0) diff --git a/src/engine/routing_algorithms/map_matching.cpp b/src/engine/routing_algorithms/map_matching.cpp index 97d2b5d35..39dc0db9b 100644 --- a/src/engine/routing_algorithms/map_matching.cpp +++ b/src/engine/routing_algorithms/map_matching.cpp @@ -55,7 +55,7 @@ mapMatchingImpl(SearchEngineData &engine_working_data, const std::vector &trace_coordinates, const std::vector &trace_timestamps, const std::vector> &trace_gps_precision, - const bool use_tidying) + const bool allow_splitting) { map_matching::MatchingConfidence confidence; map_matching::EmissionLogProbability default_emission_log_probability(DEFAULT_GPS_PRECISION); @@ -159,11 +159,7 @@ mapMatchingImpl(SearchEngineData &engine_working_data, const bool gap_in_trace = [&]() { // do not determine split if wasn't asked about it - if (!use_tidying) - { - return false; - } - else + if (allow_splitting) { // use temporal information if available to determine a split if (use_timestamps) @@ -176,6 +172,10 @@ mapMatchingImpl(SearchEngineData &engine_working_data, return t - prev_unbroken_timestamps.back() > MAX_BROKEN_STATES; } } + else + { + return false; + } }(); if (!gap_in_trace)