MCPcopy Create free account
hub / github.com/comaps/comaps / ValidatePathByLength

Function ValidatePathByLength

tools/openlr/score_paths_connector.cpp:97–121  ·  view source on GitHub ↗

\returns true if |path| may be used as a candidate. In that case |lenScore| is filled with score of this candidate based on length. The closer length of the |path| to |distanceToNextPoint| the more score.

Source from the content-addressed store, hash-verified

95/// with score of this candidate based on length. The closer length of the |path| to
96/// |distanceToNextPoint| the more score.
97bool ValidatePathByLength(Graph::EdgeVector const & path, double distanceToNextPoint, LinearSegmentSource source,
98 Score & lenScore)
99{
100 CHECK(!path.empty(), ());
101 CHECK_NOT_EQUAL(source, LinearSegmentSource::NotValid, ());
102
103 Score const kMaxScoreForRouteLen = 110;
104
105 double pathLen = 0.0;
106 for (auto const & e : path)
107 pathLen += EdgeLength(e);
108
109 // 0 <= |pathDiffRatio| <= 1. The more pathDiffRatio the closer |distanceToNextPoint| and |pathLen|.
110 double const pathDiffRatio = 1.0 - abs(distanceToNextPoint - pathLen) / max(distanceToNextPoint, pathLen);
111
112 bool const shortPath = path.size() <= 2;
113 double const kMinValidPathDiffRation = source == LinearSegmentSource::FromLocationReferenceTag ? 0.6 : 0.25;
114 if (pathDiffRatio <= kMinValidPathDiffRation && !shortPath)
115 return false;
116
117 lenScore = static_cast<Score>(kMaxScoreForRouteLen * (pathDiffRatio - kMinValidPathDiffRation) /
118 (1.0 - kMinValidPathDiffRation));
119
120 return true;
121}
122
123bool AreEdgesEqualWithoutAltitude(Graph::Edge const & e1, Graph::Edge const & e2)
124{

Callers 1

FindBestPathMethod · 0.85

Calls 3

EdgeLengthFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected