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

Method PrepareSchemePT

libs/drape_frontend/transit_scheme_builder.cpp:864–953  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

862}
863
864void TransitSchemeBuilder::PrepareSchemePT(TransitDisplayInfo const & transitDisplayInfo, LinesDataPT const & lineData,
865 MwmSchemeData & scheme)
866{
867 m2::RectD boundingRect;
868
869 for (auto const & [lineId, lineData] : scheme.m_linesPT)
870 {
871 if (transitDisplayInfo.m_linesMetadataPT.find(lineId) == transitDisplayInfo.m_linesMetadataPT.end())
872 continue;
873
874 auto const & color = lineData.m_color;
875
876 CHECK(!lineData.m_color.empty(), ());
877
878 for (size_t i = 0; i < lineData.m_stopIds.size() - 1; ++i)
879 {
880 ::transit::TransitId stop1Id = lineData.m_stopIds[i];
881 ::transit::TransitId stop2Id = lineData.m_stopIds[i + 1];
882
883 StopNodeParamsPT & params1 = GetStopOrTransfer(scheme, stop1Id);
884 StopNodeParamsPT & params2 = GetStopOrTransfer(scheme, stop2Id);
885
886 m2::PointD dir1;
887 m2::PointD dir2;
888
889 auto it = transitDisplayInfo.m_edgesPT.find(::transit::EdgeId(stop1Id, stop2Id, lineId));
890
891 if (it == transitDisplayInfo.m_edgesPT.end())
892 {
893 dir1 = (params2.m_pivot - params1.m_pivot).Normalize();
894 if (dir1.IsAlmostZero() && dir2.IsAlmostZero())
895 dir1 = kDefaultDirection;
896
897 dir2 = -dir1;
898 }
899 else
900 {
901 ::transit::ShapeLink const & shapeLink = it->second.m_shapeLink;
902 auto const itShape = transitDisplayInfo.m_shapesPT.find(shapeLink.m_shapeId);
903 CHECK(itShape != transitDisplayInfo.m_shapesPT.end(), (shapeLink.m_shapeId));
904
905 auto const & polyline = itShape->second.GetPolyline();
906
907 auto const [startIndex, endIndex] = std::minmax(shapeLink.m_startIndex, shapeLink.m_endIndex);
908
909 dir1 = (polyline[startIndex + 1] - polyline[startIndex]).Normalize();
910 dir2 = (polyline[endIndex] - polyline[endIndex - 1]).Normalize();
911
912 if (shapeLink.m_startIndex > shapeLink.m_endIndex)
913 std::swap(dir1, dir2);
914
915 for (size_t j = shapeLink.m_startIndex; j <= shapeLink.m_endIndex; ++j)
916 boundingRect.Add(polyline[j]);
917 }
918
919 UpdateShapeInfos(params1.m_shapeInfoOut, dir1, color);
920 UpdateShapeInfos(params2.m_shapeInfoIn, dir2, color);
921 }

Callers

nothing calls this directly

Calls 11

EdgeIdClass · 0.85
UpdateShapeInfosFunction · 0.85
IsAlmostZeroMethod · 0.80
swapFunction · 0.50
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
NormalizeMethod · 0.45
AddMethod · 0.45
CenterMethod · 0.45

Tested by

no test coverage detected