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

Function SerializeRestrictions

generator/restriction_generator.cpp:50–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50void SerializeRestrictions(RestrictionCollector & restrictionCollector, std::string const & mwmPath)
51{
52 std::vector<Restriction> restrictions = restrictionCollector.StealRestrictions();
53 CHECK(std::is_sorted(restrictions.cbegin(), restrictions.cend()), ());
54
55 RestrictionHeader header;
56
57 auto prevTypeEndIt = restrictions.cbegin();
58 for (size_t i = 1; i <= RestrictionHeader::kRestrictionTypes.size(); ++i)
59 {
60 decltype(restrictions.cbegin()) firstNextType;
61 if (i != RestrictionHeader::kRestrictionTypes.size())
62 {
63 firstNextType = std::lower_bound(restrictions.cbegin(), restrictions.cend(),
64 Restriction(RestrictionHeader::kRestrictionTypes[i], {} /* links */),
65 base::LessBy(&Restriction::m_type));
66 }
67 else
68 {
69 firstNextType = restrictions.cend();
70 }
71
72 CHECK_GREATER_OR_EQUAL(i, 1, ("Unexpected overflow."));
73 auto const prevType = RestrictionHeader::kRestrictionTypes[i - 1];
74 header.SetNumberOf(prevType, base::checked_cast<uint32_t>(std::distance(prevTypeEndIt, firstNextType)));
75
76 prevTypeEndIt = firstNextType;
77 }
78
79 LOG(LINFO, ("Routing restriction info:", header));
80
81 FilesContainerW cont(mwmPath, FileWriter::OP_WRITE_EXISTING);
82 auto w = cont.GetWriter(RESTRICTIONS_FILE_TAG);
83 header.Serialize(*w);
84
85 base::SortUnique(restrictions);
86 RestrictionSerializer::Serialize(header, restrictions.begin(), restrictions.end(), *w);
87}
88
89bool BuildRoadRestrictions(IndexGraph & graph, std::string const & mwmPath, std::string const & restrictionPath,
90 std::string const & osmIdsToFeatureIdsPath)

Callers 2

BuildRoadRestrictionsFunction · 0.85
TestRestrictionBuildingFunction · 0.85

Calls 13

RestrictionClass · 0.85
LessByFunction · 0.85
distanceFunction · 0.85
SortUniqueFunction · 0.85
SerializeFunction · 0.85
SetNumberOfMethod · 0.80
GetWriterMethod · 0.80
cbeginMethod · 0.45
cendMethod · 0.45
sizeMethod · 0.45
SerializeMethod · 0.45
beginMethod · 0.45

Tested by 1

TestRestrictionBuildingFunction · 0.68