OSM road data simplification method based on multi-lane information recognition on the same road
By identifying and simplifying multi-lane information in OSM road data, and utilizing graph data structures and depth-first search methods, the problems of topological errors and geometric deviations in existing technologies are resolved, achieving more accurate and efficient road network simplification, which is suitable for urban and rural planning and traffic analysis.
Patent Information
- Application Number
- CN202411031115.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2044-07-30
AI Technical Summary
Existing OSM road data simplification methods are prone to introducing topological errors and losing key topological information when processing multi-lane areas. They also have large geometric shape deviations and cannot accurately reflect the actual road structure, affecting the accuracy and efficiency of urban and rural planning and traffic analysis.
By identifying multiple lanes on the same road, using graph data structures and depth-first search methods, lane segments are merged, minimum loops are identified and simplified, key topological information is retained, and geometric optimization is performed to ensure the topological structure and geometric accuracy of the road network.
It improves the accuracy and applicability of road network simplification, retains key topological information of complex road structures, reduces redundant data, and improves the efficiency and reliability of urban and rural planning and traffic analysis.
Smart Images

Figure CN118747963B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a road data simplification method, in particular to an OSM road data simplification method based on identification of multi-lane information on the same road. Background Art
[0002] Currently, crowdsourced geographic information and open map data, such as OpenStreetMap (OSM), are widely used in urban computing. However, open road network data like OSM typically collects and stores lanes as their fundamental spatial entity. Each lane is treated as an independent line segment and carries lane-level attribute information. This differs from the abstract model used in urban analysis, which uses the road centerline to represent the collection of lanes on both sides of the road. Directly using open road network data like OSM can lead to duplicate calculations for multi-lane areas such as arterial roads, elevated roads, and overpasses.
[0003] To meet the needs of urban computing, existing road simplification methods primarily focus on the geometric characteristics of roads. One approach uses algorithms like clustering and outlier detection to merge similar segments into a single road. Other methods, such as OSMnx, leverage the topological relationships and connectivity between road segments, analyzing the structural characteristics of the road network to infer the relationships between segments. This allows for the extraction of the skeleton structure of complex road networks, such as arterial roads, elevated roads, and overpasses.
[0004] However, existing technologies still face the following problems and challenges in adapting to the needs of urban and rural planning:
[0005] 1. Focusing on geometric features while ignoring road functions and topological properties, which can easily introduce topological errors: Existing methods have difficulty accurately identifying and processing line segments of different lanes on the same road. They may mistakenly merge line segments from different roads during simplification, introducing topological errors that destroy the topological structure of the road network and affect the accuracy of subsequent analysis.
[0006] 2. Oversimplification of complex road sections leads to loss of key topological information and distortion of network structure: Existing methods (such as OSMnx) often merge multiple adjacent intersections into one node when processing complex intersections, ignoring the connection relationship and turning restrictions between intersections. This leads to distortion of the simplified road network and fails to accurately depict the actual road structure.
[0007] 3. Ignoring the optimization of the shape of the merged line segments: Existing methods often ignore the optimization of the shape of the merged road segments, resulting in large deviations in the geometric shape of the simplified results, affecting the geometric accuracy of the road network. Summary of the Invention
[0008] The purpose of the present invention is to provide an OSM road data simplification method based on the identification of multiple lanes on the same road.
[0009] The purpose of the present invention can be achieved by the following technical solutions:
[0010] A method for simplifying OSM road data based on identification of multiple lanes on the same road, comprising:
[0011] Step S1: Obtain OSM lane data of the target area and convert it into a graph data structure to obtain an information graph;
[0012] Step S2: Traverse all lanes in the information graph, merge lanes with the same name into one road, and for each road, extract all nodes connected to it from the information graph and construct a subgraph;
[0013] Step S3: For each subgraph, the nodes and lanes to be deleted are screened out according to the pre-configured first rule, and a preliminarily simplified subgraph is obtained after deletion;
[0014] Step S4: Determine whether there is a preliminarily simplified subgraph with the number of nodes greater than or equal to 2. If yes, execute step S5; otherwise, execute step S7.
[0015] Step S5: Select a preliminarily simplified subgraph with the number of nodes greater than or equal to 2, and find the minimum cycle by using a stack-based depth-first search method;
[0016] Step S6: Determine the minimum loop and determine whether the minimum loop found is a road area. If so, simplify the minimum loop into a new lane, update the subgraph, and return to step S4.
[0017] Step S7: Update the information graph based on the current sub-graph.
[0018] The step S1 comprises:
[0019] Step S1-1: Obtain OSM lane data of the target area;
[0020] Step S1-2: Obtain the intersection points of all lanes based on the OSM lane data of the target area, and merge the intersection points of different lanes corresponding to the same road to obtain nodes;
[0021] Step S1-3: Storing information about each node and the lanes connected to each node, and storing information about each lane and the nodes connected to each lane.
[0022] The processing of a single subgraph in step S3 includes:
[0023] Step S3-1: traverse all lanes in the subgraph and select all lanes connected to only one node as lanes to be deleted;
[0024] Step S3-2: All nodes connected to the lane to be deleted are considered as nodes to be deleted;
[0025] Step S3-3: Delete all lanes and nodes to be deleted to obtain a preliminarily simplified subgraph.
[0026] The method of finding the minimum cycle by using a stack-based depth-first search method includes:
[0027] Step S5-1: Construct node access record graph R i , used to record the access status and loop length of the node;
[0028] Step S5-2: Create loop storage list C i , used to store all the loops found;
[0029] Step S5-3: In the subgraph, select the node n with the largest number of connections best As a starting point, create an empty stack S i , n best Push it into the stack and access the record graph R at the node i Mark node n best Has been visited;
[0030] Step S5-4: When stack S i If it is not empty, take the top node n of the stack top , find all its i The adjacent nodes n marked as unvisited next , stored in the adjacent node set N next middle;
[0031] Step S5-5: Traverse N next Each adjacent node n in next , when the adjacent node n next Not on stack S i or equal to the top node n top , and stack S i If the node status is not visited, then n next Push onto stack S i , in stack S i Mark n next Has been visited and updated n next In stack S i Otherwise, proceed to step 8;
[0032] Step S5-6: When the adjacent node n next Equal to the top node n top , and stack S i If the length is greater than or equal to 2, it means a loop is formed, and the loop c is obtained. i ={n top,...,N next Otherwise, continue to execute step S5-5 and traverse the next adjacent node;
[0033] Step S5-7: For the current stack S i , handle according to the following situations:
[0034] If the stack S i The length of is equal to 3, and there are multiple repeated segments between the first node and the second node in the stack, then the current ring c i and its total path length are added to the loop storage list C i , continue to execute steps S5-8;
[0035] If the stack S i If the length of is equal to 3, and there is only one edge between the first node and the second node in the stack, then continue to step S5-8;
[0036] If the stack S i If the length of the ring is greater than 3, the current ring c i and its total path length are added to the loop storage list C i , continue to execute steps S5-8;
[0037] Step S5-8: Move the top node n to the top From stack S i Pop up and reset the node access record graph R i The status and loop length of all adjacent nodes of the node;
[0038] Step S5-9 repeats steps S5-4 to S5-8 until the stack S i If it is empty, the depth-first search ends;
[0039] Step S5-10: Store list C in loop i In the example, the cycle with the least number of nodes is selected as the minimum cycle of the subgraph.
[0040] The step of determining the minimum loop and judging whether the found minimum loop is a road area includes:
[0041] Step S6-1-1: Store list C for loop i Each loop c i , calculate loop c i The circularity r i , the circularity calculation formula is:
[0042]
[0043] Among them, S i is the total area of the loop enclosed area, L i is the total length of the loop;
[0044] If the circularity r i is less than r0, then the loop c i If the conditions are met, keep the loop in List C. i middle;
[0045] If the circularity r i is greater than or equal to r0, then the loop c i Does not meet the conditions, remove the list from list C i Delete it and continue to traverse other loops in the list;
[0046] Step S6-1-2: Store list C in loop i In , the cycle with the least number of nodes is selected as the minimum cycle of the subgraph;
[0047] The minimum loop is simplified into a new lane, including:
[0048] Step S6-2-1: Find the two largest turning nodes n of the minimum loop s and n e , respectively along the node n s To node n e , and along the e To node n s The vector direction traverses all loop nodes and obtains two node sequences R L and R S ;
[0049] Step S6-2-2: For the node sequence R L All nodes on the node sequence R S Find the nearest node and get the midpoint of the two points as the waypoint;
[0050] Step S6-2-3: Connect all waypoints to obtain a new lane, and replace the minimum loop with the new lane and waypoints.
[0051] The two largest turning nodes n of the minimum loop are found s and n e ,for:
[0052] For each node in the minimum switch, calculate the angle between its adjacent line segments and the two nodes with the largest angles as the maximum turning nodes n. s and n e .
[0053] In step S6-2-1, the node sequence with the larger length is used as the node sequence R L , another node sequence as node sequence R S .
[0054] The step S6-2-2 specifically includes:
[0055] Step S6-2-2-1: For node sequence R S As a benchmark, traverse the node sequence R L Each node n in j ;
[0056] Step S6-2-2-2: In node sequence R S Find the distance n j The nearest node n k , n j and n k The midpoint of is the waypoint;
[0057] Step S6-2-2-3: Determine the node sequence R S There is a skipped node n in skip If yes, then determine the skipped node n skip Is it a waypoint? If yes, execute step S6-2-2-4. Otherwise, find node n. skip In the node sequence R L The nearest point in the middle is calculated as the passing point.
[0058] Step S6-2-2-4: Determine whether the node sequence R is completed L Traverse all nodes in, if yes, then all the passing points are sorted according to their node sequence R L The waypoint sequence is obtained by sorting in the order in , otherwise, return to step S6-2-2-2 to continue traversing.
[0059] The step S6-2-2 further includes:
[0060] Step S6-2-2-5: For any two adjacent waypoints in the obtained waypoint sequence, calculate the distance between them:
[0061] If the distance between two adjacent waypoints is less than the threshold β, the two nodes are merged into one waypoint;
[0062] If the distance between two adjacent waypoints is greater than or equal to the threshold β, nodes ql and ql+1 are retained without merging.
[0063] The threshold β is 20 meters.
[0064] Compared with the prior art, the present invention has the following beneficial effects:
[0065] 1. Improved the accuracy and applicability of road network simplification. This application comprehensively utilizes the geometric, topological and functional attribute characteristics of roads, and proposes a novel road similarity measurement method that can accurately identify line segments of different lanes on the same road. Unlike existing methods that mainly focus on geometric features, the similarity measurement method of this application fully considers the functional attributes and topological connectivity of roads, ensuring that the simplification process does not introduce topological errors. At the same time, this application performs geometric optimization on the simplified road network data, thereby improving the geometric accuracy of the simplified results. Therefore, the road network obtained by this application is more accurate in topological structure and geometric shape, and can better meet the needs of urban and rural planning, traffic analysis and other fields;
[0066] 2. It preserves the key topological information of complex road structures to the greatest extent possible. For complex multi-lane areas such as main roads, elevated roads, and overpasses, existing topology extraction methods often adopt overly rough strategies, resulting in the loss of key topological information. This application proposes a special topology extraction and preservation strategy that, while identifying and simplifying multi-lane information, preserves key topological information such as road connectivity and traffic restrictions as much as possible. The simplified road network can accurately reflect the actual road structure and traffic rules, greatly improving its usability and reliability in practical applications;
[0067] 3. Improved the efficiency of road network analysis. By identifying and aggregating line segments of different lanes on the same road, this application significantly reduces redundant data, making the simplified road network data more refined. The computational complexity and time consumption of various network analyses conducted on this basis, such as shortest path calculation and accessibility analysis, will also be greatly reduced. Therefore, this application not only further improves the applicability of road network data in the field of urban and rural planning, but also indirectly improves the efficiency of subsequent analysis;
[0068] 4. Simplifies the use and maintenance of road network data. The road network simplification method provided in this application automates the processing of raw OSM data into high-quality road networks suitable for specific areas, reducing the workload of manual editing and correction. For data users, the simplified road network retains key information while having a clearer structure and smaller data size, making it easier to understand, process, and apply. BRIEF DESCRIPTION OF THE DRAWINGS
[0069] Figure 1 Schematic diagram of the main steps of the method of the present invention;
[0070] Figure 2 This is a schematic diagram of an OSM source data;
[0071] Figure 3 A schematic diagram of the relationship between the information graph and the subgraph;
[0072] Figure 4 Schematic diagram of the subgraph simplification process;
[0073] Figure 5 This is a simplified state diagram of the information graph. DETAILED DESCRIPTION
[0074] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0075] A method for simplifying OSM road data based on identifying multiple lanes on the same road, such as Figure 1 As shown, including:
[0076] Step S1: Obtain OSM lane data of the target area and convert it into a graph data structure to obtain an information graph G, including:
[0077] Step S1-1: Obtain OSM lane data of the target area;
[0078] Step S1-2: Obtain the intersection points of all lanes based on the OSM lane data of the target area, and merge the intersection points of different lanes corresponding to the same road to obtain nodes;
[0079] Step S1-3: Storing information about each node and the lanes connected to each node, and storing information about each lane and the nodes connected to each lane.
[0080] Specifically, the graph data G is defined to describe the topological structure of the urban road network in the OSM road data, where G = (N, E), N = (N id ,V N ,F N ), E=(E id ,V E ,F E ). Consider each intersection as a node n, and record all nodes as a set N, where n1, n2, ..., n m ∈N; each road segment is regarded as a line segment e, and all line segments are recorded as a set E, where e1, e2, ..., e p ∈E. Where, N id and E id Indicates the unique code of each node and line segment, which is used to call its corresponding V N 、F N 、V E 、F E The information in V represents the connection relationship of the graph, V NThe connection relationship between storage node n and line segment e can be expressed as n i ={e j1 ,e j2 ,…}(i≤m; j1, j2≤p); V E The connection relationship between the storage segment e and the node n can be expressed as e i ={n j1 ,n j2 ,…}(i≤p;j1,j2≤m). F represents spatial information, F N Storage node spatial coordinate information, F E Stores the spatial path of a line segment, including its length, coordinates of the midpoints of the path, etc.
[0081] Step S2: Traverse all lanes in the information graph, merge lanes with the same name into one road, and for each road, extract all nodes connected to it from the information graph and construct a subgraph;
[0082] Step S3: For each subgraph, the nodes and lanes to be deleted are screened according to the pre-configured first rule. After deletion, a preliminarily simplified subgraph is obtained. The processing of a single subgraph includes:
[0083] Step S3-1: traverse all lanes in the subgraph and select all lanes connected to only one node as lanes to be deleted;
[0084] Step S3-2: All nodes connected to the lane to be deleted are considered as nodes to be deleted;
[0085] Step S3-3: Delete all lanes and nodes to be deleted to obtain a preliminarily simplified subgraph.
[0086] Specifically, in this implementation, the process is as follows:
[0087] First, create an empty dictionary terminal_map to store the mapping relationship between the line segment to be deleted and its associated node;
[0088] Then, traverse the subgraph G i All line segments e∈E i , the statistical line segment e in the subgraph G i The number of nodes n_sub associated in G. If n_sub = 1, that is, segment e is in the subgraph G. i If there is only one node associated with it, add the key-value pair (e,n) to terminal_map; otherwise, keep the line segment e;
[0089] After that, traverse each key-value pair (e,n) in terminal_map and find the corresponding key-value pair in subgraph G. iDelete the line segment e and node n, and update the associated line segment sets of other nodes connected to the line segment e, removing the line segment e from them;
[0090] Finally, repeat the above steps until terminal_map is empty, and obtain the initially simplified subgraph G i ';
[0091] Step S4: Determine whether there is a preliminarily simplified subgraph with the number of nodes greater than or equal to 2. If yes, execute step S5; otherwise, execute step S7.
[0092] Step S5: Select a preliminarily simplified subgraph with the number of nodes greater than or equal to 2, and find the minimum cycle by using a stack-based depth-first search method;
[0093] Among them, the minimum cycle is found through a stack-based depth-first search method, including:
[0094] Step S5-1: Construct node access record graph R i , used to record the access status and loop length of the node;
[0095] Step S5-2: Create loop storage list C i , used to store all the loops found;
[0096] Step S5-3: In the subgraph, select the node n with the largest number of connections best As a starting point, create an empty stack S i , n best Push it into the stack and access the record graph R at the node i Mark node n best Has been visited;
[0097] Step S5-4: When stack S i If it is not empty, take the top node n of the stack top , find all its i The adjacent nodes n marked as unvisited next , stored in the adjacent node set N next middle;
[0098] Step S5-5: Traverse N next Each adjacent node n in next , when the adjacent node n next Not on stack S i or equal to the top node n top , and stack S i If the node status is not visited, then n next Push onto stack S i , in stack S i Mark n nextHas been visited and updated n next In stack S i Otherwise, proceed to step 8;
[0099] Step S5-6: When the adjacent node n next Equal to the top node n top , and stack S i If the length is greater than or equal to 2, it means a loop is formed, and the loop c is obtained. i ={n top ,...,N next Otherwise, continue to execute step S5-5 and traverse the next adjacent node;
[0100] Step S5-7: For the current stack S i , handle according to the following situations:
[0101] If the stack S i The length of is equal to 3, and there are multiple repeated segments between the first node and the second node in the stack, then the current ring c i and its total path length are added to the loop storage list C i , continue to execute steps S5-8;
[0102] If the stack S i If the length of is equal to 3, and there is only one edge between the first node and the second node in the stack, then continue to step S5-8;
[0103] If the stack S i If the length of the ring is greater than 3, the current ring c i and its total path length are added to the loop storage list C i , continue to execute steps S5-8;
[0104] Step S5-8: Move the top node n to the top From stack S i Pop up and reset the node access record graph R i The status and loop length of all adjacent nodes of the node;
[0105] Step S5-9 repeats steps S5-4 to S5-8 until the stack S i If it is empty, the depth-first search ends;
[0106] Step S5-10: Store list C in loop i In the example, the cycle with the least number of nodes is selected as the minimum cycle of the subgraph.
[0107] Step S6: Determine the minimum loop and determine whether the minimum loop found is a road area. If so, simplify the minimum loop into a new lane, update the subgraph, and return to step S4.
[0108] Determine the minimum loop and judge whether the found minimum loop is a road area, including:
[0109] Step S6-1-1: Store list C for loop i Each loop c i , calculate loop c i The circularity r i , the circularity calculation formula is:
[0110]
[0111] Among them, S i is the total area of the loop enclosed area, L i is the total length of the loop;
[0112] If the circularity r i is less than r0, then the loop c i If the conditions are met, keep the loop in List C. i middle;
[0113] If the circularity r i is greater than or equal to r0, then the loop c i Does not meet the conditions, remove the list from list C i Delete it and continue to traverse other loops in the list;
[0114] Step S6-1-2: Store list C in loop i In , the cycle with the least number of nodes is selected as the minimum cycle of the subgraph;
[0115] The smallest loop is simplified into a new lane, including:
[0116] Step S6-2-1: Find the two largest turning nodes n of the minimum loop s and n e , respectively along the node n s To node n e , and along the e To node n s The vector direction traverses all loop nodes and obtains two node sequences R L and R S ;
[0117] Specifically, find the two largest turning nodes n of the minimum loop s and n e ,for:
[0118] For each node in the minimum switch, calculate the angle between its adjacent line segments and the two nodes with the largest angles as the maximum turning nodes n. s and ne .
[0119] In addition, the node sequence with the larger length is taken as the node sequence R L , another node sequence as node sequence R S .
[0120] Step S6-2-2: For the node sequence R L All nodes on the node sequence R S Find the nearest node and get the midpoint of the two points as the waypoint, including:
[0121] Step S6-2-2-1: For node sequence R S As a benchmark, traverse the node sequence R L Each node n in j ;
[0122] Step S6-2-2-2: In node sequence R S Find the distance n j The nearest node n k , n j and n k The midpoint of is the waypoint;
[0123] Step S6-2-2-3: Determine the node sequence R S There is a skipped node n in skip If yes, then determine the skipped node n skip Is it a waypoint? If yes, execute step S6-2-2-4. Otherwise, find node n. skip In the node sequence R L The nearest point in the middle is calculated as the passing point.
[0124] Step S6-2-2-4: Determine whether the node sequence R is completed L Traverse all nodes in, if yes, then all the passing points are sorted according to their node sequence R L The waypoint sequence is obtained by sorting in the order in , otherwise, return to step S6-2-2-2 to continue traversing.
[0125] Step S6-2-2-5: For any two adjacent waypoints in the obtained waypoint sequence, calculate the distance between them:
[0126] If the distance between two adjacent waypoints is less than a threshold β, the two nodes are merged into one waypoint. In this embodiment, the threshold β is 20 meters.
[0127] If the distance between two adjacent waypoints is greater than or equal to the threshold β, nodes ql and ql+1 are retained without merging.
[0128] Step S6-2-3: Connect all waypoints to obtain a new lane, and replace the minimum loop with the new lane and waypoints.
[0129] In particular, in this embodiment, for the new lane L new Each node q on l , check whether it is an atomic graph G i ', if so, then according to V N 、F N 、V E 、F E , transfer the other line segments connected to the original node to the new node at the corresponding position, and update V N 、F N 、V E 、F E 、E i 、N i , complete subgraph G i ″ Update of topological relationships; otherwise, add new nodes and their connection relationships to N i 、V N 、F N and update E i 、V E 、F E , complete subgraph G i Topological relationship update
[0130] Step S7: Update the information graph based on the current sub-graph.
[0131] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. These embodiments are only used to illustrate the present invention and are not intended to limit the scope of protection of the present invention.
[0132] The present invention is described in detail using Yongda Road (Xiayu Road Section) in Ningbo City, Zhejiang Province as an example. The OpenStreetMap (OSM) source data for this area is as follows: Figure 2 The present invention provides an OSM road data optimization method based on the simplification of multi-lane information recognition on the same road, and its process is as follows: Figure 1 As shown, the specific steps include:
[0133] Step (1) Use the OSM map API interface to download the OSM road network data within the specified area. The data content includes the ID of the road segment, the latitude and longitude coordinates of the road node, the road name and other attribute information. The obtained OSM data is converted into a graph data structure G = (N, E), where N is the node set and E is the segment set. In the graph data structure G, each node n∈N contains a unique ID identifier, longitude and latitude coordinates and other spatial information, denoted as n = (nid, n_lon, n_lat); each line segment e∈E contains a unique ID identifier, starting node ID, ending node ID, and road name and other attribute information, denoted as e = (eid, nid_start, nid_end, e_name).
[0134] In this embodiment, the OSM road data of the selected area is downloaded and read to generate a graph data structure G, as shown in Tables 1 and 2. The road node table and the line segment table are associated through the node ID (nid), reflecting the topological structure of the graph G.
[0135] Table 1 Partial data of road node table
[0136] Node ID (nid) Longitude (n_lon) Latitude (n_lat) …… …… …… 178 118.7218938 32.0047940 179 118.7217814 32.0046574 180 118.7166109 31.9979554 …… …… ……
[0137] Table 2 Partial data of road segment table
[0138] Segment ID (eid) Starting point ID (nid_start) End point ID (nid_end) Road name (e_name) …… …… …… …… 2315 179 178 Yongda Road 2316 180 179 Yongda Road …… …… …… …… 2823 180 179 Yongda Road …… …… …… …… 31 35 178 180 Yongda Road 3136 178 180 Yongda Road …… …… …… ……
[0139] Step (2) Cut the graph G into multiple subgraphs G according to the road names i This step includes the following sub-steps:
[0140] Step (21) traverses all line segments in the graph G and, based on the road name label e name, merges the line segments with the same road name into a set E i . Each set E i That is, it represents a complete road, including all lane segments on the road. Get the segment set of all roads {E1, E2, ..., E n};
[0141] Step (22) for each road set E i , extract the starting and ending points of all line segments, and record the set of these nodes as N i , and the line segment set E i Together they form a subgraph G i =(N i , E i ), represents the network topology of the road. Finally, the original road network graph G is cut into a set of subgraphs {G1, G2, ..., G n};
[0142] Step (23) For each subgraph, count the number of nodes associated with each line segment. i If the number of nodes associated with the subgraph is 1, then the line segment e and its associated nodes are deleted from the subgraph. This process continues until there are no more line segments that meet the above conditions in each subgraph, and the subgraph G after preliminary simplification is obtained. i ';
[0143] In this embodiment, all line segments with the road name label e_name being "Yongda Road" are extracted and merged into a set E 永达路 ; Extract the starting and ending points of all line segments of the thoroughfare, and record the set of these nodes as N 永达路 ; The road subgraph G 永达路 The relationship with graph G is as follows Figure 3 As shown; and since the subgraph G 永达路 There is no line segment in the graph that only connects one node, so the subgraph G 永达路 This is the initially simplified subgraph G 永达路 ', its topological relationship is as follows Figure 4 (a)
[0144] Step (3) uses the stack-based depth-first search (DFS) algorithm to search the simplified subgraph G i 'Perform loop detection and find the minimum loop; simplify the minimum loop into a new line segment and replace the corresponding loop segment in the original graph G with the new line segment; update the relevant topological relationship of graph G. This step includes the following sub-steps:
[0145] Step (31) for each initially simplified subgraph G i ': Build node access record graph R i , used to record the access status and path length of the node; build the loop storage list C i , used to store all the loops found. Select the node set N i The node with the most connections n best As the starting point of DFS, push it into stack S i , and in R i Mark as visited;
[0146] Step (32) When the stack Si is not empty, take the top node n top , find its i All adjacent nodes n marked as unvisited next , and exists in the set N next In; traverse N next Each node n in next , if the adjacent node n next Not on stack S i or equal to the top node ntop , and R i If the node status is not visited, then n next Push onto stack S i , in R i Mark n next Has been visited and updated n next In R i Otherwise, directly execute step (35);
[0147] Step (33) When the adjacent node n next Equal to the starting point n best , and stack S i When the length is greater than or equal to 2, it means a loop c is found i ={n top ,…,n next}, store the loop in list C i , continue to execute step (34); otherwise, return to execute step (32) and continue to traverse N next Other adjacent nodes in
[0148] Step (34) for the current stack S i , if stack S i The length of is equal to 3, and there are multiple repeated segments between the first node and the second node in the stack, then the current ring c i and its total path length are added to the loop storage list C i , continue to step (35); if stack S i The length of is equal to 3, and there is only one edge between the first node and the second node in the stack, then continue to step (35); if the stack S i If the length of the ring is greater than 3, the current ring c i and its total path length are added to the loop storage list C i , continue to step (35);
[0149] Step (35) adds the top node n top From stack S i Pop up and reset n top In R i The status and loop length of all adjacent nodes in the network;
[0150] Step (36) Repeat steps (32) to (35) until stack S i is empty, that is, all best All the starting paths are traversed; the loop storage list C i In the graph, select the cycle with the least number of nodes as the subgraph G i 'The minimum loop R min , R min={n best ,n1,…,n k ,n best};
[0151] In this embodiment, when n best n 180 , go to step (31), n 180 As the starting point of DFS, it is pushed into stack S 永达路 In R 永达路 is marked as visited; at this time, stack S 永达路 Not empty, top node n top =n 180 , go to step (32), the adjacent node set N 180_next ={n 178 ,n 179}; Traverse the set N 180_next , node n 178 Not on stack S 永达路 So we will set n 178 Push onto stack S 永达路 In R 永达路 Mark as visited, update the loop length to 1, and continue searching for node n 178 Adjacent nodes, adjacent node set N 178_next ={n 179 ,n 180}; Traverse the set N 178_next , node n 179 Not on stack S 永达路 So we will set n 179 Push onto stack S 永达路 In R 永达路 Mark as visited, update the loop length to 2, and continue searching for node n 179 Adjacent nodes, adjacent node set N 179_next ={n 180 ,n 178}; Traverse the set N 179_next , node n 180 =n top , and at this time stack S 永达路 The length is greater than or equal to 2, indicating that a loop c1={n 180 ,n 178 ,n 179 ,n 180}, then execute step (34), at this time stack S 永达路 The length is equal to 3, and the first node n in the stack 180 and the second node n 178 There are multiple repeated segments between them, so the loop c1 and its total path length 2 are added to the loop storage list C 永达路 Then, step (35) is executed to move the top node n180 From stack S 永达路 Pop up and reset n 180 In R 永达路 The status and loop length of all adjacent nodes in . By completing step (36), the loop storage list C is obtained. 永达路 The data are shown in Table 3;
[0152] Table 3 Loop storage list C 永达路 data
[0153] Loop ID Nodes included in the loop 1 <![CDATA[n 180 ,n 178 ,n 179 ,n 180 ]]> 2 <![CDATA[n 180 ,n 179 ,n 180 ]]> 3 <![CDATA[n 180 ,n 178 ,n 180 ]]>
[0154] Step (4) in the minimum loop R min Find the two largest turning points as the starting and ending points of the loop splitting, split and simplify the loop to obtain new line segments; use the new line segments to replace the corresponding loop segments in the original graph G, and update the relevant topological relationships. This step includes the following sub-steps:
[0155] Step (41) loop storage list C i For each loop in , calculate its circularity r i , if the circularity r i is less than r0, then the loop c i If the conditions are met, keep the loop in List C. i If the circularity r i is greater than or equal to 0.2, then the loop c i Does not meet the conditions, remove the list from list C i Delete it and continue to traverse other loops in the list;
[0156] In this embodiment, the loop storage list C 永达路 The circular rates of the three loops c1, c2, and c3 are: r1 = 0.08, r2 = 0.06, and r3 = 0.09, which all meet the requirements;
[0157] Step (42) stores list C in the loop i In , the cycle with the least number of nodes is selected as the minimum cycle of the subgraph;
[0158] In this embodiment, loop storage list C is selected 永达路 The loop c1 with the least number of nodes is taken as the minimum loop; Step (43) is for the minimum loop R min Each node n on m , calculate the angle θ between it and the adjacent line segments before and after m (θ m ∈[0,π]), take θ m The two nodes with the largest cosine values determine the maximum turning point, denoted as n s and n e; If there are multiple nodes with the same maximum angle, the node with the smaller node ID is taken as the maximum turning point;
[0159] Step (44) for each minimum loop R min , respectively along n s to n e , along n e to n s The vector direction traverses the loop nodes and obtains the node sequence R1={n s ,...,n e} and R2={n e ,...,n s}, and according to the length of the node sequence, the longer and shorter segments of the node sequence are recorded as R L 、R S ;
[0160] In this embodiment, the loops c2 and c3 have the same length, and the loop with c2={n 180 ,n 179 ,n 180} is the minimum loop R min Since the loop has only two nodes (n 180 and n 179 ), the two can be directly recorded as the maximum turning point, that is, n s =n 180 , n e =n 179 ; Enter step (44), respectively along n 180 to n 179 , along n 179 to n 180 The vector direction traverses the loop nodes and obtains the node sequence R1={n 180 ,n 179 ,n 180}(through line segment e 2316 ) and R2={n 180 ,n 179 ,n 180}(through line segment e 2823 ); Since the length of R1 and R2 node sequences is the same, we can record R L =R1, R S =R2;
[0161] Step (45) For each point p in RL j , in R S Find the distance p in j The nearest point pk, p j and p k The midpoint of the new line segment L newNode q1 on the node and set the state of q1 to "mid_pt"; in this step, if R S There is a skipped node n in skip (ie p k In R S The difference between the index in and the index of the last processed node is greater than 1), and the state of the node is not "mid_pt", then the node n is found. skip In R L The nearest point in the middle, calculate the midpoint between the two, and add the midpoint to the new line segment L new and set its status to "mid_pt";
[0162] Step (46) adds the new node q l According to its L The corresponding point p j Add the node sequence Q in the order of new All new node sequences Q=[q1,q2,...,q n ]; If two adjacent nodes q in sequence Q l and q l+1 If the distance is less than 20m, the two nodes are merged into a new node q m , where q m The longitude and latitude coordinates are q l and q l+1 The midpoint coordinates, q m The node ID is q l The node ID of q m Replace q in the node sequence l and q l+1 Until the distance between all adjacent nodes in the node sequence Q is greater than or equal to 20m, all nodes are connected in sequence according to the order of the nodes in the new node sequence Q to form a simplified new line segment L new ;
[0163] Step (47) adds the new line segment L new Through two maximum turning points n s 、n e , replace subgraph G i 'The corresponding loop in the figure is the simplified subgraph G. i ", and update the corresponding road node table and line segment table data;
[0164] In this embodiment, for R L Point n in 180 、n 179 , R S The points closest to it are n 180 、n 179, that is, the nodes q1 and q2 on the new segment are respectively connected to the original node n 180 、n 179 Overlap, q1 = n 180 ,q2=n 179 , without creating new nodes, generate node sequence Q = [q1,q2]; in sequence Q, the distance between nodes q1 and q2 is greater than 20m, and there is no need to merge; according to the order of the nodes in the new node sequence Q, connect nodes q1 and q2 in sequence to form a simplified new line segment L new_1 ; passing through two maximum turning points n s 、n e , replace subgraph G 永达路 'The corresponding loop in the figure is the simplified subgraph G. 永达路 ",like Figure 4 (b)
[0165] Step (5) Repeat steps (3) to (4) until there is no subgraph G that meets the conditions. i '(i.e. the number of nodes in the subgraph is less than 2), the graph G is updated to obtain the final simplified road graph G' that completes the recognition of multiple lanes on the same road.
[0166] In this embodiment, after executing step (5) once, the loop c3={n 180 ,n 178 ,n 180}, and after completing step (45), the simplified subgraph G is obtained 永达路 ",like Figure 4 (c) As shown; in step (5) again, there is only one loop {n 180 ,n 178 ,n 179 ,n 180}, that is, the minimum loop R min ={n 180 ,n 178 ,n 179 ,n 180}, go to step (41), calculate n 178 、n 179 、n 180 The angle between the adjacent line segments before and after is selected, and the angle with the smallest cosine value is selected. 180 and n 178 As the biggest turning point, record n s =n 180 , n e =n 178 ; Enter step (42), respectively along n 180 to n 178 , along n 178 to n 180 The vector direction traverses the loop nodes and obtains the node sequence R1={n180 ,n 178 ,n 180}(through line segment e 3135 ) and R2={n 180 ,n 178 ,n 179 ,n 180}(through line segment e 2315 、e 2823 ), and record R L =R2, R S =R1; go to step (43), for R L Node n in 178 、n 179 、n 180 , in R S The points closest to it are n 178 、n 178 、n 180 , that is, the nodes q3 and q5 on the new segment are respectively connected to the original node n 178 、n 180 Coincidence (q3=n 178 ,q5=n 180 ), node q4 is node n 178 With n 179 The midpoint of the node sequence Q = [q3,q4,q5] is generated, and the node positions are as follows Figure 4 As shown in (d); since the distance between adjacent nodes q3 and q4 is less than 20m, the two nodes are merged into a new node q6. The longitude and latitude coordinates of node q6 are the midpoint coordinates of q3 and q4, and the node ID of q6 is the node ID of q3. q6 replaces q3 and q4 in the node sequence, that is, the node sequence Q = [q6, q5]. The node position is as follows Figure 4 As shown in (e); according to the order of the nodes in the new node sequence Q, nodes q6 and q5 are connected in sequence to form a simplified new line segment L new_3 ; passing through two maximum turning points n s 、n e , replace subgraph G 永达路 'The corresponding loop is obtained to obtain the simplified subgraph G 永达路 ",like Figure 4 As shown in (f); the same subgraph G is performed on the graph G 永达路 The above simplified process continues until there is no subgraph G that meets the conditions. i '(i.e. the number of nodes in the subgraph is less than 2), and the final simplified road graph G' is obtained for the identification of multiple lanes on the same road, as shown in Figure (5);
[0167] The road network simplification and optimization method proposed in this embodiment makes full use of the geometry, topology, attributes and other information of the road, accurately identifies and merges repeated line segments on the same road, and by optimizing the expansion and reorganization of loops, it eliminates redundancy while maintaining the original topological structure to the greatest extent possible. Figure 2 As shown in the figure, the same road is divided into multiple line segments for storage, which makes it difficult to directly use it for analysis in the field of urban and rural planning. However, after the multi-lane information of the same road is identified and simplified by the method of the present invention, the redundancy of OSM road data is greatly reduced, the topological relationship is clearer, and the geometric shape distortion is small, which can significantly improve the efficiency and quality of subsequent road network analysis.
[0168] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
Claims
1. A method for simplifying OSM road data based on identification of multiple lanes on the same road, characterized in that: include: Step S1: Obtain OSM lane data of the target area and convert it into a graph data structure to obtain an information graph; Step S2: Traverse all lanes in the information graph, merge lanes with the same name into one road, and for each road, extract all nodes connected to it from the information graph and construct a subgraph; Step S3: For each subgraph, the nodes and lanes to be deleted are screened out according to the pre-configured first rule, and a preliminarily simplified subgraph is obtained after deletion; Step S4: Determine whether there is a preliminarily simplified subgraph with the number of nodes greater than or equal to 2. If yes, execute step S5; otherwise, execute step S7. Step S5: Select a preliminarily simplified subgraph with the number of nodes greater than or equal to 2, and search for cycles using a stack-based depth-first search method; Step S6: Determine the minimum loop and determine whether the minimum loop found is a road area. If so, simplify the minimum loop into a new lane, update the subgraph, and return to step S4. Step S7: updating the information graph based on the current subgraph; The step of determining the minimum loop and judging whether the found minimum loop is a road area includes: Step S6-1-1: Store list C for loop i Each loop c i , calculate loop c i The circularity r i , the circularity calculation formula is: Among them, S i is the total area of the loop enclosed area, L i is the total length of the loop; If the circularity r i is less than r0, then the loop c i If the conditions are met, keep the loop in List C. i middle; If the circularity r i is greater than or equal to r0, then the loop c i If the conditions are not met, remove the loop from list C i Delete it and continue to traverse other loops in the list; Step S6-1-2: Store list C in loop i In , the cycle with the least number of nodes is selected as the minimum cycle of the subgraph; The minimum loop is simplified into a new lane, including: Step S6-2-1: Find the two largest turning nodes n of the minimum loop s and n e , respectively along the node n s To node n e , and along the e To node n s The vector direction traverses all loop nodes and obtains two node sequences R L and R S ; Step S6-2-2: For the node sequence R L All nodes on the node sequence R S Find the nearest node and get the midpoint of the two points as the waypoint; Step S6-2-3: Connect all waypoints to obtain a new lane, and replace the minimum loop with the new lane and waypoints.
2. The OSM road data simplification method based on identification of multiple lanes on the same road according to claim 1, characterized in that: The step S1 comprises: Step S1-1: Obtain OSM lane data of the target area; Step S1-2: Obtain the intersection points of all lanes based on the OSM lane data of the target area, and merge the intersection points of different lanes corresponding to the same road to obtain nodes; Step S1-3: Storing information about each node and the lanes connected to each node, and storing information about each lane and the nodes connected to each lane.
3. The OSM road data simplification method based on identification of multiple lanes on the same road according to claim 1, characterized in that: The processing of a single subgraph in step S3 includes: Step S3-1: traverse all lanes in the subgraph and select all lanes connected to only one node as lanes to be deleted; Step S3-2: All nodes connected to the lane to be deleted are considered as nodes to be deleted; Step S3-3: Delete all lanes and nodes to be deleted to obtain a preliminarily simplified subgraph.
4. The OSM road data simplification method based on identification of multiple lanes on the same road according to claim 1, characterized in that: The method of finding the minimum cycle by using a stack-based depth-first search method includes: Step S5-1: Construct node access record graph R i , used to record the access status and loop length of the node; Step S5-2: Create loop storage list C i , used to store all the loops found; Step S5-3: In the subgraph, select the node n with the largest number of connections best As a starting point, create an empty stack S i , n best Push it into the stack and access the record graph R at the node i Mark node n best Has been visited; Step S5-4: When stack S i If it is not empty, take the top node n of the stack top , find all its i The adjacent nodes n marked as unvisited next , stored in the adjacent node set N next middle; Step S5-5: Traverse N next Each adjacent node n in next , when the adjacent node n next Not on stack S i or equal to the top node n top , and stack S i If the node status is not visited, then n next Push onto stack S i , in stack S i Mark n next Has been visited and updated n next In stack S i Otherwise, proceed to step 8; Step S5-6: When the adjacent node n next Equal to the top node n top , and stack S i If the length is greater than or equal to 2, it means a loop is formed, and the loop c is obtained. i ={n top ,...,N next Otherwise, continue to execute step S5-5 and traverse the next adjacent node; Step S5-7: For the current stack S i , handle according to the following situations: If the stack S i The length of is equal to 3, and there are multiple repeated segments between the first node and the second node in the stack, then the current ring c i and its total path length are added to the loop storage list C i , continue to execute steps S5-8; If the stack S i If the length of is equal to 3, and there is only one edge between the first node and the second node in the stack, then continue to step S5-8; If the stack S i If the length of the ring is greater than 3, the current ring c i and its total path length are added to the loop storage list C i , continue to execute steps S5-8; Step S5-8: Move the top node n to the top From stack S i Pop up and reset the node access record graph R i The status and loop length of all adjacent nodes of the node; Step S5-9 repeats steps S5-4 to S5-8 until the stack S i If it is empty, the depth-first search ends; Step S5-10: Output loop storage list C i .
5. The OSM road data simplification method based on identification of multiple lanes on the same road according to claim 1 is characterized in that: The two largest turning nodes n of the minimum loop are found s and n e ,for: For each node in the minimum switch, calculate the angle between its adjacent line segments and the two nodes with the largest angles as the maximum turning nodes n. s and n e .
6. The OSM road data simplification method based on identification of multiple lanes on the same road according to claim 1, characterized in that: In step S6-2-1, the node sequence with the larger length is used as the node sequence R L , another node sequence as node sequence R S .
7. The OSM road data simplification method based on identification of multiple lanes on the same road according to claim 1 is characterized in that: The step S6-2-2 specifically includes: Step S6-2-2-1: For node sequence R S As a benchmark, traverse the node sequence R L Each node n in j ; Step S6-2-2-2: In node sequence R S Find the distance n j The nearest node n k , n j and n k The midpoint of is the waypoint; Step S6-2-2-3: Determine the node sequence R S There is a skipped node n in skip If yes, then determine the skipped node n skip Is it a waypoint? If yes, execute step S6-2-2-4. Otherwise, find node n. skip In the node sequence R L The nearest point in the middle is calculated as the passing point. Step S6-2-2-4: Determine whether the node sequence R is completed L Traverse all nodes in, if yes, then all the passing points are sorted according to their node sequence R L The waypoint sequence is obtained by sorting in the order in , otherwise, return to step S6-2-2-2 to continue traversing.
8. The OSM road data simplification method based on identification of multiple lanes on the same road according to claim 7 is characterized in that: The step S6-2-2 further includes: Step S6-2-2-5: For any two adjacent waypoints in the obtained waypoint sequence, calculate the distance between them: If the distance between two adjacent waypoints is less than the threshold β, the two nodes are merged into one waypoint; If the distance between two adjacent waypoints is greater than or equal to the threshold β, nodes ql and ql+1 are retained without merging.
9. The OSM road data simplification method based on identification of multiple lanes on the same road according to claim 8, characterized in that: The threshold β is 20 meters.