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

Method Serialize

generator/camera_info_collector.cpp:51–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51void CamerasInfoCollector::Serialize(FileWriter & writer) const
52{
53 // Some cameras have several ways related to them.
54 // We create N cameras with one way attached from a camera that has N ways attached.
55 std::vector<CamerasInfoCollector::Camera> flattenedCameras;
56 for (auto const & camera : m_cameras)
57 {
58 for (auto const & way : camera.m_data.m_ways)
59 {
60 flattenedCameras.emplace_back(camera.m_data.m_center, camera.m_data.m_maxSpeedKmPH,
61 std::vector<routing::SpeedCameraMwmPosition>{way});
62 }
63 }
64
65 routing::SpeedCameraMwmHeader header;
66 header.SetVersion(routing::SpeedCameraMwmHeader::kLatestVersion);
67 header.SetAmount(base::asserted_cast<uint32_t>(flattenedCameras.size()));
68 header.Serialize(writer);
69
70 std::sort(flattenedCameras.begin(), flattenedCameras.end(), [](auto const & a, auto const & b)
71 {
72 CHECK_EQUAL(a.m_data.m_ways.size(), 1, ());
73 CHECK_EQUAL(b.m_data.m_ways.size(), 1, ());
74
75 auto const & aWay = a.m_data.m_ways.back();
76 auto const & bWay = b.m_data.m_ways.back();
77
78 if (aWay.m_featureId != bWay.m_featureId)
79 return aWay.m_featureId < bWay.m_featureId;
80
81 if (aWay.m_segmentId != bWay.m_segmentId)
82 return aWay.m_segmentId < bWay.m_segmentId;
83
84 return aWay.m_coef < bWay.m_coef;
85 });
86
87 // Now each camera has only 1 way.
88 uint32_t prevFeatureId = 0;
89 for (auto const & camera : flattenedCameras)
90 camera.Serialize(writer, prevFeatureId);
91}
92
93bool CamerasInfoCollector::ParseIntermediateInfo(std::string const & camerasInfoPath,
94 routing::OsmIdToFeatureIds const & osmIdToFeatureIds)

Callers 13

SaveMethod · 0.45
SerializeCrossMwmFunction · 0.45
CollectFeatureMethod · 0.45
BuildTransitFunction · 0.45
BuildSectionMethod · 0.45
FinishMethod · 0.45
BuildRoadAltitudesFunction · 0.45
BuildTransitFunction · 0.45
BuildCamerasInfoFunction · 0.45
BuildPostcodePointsImplFunction · 0.45
SerializeRestrictionsFunction · 0.45
BuildIsolinesInfoSectionFunction · 0.45

Calls 8

SerializeSpeedCameraFunction · 0.85
SetVersionMethod · 0.80
SetAmountMethod · 0.80
backMethod · 0.80
emplace_backMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected