This invention discloses a method and
system for recording and playing back digital twins of traffic intersections using multi-source state aggregation. The backend establishes two long connections for each intersection: one for light status and one for
traffic flow. These connections are merged into a unified
record by second and distributed to each
client via a
message queue. The recording module reuses this
record, compressing and storing it as a gzip file in NDJSON format according to a four-level
directory structure: "intersection / date / hour / 5 minutes". During playback, the corresponding segments are decompressed, and the timestamps of light status and
traffic flow are precisely aligned by second. The timestamps are returned progressively by segment number, enabling simultaneous downloading and playback, as well as index positioning. The channelization map is rendered using Canvas, mapping light status to light color animations and
traffic flow to vehicle positions.
Data integrity is visually queried using a heatmap matrix. This invention solves the problems of frontend direct connection performance, playback
timestamp misalignment, and imperceptible loading progress. It also features low storage costs and supports long-term, accurate playback.