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

Function ConvertRestrictionsOnlyToNo

libs/routing/restriction_loader.cpp:116–151  ·  view source on GitHub ↗

\brief We store |Only| restriction in mwm, like Only, featureId_1, ... , featureId_N We convert such restriction to |No| following way: For each M, greater than 1, and M first features: featureId_1, ... , featureId_(M - 1), featureId_M, ... We create restrictionNo from features: featureId_1, ... , featureId_(M - 1), featureId_K where featureId_K - has common joint with featureId_(M - 1) and feat

Source from the content-addressed store, hash-verified

114/// featureId_1, ... , featureId_(M - 1), featureId_K
115/// where featureId_K - has common joint with featureId_(M - 1) and featureId_M.
116void ConvertRestrictionsOnlyToNo(IndexGraph const & graph, RestrictionVec const & restrictionsOnly,
117 RestrictionVec & restrictionsNo)
118{
119 for (std::vector<uint32_t> const & restriction : restrictionsOnly)
120 {
121 CHECK_GREATER_OR_EQUAL(restriction.size(), 2, ());
122
123 if (!IsRestrictionFromRoads(graph, restriction))
124 continue;
125
126 for (size_t i = 1; i < restriction.size(); ++i)
127 {
128 auto const curFeatureId = restriction[i];
129 auto const prevFeatureId = restriction[i - 1];
130
131 // Looking for a joint of an intersection of prev and cur features.
132 Joint::Id const common = GetCommonEndJoint(graph.GetRoad(curFeatureId), graph.GetRoad(prevFeatureId));
133
134 if (common == Joint::kInvalidId)
135 break;
136
137 std::vector<uint32_t> commonFeatures;
138 commonFeatures.resize(i + 1);
139 std::copy(restriction.begin(), restriction.begin() + i, commonFeatures.begin());
140
141 graph.ForEachPoint(common, [&](RoadPoint const & rp)
142 {
143 if (rp.GetFeatureId() != curFeatureId)
144 {
145 commonFeatures.back() = rp.GetFeatureId();
146 restrictionsNo.emplace_back(commonFeatures);
147 }
148 });
149 }
150 }
151}
152
153void ConvertRestrictionsOnlyUTurnToNo(IndexGraph & graph, std::vector<RestrictionUTurn> const & restrictionsOnlyUTurn,
154 RestrictionVec & restrictionsNo)

Callers 3

RestrictionLoaderMethod · 0.85
UNIT_CLASS_TESTFunction · 0.85
UNIT_CLASS_TESTFunction · 0.85

Calls 9

IsRestrictionFromRoadsFunction · 0.85
GetCommonEndJointFunction · 0.85
backMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45
ForEachPointMethod · 0.45
GetFeatureIdMethod · 0.45
emplace_backMethod · 0.45

Tested by 2

UNIT_CLASS_TESTFunction · 0.68
UNIT_CLASS_TESTFunction · 0.68