A method and device for processing grid spatiotemporal data
By replacing the static H3 grid with a dynamic H3 grid linked list and combining it with distributed database storage and real-time traffic feedback, the problem of the H3 grid system lacking a time dimension is solved, and the real-time traffic query service is improved.
Patent Information
- Application Number
- CN202411753234.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2044-12-02
AI Technical Summary
The existing H3 grid system is a static grid and lacks a time dimension, making it difficult to provide real-time traffic query services.
The traditional static H3 grid is replaced by a dynamic H3 grid linked list. The grid hash table is stored in a distributed database, and the grid objects are updated at preset intervals. The grid objects are updated and queried in combination with real-time traffic feedback.
It realizes real-time traffic query services and improves the real-time performance of grid data and query services.
Smart Images

Figure CN119690968B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method and device for processing grid spatiotemporal data. Background Art
[0002] The H3 grid system uses a hexagonal grid design to divide geographic space into a series of uniformly sized and regularly shaped grid cells. It also provides hierarchical management capabilities, meaning that a higher-level grid can contain multiple lower-level grids, thereby achieving step-by-step sharding / partitioning by building a grid hierarchy. This division method not only simplifies the storage and management of spatial data but also improves the efficiency of spatial query and analysis. Intelligent transportation systems can use these grid cells to accurately organize and store traffic data, such as vehicle location, traffic flow, and road conditions, enabling rapid access and processing of traffic data. However, most commonly used H3 grids are static grids, meaning that the grid cell data lacks a time dimension and has poor real-time performance. It is difficult to provide users with real-time traffic query services based on static H3 grids.
[0003] To address this issue, we replace the static data in the traditional H3 grid with a continuously scrolling, refreshed grid linked list, thereby adding temporal information to the grid cells. This dynamic H3 grid provides users with real-time traffic query services. The technical solution presented in this invention is precisely the spatiotemporal data design for this dynamic H3 grid, along with the corresponding spatiotemporal data refresh and query solution. Summary of the Invention
[0004] The present invention addresses the shortcomings of the prior art by providing a method, device, electronic device, and computer-readable storage medium for processing grid spatiotemporal data. The present invention divides a designated road network area into an H3 grid format to obtain a corresponding first grid network. The total number of H3 grids at the bottom layer of the first grid network is counted to obtain a corresponding total number of grids, N. A corresponding grid spatiotemporal data table, designated as an H3 grid hash table, is created for the first grid network and stored in the H3 grid hash table based on a distributed database. Queue records are then added to all grid linked lists in the H3 grid hash table at a preset rolling interval Δt. The H3 grid hash table is updated based on real-time traffic feedback from the designated road network area. Upon receiving a traffic information query command input by a user, the H3 grid hash table is queried for grid spatiotemporal data based on the traffic information query command, and traffic information is analyzed based on the query results to obtain corresponding instruction feedback data, which is then fed back to the current user. The grid spatiotemporal data design scheme and corresponding spatiotemporal data refresh and query scheme provided by the present invention can construct a dynamic H3 grid and provide users with real-time query services, thereby improving the real-time performance of grid data and query services.
[0005] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present invention provides a method for processing grid spatiotemporal data, the method comprising:
[0006] Step 1: Divide a designated road network area into a grid using an H3 grid format to obtain a corresponding first grid network; count the total number of H3 grids at the bottom layer of the first grid network to obtain a corresponding total number of grids N; create a corresponding grid spatiotemporal data table for the first grid network, denoted as an H3 grid hash table; and store the H3 grid hash table based on a distributed database;
[0007] The first grid network includes N first grids; each first grid is a bottom-level H3 grid; each first grid corresponds to a grid identifier S; the H3 grid hash table includes N grid key-value pairs; each grid key-value pair corresponds one-to-one with the first grid; the key field of the grid key-value pair is the corresponding grid identifier S, and the value field is the corresponding grid linked list; each grid linked list is a first-in-first-out circular queue linked list with a fixed queue size, consisting of a preset total number of queue records M; the queue record consists of a corresponding timestamp T and a grid object set; the distributed database includes at least a Redis database;
[0008] Step 2: performing a rolling addition process on all the grid linked lists of the H3 grid hash table at a preset rolling interval Δt; and performing a grid object update process on the H3 grid hash table based on the real-time traffic feedback of the designated road network area;
[0009] Step 3: upon receiving a traffic information query instruction input by the user, performing a grid spatiotemporal data query on the H3 grid hash table based on the traffic information query instruction, and performing traffic information analysis based on the query result to obtain corresponding instruction feedback data and feed it back to the current user;
[0010] Among them, the traffic information query instruction includes a query period, a query type and a query parameter; the query type includes at least a traffic participant trajectory query, a vehicle flow statistics query and a sub-grid network query; when the query type is a traffic participant trajectory query, the query parameter is a query object identifier; when the query type is a vehicle flow statistics query, the query parameter is a query grid identifier; when the query type is a sub-grid network query, the query parameter is a clockwise / counterclockwise vertex coordinate sequence of an irregular ground area, and the clockwise / counterclockwise vertex coordinate sequence is composed of multiple area vertex coordinates sorted in clockwise / counterclockwise order.
[0011] Preferably, the time difference between the timestamp T of each queue record and the previous or next queue record matches the rolling interval Δt;
[0012] When the grid object set is empty, it means that at the time point corresponding to the current timestamp T, there is no traffic participant in motion in the current first grid; the types of traffic participants include at least motor vehicles, non-motor vehicles and pedestrians;
[0013] When the grid object set is not empty, it is composed of one or more grid objects P; each of the grid objects P corresponds to a traffic participant that is in motion within the current first grid at the time point corresponding to the current timestamp T; the grid object P includes an object identifier, an object type, and object coordinates; the object types include at least motor vehicles, non-motor vehicles, and pedestrians.
[0014] Preferably, the step of performing a queue record rolling addition process on all the grid linked lists of the H3 grid hash table at a preset rolling interval Δt specifically includes:
[0015] Every rolling interval Δt, a queue record is added to each grid linked list as the corresponding current added record; the timestamp T of the current added record is set based on the current time; and the grid object set of the current added record is set to empty.
[0016] Preferably, the grid object updating process of the H3 grid hash table based on the real-time traffic feedback of the designated road network area specifically includes:
[0017] Step 41, receiving first real-time traffic feedback of the designated road network area;
[0018] The first real-time traffic feedback includes a first time and a first participant set; the first participant set is composed of a plurality of first participant information; the first participant information includes a first participant identifier, a first participant type, and a first participant coordinate;
[0019] Step 42: take each of the first participant information as the corresponding current participant information; and take the first time and the first participant identifier, the first participant type and the first participant coordinates of the current participant information as the corresponding current time, current participant identifier, current participant type and current participant coordinates; and according to the preset coordinate and grid identifier conversion rule, perform the corresponding grid identifier conversion according to the current participant coordinates to obtain the corresponding current grid identifier; and take the grid linked list of the grid key-value pairs that match the grid identifier S in the H3 grid hash table with the current grid identifier as the corresponding current grid linked list; and take the queue record in the current grid linked list that is closest to the timestamp T and the current time interval as the corresponding current record; and take the queue record before the current record as the corresponding previous record; and check whether the previous record is If the previous record is empty, then when the grid object P whose object identifier matches the current participant identifier does not exist in the grid object set of the current record, the current participant identifier, the current participant type and the current participant coordinates serve as the corresponding object identifier, the object type and the object coordinates to form a corresponding grid object P, which is added to the grid object set of the current record; if the previous record is not empty, then when the grid object P whose object identifier matches the current participant identifier does not exist in the grid object sets of both the previous and current records, the current participant identifier, the current participant type and the current participant coordinates serve as the corresponding object identifier, the object type and the object coordinates to form a corresponding grid object P, which is added to the grid object set of the current record.
[0020] Preferably, the performing of grid spatiotemporal data query on the H3 grid hash table based on the traffic information query instruction and analyzing traffic information based on the query result to obtain corresponding instruction feedback data to the current user specifically includes:
[0021] Step 51: using the query period, query type, and query parameters of the traffic information query instruction as the corresponding current query period, current query type, and current query parameters;
[0022] Step 52: Record the queue records whose timestamps T satisfy the current query period in each grid linked list of the H3 grid hash table as valid records, and record the queue records whose timestamps T do not satisfy the current query period as invalid records;
[0023] Step 53, identifying the current query type; if the current query type is a traffic participant trajectory query, proceed to step 54; if the current query type is a traffic flow statistics query, proceed to step 55; if the current query type is a sub-grid network query, proceed to step 56;
[0024] Step 54: extract the corresponding query object identifier from the current query parameter; record the valid record of the grid object P in the H3 grid hash table where each object identifier matches the query object identifier as the corresponding first screening record; use the timestamp T, the object coordinates, and the grid identifier S corresponding to each first screening record as the corresponding first track point time, first track point coordinates, and first track point grid identifier to form a corresponding first track point; sort all the obtained first track points in chronological order to form a corresponding first query track; use the first query track as the corresponding instruction feedback data; and proceed to step 57;
[0025] Step 55: extract the corresponding query grid identifier from the current query parameter; use the grid linked list of the grid key-value pairs that match the grid identifier S and the query grid identifier in the H3 grid hash table as the corresponding current grid linked list; count the total number of the grid objects P of the motor vehicle type in the grid object set of each valid record in the current grid linked list to obtain a corresponding first total; sum all the obtained first totals to obtain a corresponding first sum; use the first sum as the corresponding instruction feedback data; and proceed to step 57;
[0026] Step 56: extract the corresponding clockwise / counterclockwise vertex coordinate sequence from the current query parameter; and sequentially connect all the region vertex coordinates of the clockwise / counterclockwise vertex coordinate sequence in the corresponding clockwise / counterclockwise order to form a corresponding first ground area; and record each first grid in the first grid network that intersects with the first ground area as a corresponding first screening grid; and record the grid key-value pairs corresponding to each first screening grid in the H3 grid hash table as corresponding sub-network grid key-value pairs; and form a corresponding sub-network grid hash table from all the obtained sub-network grid key-value pairs; and use the sub-network grid hash table as the corresponding instruction feedback data;
[0027] Step 57: Feedback the command feedback data obtained this time to the current user.
[0028] A second aspect of an embodiment of the present invention provides a device for implementing the grid spatiotemporal data processing method described in the first aspect, the device comprising: a grid spatiotemporal data construction module, a grid spatiotemporal data update module, and a grid spatiotemporal data application module;
[0029] The grid spatiotemporal data construction module is used to grid the designated road network area according to the H3 grid format to obtain the corresponding first grid network; and to count the total number of H3 grids at the bottom layer of the first grid network to obtain the corresponding total number of grids N; and to create a corresponding grid spatiotemporal data table for the first grid network, which is recorded as an H3 grid hash table; and to store the H3 grid hash table based on a type of distributed database; wherein, the first grid network includes N first grids; each first grid is a bottom-level H3 grid; each first grid corresponds to a grid identifier S; the H3 grid hash table includes N grid key-value pairs; the grid key-value pairs correspond one-to-one to the first grids; the key field of the grid key-value pair is the corresponding grid identifier S, and the value field is the corresponding grid linked list; each grid linked list is a first-in-first-out circular queue linked list with a fixed queue size, and is composed of queue records with a preset total number of queue records M; the queue record is composed of a corresponding timestamp T and a grid object set; the distributed database at least includes a Redis database;
[0030] The grid spatiotemporal data update module is used to perform a queue record rolling addition process on all the grid linked lists of the H3 grid hash table at a preset rolling interval Δt; and to perform a grid object update process on the H3 grid hash table based on the real-time traffic feedback of the designated road network area;
[0031] The grid spatiotemporal data application module is used to, upon receiving a traffic information query instruction input by a user, perform a grid spatiotemporal data query on the H3 grid hash table based on the traffic information query instruction and perform traffic information analysis based on the query result to obtain corresponding instruction feedback data and feed it back to the current user; wherein, the traffic information query instruction includes a query period, a query type and a query parameter; the query type includes at least a traffic participant trajectory query, a vehicle flow statistics query and a sub-grid network query; when the query type is a traffic participant trajectory query, the query parameter is a query object identifier; when the query type is a vehicle flow statistics query, the query parameter is a query grid identifier; when the query type is a sub-grid network query, the query parameter is a clockwise / counterclockwise vertex coordinate sequence of an irregular ground area, and the clockwise / counterclockwise vertex coordinate sequence is formed by sequentially sorting the coordinates of multiple regional vertices in a clockwise / counterclockwise order.
[0032] A third aspect of an embodiment of the present invention provides an electronic device, including: a memory, a processor, and a transceiver;
[0033] The processor is configured to be coupled to the memory, read and execute instructions in the memory, so as to implement the method steps described in the first aspect above;
[0034] The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
[0035] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, which stores computer instructions. When the computer instructions are executed by a computer, the computer executes the instructions of the method described in the first aspect above.
[0036] The embodiments of the present invention provide a method, device, electronic device, and computer-readable storage medium for processing grid spatiotemporal data. As can be seen from the above invention, the embodiments of the present invention divide a designated road network area into grids according to the H3 grid format to obtain a corresponding first grid network, and count the total number of H3 grids at the bottom layer of the first grid network to obtain a corresponding total number of grids N. A corresponding grid spatiotemporal data table is created for the first grid network, denoted as an H3 grid hash table, and the H3 grid hash table is stored based on a type of distributed database; queue records are added to all grid linked lists in the H3 grid hash table at a preset rolling interval Δt, and grid objects are updated in the H3 grid hash table based on real-time traffic feedback in the designated road network area; and upon receiving a traffic information query instruction input by a user, the H3 grid hash table is queried for grid spatiotemporal data based on the traffic information query instruction, and traffic information is analyzed based on the query result to obtain corresponding instruction feedback data and feedback it to the current user. The grid spatiotemporal data design scheme and the corresponding spatiotemporal data refresh and query scheme provided by the embodiments of the present invention can construct a dynamic H3 grid and provide users with real-time query services, thereby improving the real-time performance of both grid data and traffic query services. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A schematic diagram of a method for processing grid spatiotemporal data provided in Example 1 of the present invention;
[0038] Figure 2 A schematic diagram of the data structure of the H3 grid hash table and grid linked list provided in Example 1 of the present invention;
[0039] Figure 3 A module structure diagram of a grid spatiotemporal data processing device provided in the second embodiment of the present invention;
[0040] Figure 4 This is a structural diagram of an electronic device provided in Example 3 of the present invention. DETAILED DESCRIPTION
[0041] To make the objectives, technical solutions, and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings. It should be understood that the embodiments described herein are merely some, rather than all, of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are intended to fall within the scope of protection of the present invention.
[0042] A method for processing grid spatiotemporal data is provided in the first embodiment of the present invention. Figure 1 A method for processing grid spatiotemporal data provided in the first embodiment of the present invention is shown in a schematic diagram, which includes the following main steps:
[0043] Step 1: Divide the designated road network area into a grid according to the H3 grid format to obtain a corresponding first grid network; and count the total number of H3 grids at the bottom layer of the first grid network to obtain the corresponding total number of grids N; and create a corresponding grid spatiotemporal data table for the first grid network, denoted as an H3 grid hash table; and store the H3 grid hash table based on a type of distributed database.
[0044] Here, the first mesh network of this embodiment of the present invention includes N first meshes; each first mesh is a bottom-level H3 mesh; and each first mesh corresponds to a mesh identifier S. The reason the first mesh network is constructed based solely on the bottom-level H3 mesh is that, in the H3 mesh system, all upper-level meshes, except for the bottom-level H3 mesh, can be derived from the mesh identifier of the bottom-level H3 mesh in a step-by-step reverse derivation based on the mesh identifier definition standard. Therefore, the spatiotemporal data of each upper-level mesh can be obtained by statistically analyzing the spatiotemporal data of the lower-level meshes. Therefore, this embodiment of the present invention only describes the bottom-level H3 mesh network, i.e., the first mesh network.
[0045] like Figure 2 As shown in the data structure diagram of the H3 grid hash table and grid linked list provided in the first embodiment of the present invention, the H3 grid hash table of the embodiment of the present invention includes N grid key-value pairs; the grid key-value pairs in the H3 grid hash table correspond one-to-one to the first grid in the first grid network; the key field of each grid key-value pair is the corresponding grid identifier S, and the value field is the corresponding grid linked list.
[0046] Each grid linked list in the embodiment of the present invention is a first-in-first-out circular queue linked list with a fixed queue size, and is composed of a preset total number of queue records M. Figure 2 As shown, each queue record of the grid linked list in the embodiment of the present invention consists of a corresponding timestamp T and a grid object set.
[0047] It should be noted that the time difference between each queue record and the timestamp T of the previous or next queue record matches the preset rolling interval Δt, and the rolling interval Δt is a preset time length parameter.
[0048] It should also be noted that: 1) when the grid object set is empty, it indicates that there are no traffic participants in motion in the current first grid at the time point corresponding to the current timestamp T. The types of traffic participants in the embodiment of the present invention include at least motor vehicles, non-motor vehicles, and pedestrians; 2) when the grid object set is not empty, it is composed of one or more grid objects P, each grid object P corresponds to a traffic participant in motion in the current first grid at the time point corresponding to the current timestamp T. The grid object P includes an object identifier, an object type, and object coordinates. The object types include at least motor vehicles, non-motor vehicles, and pedestrians.
[0049] The distributed database used to store the H3 grid hash table in the embodiment of the present invention includes at least a Redis database. The reason for selecting the distributed database to store the H3 grid hash table is to improve the read and write efficiency of the H3 grid hash table.
[0050] Step 2: Perform a rolling addition process on all grid linked lists of the H3 grid hash table according to a preset rolling interval Δt; and perform a grid object update process on the H3 grid hash table based on the real-time traffic feedback of the specified road network area;
[0051] Specifically, the process includes: step 21, performing a rolling addition process on all grid linked lists of the H3 grid hash table according to a preset rolling interval Δt;
[0052] Specifically, the method includes: adding a queue record to each grid linked list at every rolling interval Δt as the corresponding current added record; setting the timestamp T of the current added record based on the current time; and setting the grid object collection of the current added record to empty;
[0053] Step 22, performing a grid object update process on the H3 grid hash table based on the real-time traffic feedback of the designated road network area;
[0054] Specifically comprising: step 221, receiving first real-time traffic feedback of a designated road network area;
[0055] The first real-time traffic feedback includes the first time and the first participant set; the first participant set is composed of a plurality of first participant information; the first participant information includes the first participant identifier, the first participant type and the first participant coordinates;
[0056] Step 222: Use each first participant information as the corresponding current participant information; use the first time and the first participant identifier, first participant type and first participant coordinates of the current participant information as the corresponding current time, current participant identifier, current participant type and current participant coordinates; and according to the preset coordinate and grid identifier conversion rules, perform the corresponding grid identifier conversion based on the current participant coordinates to obtain the corresponding current grid identifier; and use the grid linked list of grid key-value pairs matching the grid identifier S and the current grid identifier in the H3 grid hash table as the corresponding current grid linked list; and use the queue record in the current grid linked list that is closest to the timestamp T and the current time interval as the corresponding current record; and use the previous queue record of the current record as the corresponding previous record. record; and identify whether the previous record is empty; if the previous record is empty, then when there is no grid object P whose object identifier matches the current participant identifier in the grid object set of the current record, the current participant identifier, current participant type and current participant coordinates are used as corresponding object identifier, object type and object coordinates to form a corresponding grid object P, which is added to the grid object set of the current record; if the previous record is not empty, then when there is no grid object P whose object identifier matches the current participant identifier in the grid object sets of both the previous and current records, the current participant identifier, current participant type and current participant coordinates are used as corresponding object identifier, object type and object coordinates to form a corresponding grid object P, which is added to the grid object set of the current record.
[0057] Here, the conversion rules between coordinates and grid identifiers in the embodiment of the present invention are the conversion rules between map coordinates and grid identifiers in the H3 grid system. This is a public technical solution that can be obtained by querying the technical literature of the H3 grid system and will not be further described here.
[0058] It should be noted that in the current step, it is also necessary to check whether there is a grid object P (hereinafter referred to as grid object P) in the previous record whose object identifier matches the current participant identifier. ’ ) is confirmed because if the mesh object set of the previous record contains mesh object P ’ This indicates that during the interval between the previous record and the current record (interval length = Δt), the traffic participant either did not move or did not completely move out of the current grid. In this case, the embodiment of the present invention will not repeatedly write it into the grid object set of the current record, otherwise a duplicate counting problem will occur when counting traffic flow.
[0059] Step 3: upon receiving a traffic information query instruction input by the user, performing a grid spatiotemporal data query on the H3 grid hash table based on the traffic information query instruction and performing traffic information analysis based on the query result to obtain corresponding instruction feedback data and feed it back to the current user;
[0060] The traffic information query instruction includes a query period, a query type, and a query parameter; the query type includes at least a traffic participant trajectory query, a vehicle flow statistics query, and a sub-grid network query; when the query type is a traffic participant trajectory query, the query parameter is a query object identifier; when the query type is a vehicle flow statistics query, the query parameter is a query grid identifier; when the query type is a sub-grid network query, the query parameter is a clockwise / counterclockwise vertex coordinate sequence of an irregular ground area, and the clockwise / counterclockwise vertex coordinate sequence is formed by sequentially sorting the coordinates of multiple regional vertices in a clockwise / counterclockwise order;
[0061] Specifically comprising: step 31, taking the query period, query type and query parameters of the traffic information query instruction as the corresponding current query period, current query type and current query parameters;
[0062] Step 32: In each grid linked list of the H3 grid hash table, the queue records whose timestamp T meets the current query period are recorded as valid records, and the queue records whose timestamp T does not meet the current query period are recorded as invalid records;
[0063] Here, when locating queue records in each grid linked list whose timestamp T meets the current query period, the embodiment of the present invention uses the timestamps of the queue records to identify the order of the records, even though the grid linked list is a circular queue and the physical record index does not necessarily equal the actual queue record order. To improve identification efficiency, various optimized query methods can be used to improve query efficiency. By default, the embodiment of the present invention uses a binary search algorithm.
[0064] Step 33: Identify the current query type; if the current query type is a traffic participant trajectory query, go to step 34; if the current query type is a traffic flow statistics query, go to step 35; if the current query type is a sub-grid network query, go to step 36;
[0065] Step 34: Extract the corresponding query object identifier from the current query parameter; record the valid records of the grid objects P in the H3 grid hash table whose object identifiers match the query object identifier as the corresponding first screening records; and use the timestamp T, object coordinates, and grid identifier S corresponding to each first screening record as the corresponding first track point time, first track point coordinates, and first track point grid identifier to form a corresponding first track point; sort all the obtained first track points in chronological order to form the corresponding first query track; use the first query track as the corresponding instruction feedback data; and then go to step 37;
[0066] Step 35: Extract the corresponding query grid identifier from the current query parameter; use the grid linked list of grid key-value pairs matching the grid identifier S and the query grid identifier in the H3 grid hash table as the corresponding current grid linked list; count the total number of grid objects P of motor vehicle type in each valid record of the current grid linked list to obtain a corresponding first total; sum all the obtained first totals to obtain a corresponding first sum; use the first sum as the corresponding instruction feedback data; and proceed to step 37;
[0067] Step 36: Extract the corresponding clockwise / counterclockwise vertex coordinate sequence from the current query parameter; connect all the regional vertex coordinates of the clockwise / counterclockwise vertex coordinate sequence in the corresponding clockwise / counterclockwise order to form the corresponding first ground area; record each first grid in the first grid network that intersects with the first ground area as the corresponding first screening grid; record the grid key-value pairs corresponding to each first screening grid in the H3 grid hash table as the corresponding sub-network grid key-value pairs; and form a corresponding sub-network grid hash table from all the obtained sub-network grid key-value pairs; and use the sub-network grid hash table as the corresponding instruction feedback data;
[0068] Step 37: Feedback the command feedback data obtained this time to the current user.
[0069] It should also be noted that, in addition to the three real-time query services described above, the grid spatiotemporal data features of the dynamic H3 grid provided by the embodiments of the present invention can also construct a three-dimensional grid space with the H3 grid, time, and traffic participants as the X, Y, and Z axes, recorded as the first 3D data space; this first 3D data space is then divided into data grids; and a corresponding first data grid value calculation rule is set as follows: if the traffic participant corresponding to a data grid in the first 3D data space exists in the current H3 grid at the current time point / segment, then the grid value of this data grid is set to 1; otherwise, it is set to 0; and all data grids in the first 3D data space are continuously and dynamically refreshed based on the H3 grid hash table. In this way, by observing the first 3D data space, the real-time dynamics and historical trajectories of all traffic participants can be obtained, and visualization processing can also be conveniently performed based on the first 3D data space.
[0070] It should also be noted that, based on the grid spatiotemporal data features of the dynamic H3 grid provided by the embodiment of the present invention, a three-dimensional grid space can be constructed with the H3 grid, time, and number of traffic participants as the X, Y, and Z axes, denoted as a second 3D data space. Here, the number of traffic participants can be defined as the number of traffic participants of a specified type (such as motor vehicles, aircraft, or pedestrians), or the number of traffic participants of all types. This second 3D data space is then divided into data grids. A corresponding data grid value calculation rule is set as follows: the total number of traffic participants existing in the current H3 grid at the time point / segment corresponding to each data grid is counted and the statistical result is used as the grid value of the current data grid. All data grids in the second 3D data space are continuously and dynamically refreshed based on the H3 grid hash table. In this way, by observing the second 3D data space, real-time and historical traffic information at all traffic locations (points, slices, segments, and areas) can be obtained. The traffic information here can be motor vehicle traffic, non-motor vehicle traffic, pedestrian traffic, or traffic of all traffic participants. Visualization processing can also be conveniently performed based on the second 3D data space.
[0071] Figure 3 This is a module structure diagram of a grid spatiotemporal data processing device provided in the second embodiment of the present invention. The device is a terminal device or server that implements the aforementioned method embodiment, or can be a device that enables the aforementioned terminal device or server to implement the aforementioned method embodiment. For example, the device can be a device or chip system of the aforementioned terminal device or server. Figure 3 As shown, the grid spatiotemporal data processing device provided by the second embodiment of the present invention includes: a grid spatiotemporal data construction module 201, a grid spatiotemporal data update module 202 and a grid spatiotemporal data application module 203.
[0072] The grid spatiotemporal data construction module 201 is used to grid the designated road network area according to the H3 grid format to obtain a corresponding first grid network; and to count the total number of H3 grids at the bottom layer of the first grid network to obtain a corresponding total number of grids N; and to create a corresponding grid spatiotemporal data table for the first grid network, denoted as an H3 grid hash table; and to store the H3 grid hash table based on a type of distributed database; wherein, the first grid network includes N first grids; each first grid is a bottom-layer H3 grid; each first grid corresponds to a grid identifier S; the H3 grid hash table includes N grid key-value pairs; the grid key-value pairs correspond one-to-one to the first grids; the key field of the grid key-value pairs is the corresponding grid identifier S, and the value field is the corresponding grid linked list; each grid linked list is a first-in-first-out circular queue linked list with a fixed queue size, and is composed of queue records with a preset total number of queue records M; the queue record is composed of a corresponding timestamp T and a grid object set; the distributed database includes at least a Redis database.
[0073] The grid spatiotemporal data update module 202 is used to perform a rolling addition process on all grid linked lists of the H3 grid hash table according to a preset rolling interval Δt; and to perform a grid object update process on the H3 grid hash table based on real-time traffic feedback of a specified road network area.
[0074] The grid spatiotemporal data application module 203 is used to perform a grid spatiotemporal data query on the H3 grid hash table based on the traffic information query instruction when receiving the traffic information query instruction input by the user, and perform traffic information analysis based on the query result to obtain corresponding instruction feedback data and feedback it to the current user; wherein, the traffic information query instruction includes a query period, a query type and a query parameter; the query type includes at least a traffic participant trajectory query, a vehicle flow statistics query and a sub-grid network query; when the query type is a traffic participant trajectory query, the query parameter is a query object identifier; when the query type is a vehicle flow statistics query, the query parameter is a query grid identifier; when the query type is a sub-grid network query, the query parameter is a clockwise / counterclockwise vertex coordinate sequence of an irregular ground area, and the clockwise / counterclockwise vertex coordinate sequence is composed of multiple area vertex coordinates sorted in clockwise / counterclockwise order.
[0075] An embodiment of the present invention provides a grid spatiotemporal data processing device that can execute the method steps in the above method embodiment. Its implementation principles and technical effects are similar and will not be repeated here.
[0076] It should be understood that the division of the modules of the above apparatus is merely a division of logical functions. In actual implementation, they can be fully or partially integrated into a single physical entity or physically separated. Furthermore, these modules can be implemented entirely as software invoked by a processing element, or entirely as hardware. Alternatively, some modules can be implemented as software invoked by a processing element, while others can be implemented as hardware. For example, the grid spatiotemporal data construction module can be a separate processing element, or it can be integrated into a chip of the above apparatus. Furthermore, it can be stored in the memory of the above apparatus in the form of program code, invoked by a processing element of the apparatus, and perform the functions of the above-identified module. The implementation of other modules is similar. Furthermore, these modules can be fully or partially integrated together, or implemented independently. The processing element described herein can be an integrated circuit with signal processing capabilities. During implementation, the steps of the above method or the above modules can be performed by hardware integrated logic circuits in the processor element or by software instructions.
[0077] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented by scheduling program code through a processing element, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0078] In the above embodiments, all or part of the embodiments may be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the above method embodiments are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The above-mentioned computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the above-mentioned computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, Bluetooth, microwave, etc.) means. The above-mentioned computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The above-mentioned available medium can be a magnetic medium (such as a floppy disk, hard disk, tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)), etc.
[0079] Figure 4 This is a schematic diagram of the structure of an electronic device provided in the third embodiment of the present invention. The electronic device can be a terminal device or server that implements the method of the aforementioned embodiment, or it can be a terminal device or server that implements the method of the aforementioned embodiment connected to the aforementioned terminal device or server. Figure 4As shown, the electronic device may include: a processor 301 (such as a CPU), a memory 302, and a transceiver 303; the transceiver 303 is coupled to the processor 301, and the processor 301 controls the transceiver 303's transceiver actions. Various instructions may be stored in the memory 302 for completing various processing functions and implementing the processing steps described in the aforementioned embodiment method. Preferably, the electronic device involved in the embodiment of the present invention further includes: a power supply 304, a system bus 305, and a communication port 306. The system bus 305 is used to realize communication connections between components. The above-mentioned communication port 306 is used for connecting and communicating between the electronic device and other peripherals.
[0080] exist Figure 4 The system bus 305 mentioned in the figure can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface is used to realize communication between the database access device and other devices (such as clients, read-write libraries, and read-only libraries). The memory may include random access memory (RAM) and may also include non-volatile memory (Non-Volatile Memory), such as at least one disk storage.
[0081] The above-mentioned processors can be general-purpose processors, including central processing units (CPUs), network processors (NPs), graphics processing units (GPUs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0082] It should be noted that an embodiment of the present invention further provides a computer-readable storage medium, which stores instructions. When the computer-readable storage medium is run on a computer, it enables the computer to execute the methods and processing procedures provided in the above embodiments.
[0083] The embodiments of the present invention provide a method, device, electronic device, and computer-readable storage medium for processing grid spatiotemporal data. As can be seen from the above invention, the embodiments of the present invention divide a designated road network area into grids according to the H3 grid format to obtain a corresponding first grid network, and count the total number of H3 grids at the bottom layer of the first grid network to obtain a corresponding total number of grids N. A corresponding grid spatiotemporal data table is created for the first grid network, denoted as an H3 grid hash table, and the H3 grid hash table is stored based on a type of distributed database; queue records are added to all grid linked lists in the H3 grid hash table at a preset rolling interval Δt, and grid objects are updated in the H3 grid hash table based on real-time traffic feedback in the designated road network area; and upon receiving a traffic information query instruction input by a user, the H3 grid hash table is queried for grid spatiotemporal data based on the traffic information query instruction, and traffic information is analyzed based on the query result to obtain corresponding instruction feedback data and feedback it to the current user. The grid spatiotemporal data design scheme and the corresponding spatiotemporal data refresh and query scheme provided by the embodiments of the present invention can construct a dynamic H3 grid and provide users with real-time query services, thereby improving the real-time performance of both grid data and traffic query services.
[0084] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0085] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for processing grid spatiotemporal data, characterized in that: The method comprises: Step 1: Divide a designated road network area into a grid using an H3 grid format to obtain a corresponding first grid network; count the total number of H3 grids at the bottom layer of the first grid network to obtain a corresponding total number of grids N; create a corresponding grid spatiotemporal data table for the first grid network, denoted as an H3 grid hash table; and store the H3 grid hash table based on a distributed database; The first grid network includes N first grids; each first grid is a bottom-level H3 grid; each first grid corresponds to a grid identifier S; the H3 grid hash table includes N grid key-value pairs; each grid key-value pair corresponds one-to-one with the first grid; the key field of the grid key-value pair is the corresponding grid identifier S, and the value field is the corresponding grid linked list; each grid linked list is a first-in-first-out circular queue linked list with a fixed queue size, consisting of a preset total number of queue records M; the queue record consists of a corresponding timestamp T and a grid object set; the distributed database includes at least a Redis database; Step 2: performing a rolling addition process on all the grid linked lists of the H3 grid hash table at a preset rolling interval Δt; and performing a grid object update process on the H3 grid hash table based on the real-time traffic feedback of the designated road network area; Step 3: upon receiving a traffic information query instruction input by the user, performing a grid spatiotemporal data query on the H3 grid hash table based on the traffic information query instruction, and performing traffic information analysis based on the query result to obtain corresponding instruction feedback data and feed it back to the current user; Among them, the traffic information query instruction includes a query period, a query type and a query parameter; the query type includes at least a traffic participant trajectory query, a vehicle flow statistics query and a sub-grid network query; when the query type is a traffic participant trajectory query, the query parameter is a query object identifier; when the query type is a vehicle flow statistics query, the query parameter is a query grid identifier; when the query type is a sub-grid network query, the query parameter is a clockwise / counterclockwise vertex coordinate sequence of an irregular ground area, and the clockwise / counterclockwise vertex coordinate sequence is composed of multiple area vertex coordinates sorted in clockwise / counterclockwise order.
2. The method for processing grid spatiotemporal data according to claim 1, characterized in that: The time difference between the timestamp T of each queue record and the previous or next queue record matches the rolling interval Δt; When the grid object set is empty, it means that at the time point corresponding to the current timestamp T, there is no traffic participant in motion in the current first grid; the types of traffic participants include at least motor vehicles, non-motor vehicles and pedestrians; When the grid object set is not empty, it is composed of one or more grid objects P; each of the grid objects P corresponds to a traffic participant that is in motion within the current first grid at the time point corresponding to the current timestamp T; The grid object P includes an object identifier, an object type, and object coordinates; the object type includes at least motor vehicles, non-motor vehicles, and pedestrians.
3. The method for processing grid spatiotemporal data according to claim 2, characterized in that: The process of performing a queue record rolling addition process on all the grid linked lists of the H3 grid hash table according to a preset rolling interval Δt specifically includes: Every rolling interval Δt, a queue record is added to each grid linked list as the corresponding current added record; the timestamp T of the current added record is set based on the current time; and the grid object set of the current added record is set to empty.
4. The method for processing grid spatiotemporal data according to claim 2, characterized in that: The performing grid object updating processing on the H3 grid hash table based on the real-time traffic feedback of the designated road network area specifically includes: Step 41, receiving first real-time traffic feedback of the designated road network area; The first real-time traffic feedback includes a first time and a first participant set; the first participant set is composed of a plurality of first participant information; the first participant information includes a first participant identifier, a first participant type, and a first participant coordinate; Step 42: take each of the first participant information as the corresponding current participant information; and take the first time and the first participant identifier, the first participant type and the first participant coordinates of the current participant information as the corresponding current time, current participant identifier, current participant type and current participant coordinates; and according to the preset coordinate and grid identifier conversion rule, perform the corresponding grid identifier conversion according to the current participant coordinates to obtain the corresponding current grid identifier; and take the grid linked list of the grid key-value pairs that match the grid identifier S in the H3 grid hash table with the current grid identifier as the corresponding current grid linked list; and take the queue record in the current grid linked list that is closest to the timestamp T and the current time interval as the corresponding current record; and take the queue record before the current record as the corresponding previous record; and check whether the previous record is If the previous record is empty, then when the grid object P whose object identifier matches the current participant identifier does not exist in the grid object set of the current record, the current participant identifier, the current participant type and the current participant coordinates serve as the corresponding object identifier, the object type and the object coordinates to form a corresponding grid object P, which is added to the grid object set of the current record; if the previous record is not empty, then when the grid object P whose object identifier matches the current participant identifier does not exist in the grid object sets of both the previous and current records, the current participant identifier, the current participant type and the current participant coordinates serve as the corresponding object identifier, the object type and the object coordinates to form a corresponding grid object P, which is added to the grid object set of the current record.
5. The method for processing grid spatiotemporal data according to claim 2, characterized in that: The performing of grid spatiotemporal data query on the H3 grid hash table based on the traffic information query instruction and analyzing traffic information based on the query result to obtain corresponding instruction feedback data to the current user specifically includes: Step 51: using the query period, query type, and query parameters of the traffic information query instruction as the corresponding current query period, current query type, and current query parameters; Step 52: Record the queue records whose timestamps T satisfy the current query period in each grid linked list of the H3 grid hash table as valid records, and record the queue records whose timestamps T do not satisfy the current query period as invalid records; Step 53, identifying the current query type; if the current query type is a traffic participant trajectory query, proceed to step 54; if the current query type is a traffic flow statistics query, proceed to step 55; if the current query type is a sub-grid network query, proceed to step 56; Step 54: extract the corresponding query object identifier from the current query parameter; record the valid record of the grid object P in the H3 grid hash table where each object identifier matches the query object identifier as the corresponding first screening record; use the timestamp T, the object coordinates, and the grid identifier S corresponding to each first screening record as the corresponding first track point time, first track point coordinates, and first track point grid identifier to form a corresponding first track point; sort all the obtained first track points in chronological order to form a corresponding first query track; use the first query track as the corresponding instruction feedback data; and proceed to step 57; Step 55: extract the corresponding query grid identifier from the current query parameter; use the grid linked list of the grid key-value pairs that match the grid identifier S and the query grid identifier in the H3 grid hash table as the corresponding current grid linked list; count the total number of the grid objects P of the motor vehicle type in the grid object set of each valid record in the current grid linked list to obtain a corresponding first total; sum all the obtained first totals to obtain a corresponding first sum; use the first sum as the corresponding instruction feedback data; and proceed to step 57; Step 56: extract the corresponding clockwise / counterclockwise vertex coordinate sequence from the current query parameter; and sequentially connect all the region vertex coordinates of the clockwise / counterclockwise vertex coordinate sequence in the corresponding clockwise / counterclockwise order to form a corresponding first ground area; and record each first grid in the first grid network that intersects with the first ground area as a corresponding first screening grid; and record the grid key-value pairs corresponding to each first screening grid in the H3 grid hash table as corresponding sub-network grid key-value pairs; and form a corresponding sub-network grid hash table from all the obtained sub-network grid key-value pairs; and use the sub-network grid hash table as the corresponding instruction feedback data; Step 57: Feedback the command feedback data obtained this time to the current user.
6. A device for executing the method for processing grid spatiotemporal data according to any one of claims 1 to 5, characterized in that: The device comprises: a grid spatiotemporal data construction module, a grid spatiotemporal data update module and a grid spatiotemporal data application module; The grid spatiotemporal data construction module is used to grid the designated road network area according to the H3 grid format to obtain the corresponding first grid network; and to count the total number of H3 grids at the bottom layer of the first grid network to obtain the corresponding total number of grids N; and to create a corresponding grid spatiotemporal data table for the first grid network, which is recorded as an H3 grid hash table; and to store the H3 grid hash table based on a type of distributed database; wherein, the first grid network includes N first grids; each first grid is a bottom-level H3 grid; each first grid corresponds to a grid identifier S; the H3 grid hash table includes N grid key-value pairs; the grid key-value pairs correspond one-to-one to the first grids; the key field of the grid key-value pair is the corresponding grid identifier S, and the value field is the corresponding grid linked list; each grid linked list is a first-in-first-out circular queue linked list with a fixed queue size, and is composed of queue records with a preset total number of queue records M; the queue record is composed of a corresponding timestamp T and a grid object set; the distributed database at least includes a Redis database; The grid spatiotemporal data update module is used to perform a queue record rolling addition process on all the grid linked lists of the H3 grid hash table at a preset rolling interval Δt; and to perform a grid object update process on the H3 grid hash table based on the real-time traffic feedback of the designated road network area; The grid spatiotemporal data application module is used to, upon receiving a traffic information query instruction input by a user, perform a grid spatiotemporal data query on the H3 grid hash table based on the traffic information query instruction and perform traffic information analysis based on the query result to obtain corresponding instruction feedback data and feed it back to the current user; wherein, the traffic information query instruction includes a query period, a query type and a query parameter; the query type includes at least a traffic participant trajectory query, a vehicle flow statistics query and a sub-grid network query; when the query type is a traffic participant trajectory query, the query parameter is a query object identifier; when the query type is a vehicle flow statistics query, the query parameter is a query grid identifier; when the query type is a sub-grid network query, the query parameter is a clockwise / counterclockwise vertex coordinate sequence of an irregular ground area, and the clockwise / counterclockwise vertex coordinate sequence is formed by sequentially sorting the coordinates of multiple regional vertices in a clockwise / counterclockwise order.
7. An electronic device, characterized in that: include: memory, processors, and transceivers; The processor is configured to be coupled to the memory, read and execute instructions in the memory, so as to implement the method according to any one of claims 1 to 5; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and when the computer instructions are executed by a computer, the computer is caused to execute the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Efficient spatial nearest neighbor query method for highway networks
CN103559213A
Method for realizing large-scale dynamic target visualization by utilizing grids under real-time environment
CN104199949A