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

Method SerializeDataPointsV0

libs/coding/traffic.hpp:81–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79private:
80 template <typename Writer, typename Collection>
81 static size_t SerializeDataPointsV0(Writer & writer, Collection const & points)
82 {
83 auto const startPos = writer.Pos();
84
85 if (!points.empty())
86 {
87 uint64_t const firstTimestamp = points[0].m_timestamp;
88 uint32_t const firstLat =
89 DoubleToUint32(points[0].m_latLon.m_lat, ms::LatLon::kMinLat, ms::LatLon::kMaxLat, kCoordBits);
90 uint32_t const firstLon =
91 DoubleToUint32(points[0].m_latLon.m_lon, ms::LatLon::kMinLon, ms::LatLon::kMaxLon, kCoordBits);
92 WriteVarUint(writer, firstTimestamp);
93 WriteVarUint(writer, firstLat);
94 WriteVarUint(writer, firstLon);
95 }
96
97 for (size_t i = 1; i < points.size(); ++i)
98 {
99 ASSERT_LESS_OR_EQUAL(points[i - 1].m_timestamp, points[i].m_timestamp, ());
100
101 uint64_t const deltaTimestamp = points[i].m_timestamp - points[i - 1].m_timestamp;
102 uint32_t deltaLat = DoubleToUint32(points[i].m_latLon.m_lat - points[i - 1].m_latLon.m_lat, kMinDeltaLat,
103 kMaxDeltaLat, kCoordBits);
104 uint32_t deltaLon = DoubleToUint32(points[i].m_latLon.m_lon - points[i - 1].m_latLon.m_lon, kMinDeltaLon,
105 kMaxDeltaLon, kCoordBits);
106
107 WriteVarUint(writer, deltaTimestamp);
108 WriteVarUint(writer, deltaLat);
109 WriteVarUint(writer, deltaLon);
110 }
111
112 ASSERT_LESS_OR_EQUAL(writer.Pos() - startPos, std::numeric_limits<size_t>::max(), ("Too much data."));
113 return static_cast<size_t>(writer.Pos() - startPos);
114 }
115
116 template <typename Writer, typename Collection>
117 static size_t SerializeDataPointsV1(Writer & writer, Collection const & points)

Callers

nothing calls this directly

Calls 5

DoubleToUint32Function · 0.85
WriteVarUintFunction · 0.85
PosMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected