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

Method CacheRoute

libs/drape_frontend/route_shape.cpp:483–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481}
482
483drape_ptr<df::SubrouteData> RouteShape::CacheRoute(ref_ptr<dp::GraphicsContext> context, dp::DrapeID subrouteId,
484 SubrouteConstPtr subroute, size_t styleIndex, int recacheId)
485{
486 size_t startIndex;
487 size_t endIndex;
488 if (subroute->m_styleType == df::SubrouteStyleType::Single)
489 {
490 ASSERT_EQUAL(styleIndex, 0, ());
491 startIndex = 0;
492 endIndex = subroute->m_polyline.GetSize() - 1;
493 }
494 else
495 {
496 auto const & style = subroute->m_style[styleIndex];
497 startIndex = style.m_startIndex;
498 endIndex = style.m_endIndex;
499 }
500
501 ASSERT_LESS(startIndex, endIndex, ());
502
503 auto const points = subroute->m_polyline.ExtractSegment(startIndex, endIndex);
504 if (points.empty())
505 return nullptr;
506
507 std::vector<glsl::vec4> segmentsColors;
508 if (!subroute->m_traffic.empty())
509 {
510 segmentsColors.reserve(endIndex - startIndex);
511 for (size_t i = startIndex; i < endIndex; ++i)
512 {
513 auto const speedGroup = TrafficGenerator::CheckColorsSimplification(subroute->m_traffic[i]);
514 auto const colorConstant = TrafficGenerator::GetColorBySpeedGroup(speedGroup, true /* route */);
515 dp::Color const color = df::GetColorConstant(colorConstant);
516 float const alpha = (speedGroup == traffic::SpeedGroup::G4 || speedGroup == traffic::SpeedGroup::G5 ||
517 speedGroup == traffic::SpeedGroup::Unknown)
518 ? 0.0f
519 : 1.0f;
520 segmentsColors.emplace_back(color.GetRedF(), color.GetGreenF(), color.GetBlueF(), alpha);
521 }
522 }
523
524 auto subrouteData = make_unique_dp<df::SubrouteData>();
525 subrouteData->m_subrouteId = subrouteId;
526 subrouteData->m_subroute = subroute;
527 subrouteData->m_startPointIndex = startIndex;
528 subrouteData->m_endPointIndex = endIndex;
529 subrouteData->m_styleIndex = styleIndex;
530 subrouteData->m_pivot = subroute->m_polyline.GetLimitRect().Center();
531 subrouteData->m_recacheId = recacheId;
532 subrouteData->m_distanceOffset = subroute->m_polyline.GetLength(startIndex);
533
534 std::vector<GeometryBufferData<GeometryBuffer>> geometryBufferData;
535 PrepareGeometry(points, subrouteData->m_pivot, segmentsColors,
536 static_cast<float>(subroute->m_baseDepthIndex * rs::kDepthPerSubroute), geometryBufferData);
537
538 auto state = CreateRenderState(
539 subroute->m_style[styleIndex].m_pattern.m_isDashed ? gpu::Program::RouteDash : gpu::Program::Route,
540 DepthLayer::GeometryLayer);

Callers

nothing calls this directly

Calls 15

GetColorConstantFunction · 0.85
CreateRenderStateFunction · 0.85
make_refFunction · 0.85
GetBindingInfoFunction · 0.85
ExtractSegmentMethod · 0.80
GetRedFMethod · 0.80
GetGreenFMethod · 0.80
GetBlueFMethod · 0.80
GetSizeMethod · 0.45
emptyMethod · 0.45
reserveMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected