| 245 | } |
| 246 | |
| 247 | RouteWeight IndexGraphStarter::CalcSegmentWeight(Segment const & segment, EdgeEstimator::Purpose purpose) const |
| 248 | { |
| 249 | if (IsGuidesSegment(segment)) |
| 250 | return CalcGuidesSegmentWeight(segment, purpose); |
| 251 | |
| 252 | if (IsRegionsGraphMode() && !IsFakeSegment(segment)) |
| 253 | return m_regionsGraph->CalcSegmentWeight(segment); |
| 254 | |
| 255 | if (!IsFakeSegment(segment)) |
| 256 | return m_graph.CalcSegmentWeight(segment, purpose); |
| 257 | |
| 258 | auto const & vertex = m_fake.GetVertex(segment); |
| 259 | Segment real; |
| 260 | if (m_fake.FindReal(segment, real)) |
| 261 | { |
| 262 | double const partLen = ms::DistanceOnEarth(vertex.GetPointFrom(), vertex.GetPointTo()); |
| 263 | |
| 264 | if (IsRegionsGraphMode()) |
| 265 | return RouteWeight(partLen); |
| 266 | |
| 267 | double const fullLen = ms::DistanceOnEarth(GetPoint(real, false), GetPoint(real, true)); |
| 268 | // Note 1. |fullLen| == 0.0 in case of Segment(s) with the same ends. |
| 269 | // Note 2. There is the following logic behind |return 0.0 * m_graph.CalcSegmentWeight(real, ...);|: |
| 270 | // it's necessary to return a instance of the structure |RouteWeight| with zero wight. |
| 271 | // Theoretically it may be differ from |RouteWeight(0)| because some road access block |
| 272 | // may be kept in it and it is up to |RouteWeight| to know how to multiply by zero. |
| 273 | |
| 274 | Weight weight; |
| 275 | if (IsGuidesSegment(real)) |
| 276 | weight = CalcGuidesSegmentWeight(real, purpose); |
| 277 | else |
| 278 | weight = m_graph.CalcSegmentWeight(real, purpose); |
| 279 | if (fullLen == 0.0) |
| 280 | return 0.0 * weight; |
| 281 | |
| 282 | return (partLen / fullLen) * weight; |
| 283 | } |
| 284 | |
| 285 | return m_graph.CalcOffroadWeight(vertex.GetPointFrom(), vertex.GetPointTo(), purpose); |
| 286 | } |
| 287 | |
| 288 | double IndexGraphStarter::CalculateETA(Segment const & from, Segment const & to) const |
| 289 | { |
no test coverage detected