Traffic flow simulation methods, apparatus, electronic devices and computer-readable storage media

By combining Unreal Engine and Geographic Information System, traffic flow simulation is performed based on real-world road data, solving the problems of large development workload, low route accuracy, and low operating efficiency in existing traffic flow simulation technologies, and achieving efficient and accurate traffic flow display.

CN120430086BActive Publication Date: 2025-10-28BEIJING REALFLY AVIATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510931247.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-07
Publication Date
2025-10-28
Estimated Expiration
2045-07-07

AI Technical Summary

Technical Problem

Existing technologies for traffic flow simulation in virtual reality software suffer from problems such as large development workload, low route accuracy, low operating efficiency, and high computational load on display devices.

Method used

Using Unreal Engine, traffic flow is simulated based on real-world road data. Road data from a geographic information system is used for coordinate transformation and supplementation. A spline component pool is created, and road data within the camera's field of view is selected to generate simulated roads and vehicles. A traffic flow management class is used for unified management and display.

Benefits of technology

It reduces the workload of developers, improves route accuracy and software efficiency, and reduces the computational load on display devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120430086B_ABST
    Figure CN120430086B_ABST
Patent Text Reader

Abstract

This disclosure provides a traffic flow simulation method, apparatus, electronic device, and computer-readable storage medium, relating to the field of traffic flow simulation. The method, executed by Unreal Engine, includes: obtaining simulated road data based on the latitude, longitude, and height coordinates of the original road data; when preset conditions are met, selecting road data to be displayed from the simulated road data that is within the current coordinate viewpoint range of the simulated camera; creating a spline component pool and repeatedly performing the following operations until the traffic flow simulation ends: generating corresponding simulated roads and a corresponding number of simulated vehicles for each road in the road data to be displayed using at least one spline component in the spline component pool, thus forming traffic flow data; performing traffic flow simulation on each road based on the time elapsed per frame and the traffic flow data of each road; when preset conditions are met, re-selecting the road data to be displayed and performing the above operations until the traffic flow simulation ends.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to fields such as virtual reality technology, and more specifically, to a traffic flow simulation method, apparatus, electronic device, and computer-readable storage medium. Background Technology

[0002] In the field of virtual reality, with the rapid development of computer graphics and hardware performance, software users have increasingly higher requirements for the realism of simulation effects. Virtual reality technology can be used to simulate traffic flow on real roads, that is, to display a simulated display of multiple vehicles moving along a road.

[0003] Currently, in the field of virtual reality software development, there are two main implementation schemes for achieving traffic flow simulation.

[0004] Option 1: Traffic flow simulation is achieved by independently controlling the travel routes of individual vehicles. This method mainly has the following problems:

[0005] (1) For software developers, the development cost of independently controlling the travel route of each vehicle is high, which makes it difficult to create a large number of vehicles for display in a scene. However, if there are not enough vehicles, the simulation display effect will not be realistic.

[0006] (2) In most cases, vehicles in the real world need to travel along roads, so multiple vehicles will move along the same path. The disadvantage of controlling the travel route of each vehicle independently is that it is difficult to ensure that the travel routes of vehicles traveling on the same road are sufficiently uniform, and performing completely consistent route control on vehicles on the same travel route is itself a kind of duplication in development and a waste of efficiency.

[0007] (3) When the roads in the real world change, the virtual reality software that simulates the real world also needs to be adjusted accordingly to ensure consistency with the real world. At this time, controlling the travel route of each vehicle independently means adjusting the route of each vehicle on the changed road, which will increase the difficulty of software maintenance and reduce the efficiency of software maintenance.

[0008] (4) Independent control of the travel route of each vehicle during software operation requires real-time calculation of the position of each vehicle on the route, which will increase the amount of computation. When there are a large number of vehicles on the screen, the amount of computation generated by calculating the vehicle positions will significantly reduce the overall smoothness of the software operation.

[0009] Option 2: In the field of virtual reality software development, Unreal Engine 5 (UE5) boasts advantages such as powerful functionality, high operating efficiency, and low development costs. Therefore, projects such as city simulation and traffic simulation can choose to use Unreal Engine 5 for virtual reality software development. Displaying vehicles and the resulting traffic flow in virtual reality software is a crucial part of the simulation system. Typically, Unreal Engine 5 uses a spline component (USplineComponent) as the traffic flow control component to achieve unified control of the travel routes of multiple vehicles simultaneously. By setting the coordinate data of each spline node (FSplinePoint) in the spline component, a suitable travel route can be generated. Multiple vehicles are then positioned on the generated route, and their positions are updated to form a traffic flow. However, this method has the following drawbacks:

[0010] (1) When virtual reality software simulates a large scene, such as simulating a city, it is necessary to set up a large number of vehicle control components and set the road coordinates (spline node coordinates) one by one, which is a huge workload for software development staff.

[0011] (2) Road coordinate data manually set by virtual reality software developers cannot guarantee the accuracy of the route.

[0012] (3) A large amount of manually set coordinate data and spline components are difficult to organize and manage effectively. During software operation, since each spline component is set with different spline node coordinate data, that is, each spline component has unique properties, a large number of spline components need to be reset for each simulation, which not only increases the workload, but also is not conducive to optimizing the software running efficiency.

[0013] (4) Since each spline component exists independently, the static mesh model used to display the vehicle needs to be rendered independently, which will increase the computational burden of the display computing device. When the number of vehicles is large, it may affect the overall smoothness of the software operation.

[0014] In other words, current traffic flow simulation using Unreal Engine 5 suffers from drawbacks such as high development workload, low route accuracy, low operating efficiency, and high computational load on display devices.

[0015] Therefore, improving the efficiency and accuracy of traffic flow simulation, reducing the computational load of the software, and reducing the workload of developers have become urgent problems to be solved. Summary of the Invention

[0016] This disclosure provides a traffic flow simulation method, apparatus, electronic device, and computer-readable storage medium, which can simulate traffic flow based on real-world road data using Unreal Engine, effectively improving the efficiency and accuracy of traffic flow simulation.

[0017] In a first aspect, embodiments of this disclosure provide a traffic flow simulation method, which is executed by Unreal Engine, and the method includes:

[0018] Obtain the original road data, and based on the latitude, longitude and altitude coordinates of the original road data, perform coordinate system transformation and coordinate point calculation to obtain simulated road data, and save the simulated road data, which includes at least one road;

[0019] Create a spline component pool. When preset conditions are met, filter out and save the road data to be displayed from the simulated road data that is within the current coordinate view range of the simulated camera. The preset conditions include starting traffic flow simulation or when the simulated camera moves a distance exceeding the set displacement threshold.

[0020] Repeat the following steps until the traffic flow simulation ends:

[0021] For each road in the road data to be displayed, generate a corresponding simulated road using at least one spline component from the spline component pool.

[0022] For each road in the road data to be displayed, based on the length of the simulated road corresponding to each road and the preset vehicle density, a corresponding number of simulated vehicles are generated for each road.

[0023] For each road in the road data to be displayed, the road data corresponding to each road and its corresponding number of simulated vehicles are encapsulated to form the traffic flow data corresponding to each road;

[0024] For each road in the road data to be displayed, traffic flow simulation is performed based on the time elapsed in each frame of the program's runtime and the traffic flow data corresponding to each road;

[0025] When the preset conditions are met, new road data to be displayed is re-selected, and the above operations are performed on the new road data to be displayed until the traffic flow simulation ends.

[0026] Secondly, embodiments of this disclosure provide a traffic flow simulation device, which includes Unreal Engine, and the device comprises:

[0027] The first-level logic operation module is used to acquire the original road data, perform coordinate system transformation and coordinate point calculation based on the latitude, longitude and height coordinates of the original road data, obtain simulated road data, and save the simulated road data, which includes at least one road.

[0028] The filtering logic operation module is used to create a spline component pool. When preset conditions are met, it filters out the road data to be displayed from the simulated road data that is within the current coordinate view range of the simulated camera and saves it. The preset conditions include starting traffic flow simulation or when the simulated camera moves a distance exceeding the set displacement threshold.

[0029] The second-level logic operation module is used to repeatedly perform the following operations until the traffic flow simulation ends:

[0030] For each road in the road data to be displayed, generate a corresponding simulated road using at least one spline component from the spline component pool.

[0031] For each road in the road data to be displayed, based on the length of the simulated road corresponding to each road and the preset vehicle density, a corresponding number of simulated vehicles are generated for each road.

[0032] For each road in the road data to be displayed, the road data corresponding to each road and its corresponding number of simulated vehicles are encapsulated to form the traffic flow data corresponding to each road;

[0033] For each road in the road data to be displayed, traffic flow simulation is performed based on the time elapsed in each frame of the program's runtime and the traffic flow data corresponding to each road;

[0034] When the preset conditions are met, new road data to be displayed is re-selected, and the above operations are performed on the new road data to be displayed until the traffic flow simulation ends.

[0035] Thirdly, embodiments of this disclosure provide an electronic device, including a processor and a memory, which are interconnected;

[0036] The aforementioned memory is used to store computer programs;

[0037] The processor is configured to execute the method provided in the first aspect when the computer program is invoked.

[0038] Fourthly, embodiments of this disclosure provide a computer-readable storage medium storing a computer program that is executed by a processor to implement the method provided in the first aspect above.

[0039] Fifthly, embodiments of this disclosure provide a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method provided in the first aspect.

[0040] In this embodiment of the disclosure, using Unreal Engine, coordinate system transformation and coordinate point calculation operations are performed based on the latitude, longitude, and altitude coordinates of the acquired real-world original road data to obtain and save corresponding simulated road data. The obtained simulated road data includes at least one road. From the simulated road data, when preset conditions are met, road data to be displayed that is within the current coordinate range of the simulated camera is selected and saved. These preset conditions include starting traffic flow simulation or the simulated camera moving a distance exceeding a set displacement threshold. A spline component pool is created, and the following operations are repeated until the traffic flow simulation ends: [The remaining text appears to be incomplete and requires further context.] At least one spline component generates a corresponding simulated road for each road in the road data to be displayed; based on each road in the road data to be displayed, and based on the length of the simulated road corresponding to each road and the preset vehicle density, a corresponding number of simulated vehicles are generated for each road; the road data corresponding to each road and its corresponding number of simulated vehicles are encapsulated to generate traffic flow data corresponding to each road; traffic flow simulation is performed on each road according to the time elapsed in each frame during program execution and the traffic flow data of each road; when preset conditions are met, new road data to be displayed is re-selected, and the above operations are performed on the new road data to be displayed until the traffic flow simulation ends. The method in this embodiment converts existing real-world road data into simulated road data and performs traffic flow simulation based on the simulated road data. On the one hand, this eliminates the need for software developers to manually set road node coordinates, reducing their workload. On the other hand, since the simulated road data is based on real original road data, traffic flow simulation based on this simulated road data improves route accuracy. By using the camera position as the center point to filter the traffic flow to be displayed, and by generating corresponding simulated roads for each road in the road data to be displayed using at least one spline component in the spline component pool, unified management and reuse of spline components are achieved, improving software operating efficiency and reducing the complexity of spline component management. Attached Figure Description

[0041] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments of this disclosure will be briefly introduced below.

[0042] Figure 1A flowchart illustrating a traffic flow simulation method provided in an embodiment of this disclosure;

[0043] Figure 2 A flowchart illustrating another traffic flow simulation method provided in this embodiment of the disclosure;

[0044] Figure 3 A schematic diagram illustrating the logical relationship of a traffic flow simulation method provided in this embodiment of the disclosure;

[0045] Figure 4 This is a schematic diagram of the structure of a traffic flow simulation device provided in an embodiment of the present disclosure;

[0046] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0047] The embodiments of this disclosure are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this disclosure, and do not constitute a limitation on the technical solutions of the embodiments of this disclosure.

[0048] To make the objectives, technical solutions, and advantages of this disclosure clearer, the embodiments of this disclosure will be described in further detail below with reference to the accompanying drawings.

[0049] To overcome the shortcomings of existing visual traffic simulation systems, such as large development workload, low route accuracy, low operating efficiency, and high computational load on display devices, see [reference needed]. Figure 1 , Figure 1 This is a flowchart illustrating a traffic flow simulation method provided in an embodiment of this disclosure. The method is executed by Unreal Engine. Figure 1 As shown, the method includes the following steps:

[0050] Step S101: Obtain the original road data. Based on the latitude, longitude and altitude coordinates of the original road data, perform coordinate system transformation and coordinate point calculation to obtain simulated road data and save the simulated road data. The simulated road data includes at least one road.

[0051] Step S102: Create a spline component pool. When the preset conditions are met, filter out the road data to be displayed from the simulated road data that are within the current coordinate view range of the simulated camera and save it. The preset conditions include starting traffic flow simulation or when the simulated camera moves a distance exceeding the set displacement threshold.

[0052] Step S103, repeat the following operations until the traffic flow simulation ends:

[0053] For each road in the road data to be displayed, generate a corresponding simulated road using at least one spline component from the spline component pool.

[0054] For each road in the road data to be displayed, based on the length of the simulated road corresponding to each road and the preset vehicle density, a corresponding number of simulated vehicles are generated for each road.

[0055] For each road in the road data to be displayed, the road data corresponding to each road and its corresponding number of simulated vehicles are encapsulated to form the traffic flow data corresponding to each road;

[0056] For each road in the road data to be displayed, traffic flow simulation is performed based on the time elapsed in each frame of the program's runtime and the traffic flow data corresponding to each road;

[0057] When the preset conditions are met, new road data to be displayed is re-selected, and the above operations are performed on the new road data to be displayed until the traffic flow simulation ends.

[0058] Optionally, the traffic flow simulation method in this embodiment can be executed using Unreal Engine 5. It is understood that this embodiment does not limit the specific engine used in Unreal Engine, as long as it can implement the traffic flow simulation method in this embodiment.

[0059] The main steps for simulating traffic flow using Unreal Engine 5 are as follows:

[0060] Step S201: Read and parse the original road data (i.e., the original road data mentioned above):

[0061] The raw road data is based on a geographic information system (GIS). This raw road data contains at least one road and stores the latitude, longitude, and altitude coordinates of all geographic points along each road in a specific order. Unreal Engine 5 reads the raw road data from external storage into memory, converts the latitude, longitude, and altitude coordinates in the raw road data into the 3D coordinate system used by Unreal Engine at runtime, and caches this data on a road-by-road basis to obtain the converted road data for use in subsequent steps.

[0062] It should be noted that any road in this embodiment refers to a road with a travel direction of either the first or the second direction. If it is a two-way road, then the road includes two roads.

[0063] Step S202: Further process the road data after coordinate transformation:

[0064] Raw road data is a mathematical abstraction of roads in the real world, typically a set of coordinates representing lines connecting the midpoints of roads. To save space, the number of coordinates in raw road data is often small, which can easily lead to "clipping" when displayed with the terrain mesh model used in virtual reality. In this step, for each road in the raw road data, an algorithm calculates a new planar coordinate point between two adjacent coordinates on each road, and uses raycasting in Unreal Engine 5 to calculate the new height. This height is then combined with the planar coordinate point to form a new 3D coordinate point, each containing coordinates in the X, Y, and Z axes. The new coordinate points are then saved in an orderly manner along with the original coordinate points, forming road data that better fits the terrain, resulting in road data with supplementary nodes (see the detailed process of obtaining road data with supplementary nodes below). Since most roads in the real world are two-way, further processing of the road data is required. Two-way lanes are generated by connecting the midpoints of each road. The specific steps are as follows:

[0065] Step S2021: Based on the order in which the coordinates in the road data after the supplementary node are saved, take the first and second coordinates of the road data after the supplementary node to obtain the spatial vector pointing from the first coordinate to the second coordinate.

[0066] Step S2022: Normalize the vector obtained in step S2021 to obtain a unit vector with a length of 1 meter.

[0067] Step S2023: Rotate the unit vector horizontally by 90 degrees clockwise and counterclockwise respectively to obtain two new vectors perpendicular to the original unit vector. Based on the road width of each road (the width can be set as a parameter by the program caller), multiply the two newly obtained perpendicular vectors by the road width to obtain two vector endpoints. These two endpoints are the road coordinates to be used.

[0068] Step S2024: If the total number of coordinates for each road in the road data after the supplementary nodes is m, take the nth coordinate and the (n+1)th coordinate (n=1, 2, 3...m-1) in sequence. Perform steps S2021, S2022, and S2023 for each road in the road data after all the supplementary nodes. Save the coordinates obtained after rotating all clockwise vectors in ascending order and save the coordinates obtained after rotating all counterclockwise vectors in descending order. Combine the height coordinates in the Z-axis direction of the road data after the supplementary nodes to obtain the total coordinate data of the two-way lanes (i.e., the simulated road data mentioned above).

[0069] Step S203: Create a traffic flow management class object, and add a container in this class to store the road data that needs to be displayed and updated in each frame. Define variables such as traffic flow display range, vehicle spacing, vehicle speed, supplementary road node spacing, and camera displacement threshold in the traffic flow management class to control the effect of the traffic flow simulation. The camera displacement threshold refers to the distance the camera (i.e., the simulated camera mentioned above) must move between two consecutive road data updates (i.e., the filtering of roads to be displayed). That is, after one road data update is performed, the next road data update will not be performed until the camera moves a distance exceeding the threshold.

[0070] Step S204: Update road data in real time through the traffic flow management class during program execution;

[0071] Since the simulated road data obtained in step S202 is often very large, and it is often unnecessary to display all traffic flow on all roads during program execution, a road update function needs to be added to the traffic flow management class. The road update function determines the roads to be displayed (i.e., the road data to be displayed) through location calculation. The road update function needs to perform the following functions:

[0072] ① Obtain the current camera coordinates, then filter out the roads (i.e., the road data to be displayed) from all simulated road data that are no more than the distance from the camera coordinates to the road display range and cache them in a temporary data container.

[0073] Among them, the preset conditions for selecting roads whose distance from the camera coordinates is not greater than the road display range (i.e., the time point specified by the predetermined rules) include: when traffic flow simulation is started or when the simulated camera moves a distance exceeding the set displacement threshold.

[0074] In other words, when the road selection is performed for the first time, the coordinates of the simulated camera at this time (i.e., the initial position of the simulated camera) are recorded and recorded as the "last road selection coordinates". When the simulated camera is displaced, the distance between the new coordinates after the displacement and the last road selection coordinates is calculated. When the distance exceeds the preset displacement threshold, the road selection is performed again, and the original data is overwritten with the current coordinates and recorded as the updated last road selection coordinates, until the traffic flow simulation ends.

[0075] ② Retrieve and return spline components used for caching and displaying roads from the spline component pool. The spline component pool can improve component utilization and avoid the waste of runtime efficiency caused by repeatedly creating and deleting components.

[0076] ③ Iterate through the temporary container of road data to be displayed mentioned in ①. Each road in the road data to be displayed must correspond to a corresponding spline component in Unreal Engine 5 and be stored in the road data container. The coordinate data used in the spline component is the coordinate data of each road. If there is a generated but unused spline component in the spline component pool, retrieve the generated but unused spline component and use it directly; if there is no available spline component in the spline component pool, generate a new spline component and use it; if a spline component was used in the previous function call but is deactivated in this function call because it exceeds the road display range, clear the coordinate data of the spline component, set its status to unused, and store it in the spline component pool. Through at least one spline component in the spline component pool, a corresponding simulated road can be generated for each road in the road data to be displayed.

[0077] In Unreal Engine 5, USplineComponent is a component class used to create and manipulate spline curves in 3D space. A spline curve is a smooth curve defined by a set of control points and can be used to create complex motion paths, shapes, or animations. USplineComponent provides a series of member functions for manipulating spline curves, including adding and deleting control points, setting the position and tangent of control points, and getting points and tangents on the spline curve.

[0078] By calling the road update function, the program will update the roads to be displayed (i.e., the road data to be displayed) in real time during program execution.

[0079] Step S205: During program execution, generate vehicles and update vehicle locations in real time using the traffic flow management class.

[0080] The traffic flow management class includes road vehicle generation and vehicle update functions. When a new spline component is created in step S204, the vehicle generation function generates a corresponding number of vehicles based on the road length (i.e., the length of the simulated road) and the vehicle density set by the user, i.e., generating a corresponding number of simulated vehicles for each road. For each road in the road data to be displayed, the road data corresponding to each road and its corresponding number of simulated vehicles are encapsulated to form the traffic flow data for each road. The generated vehicle data (i.e., traffic flow data) is saved by the traffic flow management class in step S203, and the generated vehicle models are displayed using the Unreal Engine S205's instancedStaticMeshComponent. After the road update function in step S204 is called, the vehicle update function is called. The vehicle update function calculates the coordinates of all vehicles at this moment based on the actual elapsed time of the program and the traffic flow data of each road, and updates the vehicle models to their positions, thus creating the effect of vehicles moving on the road, thereby completing the simulation of traffic flow.

[0081] The beneficial effects of this disclosure are as follows:

[0082] (1) The method of this disclosure uses existing original road data in the geographic information system, which eliminates the need for software developers to manually set road node coordinates, thus reducing the workload of developers.

[0083] (2) The method of this embodiment supplements the road node coordinates using software algorithms based on the original road data, and uses ray detection to determine the geographic height of each node, so that the generated road fits the ground model better.

[0084] (3) The method of this embodiment uses a traffic flow management class to uniformly manage road data and vehicle data. It filters the traffic flow to be displayed by taking the camera position as the center point and the user-set distance as the range. Furthermore, the spline component used to display the traffic flow can be uniformly managed and reused, which improves the software running efficiency and reduces the complexity of spline component management.

[0085] (4) The method of this embodiment uses a vehicle flow data container class combined with an instance static mesh component to manage vehicles. Each type of vehicle only needs to use one instance static mesh component and only needs to perform one rendering, which can reduce the computational load of the display device and improve the running efficiency of the software.

[0086] The following description of several exemplary embodiments illustrates the technical solutions of this disclosure and the technical effects produced by these solutions. It should be noted that the following embodiments can be referenced, learned from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.

[0087] This disclosure provides a possible implementation method. After acquiring the original road data, the method further includes: storing the acquired original road data in an original road data container, wherein the original road data includes at least one original road, and the road data corresponding to each original road includes a road number, road name, road length, and the latitude, longitude, and altitude of each node in the road.

[0088] Optionally, road data reading and parsing functions are created in the traffic flow management class. A raw road data container is added to the class to store all raw road data. A corresponding data structure needs to be defined, which must contain at least the following variables: road number, road name, road length, latitude, longitude, and altitude of all nodes on the road, and world space coordinates of all nodes on the road. The raw road data is taken from existing data in the geographic information system. The raw road data records the geographic information of roads in the real world and is stored on the disk in file format. In this embodiment, road data in Shapefile format is used. The reading function obtains the file handle through the file path, and then obtains the road number, road name, road length, and latitude, longitude, and altitude of each node on the road from the data file using the file handle. The data for each road is then stored in the raw road data container as a structure.

[0089] Shapefile is an open spatial data format used to describe geometric objects: points, polylines, and polygons. Shapefile is a vector graphics format that can save the position and related attributes of geometric shapes.

[0090] By utilizing existing raw road data in a geographic information system, the software developers can reduce their workload by eliminating the need to manually set road node coordinates.

[0091] This disclosure provides a possible implementation method, which involves performing coordinate system transformation and coordinate point calculation based on the latitude, longitude, and altitude coordinates of the original road data to obtain simulated road data, and saving the simulated road data includes: converting the geographic coordinates of each node of each road in the original road data into 3D coordinates in Unreal Engine to obtain the converted road data, wherein the geographic coordinates of each node include longitude, latitude, and altitude coordinates; saving the converted road data in a road data container; for each road in the converted road data, performing node supplementation to obtain road data with supplemented nodes, and saving the road data with supplemented nodes in the road data container; for each road in the road data with supplemented nodes: determining the horizontal direction unit from the nth node to the (n+1)th node in each road. A vector is generated, where n = 1, 2, 3…m-1, m is the total number of nodes in each road, and m and n are both positive integers. A clockwise and counterclockwise unit vector perpendicular to the horizontal direction of the unit vector are determined. The clockwise and counterclockwise unit vectors are multiplied by the road width of each road to obtain the clockwise and counterclockwise direction vectors, respectively. The endpoint of the clockwise direction vector is used as one of the forward coordinates of each road, and the endpoint of the counterclockwise direction vector is used as one of the reverse coordinates of each road. Based on all the forward coordinates, all the reverse coordinates, and all the height coordinates of each road, the road coordinates of each road are determined, where each height coordinate of each road is determined by the height of each node of that road. The obtained road coordinates of all roads are used as simulated road data. The simulated road data is stored in a road data container.

[0092] Optionally, based on the latitude, longitude and height coordinates of each node in the obtained original road data, a coordinate system transformation is performed to convert it into world space coordinates applicable to Unreal Engine, namely X-axis, Y-axis and Z-axis coordinates, to obtain the road data after coordinate transformation, and save it in a road data container. This road data container can be added in the traffic flow management class (see the description in the text for details).

[0093] To make the road data after coordinate transformation more closely match the ground model used in the program, the density of road nodes can be increased to perform node supplementation on the road data after coordinate transformation, resulting in road data with supplemented nodes. This supplemented road data is then stored in a road data container.

[0094] Regarding node supplementation, this disclosure provides a possible implementation method. For each road in the road data after coordinate transformation, node supplementation is performed to obtain road data with supplemented nodes. This includes: for any road in the road data after coordinate transformation, if the number of nodes in the road is less than or equal to 1, no node supplementation operation is performed on that road; if the number of nodes in the road is greater than 1, the node supplementation operation is performed on that road in the following manner: for any two adjacent nodes in the road, the distance between the two adjacent nodes is determined; if the distance between adjacent nodes is less than or equal to a preset supplementary road node spacing, no node supplementation is performed. Perform node supplementation between two adjacent nodes; or, if the distance between adjacent nodes is greater than the spacing between supplementary road nodes, determine two adjacent nodes as adjacent nodes to be supplemented, determine the ratio between the distance between adjacent nodes and the spacing between supplementary road nodes, and round down the ratio to obtain the number of nodes to be supplemented between the adjacent nodes to be supplemented; based on the spacing between supplementary road nodes and the number of nodes to be supplemented, perform node supplementation between the adjacent nodes to be supplemented; after all adjacent nodes to be supplemented have completed the node supplementation operation, obtain one of the road data after the supplemented nodes; wherein, the road data after the supplemented nodes includes the road data after each supplemented node.

[0095] Optionally, nodes can be supplemented in the following ways:

[0096] The process iterates through all roads in the transformed coordinate road data stored in the road data container. If the number of nodes in any road data is less than or equal to 1, no node supplementation is performed. If the number of nodes in the road data is greater than 1, the distance between each node and the previous node (these two nodes are adjacent nodes) is calculated starting from the second node of this road. This distance is recorded as the adjacent node distance. If the adjacent node distance is greater than a pre-set supplementary road node spacing, the corresponding number of nodes are supplemented between these two adjacent nodes. These two adjacent nodes that need node supplementation are recorded as adjacent nodes to be supplemented. The ratio between the adjacent node distances to be supplemented and the supplementary road node spacing is determined. This ratio is rounded down to obtain the number of nodes to be supplemented. Then, the number of nodes to be supplemented is supplemented between these adjacent nodes according to the supplementary road node spacing. Similarly, the node supplementation operation is performed on the other adjacent nodes to be supplemented for this road, resulting in one of the road data after node supplementation.

[0097] In the same way, perform node supplementation operations on each road that needs to be supplemented to obtain all the road data after supplementing nodes, i.e., the road data after supplementing nodes.

[0098] For each supplementary node in the road data after the supplementary node, the geographic height is determined using ray tracing in Unreal Engine 5, and the height coordinates of each supplementary node are obtained.

[0099] For each road in the road data after adding nodes:

[0100] Assuming the total number of nodes on the road is m, determine the horizontal vector pointing from the nth node to the (n+1)th node. Normalize this vector to obtain a unit vector, where n = 1, 2, 3…m-1. Then rotate this unit vector 90 degrees clockwise and counterclockwise respectively to obtain two new vectors perpendicular to the original vector, namely the clockwise unit vector and the counterclockwise unit vector. Multiply the obtained clockwise and counterclockwise unit vectors by the width of the road to obtain two new vectors. The endpoints of these two new vectors can be used as a positive-order coordinate and a negative-order coordinate on the road.

[0101] By obtaining all the forward and reverse coordinates of each road in the above manner, and combining them with the elevation coordinates of each road, the road coordinates of the two-way lanes of that road can be determined. The elevation coordinates of each road are consistent with the elevation of the nodes of that road.

[0102] Following the above method, the road coordinates of all roads can be determined. The road coordinates of all roads are the simulated road data mentioned above. The obtained simulated road data is stored in a road data container.

[0103] Through the embodiments of this disclosure, the coordinates of road nodes are supplemented using software algorithms based on the original road data, and the geographic height of each supplemented node is determined using ray detection, so that the generated road fits the ground model better and avoids the "clipping" phenomenon during operation.

[0104] This disclosure provides a possible implementation method for generating a corresponding simulated road for each road in the road data to be displayed using at least one spline component in the spline component pool. This includes: recording the road data to be displayed as the current road data to be displayed, and recording the road data to be displayed obtained from the previous filtering as the previously displayed road data. The total number of roads included in the current road data to be displayed is the current number of roads, which is the sum of the total number of roads in the first direction and the total number of roads in the second direction in the current road data to be displayed. The first direction and the second direction represent two opposite driving directions. When there are duplicate roads in the displayed road data and roads in the previously displayed road data, the number of duplicate roads is recorded as the duplicate road count. The data in the spline components corresponding to the previously displayed roads (excluding duplicate roads) is cleared, and the spline components after the data clearing are recorded as unused spline components. The number of unused spline components is the unused component count, and the spline components corresponding to duplicate roads are reused spline components. If the sum of the unused component count and the duplicate road count is less than the current road count, a first number of new splines are generated from the spline component pool. The components are defined as follows: a first quantity is the difference between the current number of roads and a second quantity; the second quantity is the sum of the number of unused components and the number of duplicate roads. Using unused spline components, reused spline components, and the first quantity of new spline components, a simulated road is generated for each road in the current road data to be displayed. Any unused spline component, any reused spline component, and any new spline component serve as a target spline component. The coordinate data of each spline node in any target spline component is derived from the coordinates of the road corresponding to that target spline component. The coordinates are determined; or, if the sum of the number of unused components and the number of duplicate roads is greater than the current number of roads, the difference between the current number of roads and the number of duplicate roads is determined to obtain a third number; using the third number of unused spline components and reused spline components, a corresponding simulated road is generated for each road in the current road data to be displayed. Any unused spline component and any reused spline component are used as a target spline component. The coordinate data of each spline node in any target spline component is determined by the road coordinates of the road corresponding to that target spline component.

[0105] Optionally, the steps for generating the simulated road corresponding to each road in the road data to be displayed using at least one spline component from the spline component pool are as follows:

[0106] Step 1: First, detect which roads should be displayed within the current range of the simulated camera (i.e., the new roads to be displayed). Step 2: Compare the previously displayed roads (i.e., previously displayed road data) with the new roads to be displayed (i.e., the current road data). Which roads overlap? (Overlapping roads are still to be displayed). Roads that don't overlap are no longer needed. Clear the data for these no-longer-needed roads and set their components to an unused state (i.e., set them to unused spline components), ready to be used later. Step 3: Calculate the number of roads. After excluding the roads still to be displayed, determine how many components are needed for the newly added roads. If the number of unused components in the current pool is sufficient, no new components are generated. If not, new components are generated and set to an unused state. Step 4: Use the unused components in the pool to generate the new roads. Step 5: After the road update is complete, begin the new traffic flow update.

[0107] The following will provide a detailed explanation using Examples 1 and 2.

[0108] Example 1: Suppose the roads to be displayed in the previous road data set were A, B, and C. The road data corresponding to these three roads is the previously displayed road data mentioned above. The roads to be displayed in the current road data set are B, C, D, E, and F. The road data corresponding to these five roads is the current road data to be displayed mentioned above. Therefore, the current number of roads is 5.

[0109] In Example 1, there are duplicate roads B and C in the currently displayed road data, with a total of 2 duplicate roads. Roads B and C, along with their corresponding spline components, can be left unprocessed and displayed. These unprocessed spline components are the reused spline components mentioned above. The number of reused spline components matches the number of duplicate roads, both being 2. The spline component corresponding to road A (i.e., the road not displayed) is cleared and set to unused, at which point the number of unused components is 1.

[0110] In Example 1, since the sum of the number of unused components (i.e., 1) and the number of duplicate roads (i.e., 2) (i.e., 3) is less than the current number of roads (i.e., 5), it is necessary to generate a new number (i.e., 2) of spline components through the spline component pool. The first number is the difference between the current number of roads (i.e., 5) and the second number (i.e., the sum of the number of unused components and the number of duplicate roads, i.e., 3).

[0111] Then, by using unused spline components, reused spline components, and a first number of new spline components, a corresponding simulated road is generated for each road in the current road data to be displayed. The coordinate data of the spline node corresponding to each road is determined by the road coordinates of that road.

[0112] Example 2: Suppose the roads to be displayed in the previous road data were A, B, C, and D, and the roads to be displayed in the current road data are D, E, and F. In this Example 2, the current number of roads is 3, the number of unused components is 3, and the number of duplicate roads (i.e., the number of reused spline components) is 1. At this point, the sum of the number of unused components and the number of reused spline components (i.e., 4) is greater than the current number of roads (i.e., 3). Therefore, a third quantity needs to be determined, which is the difference between the current number of roads and the number of duplicate roads (i.e., 2).

[0113] Then, using a third number of unused spline components (i.e., 2) and a reused spline component (1), a simulated road is generated for each of the D, E, and F in the current road data to be displayed.

[0114] The following are several other possible implementations of this disclosure regarding how to generate simulated roads using spline components. Generating a corresponding simulated road for each road in the road data to be displayed using at least one spline component from the spline component pool includes: recording the road data to be displayed as the current road data to be displayed, and recording the previously filtered road data to be displayed as the previously displayed road data. The total number of roads in the current road data to be displayed is the current road quantity, which is the sum of the total number of roads in the first direction and the total number of roads in the second direction of the current road data to be displayed, where the first and second directions represent two opposite driving directions. If there are no duplicate roads between the roads in the current road data to be displayed and the roads in the previously displayed road data, the data in the spline component corresponding to the previously displayed road data is cleared, and the spline component after the cleared data is recorded as an unused spline component. The number of unused spline components is the number of unused components. If the number of unused components is less than the current road quantity, a fourth spline component is generated from the spline component pool. A new number of spline components is generated, where the fourth number is the difference between the current number of roads and the number of unused components. Using the unused spline components and the fourth number of new spline components, a corresponding simulated road is generated for each road in the current road data to be displayed. Any unused spline component and any new spline component serve as a target spline component. The coordinate data of each spline node in any target spline component is determined by the road coordinates of the road corresponding to that target spline component. Alternatively, if the number of unused components is greater than the current number of roads, the remaining unused spline components (excluding those exceeding the current number of roads) are set to an idle state. Using the current number of unused spline components, a corresponding simulated road is generated for each road in the current road data to be displayed. Any unused spline component serves as a target spline component, and the coordinate data of each spline node in any target spline component is determined by the road coordinates of the road corresponding to that target spline component.

[0115] Optionally, the following detailed explanation is provided in conjunction with Examples 3 and 4.

[0116] Example 2: Suppose the roads to be displayed in the previous road data were A, B, and C (corresponding to previously displayed roads). The roads to be displayed in the current road data are D, E, F, and G (corresponding to the current road data to be displayed), then the current number of roads is 5.

[0117] In Example 3, there are no duplicate roads between the roads in the currently displayed road data and the roads in the previously displayed road data. At this time, roads A, B, and C in the previously displayed road data are all not displayed. The spline components corresponding to roads A, B, and C need to be cleared and set to unused spline components. At this time, the number of unused components is 3.

[0118] In Example 3, since the number of unused components (i.e., 3) is less than the current number of roads (i.e., 4), a new number of spline components (i.e., 1) needs to be generated from the spline component pool. The fourth number is the difference between the current number of roads (i.e., 4) and the number of unused components (i.e., 3).

[0119] Then, using the unused spline component and a fourth new spline component, a corresponding simulated road is generated for each road in the current road data to be displayed. The coordinate data of the spline node corresponding to each road is determined by the road coordinates of that road.

[0120] Example 4: Suppose the roads to be displayed in the previous road data were A, B, C, D, and E, and the roads to be displayed in the current road data are F, G, H, and I. Then, in this Example 4, the current number of roads is 4.

[0121] In Example 4, there are no duplicate roads between the roads in the currently displayed road data and the roads in the previously displayed road data. At this time, roads A, B, C, D, and E in the previously displayed road data are all roads that are not displayed. The spline components corresponding to roads A, B, C, D, and E need to be cleared and set to unused spline components. At this time, the number of unused components is 5.

[0122] In Example 4, since the number of unused components (i.e., 5) is greater than the current number of roads (i.e., 4), it is not necessary to generate new spline components from the spline component pool. The remaining unused spline components (i.e., 1) beyond the current number of roads can be set to an idle state.

[0123] Then, using four unused spline components (i.e., the current number of roads is 4), a corresponding simulated road can be generated for each road in the current road data to be displayed.

[0124] It is understood that Examples 1, 2, 3 and 4 above are merely several possible examples provided by the embodiments of this disclosure, and this embodiment does not limit them in any way.

[0125] Through the embodiments of this disclosure, spline components are managed uniformly and reused through a spline component pool, which improves software operating efficiency and reduces the complexity of spline component management.

[0126] This disclosure provides a possible implementation method for generating a corresponding number of simulated vehicles for each road, including: for each road in the road data to be displayed, adding a corresponding number of simulated vehicles to each road by instantiating a static mesh component; for each road in the road data to be displayed, performing traffic flow simulation on the simulated road corresponding to each road based on time information and traffic flow data corresponding to each road, including: for each road in the road data to be displayed, performing traffic flow simulation based on the elapsed time of each frame during program execution and the traffic flow data corresponding to each road; determining the current position of each simulated vehicle in each road based on the vehicle data of each simulated vehicle in each road and the input elapsed time information; and updating the position of each simulated vehicle in each road in real time based on the current position of each simulated vehicle in each road by instantiating a static mesh component and the input elapsed time information, so as to complete the traffic flow simulation of the simulated road corresponding to each road.

[0127] Optionally, the number of vehicles to be generated for each road in the road data to be displayed is determined based on the road length and vehicle density. A corresponding number of vehicle models (i.e., simulated vehicles) are added to each road in the instancedStaticMeshComponent. The road data to be displayed is obtained and encapsulated with the vehicles into traffic flow data. Specifically, the road data (i.e., road coordinates) of each road in the road data to be displayed, along with the corresponding number of vehicles, are encapsulated to obtain the traffic flow data for each road. Based on the traffic flow data for each road, the vehicle data for each simulated vehicle is determined. Based on the position data stored in the vehicle data of each road and the elapsed time passed by the function, the latest position of each simulated vehicle after the elapsed time is calculated. The position of the simulated vehicles (i.e., vehicle models) is updated in real time using the instancedStaticMeshComponent, thus completing the traffic flow simulation for each road in the road data to be displayed.

[0128] In Unreal Engine, UInstancedStaticMeshComponent is a special static mesh component used to efficiently render multiple identical static mesh instances in a scene, which can greatly reduce memory usage and improve rendering performance.

[0129] Through the embodiments of this disclosure, vehicles are managed by using a vehicle flow data container class combined with an instance static mesh component. Each type of vehicle only needs to use one instance static mesh component and only needs to perform rendering once, which can reduce the computational load of the display device and improve the software running efficiency.

[0130] This disclosure provides a possible implementation method, which further includes: creating a traffic flow management class, wherein the traffic flow management class is used to perform at least one of the following: adding a road data container in the traffic flow management class to store simulated road data; defining traffic flow simulation variables in the traffic flow management class, wherein the traffic flow simulation variables include traffic flow display range, vehicle spacing, vehicle speed, supplementary road node spacing, and camera displacement threshold, wherein the camera displacement threshold refers to the distance the camera needs to move in order to trigger the road update function; adding a vehicle generation function in the traffic flow management class, wherein for each road in the road data to be displayed, the vehicle generation function generates a corresponding number of simulated vehicles for each road based on the length of the simulated road corresponding to each road and the preset vehicle density, and stores the corresponding number of simulated vehicles for each road in the traffic flow management class.

[0131] For a detailed description of traffic flow management, please refer to the preceding and following text; it will not be repeated here.

[0132] This disclosure provides a possible implementation method. When preset conditions are met, road data to be displayed that is within the current coordinate view range of the simulated camera is selected from the simulated road data and saved. This includes: creating a traffic flow management class and adding a road update function to the traffic flow management class; using the road update function, for any road in the simulated road data, determining the following information according to the time point in the preset conditions: determining the current coordinates of the simulated camera; determining the first distance between the starting coordinates of the road and the current coordinates of the simulated camera; determining the second distance between the ending coordinates of the road and the current coordinates of the simulated camera; if at least one of the first distance and the second distance is less than or equal to the predefined traffic flow display range, then the road is determined as a road to be displayed; determining all road data corresponding to the roads to be displayed as road data to be displayed; creating a temporary data container and temporarily storing the road data to be displayed in the temporary data container; creating a display road data container and saving the road data to be displayed temporarily stored in the temporary data container to the display road data container, so that Unreal Engine can call the road data to be displayed from the display road data container when performing traffic flow simulation.

[0133] Optionally, the following example illustrates how to filter out road data to be displayed from simulated road data at a time point specified by predetermined rules (i.e., when preset conditions are met).

[0134] Add a road update function to the traffic flow management class. This road update function is used to implement the following functionality:

[0135] The simulated road data is traversed, and the first distance between the starting coordinates and the current coordinates of the simulated camera, and the second distance between the ending coordinates and the current coordinates of the simulated camera are calculated for each road. If either of these two distances is less than the predefined traffic flow display range, the road is considered to meet the display criteria, and its data is added to a temporary data container as a road to be displayed. After the simulated road data has been traversed, the road data corresponding to all roads to be displayed constitutes the road data to be displayed. A temporary data container is created to store this road data; the data stored in this temporary data container represents all the roads that need to be displayed in the scene.

[0136] Create a display road data container and save the road data to be displayed that is temporarily stored in the temporary data container to the display road data container. When Unreal Engine performs traffic flow simulation, it calls the road data to be displayed from the display road data container.

[0137] By using the embodiments of this disclosure, and filtering the traffic flow to be displayed by using the location of the simulated camera as the center point and the distance set by the user to determine the range, the traffic flow simulation effect can be made more realistic, and the display effect of the traffic flow simulation can be improved.

[0138] See Figure 2 , Figure 2 This is a flowchart illustrating another traffic flow simulation method provided in this embodiment of the disclosure. Taking road data in Shapefile format as an example, it explains the process of automatically generating visual traffic flow simulation from road data in this embodiment of the disclosure, and provides a detailed explanation of how to perform traffic flow simulation using road data in Unreal Engine 5 software. Figure 2 As shown, the specific steps are as follows:

[0139] Step S301: Read and parse the raw road data (i.e., the raw road data):

[0140] In Unreal Engine 5's C++ code, create a traffic flow management class and define a data structure corresponding to the original road data format within it. This structure must contain at least the following variables: road number, road name, road length, latitude, longitude, and altitude of all nodes along the road, and world space coordinates of all nodes. Next, add a raw road data container to the traffic flow management class to store all the original road data. After adding the container, add functions for reading and parsing the road data. The original road data is taken from existing data in a geographic information system (GIS). This raw road data records the geographic information of roads in the real world and is stored on disk as a file. Shapefile format road data can be used. The read function obtains a file handle through the file path, and then uses the file handle to retrieve the road number, road name, road length, and latitude, longitude, and altitude of each node along the road for each road stored in the data file. The read data for each road is then stored as a structure in the raw road data container.

[0141] Step S302: Further process the original road data. The specific steps are as follows:

[0142] Step S3021: Using the Cesium plugin in Unreal Engine 5, the coordinate data of each node in each road in the original road data container is converted from longitude, latitude, and altitude to world space coordinates in Unreal Engine 5, i.e., X-axis, Y-axis, and Z-axis coordinates. The converted world space coordinates (i.e., the road data after coordinate conversion) are stored in the corresponding structure data object in the created road data container. Cesium is a plugin in Unreal Engine 5 that provides online maps. When processing large amounts of geographic information data, the Cesium plugin has a powerful online map data acquisition mechanism. By establishing efficient data interaction interfaces with a series of online map service platforms, it can acquire high-resolution map data from the cloud in real time, including various types of geographic information data such as terrain, satellite imagery, and vector maps.

[0143] Step S3022, Increase the density of road nodes: Traverse all roads in the road data container after coordinate transformation. If the number of nodes in a road data is less than or equal to 1, no nodes are added; if the number of nodes in a road data is greater than 1, calculate the distance between each node and the previous node starting from the second node of this road. If this distance is greater than the set spacing for supplementary road nodes, add the corresponding number of nodes. For example: if the spacing for supplementary road nodes is set to 20 meters, and the distance between the fourth node and the third node of a certain road is 65 meters, then 3 nodes need to be added between the third and fourth nodes, rounded down (65 ÷ 20). The positions of the supplementary nodes are obtained through vector calculation. In this example, the third node is set as the starting point, and the fourth node as the ending point. Subtracting the world space coordinates of the starting point from the ending point coordinates yields a direction vector pointing from the starting point to the ending point. This vector is then normalized to obtain a unit vector of length 1 in that direction. Multiplying this unit vector by the spacing between the supplementary road nodes gives the coordinate offset value. In Unreal Engine 5, the unit is centimeters. Therefore, in this example, the distance between the first supplementary node and the starting point's world space coordinates is 2000 centimeters. Multiplying the unit vector by 2000 gives the coordinate offset value for this supplementary node. Adding this coordinate offset value to the starting point coordinates gives the coordinate value of the first supplementary node. The distance between the second supplementary node and the starting point's world space coordinates is 4000 centimeters, which is calculated by multiplying the unit vector by 4000 and adding it to the starting point's world space coordinates. The calculation of the coordinates of subsequent supplementary nodes follows the same logic. The world space coordinates of all supplementary nodes are stored in the road data.

[0144] Step S3023: Use raycasting in Unreal Engine 5 to determine the geographic altitude of the supplementary node, and update the Z-axis coordinates of the detection results to the Z-axis coordinates of the supplementary node. The specific implementation method is as follows: Assuming the geographic coordinates of the supplementary node are (longitude 117.0, latitude 39.0), first define a coordinate point A at a reasonable altitude (e.g., 10,000 meters) directly above this coordinate point. Then define another coordinate point B at a reasonable depth (e.g., 1,000 meters) directly below this coordinate point. Cast a ray from point A to point B. This ray will inevitably intersect the ground model to produce an intersection point, and the latitude and longitude of this intersection point must be consistent with the latitude and longitude of the supplementary node (in this example, longitude 117.0, latitude 39.0). The altitude of this intersection point is the required geographic altitude.

[0145] Following the above method, the road data after the supplementary nodes can be obtained and stored in the road data container.

[0146] Step S3024, assuming that the total number of nodes in each road in this road data after point supplementation (i.e., road data after supplementary nodes) is m, take the nth coordinate and the (n + 1)th coordinate of each road data (n = 1, 2, 3... m - 1), obtain the direction vector pointing from the nth coordinate to the (n + 1)th coordinate, and unitize the obtained vector to obtain a unit vector with a length of 1 meter and pointing from the nth coordinate to the (n + 1)th coordinate. Rotate this unit vector 90 degrees clockwise and counterclockwise respectively in the horizontal direction to obtain 2 new vectors perpendicular to the original vector, namely the clockwise unit vector and the counterclockwise unit vector. Multiply the 2 newly obtained unit vectors by the road width according to the road width to obtain two new vectors (i.e., the clockwise direction vector and the counterclockwise direction vector), and the endpoints of these two new vectors are the road coordinates of the two-way lane to be used. Then, perform the above operations on the (n + 1)th coordinate and the (n + 2)th coordinate (n < m) in turn. After completing the operations on all the road coordinate data of this road, save the coordinates obtained after rotating all the vectors clockwise in ascending order, and save the coordinates obtained after rotating all the vectors counterclockwise in descending order, so as to obtain all the coordinate data in the horizontal direction of the two-way lane. Combining with the height coordinates of the nodes of each road, the coordinate data in the three directions of the X-axis, Y-axis, and Z-axis corresponding to the simulated road data can be obtained, and this simulated road data is saved in the road data container.

[0147] Among them, the road width can be set by the program caller as a parameter.

[0148] Step S303: Add variables, functions, or containers required to control vehicles in the traffic flow management class.

[0149] Add variables, functions, or containers required to control vehicles in the traffic flow management class to uniformly manage the road data and vehicle data that need to be displayed during the operation of the program. The traffic flow management class needs to inherit from the AActor class in Unreal Engine 5 (where the first "A" refers to the type of the class, and the subsequent "Actor" is the name of the class). After inheritance, this class will automatically have a frame loop function to update data every frame during software operation. And add a traffic flow data container used to save the traffic flow that needs to be updated and displayed every frame. Define variables such as the traffic flow display range, vehicle spacing, vehicle driving speed, supplementary road node spacing, camera displacement threshold, etc. in the class to control the simulation effect of the traffic flow.

[0150] Step S304: Update the road data in real time, and the specific steps are as follows:

[0151] Step S3041, establish an empty temporary data container to save all road data that meet the display conditions later.

[0152] Step S3042: Iterate through the simulated road data in the road data container from step S302, calculating the distance between the starting coordinates and the current coordinates of the simulated camera for each road, and the distance between the ending coordinates and the current coordinates of the simulated camera. If either of these two distances is less than the traffic flow display range, the road is considered to meet the display conditions, and its data is added to the temporary data container. After the road data container has been traversed, the data stored in the temporary data container represents all the roads that need to be displayed in the scene.

[0153] Step S3043: Iterate through all roads stored in the temporary data container that need to be displayed in the scene, and generate vehicle travel routes using the spline component (USplineComponent) in Unreal Engine 5. The coordinate data of each spline node (FSplinePoint) in the spline component corresponds to the coordinate data of each road node in the road data. If an already generated spline component object exists, clear the node data of this spline component object and then add new node data to reduce the performance overhead of generating new spline components. If the number of existing spline components is greater than the number of road data in the temporary data container, the excess spline components are set to not be displayed.

[0154] Step S3044: Store all road data that needs to be displayed in the scene from the temporary data container into the display road data container. Only the road data in the display road data container will be displayed in the program.

[0155] Step S305: Update vehicle location in real time. The specific steps are as follows:

[0156] Step S3051: Determine the number of vehicles to be generated based on the road length and vehicle density.

[0157] Step S3052: Add the corresponding number of vehicle models to the instance static mesh component (UInstancedStaticMeshComponent).

[0158] Step S3053: Traverse the display road data container in step S3044, obtain all road data that needs to be displayed, and encapsulate the road data and vehicles that need to be displayed into traffic flow data (i.e., road data and data of all vehicles on this road).

[0159] Step S3054: Determine the data for each vehicle based on the traffic flow data for each road.

[0160] Step S3055: Calculate the vehicle's latest position after time has elapsed based on the location data stored in the vehicle data and the elapsed time passed to the function.

[0161] Step S3056: Update the position of the vehicle model using the instancedStaticMeshComponent.

[0162] Taking road data in Shapefile format as an example, the logical relationship of the method for automatically generating visual traffic flow simulation from road data in this embodiment of the disclosure is explained as follows:

[0163] like Figure 3 As shown, Figure 3 The road data is existing raw geographic data, and in this embodiment, it uses the Shapefile data format. Unreal Engine 5 software is the main component of this embodiment. The simulated traffic flow is the result of the software calculating, processing, and displaying the road data; the simulated traffic flow exists within the Unreal Engine 5 window. When the Unreal Engine 5 software runs, it updates the simulated traffic flow and displays the updated results in the Unreal Engine 5 window.

[0164] Through the embodiments of this disclosure, software developers are not required to manually set road node coordinates, reducing their workload; ray detection is used to determine the geographic height of each node, making the generated road fit the ground model better; spline component pools are used to uniformly manage and reuse spline components, improving software operating efficiency and reducing the complexity of spline component management; the computational load on display devices can be reduced, improving software operating efficiency.

[0165] The traffic flow simulation program corresponding to the traffic flow simulation method in this embodiment runs on Unreal Engine and includes:

[0166] The first layer of logical operations involves loading and caching the original road data. This is used to obtain the original road data, perform coordinate system transformation and coordinate point calculation based on the latitude, longitude, and altitude coordinates of the original road data, obtain simulated road data, and save the simulated road data. The simulated road data includes at least one road.

[0167] The second layer of logical operation—generating simulated road data. When preset conditions are met, road data to be displayed that are within the current coordinate field of view of the simulated camera are selected from the simulated road data and saved. The preset conditions include starting traffic flow simulation or when the simulated camera moves a distance exceeding a set displacement threshold.

[0168] The third layer of logical operations—creates the data containers needed for the simulation program to perform traffic flow simulation. It initializes the spline component pool and the displayed simulated road cache pool.

[0169] The fourth layer of logic operations—traffic flow simulation—generates a corresponding simulated road for each road in the road data to be displayed, using at least one spline component from the spline component pool.

[0170] For each road in the road data to be displayed, based on the length of the simulated road corresponding to each road and the preset vehicle density, a corresponding number of simulated vehicles are generated for each road.

[0171] For each road in the road data to be displayed, the road data corresponding to each road and its corresponding number of simulated vehicles are encapsulated to form the traffic flow data corresponding to each road;

[0172] For each road in the road data to be displayed, traffic flow simulation is performed based on the time elapsed in each frame of the program's runtime and the traffic flow data corresponding to each road;

[0173] When the preset conditions are met, new road data to be displayed is re-selected, and the above operations are performed on the new road data to be displayed until the traffic flow simulation ends.

[0174] This disclosure provides a traffic flow simulation device, such as... Figure 4 As shown, the traffic flow simulation device 40 includes Unreal Engine. The device may include: a first-layer logic operation module 401, a filtering logic operation module 402, and a second-layer logic operation module 403, wherein:

[0175] The first-level logic operation module 401 is used to acquire the original road data, perform coordinate system transformation and coordinate point calculation based on the latitude, longitude and height coordinates of the original road data, obtain simulated road data, and save the simulated road data, wherein the simulated road data includes at least one road.

[0176] The filtering logic operation module 402 is used to create a spline component pool. When preset conditions are met, it filters out the road data to be displayed from the simulated road data that is within the current coordinate view range of the simulated camera and saves it. The preset conditions include starting traffic flow simulation or when the simulated camera moves a distance exceeding the set displacement threshold.

[0177] The second-level logic operation module 403 is used to repeatedly perform the following operations until the traffic flow simulation ends:

[0178] For each road in the road data to be displayed, generate a corresponding simulated road using at least one spline component from the spline component pool.

[0179] For each road in the road data to be displayed, based on the length of the simulated road corresponding to each road and the preset vehicle density, a corresponding number of simulated vehicles are generated for each road.

[0180] For each road in the road data to be displayed, the road data corresponding to each road and its corresponding number of simulated vehicles are encapsulated to form the traffic flow data corresponding to each road;

[0181] For each road in the road data to be displayed, traffic flow simulation is performed based on the time elapsed in each frame of the program's runtime and the traffic flow data corresponding to each road;

[0182] When the preset conditions are met, new road data to be displayed is re-selected, and the above operations are performed on the new road data to be displayed until the traffic flow simulation ends.

[0183] In an optional embodiment, the first-level logic operation module 401 is specifically used to: convert the geographic coordinates of each node of each road in the original road data into 3D coordinates in Unreal Engine to obtain road data after coordinate conversion, wherein the geographic coordinates of each node include longitude coordinates, latitude coordinates, and altitude coordinates; store the road data after coordinate conversion in a road data container; for each road in the road data after coordinate conversion, perform node supplementation to obtain road data after supplemented nodes, and store the road data after supplemented nodes in the road data container; for each road in the road data after supplemented nodes: determine the horizontal unit vector from the nth node to the (n+1)th node in each road, where n = 1, 2, 3…m- 1. m represents the total number of nodes on each road, and m and n are both positive integers; determine the clockwise and counterclockwise unit vectors perpendicular to the horizontal direction of the unit vector; multiply the clockwise and counterclockwise unit vectors by the road width of each road to obtain the clockwise and counterclockwise vectors respectively; use the endpoint of the clockwise vector as one of the positive coordinates of each road and the endpoint of the counterclockwise vector as one of the reverse coordinates of each road; based on all the positive coordinates, all the reverse coordinates, and all the height coordinates of each road, determine the road coordinates of each road, where each height coordinate of each road is determined by the height of each node of each road; use the obtained road coordinates of all roads as simulated road data;

[0184] The simulated road data is stored in a road data container.

[0185] In an optional embodiment, the first-level logic operation module 401 is specifically used for: for any road in the road data after coordinate transformation, if the number of nodes in the road is less than or equal to 1, no node supplementation operation is performed on the road; if the number of nodes in the road is greater than 1, the node supplementation operation is performed on the road in the following manner: for any two adjacent nodes in the road, the distance between the two adjacent nodes is determined; if the distance between the adjacent nodes is less than or equal to a preset supplementary road node spacing, no node supplementation operation is performed between the two adjacent nodes; or, if the distance between the adjacent nodes is greater than the supplementary road node spacing, the two adjacent nodes are determined as adjacent nodes to be supplemented, and the ratio between the distance between the adjacent nodes and the supplementary road node spacing is determined, and the ratio is rounded down to obtain the number of nodes to be supplemented between the adjacent nodes to be supplemented; based on the supplementary road node spacing and the number of nodes to be supplemented, the node supplementation operation is performed between the adjacent nodes to be supplemented; after all the adjacent nodes to be supplemented have completed the node supplementation operation, one of the road data after the supplemented nodes is obtained; wherein, the road data after the supplemented nodes includes the road data after each supplemented node.

[0186] In an optional embodiment, the second-level logic operation module 403 is specifically used for: recording the road data to be displayed as the current road data to be displayed, and recording the road data to be displayed obtained from the previous filtering as the previously displayed road data, wherein the total number of roads included in the current road data to be displayed is the current number of roads, and the current number of roads is the sum of the total number of roads in the first direction and the total number of roads in the second direction in the current road data to be displayed, where the first direction and the second direction represent two opposite driving directions; there is overlap between the roads in the current road data to be displayed and the roads in the previously displayed road data. When reusing roads, the number of recurring roads is recorded as the number of recurring roads. The data in the spline components corresponding to the previously displayed roads (excluding recurring roads) is cleared. The spline components after clearing the data are recorded as unused spline components. The number of unused spline components is the number of unused components. The spline components corresponding to recurring roads are called reused spline components. If the sum of the number of unused components and the number of recurring roads is less than the current number of roads, a first number of new spline components is generated from the spline component pool. The first number is the sum of the current number of roads and the number of recurring roads. The difference between the two quantities, where the second quantity is the sum of the number of unused components and the number of duplicate roads; using unused spline components, reused spline components, and the first number of new spline components, a corresponding simulated road is generated for each road in the current road data to be displayed. Any unused spline component, any reused spline component, and any new spline component serve as a target spline component. The coordinate data of each spline node in any target spline component is determined by the road coordinates of the road corresponding to that target spline component; or, if If the sum of the number of unused components and the number of duplicate roads is greater than the current number of roads, then the difference between the current number of roads and the number of duplicate roads is determined to obtain a third number. Using the unused spline components and reused spline components of the third number, a corresponding simulated road is generated for each road in the current road data to be displayed. Any unused spline component and any reused spline component are used as a target spline component. The coordinate data of each spline node in any target spline component is determined by the road coordinates of the road corresponding to that target spline component.

[0187] In an optional embodiment, the second-layer logic operation module 403 is specifically used for: recording the road data to be displayed as the current road data to be displayed, and recording the road data to be displayed obtained from the previous filtering as the previously displayed road data, wherein the total number of roads contained in the current road data to be displayed is the current number of roads, and the current number of roads is the sum of the total number of roads in the first direction and the total number of roads in the second direction in the current road data to be displayed, where the first direction and the second direction represent two opposite driving directions; when there are no duplicate roads between the roads in the current road data to be displayed and the roads in the previously displayed road data, the data in the spline component corresponding to the previously displayed road data is cleared, and the spline component after clearing the data is recorded as an unused spline component, wherein the number of unused spline components is the number of unused components; if the number of unused components is less than the current number of roads, then a first number of new spline components are generated through the spline component pool, wherein the first number is the current number of roads and the number of unused components. The difference in quantity; using unused spline components and a first number of new spline components, a corresponding simulated road is generated for each road in the current road data to be displayed, wherein any unused spline component and any new spline component serve as a target spline component, and the coordinate data of each spline node in any target spline component is determined by the road coordinates of the road corresponding to that target spline component; or, if the number of unused components is greater than the current number of roads, then other unused spline components beyond the current number of roads are set to an idle state; using the current number of unused spline components, a corresponding simulated road is generated for each road in the current road data to be displayed, wherein any unused spline component serves as a target spline component, and the coordinate data of each spline node in any target spline component is determined by the road coordinates of the road corresponding to that target spline component.

[0188] In an optional embodiment, the second-layer logic operation module 403 is specifically used for: adding a corresponding number of simulated vehicles to each road in the road data to be displayed by using an instance static grid component; adding a corresponding number of simulated vehicles to each road in the road data to be displayed by using an instance static grid component; determining the vehicle data of each simulated vehicle in each road based on the traffic flow data corresponding to each road; determining the current position of each simulated vehicle in each road based on the vehicle data of each simulated vehicle in each road and the input elapsed time information; and updating the position of each simulated vehicle in each road in real time based on the current position of each simulated vehicle in each road by using an instance static grid component and the input elapsed time information, so as to complete the traffic flow simulation of the simulated road corresponding to each road.

[0189] In an optional embodiment, the above-mentioned apparatus further includes a class object creation module for a traffic flow management class, configured to: create a traffic flow management class, wherein the traffic flow management class is configured to perform at least one of the following: add a road data container to the traffic flow management class to store simulated road data; define traffic flow simulation variables through the traffic flow management class, wherein the traffic flow simulation variables include traffic flow display range, vehicle spacing, vehicle speed, supplementary road node spacing, and camera displacement threshold, the camera displacement threshold being the distance the camera needs to move when triggering a road update function; add a vehicle generation function to the traffic flow management class, and for each road in the road data to be displayed, generate a corresponding number of simulated vehicles for each road based on the length of the simulated road corresponding to each road and a preset vehicle density, and store the corresponding number of simulated vehicles for each road through the traffic flow management class.

[0190] In an optional embodiment, the filtering logic operation module 402 is specifically used for: adding a road update function to the traffic flow management class through a road update function; using the road update function, for any road in the simulated road data, determining the following information according to the time point in the preset conditions: determining the current coordinates of the simulated camera; determining the first distance between the starting coordinates of the road and the current coordinates of the simulated camera; determining the second distance between the ending coordinates of the road and the current coordinates of the simulated camera; if at least one of the first distance and the second distance is less than or equal to the predefined traffic flow display range, then the road is determined as a road to be displayed; determining the road data corresponding to all roads to be displayed as road data to be displayed; creating a temporary data container to temporarily store the road data to be displayed in the temporary data container; creating a display road data container to save the road data to be displayed temporarily stored in the temporary data container to the display road data container, so that Unreal Engine can call the road data to be displayed from the display road data container when performing traffic flow simulation.

[0191] In an optional embodiment, the above-mentioned device further includes a data caching function module, used to: store the acquired raw road data in a raw road data container, wherein the raw road data includes at least one raw road, and the road data corresponding to each raw road includes a road number, road name, road length, and the latitude, longitude and altitude of each node in the road.

[0192] In one alternative embodiment, the preset vehicle density is determined based on a preset vehicle spacing.

[0193] Through the embodiments of this disclosure, by converting existing real-world road data into simulated road data and simulating traffic flow based on the simulated road data, on the one hand, software developers are not required to manually set road node coordinates, reducing their workload; on the other hand, since the simulated road data is based on real original road data, traffic flow simulation based on this simulated road data improves route accuracy. By using the camera position as the center point to filter the traffic flow to be displayed, and by generating corresponding simulated roads for each road in the road data to be displayed using at least one spline component in the spline component pool, unified management and reuse of spline components are achieved, improving software operating efficiency and reducing the complexity of spline component management.

[0194] The apparatus of this disclosure embodiment can execute the method provided in this disclosure embodiment, and its implementation principle is similar, and it has corresponding technical effects. The actions performed by each module in the apparatus of each embodiment of this disclosure correspond to the steps in the method of each embodiment of this disclosure. For a detailed functional description of each module of the apparatus, please refer to the description in the corresponding method shown above, and it will not be repeated here.

[0195] This disclosure provides an electronic device (computer apparatus / device / system) including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method provided in any optional embodiment of this disclosure.

[0196] In one alternative embodiment, an electronic device is provided, such as Figure 5 As shown, Figure 5 The illustrated electronic device 4000 includes a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 4004 is not limited to one type, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of this disclosure.

[0197] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with this disclosure. Processor 4001 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0198] Bus 4002 may include a pathway for transmitting information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 4002 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0199] The memory 4003 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation herein.

[0200] The memory 4003 is used to store computer programs that execute embodiments of the present disclosure, and is controlled by the processor 4001 to execute them. The processor 4001 is used to execute the computer programs stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.

[0201] This disclosure provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments.

[0202] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments.

[0203] It should be understood that although arrows indicate various operation steps in the flowcharts of the embodiments of this disclosure, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of the embodiments of this disclosure, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured as required, and the embodiments of this disclosure do not limit this.

[0204] The above description is only an optional implementation method for some implementation scenarios of this disclosure. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this disclosure without departing from the technical concept of this disclosure also fall within the protection scope of the embodiments of this disclosure.

Claims

1. A traffic flow simulation method, characterized in that, The method is executed by Unreal Engine, and the method includes: Obtain raw road data, perform coordinate system transformation and coordinate point calculation based on the latitude, longitude and altitude coordinates of the raw road data to obtain simulated road data, and save the simulated road data, wherein the simulated road data includes at least one road; Create a spline component pool. When preset conditions are met, filter out and save the road data to be displayed from the simulated road data that is within the current coordinate view range of the simulated camera. The preset conditions include starting traffic flow simulation or when the simulated camera moves a distance exceeding a set displacement threshold. Repeat the following steps until the traffic flow simulation ends: For each road in the road data to be displayed, a corresponding simulated road is generated using at least one spline component from the spline component pool. For each road in the road data to be displayed, a corresponding number of simulated vehicles are generated for each road based on the length of the simulated road and the preset vehicle density. For each road in the road data to be displayed, the road data corresponding to each road and its corresponding number of simulated vehicles are encapsulated to form the traffic flow data corresponding to each road; For each road in the road data to be displayed, traffic flow simulation is performed based on the time elapsed in each frame during program execution and the traffic flow data corresponding to each road; When the preset conditions are met, new road data to be displayed is re-selected, and the above operations are performed on the new road data to be displayed until the traffic flow simulation ends.

2. The method according to claim 1, characterized in that, The process of performing coordinate system transformation and coordinate point calculation based on the latitude, longitude, and altitude coordinates of the original road data to obtain simulated road data, and saving the simulated road data includes: The geographic coordinates of each node of each road in the original road data are converted into 3D coordinates in the Unreal Engine to obtain the converted road data. The geographic coordinates of each node include longitude, latitude and altitude coordinates. The transformed road data is stored in a road data container; For each road in the road data after coordinate transformation, nodes are added to obtain road data with added nodes, and the road data with added nodes is stored in the road data container; For each road in the road data following the supplementary node: Determine the horizontal unit vector pointing from the nth node to the (n+1)th node in each road, where n = 1, 2, 3...m-1, m is the total number of nodes in each road, and m and n are both positive integers; Determine the clockwise unit vector and the counterclockwise unit vector that are perpendicular to the horizontal direction of the unit vector; Multiply the clockwise unit vector and the counterclockwise unit vector by the width of each road to obtain the clockwise vector and the counterclockwise vector, respectively. The endpoint of the clockwise direction vector is taken as one of the positive coordinates of each road, and the endpoint of the counterclockwise direction vector is taken as one of the reverse coordinates of each road. Based on all forward coordinates, all reverse coordinates, and all elevation coordinates of each road, the road coordinates of each road are determined, wherein each elevation coordinate of each road is determined by the elevation of each node of each road; The road coordinates of all the obtained roads are used as the simulated road data; The simulated road data is stored in the road data container.

3. The method according to claim 2, characterized in that, For each road in the transformed coordinate road data, node supplementation is performed to obtain road data with supplemented nodes, including: For any road in the transformed coordinate road data, if the number of nodes in the road is less than or equal to 1, no node addition operation is performed on the road; if the number of nodes in the road is greater than 1, node addition operation is performed on the road in the following manner: For any two adjacent nodes in the road, determine the distance between the two adjacent nodes; If the distance between adjacent nodes is less than or equal to the preset spacing between supplementary road nodes, then no node supplementation operation will be performed between the two adjacent nodes. Alternatively, if the distance between adjacent nodes is greater than the spacing between supplementary road nodes, then the two adjacent nodes are determined to be adjacent nodes to be supplemented, and the ratio between the distance between adjacent nodes and the spacing between supplementary road nodes is determined. The ratio is then rounded down to obtain the number of nodes to be supplemented between the adjacent nodes to be supplemented. Based on the spacing between the supplementary road nodes and the number of nodes to be supplemented, a node supplementation operation is performed between the adjacent nodes to be supplemented. After all adjacent nodes to be supplemented have completed the node supplementation operation, one of the road data is obtained after the supplementation of nodes; The road data following the supplementary node includes the road data following each supplementary node.

4. The method according to claim 1, characterized in that, The step of generating a corresponding simulated road for each road in the road data to be displayed using at least one spline component from the spline component pool includes: The road data to be displayed is recorded as the current road data to be displayed, and the road data to be displayed obtained from the previous filtering is recorded as the previously displayed road data. The total number of roads included in the current road data to be displayed is the current number of roads. The current number of roads is the sum of the total number of roads in the first direction and the total number of roads in the second direction in the current road data to be displayed. The first direction and the second direction represent two opposite driving directions. When there are duplicate roads between the roads in the current road data to be displayed and the roads in the previously displayed road data, the number of duplicate roads is recorded as the number of duplicate roads. The data in the spline components corresponding to the non-displayed roads in the previously displayed road data (excluding the duplicate roads) is cleared. The spline components after the cleared data are recorded as unused spline components. The number of unused spline components is the number of unused components. The spline components corresponding to the duplicate roads are reused spline components. If the sum of the number of unused components and the number of duplicate roads is less than the current number of roads, then a first number of new spline components are generated through the spline component pool, wherein the first number is the difference between the current number of roads and a second number, and the second number is the sum of the number of unused components and the number of duplicate roads; Using the unused spline component, the reused spline component, and the first number of new spline components, a corresponding simulated road is generated for each road in the current road data to be displayed. Each unused spline component, each reused spline component, and each new spline component serves as a target spline component. The coordinate data of each spline node in any target spline component is determined by the road coordinates of the road corresponding to that target spline component. Alternatively, if the sum of the number of unused components and the number of duplicate roads is greater than the current number of roads, then the difference between the current number of roads and the number of duplicate roads is determined to obtain a third number; Using the third number of unused spline components and the reused spline components, a corresponding simulated road is generated for each road in the current road data to be displayed. Each unused spline component and each reused spline component serves as a target spline component. The coordinate data of each spline node in any target spline component is determined by the road coordinates of the road corresponding to that target spline component.

5. The method according to claim 1, characterized in that, Generating a corresponding simulated road for each road in the road data to be displayed, using at least one spline component from the spline component pool, includes: The road data to be displayed is recorded as the current road data to be displayed, and the road data to be displayed obtained from the previous filtering is recorded as the previously displayed road data. The total number of roads included in the current road data to be displayed is the current number of roads. The current number of roads is the sum of the total number of roads in the first direction and the total number of roads in the second direction in the current road data to be displayed. The first direction and the second direction represent two opposite driving directions. When there are no duplicate roads between the roads in the current road data to be displayed and the roads in the previously displayed road data, the data in the spline component corresponding to the previously displayed road data is cleared, and the spline component after the cleared data is recorded as an unused spline component. The number of unused spline components is the number of unused components. If the number of unused components is less than the current number of roads, a fourth number of new spline components are generated through the spline component pool, wherein the fourth number is the difference between the current number of roads and the number of unused components; Using the unused spline components and the fourth number of new spline components, a corresponding simulated road is generated for each road in the current road data to be displayed. Each unused spline component and each new spline component is a target spline component. The coordinate data of each spline node in any target spline component is determined by the road coordinates of the road corresponding to that target spline component. Alternatively, if the number of unused components is greater than the current number of roads, then other unused spline components that exceed the current number of roads are set to an idle state; Using the unused spline components of the current number of roads, a corresponding simulated road is generated for each road in the current road data to be displayed. Any unused spline component serves as a target spline component, and the coordinate data of each spline node in any target spline component is determined by the road coordinates of the road corresponding to that target spline component.

6. The method according to claim 1, characterized in that, The generation of the corresponding number of simulated vehicles for each road includes: For each road in the road data to be displayed, a corresponding number of simulated vehicles are added to each road using an instance static mesh component; The step of simulating traffic flow for each road in the road data to be displayed, based on the time elapsed in each frame of the program's runtime and the traffic flow data corresponding to each road, includes: For each road in the road data to be displayed, the vehicle data of each simulated vehicle in each road is determined based on the traffic flow data corresponding to each road; Based on the vehicle data of each simulated vehicle on each road and the incoming elapsed time information, determine the current position of each simulated vehicle on each road; Using the instance static mesh component and the incoming elapsed time information, the position of each simulated vehicle on each road is updated in real time based on the current position of each simulated vehicle on each road, so as to complete the traffic flow simulation of the simulated road corresponding to each road.

7. The method according to claim 1, characterized in that, The method further includes: Create a traffic flow management class, wherein the traffic flow management class is used to perform at least one of the following: Add a road data container to the traffic flow management class to store the simulated road data. The traffic flow management class defines traffic flow simulation variables, which include traffic flow display range, vehicle spacing, vehicle speed, supplementary road node spacing, and camera displacement threshold. The camera displacement threshold refers to the distance that the simulated camera needs to move to trigger a road update function once. A vehicle generation function is added to the traffic flow management class. For each road in the road data to be displayed, the vehicle generation function generates a corresponding number of simulated vehicles for each road based on the length of the simulated road and the preset vehicle density. The corresponding number of simulated vehicles for each road is then saved through the traffic flow management class.

8. The method according to claim 1, characterized in that, When preset conditions are met, the step of filtering and saving road data to be displayed from the simulated road data that is within the current coordinate field of view of the simulated camera includes: Create a traffic flow management class, and add road update functionality to the traffic flow management class through a road update function; Using the road update function, for any road in the simulated road data, the following information is determined according to the time point in the preset conditions: Determine the current coordinates of the simulated camera; Determine the first distance between the starting coordinates of the road and the current coordinates of the simulated camera; Determine the second distance between the end coordinates of the road and the current coordinates of the simulated camera; If at least one of the first distance and the second distance is less than or equal to the predefined traffic flow display range, then the road is determined as a road to be displayed; All road data corresponding to the roads to be displayed are determined as the road data to be displayed; Create a temporary data container to temporarily store the road data to be displayed; A display road data container is created, and the road data to be displayed that is temporarily stored in the temporary data container is saved into the display road data container so that the Unreal Engine can call the road data to be displayed from the display road data container when performing traffic flow simulation.

9. The method according to claim 1, characterized in that, After acquiring the raw road data, the method further includes: The acquired raw road data is stored in a raw road data container. The raw road data includes at least one raw road, and the road data corresponding to each raw road includes the road number, road name, road length, and the latitude, longitude, and altitude of each node in the road.

10. A traffic flow simulation device, characterized in that, The device includes Unreal Engine, and the device comprises: The first-level logic operation module is used to acquire the original road data, perform coordinate system transformation and coordinate point calculation based on the latitude, longitude and altitude coordinates of the original road data, obtain simulated road data, and save the simulated road data, wherein the simulated road data includes at least one road; The filtering logic operation module is used to create a spline component pool. When preset conditions are met, it filters out and saves the road data to be displayed from the simulated road data that is within the current coordinate view range of the simulated camera. The preset conditions include starting traffic flow simulation or when the simulated camera moves a distance exceeding a set displacement threshold. The second-level logic operation module is used to repeatedly perform the following operations until the traffic flow simulation ends: For each road in the road data to be displayed, a corresponding simulated road is generated using at least one spline component from the spline component pool. For each road in the road data to be displayed, a corresponding number of simulated vehicles are generated for each road based on the length of the simulated road and the preset vehicle density. For each road in the road data to be displayed, the road data corresponding to each road and its corresponding number of simulated vehicles are encapsulated to form the traffic flow data corresponding to each road; For each road in the road data to be displayed, traffic flow simulation is performed based on the time elapsed in each frame during program execution and the traffic flow data corresponding to each road; When the preset conditions are met, new road data to be displayed is re-selected, and the above operations are performed on the new road data to be displayed until the traffic flow simulation ends.

Citation Information

Patent Citations

  • Traffic flow simulation method and related equipment

    CN114357616A

  • Road scene generation method and device and electronic equipment

    CN115512052A