| 862 | } |
| 863 | |
| 864 | void 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 | } |