Learning index-oriented road network dual-granularity depth-first ordering method
By constructing a directed road network map and calculating direction vectors, a dual-granularity depth-first sorting method is used to solve the problem of insufficient sorting continuity in road network trajectory data indexing, and to realize efficient continuous mapping and querying of trajectory data.
Patent Information
- Application Number
- CN202511354767.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-22
- Publication Date
- 2026-01-09
AI Technical Summary
Existing road network trajectory data indexing methods suffer from insufficient sorting continuity, loss of direction information, and low query efficiency on directed road networks, making it difficult to effectively support trajectory data processing with high-density nodes.
A dual-granularity depth-first search method for road networks, oriented towards learning-based indexes, is adopted. By constructing a directed road network graph, calculating direction vectors, and performing dual-granularity depth-first search, combined with sorting strategies at the road and road segment granularities, continuous mapping of trajectory points and efficient querying are achieved.
It improves the continuity of trajectory data in the index and query efficiency, reduces the dispersion of trajectory points, conforms to the actual driving route selection pattern, and reduces the complexity of index construction and query.
Smart Images

Figure CN121297876A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer applications, specifically relating to a dual-granularity depth-first sorting method for road networks oriented towards learning-type indexes. Background Technology
[0002] In recent years, with the development of mobile devices and sensor technology, a large amount of spatiotemporal trajectory data has been collected, stored, and used in real time for scenarios such as traffic analysis, user behavior modeling, and trajectory querying. In order to improve the query efficiency of large-scale spatiotemporal trajectory data, researchers generally adopt strategies such as spatial dimensionality reduction and index structure optimization to map high-dimensional trajectory points into one-dimensional space, so as to facilitate continuous data storage and fast retrieval.
[0003] In this process, the mapping between trajectory points and underlying roads becomes crucial. This requires a reasonable sorting of roads in the underlying directed road network to ensure that the trajectory points maintain the continuity of their original trajectories as much as possible after dimensionality reduction mapping. Currently, the sorting and indexing of directed road networks largely rely on graph traversal algorithms and path planning strategies.
[0004] Regarding path planning strategies, Chinese patent application ZL2013103060014 discloses a navigation method and apparatus based on digital road network maps and depth-first search (DFS), which abstracts the digital map into a graph model and uses DFS for path planning. While this method explored the application of DFS in navigation relatively early, its path enumeration method is random and difficult to maintain determinism in large-scale road networks. Chinese patent application ZL 2018102763299 discloses a method, apparatus, and system for determining reachable paths between two points. This method proposes a path search method based on adjacency and reachability matrices, combined with DFS for pruning. This scheme can filter out unreachable nodes, but in complex road networks, it still easily suffers from excessive search depth and insufficient path continuity.
[0005] Regarding trajectory data processing strategies, Chinese patent application ZL 2016101842044 discloses a trajectory data processing method that uses incremental fitting vectors for trajectory compression, simplifying trajectory data by avoiding redundant calculations. However, this method mainly focuses on data compression, neglecting the continuous mapping of trajectory points in the index structure, making it difficult to support efficient queries. Chinese patent application ZL2015104547036 discloses an online GPS trajectory data compression algorithm based on offset calculation, proposing a trajectory compression technique with real-time key point correction. This method can identify key points in real time during trajectory acquisition, but it relies too heavily on the geometric features of points and does not adequately consider the direction and connectivity of the trajectory in the road topology, resulting in limited index performance.
[0006] In summary, existing methods suffer from high time complexity, uneven search depth, and discontinuous result sequences when processing trajectory data on directed road networks with high-density nodes, making it difficult to effectively support the continuous mapping and access efficiency of trajectory data in the index structure. Summary of the Invention
[0007] To address the issues of insufficient sorting continuity and loss of direction information in the existing technology for constructing trajectory indexes in directed road networks, this application proposes a dual-granularity depth-first sorting method for road networks oriented towards learning-based indexes, combining path planning strategies and trajectory data processing strategies. This application reduces the dispersion of trajectory points when storing them, thereby improving the continuity of trajectory data in the index and query efficiency.
[0008] To achieve the above objectives, the present invention is implemented through the following technical solution:
[0009] This application presents a two-granularity depth-first sorting method for road networks oriented towards learning-based indexes. The method specifically includes the following steps:
[0010] Step 1: Construct a directed road network graph: Based on the directed road network data, extract information on intersections, directed road segments between intersections, and directed roads to which the directed road segments belong. A directed road contains multiple directed road segments. Construct a directed road network graph with intersections as nodes and directed road segments between intersections as edges.
[0011] Step 2: Construct a mapping table: Traverse each directed road segment, calculate the direction vector based on the latitude and longitude coordinates of the intersection of the start and end points of the directed road segment, and construct a mapping table from road segments to direction vectors;
[0012] Step 3: Use dual-granularity depth-first search to visit and traverse roads according to the principle of minimum directional offset to achieve overall directed road network sorting: Based on an explicit stack, the downward exploration is performed in units of directed roads. That is, when a directed road segment is visited, the entire directed road to which the directed road segment belongs is marked as visited. During the downward exploration, the road with the smallest angle with the current road segment and which has not been visited is selected as the next traversal target. During the backtracking process, the backward movement is performed layer by layer in units of directed road segments.
[0013] Step 4: Conversion of high-dimensional trajectory to one-dimensional road axis: Sort the directed road segments according to the traversal order in Step 3, construct a one-dimensional road axis based on the road segment sorting result, and project the spatial trajectory points containing longitude and latitude to the corresponding one-dimensional positions to realize the conversion of high-dimensional trajectory to one-dimensional road axis.
[0014] A further improvement of this application is that, in step 1, a directed road network graph is constructed based on the directed road network data, specifically including the following steps:
[0015] Step 1.1: Extract the starting and ending intersection node numbers, the directed roads to which the directed road segment belongs, and the segment number, length, and latitude and longitude coordinates of the starting and ending intersection points of each directed road segment from the directed road network data;
[0016] Step 1.2: Traverse all directed road segments. For each directed road segment, check whether the starting point of each directed road segment outside the directed road segment is the ending point of the directed road segment. If so, add the directed road segment to the list of adjacent road segments of the directed road segment and construct a directed road network graph with intersections as nodes and directed road segments between intersections as edges.
[0017] A further improvement in this application is that, in step 2, constructing the mapping table from road segments to direction vectors specifically involves: traversing all directed road segments according to their road segment numbers, and obtaining the latitude and longitude (London, Latitude, Longitude, and Termination) of the start and end nodes of each directed road segment. start lat start ) and (lon end lat end ), calculate the direction vector of this directed road segment as (lon start -lon end ,lat start -lat end Save the data and construct a mapping table from road segments to direction vectors.
[0018] A further improvement in this application is that step 3 specifically includes the following steps:
[0019] Step 3.1: Adopt a depth-first strategy with "directed roads" as the basic unit: First, push any unvisited directed road segment onto the stack. When the stack is not empty, pop the top directed road segment from the stack. If the directed road segment has not been visited, visit the directed road segment and mark the entire directed road to which the directed road segment belongs as visited, thus realizing the exploration process based on roads.
[0020] Step 3.2: After accessing a directed road, for that directed road, obtain the direction vectors of all directed road segments through the constructed mapping table of road segments to direction vectors. Starting from the initial directed road segment, calculate the direction offset angle between each directed road segment and all its adjacent forward directed road segments layer by layer. The formula for calculating the angle θ between directed road segments is:
[0021]
[0022] in, This represents the direction vector of the current directed road segment. Let be the direction vector of the adjacent road segment of this directed road segment. It is the inner product of the direction vector of the current directed road segment and the direction vector of the adjacent road segment. Let be the magnitude of the direction vector of the current directed road segment. The magnitude of the direction vector of the adjacent road segment;
[0023] Step 3.3: Push all unvisited adjacent road segments onto the stack layer by layer. For adjacent roads on the same layer, push them onto the stack in descending order of the angle between the directed road segments to ensure that the road segment with the smallest traversal direction offset is popped first. If multiple adjacent road segments have the same angle, push them onto the stack in descending order of road number to ensure that the popped road segment numbers are arranged in ascending order and to achieve the determinism of the sorting result.
[0024] Step 3.4: If the current directed road segment has no unvisited adjacent road segments to continue expanding, the backtracking process is triggered, and the stack popping operation continues. Based on the connection relationship between directed road segments within the directed road, the stack popping operation is performed layer by layer on a directed road segment basis to ensure the integrity of the traversal.
[0025] A further improvement in this application is that step 4 specifically includes the following steps:
[0026] Step 4.1: Save the directed road segments in traversal order to a road segment list, and denote the sorted directed road segment list as [road0, road1…road… n ], where road i For the i-th directed road segment, i = 1, 2, 3, ..., n, match the trajectory points containing longitude and latitude to the corresponding road segments. Then each trajectory point obtains the directed road segment number it is in at the current time and the distance from the starting point of the directed road segment it is in.
[0027] Step 4.2: Calculate the one-dimensional position value after dimensionality reduction using the formula, denoted as position:
[0028]
[0029] Where len(road) i (road segment) i The length of the trajectory point, j is the road segment number at the current moment, and distance. j The distance of the trajectory point from the road segment at the current moment. j The distance from the starting point converts the two-dimensional trajectory point into a one-dimensional position value.
[0030] The beneficial effects of this application are:
[0031] This application employs a dual-granularity depth-first traversal strategy during the sorting process. In the downward exploration phase, the entire directed road is visited as a unit; in the backtracking phase, road segments are traversed layer by layer, thus achieving an organic combination of road-level and segment-level granularity. This method ensures that segment sorting is performed on the basis of road-level sorting, avoiding the problem of discontinuous segment numbers within the same road that occurs when sorting solely on a segment-level basis.
[0032] In terms of sorting decisions, this application introduces the concept of directional offset angle. By calculating the angle between the directional vectors of the current directional road segment and its adjacent road segments, the adjacent road with the smallest directional offset is accessed first, thereby ensuring the consistency of direction of subsequent trajectory data points after dimensionality reduction, which is in line with the actual driving principle of taking fewer detours.
[0033] Regarding data dimensionality reduction, this application constructs a one-dimensional road segment axis based on the sorting results and projects two-dimensional trajectory points onto the corresponding road segment locations. Through this mechanism, the two-dimensional trajectory point sequence is transformed into a continuous one-dimensional sequence, reducing the complexity of the subsequent index construction process. Attached Figure Description
[0034] Figure 1 This is a flowchart of the directed road network sorting method of the present invention.
[0035] Figure 2 This is a flowchart illustrating the construction process of the mapping table from road segments to direction vectors in this invention.
[0036] Figure 3 This is a trajectory diagram of an embodiment of the present invention. Detailed Implementation
[0037] The following will disclose embodiments of the present invention. For clarity, many practical details will be described in the following description. However, it should be understood that these practical details are not intended to limit the present invention. That is, in some embodiments of the present invention, these practical details are not essential.
[0038] A directed road network consists of intersections and roads comprising multiple segments, each segment being ordered and possessing a unique sequence number. For example... Figure 2 As shown, this embodiment of the invention has a total of 13 directed road segments, denoted as Si, i = 1, 2, 3...13, and road network intersections are denoted as Ni, i = 1, 2, 3...14. The specific road network information is shown in the table below:
[0039] Road section number Start and End Road Road segment length (meters) S1 N1,N2 Road 1 300 S2 N2, N3 Road 1 100 S3 N3, N4 Road 1 200 S4 N2, N5 Road 2 500 S5 N5, N6 Road 2 300 S6 N6, N7 Road 2 150 S7 N3, N8 Road 3 300 S8 N8, N9 Road 3 250 S9 N7, N10 Road 4 180 S10 N10, N11 Road 4 200 S11 N2, N12 Road 5 300 S12 N12, N13 Road 5 100 S13 N3, N14 Road 6 150
[0040] like Figure 1 As shown, this invention is a dual-granularity depth-first sorting method for road networks oriented towards learning-based indexes, comprising the following steps:
[0041] Step 1: Based on the directed road network data, extract the intersections, the directed road segments between intersections and the road information to which the road segments belong, and construct a directed road network graph with intersections as nodes and directed road segments between intersections as edges.
[0042] After constructing the directed road network graph, we iterate through all directed road segments. For each directed road segment, we check if the starting point of every other directed road segment is the ending point of that road segment. If the condition is met, we add it to the list of adjacent road segments. The final mapping table is as follows:
[0043] {S1:[S2,S4,S11],S2:[S3,S7,S13],S4:[S5],S5:[S6],S6:[S9],S7:[S8],
[0044] S9:[S10],S11:[S12]}
[0045] Where S1:[S2,S4,S11] means that the forward adjacent road segments of road segment S1 are S2, S4 and S11.
[0046] Step 2: Traverse the directed road segments, calculate the direction vector based on the latitude and longitude coordinates of the starting and ending intersections of the road segments, and construct...
[0047] A mapping table from road sections to direction vectors;
[0048] To simplify calculations, this embodiment uses simplified intersection latitude and longitude coordinates. In addition, the length of the road segment...
[0049] There is no actual relationship between the degree and the latitude and longitude of its starting and ending points. The latitude and longitude data of the intersection are shown in the table below:
[0050]
[0051] The final mapping table can be obtained as follows:
[0052] {S1:(100,0),S2:(100,0),S3:(100,0),S4:(0,100),S5:(0,100),S6:(0,100),S7:(0,100), S8:(100,100),S9:(-100,0),S10:(-100,0),S11:(0,-100),S12:(0,-100),S13:(100,-100)}
[0053] Where S1:(100,0) indicates that the direction vector of road segment S1 is (100,0).
[0054] Step 3: Implement a dual-granularity depth-first sorting method for road networks based on an explicit stack for learning-oriented indexes, specifically including the following steps:
[0055] Step 3-1: Initialize the stack Stack:[] and the sorted list of road segments Result:[], where the last element of Stack is considered the top of the stack. First, push road segment S1 onto the stack, at which point the stack state is Stack:[S1]. When the stack is not empty, pop road segment S1 from the stack, and simultaneously pop all road segments under the entire directed road 1 to which S1 belongs.
[0056] It is then marked as "visited" and added to Result, at which point Result: [S1, S2, S3].
[0057] Step 3-2: After visiting directed road 1, for this road, starting from the initial road segment S1, calculate the directional offset angle between each road segment and all its adjacent forward directed road segments layer by layer. For S1, from the adjacent road segment mapping table, we can know that all its adjacent road segments are [S2, S4, S11]. Calculate the directional offset angle θ between S1 and S2 according to the formula:
[0058]
[0059] Similarly, the directional offset angle between S1 and S4 is 90°, and the directional offset angle between S1 and S11 is also 90°. At this point, the processing of this layer ends, and we move on to the next layer, S2, for calculation. We can obtain that the directional offsets of S2 with its adjacent roads S3, S7, and S13 are 0°, 90°, and 45°, respectively. At this point, the processing of this layer is complete, and we move on to layer S3. S3 has no adjacent roads, and this step is complete.
[0060] Step 3-3: Push all unvisited adjacent road segments onto the stack layer by layer. For adjacent roads on the same layer, push them onto the stack in descending order of θ. Note that in layer S1, S1, S4, and S11 have the same directional offset angle. At this time, the road with the larger road number, S11, should be pushed onto the stack first, followed by S4 and S2 in sequence. The stack state at this time is Stack:[S11,S4,S2,S7,S13,S3].
[0061] Steps 3-4: At this point, directed road 1 has been traversed, triggering the backtracking process. Continue executing the stack popping operation, skipping the visited road segment S3, and then backtracking to road segment S13. Finally, the complete process of this instance is shown in the table below:
[0062]
[0063]
[0064] Step 4: Construct a one-dimensional road axis based on the road sorting results, thereby projecting spatial trajectory points containing longitude and latitude to their corresponding one-dimensional locations. This specifically includes the following steps:
[0065] Step 4-1: Using a learning-oriented, dual-granularity depth-first sorting method for road networks, road segments are saved to a road segment list in traversal order. According to the aforementioned algorithm, the sorted road segment list is [S1, S2, S3, S13, S7, S8, S4, S5, S6, S9, S10, S11, S12]. Let road... i (i = 1, 2, 3...n) represents the i-th road segment in the road segment list. We will now consider 8 trajectory points for illustration. In this embodiment, the specific latitude and longitude coordinates of the trajectory points can be ignored; the key is to accurately match the trajectory points to the corresponding road segments. This application can use existing road network matching technology to match trajectory points containing longitude and latitude to the corresponding road segments. Each trajectory point then obtains the current road segment number and the distance from the starting point of its current road segment. The matching information for the 8 trajectory points is shown in the table below:
[0066] trajectory points Section of road Distance from the start of the road segment (meters) p0 S1 150 p1 S3 80 p2 S13 75 p3 S4 200 p4 S6 100 p5 S9 90 p6 S11 180 p7 S12 60
[0067] Step 4-2: Calculate the location value using the formula. Taking p2 as an example, according to the table above, the road segment where p2 is located is S13, i.e., road3. Therefore, the location value of p2 can be calculated.
[0068]
[0069] By analogy, all two-dimensional trajectory points can be converted into one-dimensional position values, achieving effective dimensionality reduction from high-dimensional space to one dimension. This lays the foundation for subsequent trajectory data indexing and query optimization. The final results are shown in the table below:
[0070] trajectory points position p0 150 p1 480 p2 675 p3 1500 p4 2200 p5 2340 p6 2810 p7 2990
[0071] This application adopts a dual-granularity depth-first sorting strategy for road networks oriented towards learning-based indexes, which ensures the continuity and directional consistency of road network sorting. Through a road-by-road exploration and segment-by-segment backtracking mechanism, the integrity and determinism of the traversal process are ensured. Adjacent roads with smaller directional offset angles are prioritized, which conforms to the actual driving path selection rules. This effectively reduces the dispersion of trajectory points after one-dimensional mapping and improves the spatial locality and query efficiency of trajectory data in the index structure.
[0072] The above description is merely an embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the present invention should be included within the scope of the claims of the present invention.
Claims
1. A dual-granularity depth-first sorting method for road networks oriented towards learning-based indexes, characterized in that: The road network dual-granularity depth-first sorting method specifically includes the following steps: Step 1: Construct a directed road network graph: Based on the directed road network data, extract information on intersections, directed road segments between intersections, and directed roads to which the directed road segments belong, and construct a directed road network graph with intersections as nodes and directed road segments between intersections as edges; Step 2: Construct a mapping table: Traverse each directed road segment, calculate the direction vector based on the latitude and longitude coordinates of the intersection of the start and end points of the directed road segment, and construct a mapping table from road segments to direction vectors; Step 3: Use dual-granularity depth-first search to visit and traverse roads according to the principle of minimum directional offset to achieve overall directed road network sorting: Based on an explicit stack, the downward exploration is performed in units of directed roads. That is, when a directed road segment is visited, the entire directed road to which the directed road segment belongs is marked as visited. During the downward exploration, the road with the smallest angle with the current road segment and which has not been visited is selected as the next traversal target. During the backtracking process, the backward movement is performed layer by layer in units of directed road segments. Step 4: Conversion of high-dimensional trajectory to one-dimensional road axis: Sort the directed road segments according to the traversal order in Step 3, construct a one-dimensional road axis based on the road segment sorting result, and project the spatial trajectory points containing longitude and latitude to the corresponding one-dimensional positions to realize the conversion of high-dimensional trajectory to one-dimensional road axis.
2. The road network dual-granularity depth-first sorting method for learning-oriented indexing according to claim 1, characterized in that: In step 1, a directed road network graph is constructed based on the directed road network data, specifically including the following steps: Step 1.1: Extract the starting and ending intersection node numbers, the directed roads to which the directed road segment belongs, and the segment number, length, and latitude and longitude coordinates of the starting and ending intersection points of each directed road segment from the directed road network data; Step 1.2: Traverse all directed road segments. For each directed road segment, check whether the starting point of each directed road segment outside the directed road segment is the ending point of the directed road segment. If so, add the directed road segment to the list of adjacent road segments of the directed road segment and construct a directed road network graph with intersections as nodes and directed road segments between intersections as edges.
3. The road network dual-granularity depth-first sorting method for learning-oriented indexing according to claim 1, characterized in that: In step 2, constructing the mapping table from road segments to direction vectors specifically involves: traversing all directed road segments based on their road segment numbers, and obtaining the latitude and longitude (London, Latitude, Longitude, and Geometry) of the start and end nodes of each directed road segment. start lat start ) and (lon end ,lat end ), calculate the direction vector of this directed road segment as (lon start -lon end ,lat start -lat end Save the data and construct a mapping table from road segments to direction vectors.
4. The road network dual-granularity depth-first sorting method for learning-oriented indexing according to claim 1, characterized in that: Step 3 specifically includes the following steps: Step 3.1: Adopt a depth-first strategy with "directed roads" as the basic unit: First, push any unvisited directed road segment onto the stack. When the stack is not empty, pop the top directed road segment from the stack. If the directed road segment has not been visited, visit the directed road segment and mark the entire directed road to which the directed road segment belongs as visited, thus realizing the exploration process based on roads. Step 3.2: After accessing a directed road, for that directed road, obtain the direction vectors of all directed road segments through the constructed mapping table of road segments to direction vectors. Starting from the initial directed road segment, calculate the direction offset angle between each directed road segment and all its adjacent forward directed road segments layer by layer. The formula for calculating the angle θ between directed road segments is: in, This represents the direction vector of the current directed road segment. Let be the direction vector of the adjacent road segment of this directed road segment. It is the inner product of the direction vector of the current directed road segment and the direction vector of the adjacent road segment. Let be the magnitude of the direction vector of the current directed road segment. The magnitude of the direction vector of the adjacent road segment; Step 3.3: Push all unvisited adjacent road segments onto the stack layer by layer. For adjacent roads on the same layer, push them onto the stack in descending order of the angle between the directed road segments to ensure that the road segment with the smallest traversal direction offset is popped first. If multiple adjacent road segments have the same angle, push them onto the stack in descending order of road number to ensure that the popped road segment numbers are arranged in ascending order and to achieve the determinism of the sorting result. Step 3.4: If the current directed road segment has no unvisited adjacent road segments to continue expanding, the backtracking process is triggered, and the stack popping operation continues. Based on the connection relationship between directed road segments within the directed road, the stack popping operation is performed layer by layer on a directed road segment basis to ensure the integrity of the traversal.
5. The road network dual-granularity depth-first sorting method for learning-oriented indexing according to claim 1, characterized in that: Step 4 specifically includes the following steps: Step 4.1: Save the directed road segments in traversal order to a road segment list, and denote the sorted directed road segment list as [road0, road1…road… n ], where road i For the i-th directed road segment, i = 1, 2, 3, ..., n, match the trajectory points containing longitude and latitude to the corresponding road segments. Then each trajectory point obtains the directed road segment number it is in at the current time and the distance from the starting point of the directed road segment it is in. Step 4.2: Calculate the one-dimensional position value after dimensionality reduction using the formula, denoted as position: Where len(road) i (road segment) i The length of the trajectory point, j is the road segment number at the current moment, and distance. j The distance of the trajectory point from the road segment at the current moment. j The distance from the starting point converts the two-dimensional trajectory point into a one-dimensional position value.