| 128 | } |
| 129 | |
| 130 | void ScoreCandidatePathsGetter::GetAllSuitablePaths(ScoreEdgeVec const & startLines, LinearSegmentSource source, |
| 131 | bool isLastPoint, double bearDistM, |
| 132 | FunctionalRoadClass functionalRoadClass, FormOfWay formOfWay, |
| 133 | double distanceToNextPointM, vector<shared_ptr<Link>> & allPaths) |
| 134 | { |
| 135 | CHECK_NOT_EQUAL(source, LinearSegmentSource::NotValid, ()); |
| 136 | |
| 137 | queue<shared_ptr<Link>> q; |
| 138 | |
| 139 | for (auto const & e : startLines) |
| 140 | { |
| 141 | Score roadScore = 0; // Score based on functional road class and form of way. |
| 142 | if (source == LinearSegmentSource::FromLocationReferenceTag && |
| 143 | !PassesRestrictionV3(e.m_edge, functionalRoadClass, formOfWay, m_infoGetter, roadScore)) |
| 144 | { |
| 145 | continue; |
| 146 | } |
| 147 | |
| 148 | q.push(make_shared<Link>(nullptr /* parent */, e.m_edge, 0 /* distanceM */, e.m_score, roadScore)); |
| 149 | } |
| 150 | |
| 151 | // Filling |allPaths| staring from |startLines| which have passed functional road class |
| 152 | // and form of way restrictions. All paths in |allPaths| are shorter then |bearDistM| plus |
| 153 | // one segment length. |
| 154 | while (!q.empty()) |
| 155 | { |
| 156 | auto const u = q.front(); |
| 157 | q.pop(); |
| 158 | |
| 159 | auto const & currentEdge = u->m_edge; |
| 160 | auto const currentEdgeLen = EdgeLength(currentEdge); |
| 161 | |
| 162 | // The path from the start of the openlr segment to the finish to the openlr segment should be |
| 163 | // much shorter then the distance of any connection of openlr segment. |
| 164 | // This condition should be checked because otherwise in rare case |q| may be overfilled. |
| 165 | if (u->m_distanceM > distanceToNextPointM) |
| 166 | continue; |
| 167 | |
| 168 | if (u->m_distanceM + currentEdgeLen >= bearDistM) |
| 169 | { |
| 170 | allPaths.emplace_back(std::move(u)); |
| 171 | continue; |
| 172 | } |
| 173 | |
| 174 | CHECK_LESS(u->m_distanceM + currentEdgeLen, bearDistM, ()); |
| 175 | |
| 176 | Graph::EdgeListT edges; |
| 177 | if (!isLastPoint) |
| 178 | m_graph.GetOutgoingEdges(currentEdge.GetEndJunction(), edges); |
| 179 | else |
| 180 | m_graph.GetIngoingEdges(currentEdge.GetStartJunction(), edges); |
| 181 | |
| 182 | // It's possible that road edges are duplicated a lot of times. It's a error but |
| 183 | // a mapper may do that. To prevent a combinatorial explosion while matching |
| 184 | // duplicated edges should be removed. |
| 185 | scpg::EdgeSortUniqueByStartAndEndPoints(edges); |
| 186 | |
| 187 | for (auto const & e : edges) |
nothing calls this directly
no test coverage detected