A method for identifying closed loops to be merged in OSM urban road data
By converting OSM urban road data into graph data, and calculating the angle and breadth priority algorithm for multi-line included angle and breadth priority algorithm to identify and repair the closed loop, the problem of missing road name information in OSM data is solved, the efficiency and accuracy of data processing are improved, and the mechanical labor time is reduced.
Patent Information
- Application Number
- CN202410925304.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2025-08-12
- Estimated Expiration
- 2044-07-11
AI Technical Summary
In the prior art, when processing OSM urban road data, there is a problem of missing road name information, resulting in the loss of road data information, and the existing methods require a lot of mechanical labor time to identify and repair closed loops.
The OSM urban road data is converted into graph data, and the polylines to be merged are identified by calculating the angle between any two polylines on the node. The breadth priority algorithm is used to identify the connection path between breakpoints, and the circular rate of the connection path is calculated to filter the polylines of the repair loop, and finally output all polylines to be merged to form a closed loop.
It improves the efficiency, accuracy and automation of OSM road data processing, reduces mechanical labor time, and improves the accuracy of urban road network topological structure analysis.
Smart Images

Figure CN118779394B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of urban planning, and in particular relates to a method for identifying closed loops to be merged in OSM urban road data. Background Art
[0002] As urbanization enters a transitional phase, research into urban spatial structure, development trends, and factor mobility patterns is crucial for addressing increasingly complex urban issues. Accurate, complete, and concise road network data is fundamental for applications such as urban and rural transportation network analysis and planning. Widely used open map data such as OpenStreetMap (OSM) provides a new avenue for acquiring real-time, extensive road data.
[0003] Current OSM road data uses a method of grouping roads by road name, typically collecting and storing lanes as the fundamental spatial entity. Each lane is treated as an independent line segment and carries lane-level attribute information. However, OSM road data often suffers from missing road names, and this problem is particularly prevalent in elements such as ramps, right-turn lanes, overpasses, and tunnels within a road segment. If researchers group all lanes within a road segment based solely on road name, the original road data will be lost.
[0004] Therefore, when simplifying OSM road data to study the configuration characteristics of urban road networks, researchers must identify and construct the topological relationship between nodes (intersections) and polylines (lanes) in the road data from the data itself, ensuring that all lanes in the same road section are packaged into a single information group. At the same time, redundant information such as multi-lane, viaduct, tunnel, and ramp is eliminated to form a closed loop representing a road section. To address these issues and requirements, existing research methods typically rely on manual processing of complex road sections, requiring a significant amount of time and mechanical labor.
[0005] Technical comparison with patent US20010037176A1 "Method and apparatus for merging multiple roadmap databases"
[0006] Patent US20010037176A1 uses a method to define closed loops from two different road map databases. This method identifies corresponding closed loops in the two databases and copies the road data in the second database that is included in the closed loop but not represented in the first database into the output road map database, thereby merging the two road map databases. The present invention, on the other hand, converts OSM city road data within a specified area into graph data. The method identifies the polylines to be merged by calculating the angle between any two polylines at a node, and calculates the number of intersecting polylines at all nodes on the polyline to be merged to identify breakpoints. A breadth-first algorithm is then used to identify the connection paths between the breakpoints, and polylines that can be used to repair the loop are selected. Finally, the method outputs a closed loop formed by the combination of all the polylines to be merged.
[0007] While patent US20010037176A1 achieves data merging by comparing closed loops in two different road map databases, the present invention directly analyzes the topological relationships within the OSM road data to identify candidate polylines that need to be merged to form closed loops, without requiring reference to other databases. Furthermore, the present invention introduces a circularity metric to select the optimal polyline combination for loop repair, resulting in more accurate closed loop identification results.
[0008] Technical comparison with patent US6597986B2 "Junction guide device for providing guidance concerning looped branch road"
[0009] Patent US6597986B2 is an in-vehicle navigation system that stores road data and multiple intersection diagrams, each of which represents a common pattern of roads bifurcating into loops at intersections. When a vehicle approaches an intersection, the system uses road data to automatically determine whether the guidance route bifurcates into a loop at the intersection and displays the corresponding intersection diagram to help the driver understand the bifurcation direction of the next intersection and whether the guidance route bifurcates into a loop. The present invention is a method for offline identification of closed loops to be merged in OSM urban road data. The purpose is to integrate scattered road data into complete closed loops for applications such as urban road network topology analysis. It is not an in-vehicle real-time navigation system.
[0010] Patent US6597986B2 stores a predefined schematic diagram of intersection loop bifurcation patterns, guiding drivers by determining whether the current intersection meets a certain pattern. The present invention, however, starts from OSM road data, analyzes the topological relationship of polylines between nodes, automatically discovers potential breakpoints, and uses a graph search algorithm to find possible repair paths, generating a closed loop that meets circularity requirements. This method has greater adaptability and robustness and does not rely on predefined templates. Summary of the Invention
[0011] The technical problem to be solved by the present invention is to provide a method for identifying closed loops to be merged in OSM urban road data, thereby improving the efficiency of identifying and repairing closed loops when processing redundant information in OSM road data.
[0012] To achieve the above-mentioned object, the present invention provides a method for identifying closed loops to be merged in OSM urban road data, comprising the following steps:
[0013] S1. Convert OSM urban road data within a specified area into map data;
[0014] S2. Identify the polylines to be merged by calculating the angle between any two polylines on the node;
[0015] S3, calculating the number of intersecting polylines of all nodes on the polyline to be merged to identify breakpoints;
[0016] S4, identifying the connection path between the breakpoints using a breadth-first algorithm;
[0017] S5. Calculate the circularity of the shortest polygon to which the connection path belongs, so as to select the polyline for repairing the loop;
[0018] S6. adding the polyline that can be used to repair the loop to the combination of polylines to be merged;
[0019] S7. For the repeated available polylines, check again whether there are breakpoints at the nodes of all polylines in the same group;
[0020] S8. Output all the polyline combinations to be merged.
[0021] Furthermore, in step S1, the OSM city road data within the specified area is converted into map data, specifically including:
[0022] 1) Download OSM city road data within the specified area, including all paths within the specified area j and node n i data;
[0023] 2) Define graph data G, which is used to describe the topological structure of the urban road network in OSM map data, where G = (N, E), N = (N id ,V N ,F N ), E=(E id ,V E ,F E ), each intersection is regarded as a node n i , all nodes are recorded as set N, where N={n1,n2,...,nm}; Each road segment is considered as a polyline e j , all line segments are recorded as E set, where E={e1,e2,...,e p}, where N id and E id Indicates the unique number of each node and line segment, used to call its corresponding V N 、F N 、V E 、F E The information in the set V Ni Storage and Node n i All connected polylines e j , expressed as V Ni ={e j1 ,e j2 ,…,e jm}, i≤m; j1, j2≤p; V E Storage and Polyline i All nodes n that have connections j , expressed as V Ei ={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 polyline, including the length and coordinates of the midpoints of the path.
[0024] Furthermore, in step S2, the polylines to be merged are identified by calculating the angle between any two polylines on the node, which specifically includes:
[0025] 1) Create an empty dictionary M d and the empty list M s , dictionary M d Used to record all polyline sets Es i Information, List M s Includes all polyline sets E si , M s =[E s1 ,E s2 ,…,E sn ], if the dictionary M d and list M s If it already exists, skip this step;
[0026] 2) Traverse the node set N and extract node n i Number N idi and its associated polyline set V Ni ;
[0027] 3) Traverse the set VNi Any two polylines e ja and e jb All combinations of n i As the starting point, the second inflection point as the end point, establish vectors t1 and t2 respectively, and calculate the angle α between the two ab ;
[0028] 4) Set the radian value threshold α0, if α ab If it is greater than α0, the polyline ej a and ej b Add the polyline set Es to be merged i , Es i ={e ja ,e jb After many experiments, considering the model performance and computational cost, α0=0.9 is adopted in this method;
[0029] 5) Update dictionary M d and list M s The mapping relationship.
[0030] Furthermore, in step S3, the number of intersecting polylines of all nodes on the polyline to be merged is calculated to identify breakpoints, which specifically includes:
[0031] 1) Create an empty dictionary N s Used to record the attributes of all nodes in the polyline; create an empty list N b Used to record the breakpoint n found bi , N b =[n b1 ,n b2 ,…,n bk ];
[0032] 2) Traverse the list M' s Each polyline set E to be merged si , traverse the set E si All polylines in e j All nodes n in p , calculation and node n p The total number of intersecting polylines to be merged Q p ;
[0033] 3) Q p Node n less than 2 p Determined as breakpoint n bi , and update node n at the same time p In the dictionary N s and add it to the list N b .
[0034] Furthermore, in step S4, a breadth-first algorithm is used to identify connection paths between breakpoints, specifically including:
[0035] 1) Traverse the list N b All breakpoints n bi , after taking out n bi At the same time from the list N b Delete n bi ;
[0036] 2) Use the breadth-first algorithm to search within a limited number of times (the default is 15 times) with n bi As the starting point, we continue to search for the next neighboring point n along the path between nodes in the graph data G. h , until another breakpoint n is found bj or reaching a limited number of times;
[0037] 3) All nodes n passed in each path search process h Recorded in collection N h , calculate the set of all nodes N h All corresponding polylines e in the graph data G hi length, and take the shortest polyline e ij .
[0038] Furthermore, in step S5, the circularity of the shortest polygon to which the connection path belongs is calculated to select the polyline for repairing the loop, which specifically includes:
[0039] 1) Traverse all polylines e ij , find the polyline e in the graph data G ij The closed polygon P with the shortest perimeter ij
[0040] 2) Calculate polygon P ij The area S ij and perimeter C ij , then calculate the polygon P ij The circularity r ij , circularity r ij The calculation formula is as follows:
[0041]
[0042] 3) If the circularity r ij is less than r0, then the polyline e ij Can be used to fix breakpoints bi , the polyline e ij The corresponding node set N ij Join List N p In, N p =[N 11,N 12 ,…,N kl (I < k, j < l, k < l), after multiple experiments, considering the model performance and computational cost, r0 = 0.2 is taken in this method;
[0043] 4) Update point n bi In the dictionary N s and the list N b to obtain the updated dictionary N' s and the list N' b .
[0044] Furthermore, in step S6, the polylines available for repairing the loop are added to the combination of polylines to be merged, specifically including:
[0045] 1) Traverse all sets N p in the list N ij , and find all polylines e ij corresponding to the set N pi in the graph data G, and add the set E pj of these polylines e pj to the set Es i ;
[0046] 2) Traverse all polylines e pj in the set E pi . If the polyline e pi is in the dictionary M<000013sj Set to empty and update polyline e at the same time j In the dictionary M d The value in is the index value t i .
[0048] Compared with the prior art, the present invention has the following advantages:
[0049] The method for identifying and repairing closed loops to be merged in OSM road data adopted by the present invention can make up for the loop incompleteness problem existing in the method of grouping roads by road names in OSM road data. Specifically, the method includes: with the help of a readable program in a computer storage medium, a large number of closed loops to be merged in OSM city road data within a specified range can be identified and repaired, thereby improving the accuracy of constructing a graph data structure using OSM road data, improving the work efficiency of identifying and repairing closed loops when processing redundant information in OSM road data, and saving a lot of mechanical labor time. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 is a flow chart of the method of the present invention;
[0051] Figure 2 It is a schematic diagram of the embodiment range of the present invention;
[0052] Figure 3 This is the schematic diagram of step 2;
[0053] Figure 4 This is the schematic diagram of step 3;
[0054] Figure 5(a) and Figure 5(b) are the calculation nodes n in step 4. qj Distance D to the starting point j Schematic diagram of;
[0055] Figures 6(a) and 6(b) are schematic diagrams of searching for the next node step by step and recording relevant information in step 4;
[0056] FIG7( a ) and FIG7 ( b ) are schematic diagrams of searching for paths between breakpoints using the breadth-first algorithm in step 4;
[0057] Figure 8 This is the schematic diagram of step 5;
[0058] Figure 9(a) and Figure 9(b) are the polyline e in step 6. pi In the dictionary M d In the middle, the set E si Schematic diagram of the treatment method;
[0059] Figure 10 is the polyline e in step 6.5 j In the dictionary M d The value in is not in the list Ms Middle Collection Es i The index value t i When the dictionary M is updated d and list M s Schematic diagram of the correlation mapping;
[0060] Figure 11 After step 8 is completed, list M' s The result of displaying all polylines contained in the in the GIS software. DETAILED DESCRIPTION
[0061] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. It should be understood that the following specific embodiments are intended only to illustrate the present invention and are not intended to limit the scope of the present invention. It should be noted that the terms "front," "rear," "left," "right," "up," and "down" used in the following description refer to directions in the accompanying drawings, and the terms "inward" and "outward" refer to directions toward or away from the geometric center of a particular component, respectively.
[0062] The present invention is described by taking a city road network as an example. The map of the area in OpenStreetMap is as follows: Figure 2 The present invention provides a method for identifying closed loops to be merged in OSM urban road data, the process of which is as follows: Figure 1 As shown, the specific steps include:
[0063] Step 1: Convert the city OSM road data into graph data: Download the OSM road data within the city, including path and node information. i The information is stored in the polyline set E, and all nodes n within the specified area are i , add the newly created node set N, and thus create a graph data G.
[0064] In step 1, the graph data G can reflect the topological relationship between intersections, roads, and intersections in the road data. id ,V N ,F N ), E=(E id ,V E ,F E ). Consider each intersection as a node n i , all nodes are recorded as set N, where N={n1,n2,...,n m}; Each road segment is regarded as a line segment e j , all polylines are recorded as a set E, where E={e1,e2,...,e p}. Among them, Nid and E id Indicates the unique number of each node and line segment, used to call its corresponding V N 、F N 、V E 、F E Information in Set V N Storage and Node n i All connected polylines e j , which can be expressed as V N ={e j1 ,e j2 ,…,e jm}(i≤m;j1,j2≤p);V E Storage and Polyline i All nodes n that have connections j , which can be expressed as V E ={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 polyline, including the length, coordinates of the midpoints of the path, etc.
[0065] Step 2.1, create an empty dictionary M d and the empty list M s , dictionary M d Used to record all the polyline sets E to be merged si Information, List M s Includes all polyline sets E si , M s =[E s1 ,E s2 ,…,E sn ].
[0066] Step 2.2, traverse the node set N and extract node n i Number N idi and its associated polyline set V Ni ;
[0067] Step 2.3, traverse the set V Ni Any two polylines e ja and e jb All combinations of n i As the starting point, the second inflection point as the end point, establish vectors t1 and t2 respectively, and calculate the angle α between the two ab , if α abIf it is greater than α0, then go to step 2.4, otherwise go to step 2.8. After many experiments, considering the model performance and computational cost, this method takes α0 = 0.9.
[0068] Step 2.4, polyline e ja and e jb Add the polyline set Es to be merged i , Es i ={e ja ,e jb}, judge the polyline e ja and e jb Is it in dictionary M d Middle: If the polyline e ja and e jb All in Dictionary M d Then go to step 2.5; if the polyline e ja In the dictionary M d In the middle, the polyline e jb Not in dictionary M d or polyline e jb In the dictionary M d In the middle, the polyline e ja Not in dictionary M d Then go to step 2.6; if the polyline e ja and e jb Not in the dictionary M d If yes, go to step 2.7;
[0069] Step 2.5, calculate list M s The number of elements O s , list M s Polyline e ja and e jb The corresponding set E si Add to List M s at the end of the list M s Polyline e ja and e jb The original collection where is set to empty, and then traverse the collection E si All polylines in e si , the polyline e si In the dictionary M d The value in is set to 0 s ;
[0070] Step 2.6, in dictionary M d Create a new line segment e that is not in the dictionary jb The key is assigned to the dictionary M d Zhonge ja The value of the polyline e ja Add polyline ejb In List M s The corresponding set E in sjb middle;
[0071] Step 2.7, calculate list M s The number of elements O s , in the dictionary M d Create a new polyline in ja and polyline e jb The key, and assign the value to O s , and at the same time set E si Join List M s middle;
[0072] In this embodiment, it is assumed that a For polyline 74, e b For polyline 104, e c For polyline 73, e d For polyline 103, let n a For node 102, n b For node 103, n c For node 123, go to step 2.2; n a Respectively with the polyline e a and e b connected, such as Figure 3 As shown. Go to step 2.3; Go to step 2.3; Select polyline e a With polyline e b , polyline e a The second vertex is vertex 10203, and the polyline e b The second inflection point is inflection point 10223; with node n a As the starting point, inflection point 10203 as the end point, establish vector t a , and then take node n a As the starting point, inflection point 10223 as the end point, establish vector t b , calculate the vector t a and vector t b The angle radian value α ab , α ab is 1.0, α ab >α0, go to step 2.4; a and e b Add the polyline set to be merged Es1, Es1={e a ,e b}; Polyline e a and e b Not in dictionary d , go to step 2.7; List M s The number of elements is 0; in the dictionary Md Create a new polyline in a and polyline e b and assign them 0 respectively; at the same time, add the set Es1 to the list M s At this time, M s =[{e a ,e b}], go to step 2.8.
[0073] Step 2.8, determine the set V Ni Any two polylines e ja and e jb Check whether all combinations of have been traversed. If so, go to step 3; otherwise, return to step 2.3.
[0074] Step 3: Calculate the number of intersecting polylines of all nodes on the polyline to be merged to identify the breakpoints: traverse all sets Es i All polylines in e j All associated nodes n p , the number of intersecting polylines Q p Node n less than 2 p Determined as breakpoint n bi ;
[0075] Step 3.1, create an empty dictionary N s Used to record the attributes of all nodes in the polyline; create an empty list N b Used to record the breakpoint n found bi , N b =[n b1 ,n b2 ,…,n bk ];
[0076] In step 3.1, the dictionary N s Used to record all nodes n in the polyline p Attributes, including node n i The number in the set N, the set of polylines intersecting the node, and the state attributes of the node; List N b Used to record the breakpoint n found bi , N b =[n b1 ,n b2 ,…,n bk ];
[0077] Step 3.2, traverse the list M s Each polyline set E to be merged si , traverse the set E si All polylines in e j All nodes n in p, calculation and node n p The total number of intersecting polylines to be merged Q p ;
[0078] Step 3.3: Q p Node n less than 2 p Determined as breakpoint n bi , and update node n at the same time p In the dictionary N s and add it to the list N b .
[0079] Step 3.4: Determine the set E si Have all the multi-segment lines been traversed? If so, go to step 4.1; otherwise, return to step 3.2.
[0080] In this embodiment, it is assumed that the polyline e a For polyline 74, e b For polyline 104, e f For polyline 242, e g For polyline 75, set point n a is point 102, n b For point 103, Figure 4 Go to step 3.2 and set E s1 The polyline e in a For example, e a The associated node is n a 、n b , where, with node n a The intersecting polylines have e a and e b , e a and e b In the collection E s1 So it will be with node n a The total number of intersecting polylines to be merged Q a Recorded as 2; similarly, with node n b Intersecting polylines have polylines e a 、Polyline e g and polyline e f ; Among them, only the polyline e a In the collection E s1 So it will be with node n b The total number of intersecting polylines to be merged Q b Record as 1; go to step 3.3; Q b <2, so node n b Determined as a breakpoint, in dictionary N s where n is the node b Create a new "links" key and assign it to node n bThe set of all the short lines to be merged {e a}, create a new "status" key and assign it to "breaknd", and at the same time, change node n b Add the number to the list N b ; In addition, in the dictionary N s where n is the node a Create a new "links" key and assign it to node n a The set of all the short lines to be merged {e a ,e b}, and create a new "status" key and assign it to "normalnd"; finally get the updated dictionary N s and list N b , go to step 3.4;
[0081] Step 4: Use the incremental breadth-first algorithm to identify potential connection paths between adjacent breakpoints: traverse each breakpoint n bi , use the incremental breadth-first algorithm to find the breakpoint n in the graph data G bi To other adjacent breakpoints n bj The shortest polyline e ij .
[0082] Breadth First Search (BFS), also known as Breadth First Search, is a blind search method that aims to systematically expand and check all nodes in a graph to find the result. Given a graph G = (N, E) and a starting vertex n0, the BFS algorithm systematically explores the edges of G to "discover" all vertices that n0 can reach, and calculates the distance from n0 to all these vertices (the minimum number of edges passed). The algorithm can also generate a breadth-first tree with root n0 and including all reachable vertices. For any vertex n that is reachable from n0, i , from n0 to n in the breadth-first tree i The path corresponds to the path from n0 to n in graph G i The shortest path, that is, the path with the minimum number of edges e 0i .
[0083] Step 4.1, traverse list N b All breakpoints n bi , after taking out n bi At the same time from the list N b Delete n bi ;
[0084] Step 4.2, use the breadth-first algorithm, within a limited number of times (the default is 15 times), with n biAs the starting point, we continue to search for the next neighboring point n along the path between nodes in the graph data G. h , until another breakpoint n is found bj Or the limited number of times is reached, the specific process of step 4.2 includes:
[0085] Step 4.2.1: Traverse the list N b All breakpoints in n bi , go to step 4.2.2;
[0086] Step 4.2.2: Set breakpoint n bi Join the queue Q and define the initial node level I = 0. The new node retrieved is higher than the previous node level, and go to step 4.2.3;
[0087] Step 4.2.3: Create dictionary N f Used to record all nodes n found qi The previous point n qi ', distance D to the starting point i and node level I i , set breakpoint n bi The previous point n q0 The information is set to empty, the distance D1 to the starting point is set to 0, and the node level is I i Set it to 0 and proceed to step 4.2.4.
[0088] Step 4.2.4: Determine the current node to be processed n qi Is it empty? If yes, go to step 4.2.5; if no, go to step 4.2.6;
[0089] Step 4.2.5: Take the head node from queue Q and set it as the current node to be processed n qi , and n qi Add to the processed node set N bo , go to step 4.2.9;
[0090] Step 4.2.6: Determine the current node level I i Is it less than the upper limit of search times I0 (default search times limit I0 = 15), if so, go to step 4.2.7; if not, go to step 4.2.8;
[0091] Step 4.2.7: Take the first node from the queue Q and set it as the current node to be processed n qk , search for all nodes n in the graph data G qj , node n qj With the current node n qi Connected, and not all pending polylines e ji For the corresponding general node, go to step 4.2.9;
[0092] Step 4.2.8: Take the first node from the queue Q and set it as the current node to be processed n qi , search for all nodes n in the graph data G qj , node n qj With the current node n qi Connected, and not all pending polylines e ji For the corresponding general node, go to step 4.3.1;
[0093] Step S4.2.9: Traverse all neighboring nodes n qj , find the neighboring node n in the graph data G qj With node n qi The connecting path polyline e qij , go to step 4.2.10;
[0094] In this embodiment, it is assumed that point n a is point 102, n b Point 103, point n d Point 104, point n e For point 93, let the polyline e f For polyline 242, let polyline e g For polyline 75, point n b As a breakpoint, point n b Join queue Q and go to step 4.2.3; in dictionary N f The middle is point n b Create a key and set the value to describe point n b The information set includes the key "prev", key "distance" and key "step"; set the value of "prev" to be empty, set the value of "distance" to be 0, set the value of "step" to be 0, and go to step 4.2.4; because the current node to be processed is n q1 If it is empty, go to step 4.2.5; take the head node n from queue Q b , set as the current processing node, and set n b Add to the processed node set N bo , then go to step 4.2.9; click n b The neighboring nodes that meet the restriction requirements are n e and point n d , point n d With point n b The connection path is a polyline e g , point n e With point n b The connection path is a polyline e f , proceed to step 4.2.10.
[0095] In another embodiment, let point n c is point 123, point n f For point 105, let point n i For point 121, let point n h For point 122, point n f is the starting point, passing through points 130, 131, 171, 93, 92, 91, 90, 101, 102, 112, 113, 114, 123, 122, 121, and the current processing point is point n i , go to step 4.2.6; click n i In the dictionary N f The value of the key "step" in the corresponding set is 15, which is equal to I0, indicating that a complete path connecting the two breakpoints cannot be found within the limit. Go to step 4.2.8; remove the first node n from the queue Q y , set as the current node to be processed, search for the current node n in the graph data G h All adjacent nodes connected to get point n i and point n c , go to step 4.3.1;
[0096] Step 4.2.10: Traverse all adjacent nodes n qj , computing node n qj Distance D to the starting point j , D j Equal to polyline e qij The length of D i The sum of the two, go to step 4.2.11;
[0097] In this embodiment, it is assumed that point n a Point 102, point n d Point 104, point n f Point 105, point n g Point 131, point n o For point 130, let the polyline e a For polyline 74, e g For polyline 75, polyline e p For polyline 205, e o For polyline 221, e n For polyline 220, when n b is the starting point, and point n f When it is the current processing point, as shown in Figure 5(a), go to step 4.2.10; the points previously traversed are point n b 、Point n d 、Point n g and point n o , calculate n f To the starting point na Distance D d , D d For polyline e a 、e g 、e p 、e o 、e n The sum of the lengths of d =699m, go to step 4.2.11.
[0098] Step 4.2.11: Determine the neighboring node n qj Is it in the processed node set N bo If yes, go to step 4.2.14; if no, go to step 4.2.12;
[0099] Step 4.2.12: In dictionary N f Update neighboring nodes n qj Related information: Update neighboring node n qj The previous level node is the current node n qi , the distance to the starting point is D j , node level I j =I i +1, then node n qj Add to the processed node set N bo , go to step 4.2.13;
[0100] Step 4.2.13: Determine the neighboring node n qj Is it in list N b If so, then node n qj Join the newly created set N end ; If not, the neighboring node n qj Join queue Q; proceed to step 4.2.15;
[0101] In this embodiment, it is assumed that point n b Point 103, point n d Point 104, point n f Point 105, point n g Point 131, point n o For point 130, let the polyline e a For polyline 74, e g For polyline 75, polyline e p For polyline 205, e o For polyline 221, e n For polyline 220, when n b is the starting point, and the current processing node is point n o , as shown in Figure 6(a), go to step 4.2.11; n oNot in set N bo In the dictionary N, go to step 4.2.12; f Create node n o The information collection includes the key "prev", key "distance" and key "step"; update the value of the key "prev" to node n g ; Update the value of the key "distance" to 580m; Update the value of the key "step" to 3, and move node n o Add to the processed node set N bo , go to step 4.2.13; node n o Not in list N b Therefore, node n o Join queue Q and proceed to step 4.2.15;
[0102] In another embodiment, when n b is the starting point, and the current processing node is point n f , as shown in Figure 6(b), go to step 4.2.11; n f Not in set N bo In the dictionary N, go to step 4.2.12; f Create node n f The information collection includes the key "prev", key "distance" and key "step"; update the value of the key "prev" to node n o ; Update the value of the key "distance" to 699m; Update the value of the key "step" to 4, and change the node n f Add to the processed node set N bo , go to step 4.2.13; node n f In list N b Therefore, node n f Join set N end , go to step 4.2.15;
[0103] Step 4.2.14: Compare the distance D calculated this time j 'With dictionary N f D recorded in j , if D j 'Smaller, then in dictionary N f Update neighboring nodes n qj The previous level node is the current node n qi , the distance to the starting point is D j , node level I j =I i +1, go to step 4.2.15; if D j ' is larger, go directly to step 4.2.15;
[0104] In another embodiment, let point n b Point 103, point n d Point 104, point n f For point 105, let the polyline e a For polyline 74, e g For polyline 75, polyline e h For polyline 76, when n b is the starting point, and the current processing node is point n f , from point n b To point n f Passing through point n in sequence d 、n f , as shown in Figure 5(b), go to step 4.2.10; node n f To the starting point n b The distance to the polyline e h Length, D f '=529m, go to step 4.2.11; node n f In the set N bo Go to step 4.2.14; compare D f ' and dot n f In the dictionary N f The value D of the middle key "distance" f , D f =699m, D f '<D f , so in dictionary N f Update point n f The key "prev" in the corresponding set is the current node n d , update the value of the key "distance" to 529m; update the value of the key "step" to 2, and go to step 4.2.15.
[0105] Step 4.2.15: Determine the current processing point n qi All neighboring nodes n qj Have all the traversals been completed? If so, proceed to step 4.2.16; if not, return to step 4.2.10;
[0106] Step 4.2.16: Determine whether queue Q is empty. If so, proceed to step 4.3.1; if not, return to step 4.2.4;
[0107] In this embodiment, it is assumed that point n b Point 103, point n c is point 123, point n d Point 104, point n f Point 105, point n hPoint 122, point n i is point 121, point n j Point 120, point n f and point n j In list N b As shown in Figure 7(a); in step 4.2, the breadth-first algorithm is used to select the points n b and point n c Start and search outward until you find breakpoint n f and breakpoint n j , and add them to the set N respectively end , get the set N end ={nf,nj}; During the search process, through the loop from step 4.2.4 to step 4.2.16, all potential connection paths from the currently analyzed breakpoint to another breakpoint are found, and the shortest path between the two breakpoints is obtained by comparing the distance between the path and the starting point. The order of path search is recorded by recording the previous node of each node and the search level of each node. b To point n f , the connection path passes through point n in sequence d 、Point n f ; From point n c To point n j , the connection path passes through point n in sequence h 、Point n i and point n j Finally, all nodes with analysis in queue Q are analyzed, and the results are shown in Figure 7(b), and then go to step 4.3.1.
[0108] Step 4.3: All nodes n passed in each path search process h Recorded in collection N h , calculate the set of all nodes N h All corresponding polylines e in the graph data G hi length, and take the shortest polyline e ij , specifically including the following steps:
[0109] Step 4.3.1, traverse the set N end All breakpoints in n bj , create an empty list N h Used to store all nodes on a path, let the current node to be processed be n bj , go to step 4.3.2;
[0110] Step 4.3.2, in list N h Add node n bj , then set the current node to n bj The previous point,
[0111] Step 4.3.3, repeat step 4.3.2 until n bj The previous point is empty, and the connection node n is obtained. bi and n bj All nodes n passed h List N h , go to step 5.1;
[0112] In this embodiment, it is assumed that the polyline e a For polyline 74, polyline e b For polyline 104, node n b For node 103, node n c For node 123, node n d is node 104, node n h The node is 122, and the current polyline to be merged is polyline e a and e b , set N end Includes node n f and node n j , let the current node to be processed be n j , go to step 4.3.2, first in list N h Add point n j , then set the current node to point n j The previous point n i , point n i Join List N h ; Set the current node to point n j The previous point n i , point n i Join List N h ; Set the current node to point n i The previous point n h , point n h Join List N h ; Set the current node to point n h The previous point n c , point n c Join List N h ; Due to point n c The previous point is empty, so stop the loop and get list N h For [n j ,n i ,n h ,n c ], go to step 5.1.
[0113] Step 5: Filter the polylines that can be used to repair the closed loop by calculating the circularity of the shortest closed polygon to which the potential connection path belongs: Search for the polyline e in the graph data G.ij The closed polygon P with the shortest perimeter ij , if the polygon P ij Circularity rate r ij is less than r0, then the polyline e ij passing through all the nodes n j in the set N ij is added to the list N p .
[0114] In step 5, calculating the circularity rate of the shortest closed polygon to which the potential connection path belongs specifically includes: converting the node path represented by the list N h into a polyline e ij , finding in the graph data G the shortest closed polygon P ij that contains the polyline e ij , and calculating the circularity rate r ij of the polygon P ij . The circularity rate refers to the ratio of 4Π times the area of a polygon to the square of its perimeter. The closer the circularity rate is to 1, the closer the polygon is to a circle. The calculation formula for the circularity rate r ij is:
[0115]
[0116] where S ij is the area of the polygon P ij , and C ij is the perimeter of the polygon P ij ;
[0117] If the circularity rate r ij is less than r0, then the polyline e ij can be used to repair the break point n bi , and the set of nodes N ij corresponding to the polyline e ij is added to the list N p , where N p = [N 11 , N 12 , …, N kl (I < k, j < l, k < l). After multiple experiments, considering the model performance and computational cost, r0 = 0.2 is taken in this method;
[0118] In step 5, its specific steps include:
[0119] Step 5.1, finding in the graph data G the polyline e h that connects all the nodes in the list N ij , and entering step 5.2;
[0120] Step 5.2, finding in the graph data G the shortest closed polygon that contains the polyline e ijand the closed polygon P with the shortest perimeter ij , go to Step 5.3;
[0121] Step 5.3, calculate the area S ij and perimeter C ij of the polygon P ij , and then calculate the circularity rate r ij of the polygon P ij . The calculation formula of the circularity rate r ij is as follows:
[0122]
[0123] Go to Step 5.4;
[0124] Step 5.4, if the circularity rate r ij is less than r0, then the polyline e ij can be used to repair the break point n bi . Add the node set N ij corresponding to the polyline e ij to the list N p . N p = [N 11 , N 12 , …, N kl (I < k, j < l, k < l). After multiple experiments, considering the model performance and operation cost, r0 = 0.2 is taken in this method. After the calculation, go to Step 5.5;
[0125] Step 5.5, update the mapping of the point n bi in the dictionary N s and the list N b to obtain the updated dictionary N’ s and the list N’ b , go to Step 5.5;
[0126] Step 5.6, judge whether all the break points n end in the set N bj have been traversed. If so, go to Step 6.1; if not, return to Step 4.3.1;
[0127] In this embodiment, let the polyline e a be the polyline 74, the polyline e b be the polyline 104, the node n b be the node 103, the node n c be the node 123, the node n d be the node 104, the node n f be the node 105, the node n h be the node 122, the node n i be the node 121j The node is 120, and the current polyline to be merged is polyline e a and e b , let the polyline e h For polyline 105, e m For polyline 106, e j For polyline 107, set N end Includes node n f and node n j ,like Figure 8 As shown, go to step 5.1; N h =[n j ,n i ,n h ,n c ], the corresponding polyline in the graph data G is the polyline e h 、e m and e j , go to step 5.2; set the polyline e h 、e m and e j The merged polyline is e z , polyline e z The corresponding closed polygon with the shortest perimeter in the graph data G passes through nodes 123, 122, 121, 120, 106, 105, 104, 103, 102, and 123. Let this polygon be P a , go to step 5.3; polygon P a The perimeter C pa It is 1102m2 and the area is S pa is 8357㎡; calculate polygon P a The circularity r a , r a =0.086, go to step 5.4; r a <r0, so list N h Convert to set N cj Join List N p , get N p =[{n j ,n i ,n h ,n c}] Go to step 5.5; change point n b In the dictionary N s Update the key value of "status" in the corresponding collection to "normalnd" and remove it from the list N b Delete and proceed to step 5.6.
[0128] Step 6: Add the polylines that can be used to repair the closed loop to the polyline combination to be merged: ijAll corresponding polylines e pi The set E p Add to collection Es i , specifically including the following steps:
[0129] Step 6.1, traverse list N p All sets N in ij , find the set N in the graph data G ij All corresponding polylines e pi The set E pj , and the set E pj Add to collection Es i , go to step 6.2;
[0130] Step 6.2: Traverse the set E pj All polylines in e pi , determine the polyline e pi Is it in dictionary M d If yes, it means that the recorded polyline has been found, and go to step 6.3; if not, go directly to step 6.4;
[0131] Step 6.3: Set Es i Updated to Collection Es i With polyline e pi In List M s The union of the corresponding sets in , go to step 6.4;
[0132] Step 6.4: Traverse the set E si All polylines in e j , determine the polyline e j Is it in dictionary M d If not, update the dictionary M d Zhonge j The value of the list M s Middle Collection Es i The index value t i , go to step 6.6; if yes, go to step 6.5;
[0133] In this embodiment, it is assumed that node n b For node 103, node n c For node 123, node n d is node 104, node n f For node 105, node n h For node 122, node n i For node 121, node n j For node 120, polyline e a For polyline 74, polyline e b For polyline 104, eg For polyline 75, e i For polyline 76, e l For polyline 77, e k is polyline 108, and the current polyline to be merged is polyline e a and e b , list N p =[{n j ,n i ,n h ,n c},{n f ,n d ,n b}], set E s1 ={e a ,e b}, which is in list M s The index value t1 in the list is 0, as shown in FIG9(a); s There is a set E s8 ={e k ,e l ,e i ,e g}, e g ∈E s8 , as shown in Figure 9(b); go to step 6.1; set {n j ,n i ,n h ,n c}The corresponding path in the graph data G is the polyline e j 、e m and e h , set {n f ,n d ,n b}The corresponding path in the graph data G is the polyline e g and e i ; Polyline e j 、e m 、e h 、e g and e i Add to collection E s1 , E s1 ={e a ,e b ,e j ,e m ,e h ,e g ,e i}, go to step 6.2; with polyline e g For example, the polyline e g In the dictionary M d , go to step 6.3; polyline eg In List M s The corresponding set in is set E s8 , so the set E s1 Update to set E s1 With set E s8 The union of s1 ={e a ,e b ,e j ,e g ,e i ,e k ,e l}, as a result, go to step 6.4; for the polyline e g , polyline e g In the dictionary M d , go to step 6.5;
[0134] Step 6.5: Determine the polyline e j In the dictionary M d Is the value in the list M s Middle Collection Es i The index value t i If not, then list M s There exists another set E in sj , and e j ∈E sj , so the set E sj Set to empty and update polyline e at the same time j In the dictionary M d The value in is the index value t i , go to step 6.6; if yes, go directly to step 6.6.
[0135] In another embodiment, let the polyline e a For polyline 74, polyline e b For polyline 104, polyline e g For polyline 75, polyline e i For polyline 76, polyline e h For polyline 105, polyline e m For polyline 106, polyline e j For polyline 107, polyline e k For polyline 108, polyline e l For polyline 77, polyline e n For polyline 220, polyline e o For polyline 221, polyline e p For polyline 205, list N p =[{n j ,n i ,nh ,n c},{n f ,n d ,n b}], set E s8 ={e o ,e n ,e i ,e p}, which is in list M s Index value t8=7 in the polyline e i In the dictionary M d The value in is 7, such as Figure 10 As shown; go to step 6.5, in the list M s There is a set E s1 ={e a ,e b ,e j ,e m ,e h ,e g ,e i ,e k ,e l}, e i ∈E s1 , E s1 In List M s The index value t1=0, e i In the dictionary M d The value in is not equal to t1. At this time, the set E s8 Set it to empty and set the polyline e i In the dictionary M d The update in is 0, go to step 6.6;
[0136] Step 6.6: Determine the set E pj All polylines in e pi Is the traversal completed? If so, go to step 7; if not, return to step 6.2;
[0137] Step 7: For the repeated available polylines, check again whether there are breakpoints at the nodes of all polylines in the same group: when the set N p All sets N in ij After the traversal is completed, if the d The polyline e in pi , then you need to check the set E according to the method described in step 3 si Is there a breakpoint in all nodes corresponding to all polylines in , and get the updated dictionary N s ' and list N b '.
[0138] In another embodiment, let point nc is point 123, point n f Point 105, point n j Point 120, polyline e a For polyline 74, polyline e b For polyline 104, polyline e g For polyline 75, polyline e i For polyline 76, polyline e h For polyline 105, polyline e m For polyline 106, polyline e j For polyline 107, polyline e k For polyline 108, polyline e l For polyline 77, set E s1 ={e b ,e a ,e g ,e i ,e l ,e k},like Figure 10 As shown, go to step 7; in this embodiment, in step 6.2, find the dictionary M d The polyline e in g , then check the set E according to the method described in step 3 s1 Is there a breakpoint in all nodes corresponding to all polylines in ? c and breakpoint n j , then we get the updated dictionary N s and list N b , go to step 8;
[0139] Step 8, repeat steps 3 to 7 until all sets E si All have been traversed, and the list M' is obtained s and dictionary M' d .
[0140] In this embodiment, after the above steps, a list M' containing all closed loops to be merged can be obtained. s and contains all the polylines to be merged in the list M' s The dictionary M' of the index value of the collection to which it belongs d , list M' s All polylines contained in the GIS software are displayed and can be obtained Figure 11 The result is shown by the red polyline.
[0141] It should be noted that the above content merely illustrates the technical idea of the present invention and cannot be used to limit the scope of protection of the present invention. For ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications all fall within the scope of protection of the claims of the present invention.
Claims
1. A method for identifying closed loops to be merged in OSM urban road data, characterized by: The method comprises the following steps: S1. Convert OSM urban road data within a specified area into map data; In step S1, the OSM city road data within the specified area is converted into map data, specifically including: 1) Download OSM city road data within the specified area, including all paths within the specified area j and node n i data; 2) Define graph data G, which is used to describe the topological structure of the urban road network in OSM map data, where G = (N, E), N = (N id , V N , F N ), E=(E id , V E , F E ), each intersection is regarded as a node n i , record all nodes as set N, where N= {n1, n2, ... , n m }; Each road segment is considered as a polyline e j , denote all segment lines as the set E, where E ={e1, e2, ... , e p }, where N id and E id Indicates the unique number of each node and segment line, used to call its corresponding V N 、F N 、V E 、F E The information in the set V N Storage and Node n i All connected polylines e j , expressed as V Ni ={e j1 ,e j2 ,…,} , i≤m; j1, j2≤p; V E Storage and Polyline i All nodes n that have connections j , expressed as V Ei ={ 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 polyline, including the length and coordinates of the midpoint of the path; Identify the polylines to be merged by calculating the angle between any two polylines on the node; In step S2, the polylines to be merged are identified by calculating the angle between any two polylines on the node, which specifically includes: 1) Create an empty dictionary M d and the empty list M s , dictionary M d Used to record all polyline sets E si Information, List M s Includes all polyline sets E si , M s = [E s1 , E s2 , … , E sn ], if the dictionary M d and list M s If it already exists, skip this step; 2) Traverse the node set N and extract node n i Number N idi and its associated polyline set V Ni ; 3) Traverse the set V Ni Any two polylines e ja and e jb All combinations of n i As the starting point, the second inflection point as the end point, establish vectors t1 and t2 respectively, and calculate the angle α between the two ab ; 4) Set the radian value threshold α0, if α ab is greater than α0, then the polyline e ja and e jb Add the polyline set Es to be merged i , Es i ={e ja ,e jb After multiple experiments, considering the model performance and computational cost, α0 = 0.9 is taken in this method; 5) Update dictionary M d and list M s The mapping relationship; S3, calculating the number of intersecting polylines of all nodes on the polyline to be merged to identify breakpoints; In step S3, the number of intersecting polylines at all nodes on the polyline to be merged is calculated to identify breakpoints, specifically including: 1) Create an empty dictionary N s Used to record the attributes of all nodes in the polyline; create an empty list N b Used to record the breakpoint n found bi , N b = [n b1 , n b2, …, n bk ]; 2) Traverse the list M s Each polyline set E to be merged si , traverse the set E si All polylines in e j All nodes n in p , calculation and node n p The total number of intersecting polylines to be merged Q p ; 3) Q p Node n less than 2 p Determined as breakpoint n bi , and update node n at the same time p In the dictionary N s and add it to the list N b ; S4, identifying the connection path between the breakpoints using a breadth-first algorithm; In step S4, a breadth-first algorithm is used to identify connection paths between breakpoints, specifically including: 1) Traverse the list N b All breakpoints n bi , after taking out n bi At the same time from the list N b Delete n bi ; 2) Use the breadth-first algorithm to select n bi As the starting point, we continue to search for the next neighboring point n along the path between nodes in the graph data G. h , until another breakpoint n is found bj or reaching a limited number of times; 3) All nodes n passed in each path search process h Recorded in collection N h , calculate the set of all nodes N h All corresponding polylines e in the graph data G hi length, and take the shortest polyline e ij ; S5. Calculate the circularity of the shortest polygon to which the connection path belongs, so as to select the polyline for repairing the loop; In step S5, the circularity of the shortest polygon of the connection path is calculated to select the polyline for repairing the loop, which specifically includes: 1) Traverse all polylines e ij , find the polyline e in the graph data G ij The closed polygon P with the shortest perimeter ij 2) Calculate polygon P ij The area S ij and perimeter C ij , then calculate the polygon P ij The circularity r ij , circularity r ij The calculation formula is as follows: ; 3) If the circularity r ij is less than r0, then the polyline e ij Can be used to fix breakpoints bi , the polyline e ij The corresponding node set N ij Join List N p After many experiments, considering the model performance and computational cost, r0 = 0.2 is taken in this method; 4) Update point n bi In the dictionary N s and list N b The mapping in gets the updated dictionary N' s and list N' b ; S6. adding the polyline that can be used to repair the loop to the combination of polylines to be merged; In step S6, the polylines that can be used to repair the loop are added to the polyline combination to be merged, which specifically includes: 1) Traverse the list N p All sets N in ij , find the set N in the graph data G ij All corresponding polylines e pi The set E pj , and the set E pj Add to collection E si middle; 2) Traverse the set E pj All polylines in e pi , if the polyline e pi In the dictionary M d In the above example, it means that the recorded polyline has been found, and the set E si Update to set E si With polyline e pi In List M s Continue to execute 3) if the polyline e p Not in dictionary M d Execute 3); 3) Traverse the set E si All polylines in e j , if the polyline e j Not in dictionary M d Then update the dictionary M d Zhonge j The value of the list M s Middle Set E si The index value t i ; If the polyline e j In the dictionary M d and it is in the dictionary M d The value in is not in the list M s Middle Set E si The index value t i , then the list M s There exists another set E in sj , e j ∈E sj , then the set E sj Set to empty and update polyline e at the same time j In the dictionary M d The value in is the index value t i ; S7. For the repeated available polylines, check again whether there are breakpoints at the nodes of all polylines in the same group; S8. Output all the polyline combinations to be merged.
Citation Information
Patent Citations
Junction guide device for providing guidance concerning looped branch road
US20010037176A1
Junction guide device for providing guidance concerning looped branch road
US6597986B2
Method for automatically combining road network intersection nodes in OSM map data
CN107704531A
Travel route conversion method and device, computer equipment and computer readable storage medium
CN116401469A