From 083845a50268a51b4470a864fb59fada61c2c9f1 Mon Sep 17 00:00:00 2001 From: mvglasow Date: Tue, 27 May 2025 21:09:35 +0300 Subject: [PATCH] [traffxml] Fix location matching on dual carriageway roads Signed-off-by: mvglasow --- routing/index_router.cpp | 2 +- routing/index_router.hpp | 18 ++++++++++++++++++ traffxml/traff_decoder.hpp | 25 +++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/routing/index_router.cpp b/routing/index_router.cpp index 1ece94437..bb538216f 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -1406,7 +1406,7 @@ bool IndexRouter::PointsOnEdgesSnapping::FindBestEdges( } // Removing all candidates which are fenced off by the road graph (|closestRoads|) from |checkpoint|. - return !IsFencedOff(checkpoint, edgeProj, closestRoads); + return !m_router.IsFakeEndingSetSimplified() || !IsFencedOff(checkpoint, edgeProj, closestRoads); }; // Getting closest edges from |closestRoads| if they are correct according to isGood() function. diff --git a/routing/index_router.hpp b/routing/index_router.hpp index dae5a530b..9e6845b3e 100644 --- a/routing/index_router.hpp +++ b/routing/index_router.hpp @@ -136,6 +136,24 @@ protected: std::shared_ptr numMwmIds, std::unique_ptr> numMwmTree, std::shared_ptr estimator, DataSource & dataSource); + + /** + * @brief Whether the set of fake endings generated for the check points is restricted. + * + * The return value is used internally when snapping checkpoints to edges. If this function + * returns true, this instructs the `PointsOnEdgesSnapping` instance to consider only edges which + * are not fenced off, i.e. can be reached from the respective checkpoint without crossing any + * other edges. If it returns false, this restriction does not apply, and all nearby edges are + * considered. + * + * Restricting the set of fake endings in this manner decreases the options considered for routing + * and thus processing time, which is desirable for regular routing and has no side effects. + * + * The `IndexRouter` implementation always returns true; subclasses may override this method and + * return different values. + */ + virtual bool IsFakeEndingSetSimplified() { return true; } + private: RouterResultCode CalculateSubrouteJointsMode(IndexGraphStarter & starter, RouterDelegate const & delegate, diff --git a/traffxml/traff_decoder.hpp b/traffxml/traff_decoder.hpp index 5c9686b1d..68e95cf48 100644 --- a/traffxml/traff_decoder.hpp +++ b/traffxml/traff_decoder.hpp @@ -188,6 +188,31 @@ public: std::unique_ptr> numMwmTree, DataSource & dataSource); protected: + /** + * @brief Whether the set of fake endings generated for the check points is restricted. + * + * The return value is used internally when snapping checkpoints to edges. If this function + * returns true, this instructs the `PointsOnEdgesSnapping` instance to consider only edges which + * are not fenced off, i.e. can be reached from the respective checkpoint without crossing any + * other edges. If it returns false, this restriction does not apply, and all nearby edges are + * considered. + * + * Restricting the set of fake endings in this manner decreases the options considered for routing + * and thus processing time, which is desirable for regular routing and has no side effects. + * For TraFF location matching, simplification has undesirable side effects: if reference points + * are located on one side of the road, the other carriageway may not be considered. This would + * lead to situations like these: + * + * --<--<-+<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<==<+-<--<-- + * -->-->-+>==>==>==>==>==>==>-->-->-->-->-->-->-->-->-->-->-->==>==>==>==>==>==>==>==>+->-->-- + * *< <* + * + * (-- carriageway, + junction, < > direction, *< end point, <* start point, == route) + * + * To avoid this, the `DecoderRouter` implementation always returns false. + */ + bool IsFakeEndingSetSimplified() override { return false; } + private: };