\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.
| 95 | /// with score of this candidate based on length. The closer length of the |path| to |
| 96 | /// |distanceToNextPoint| the more score. |
| 97 | bool 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 | |
| 123 | bool AreEdgesEqualWithoutAltitude(Graph::Edge const & e1, Graph::Edge const & e2) |
| 124 | { |
no test coverage detected