Method for rapidly calculating road where vehicle is located based on vehicle positioning
By marking and storing road information in detail and quickly querying and judging the HashMap data structure, the problems of low recognition accuracy and slow calculation speed in traditional methods are solved, and more efficient and accurate vehicle position judgment is achieved.
Patent Information
- Application Number
- CN202510063585.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-15
- Publication Date
- 2025-04-25
AI Technical Summary
The traditional method of determining the road where the vehicle is located has problems such as low accuracy and slow calculation speed, which cannot effectively support the needs of intelligent transportation systems.
By marking and storing road information in detail, using the HashMap data structure for quick query and judgment, it realizes rapid calculation and accurate identification of the road where the vehicle is located.
It improves the calculation speed and accuracy of the road where the vehicle is located, reduces the pressure of database access, optimizes memory usage, and ensures the long-term and stable operation of the system.
Smart Images

Figure CN119889036A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of road positioning, and in particular to a method for quickly calculating a road where a vehicle is located based on vehicle positioning. Background Art
[0002] In intelligent transportation systems, accurately and quickly determining the road a vehicle is on is of great significance for traffic management, navigation services, and other aspects. Traditional methods for determining the road a vehicle is on have problems such as low accuracy and slow calculation speed. For example, the current vehicle positioning terminal can only report vehicle positioning data (including latitude and longitude, speed information), but cannot identify the road the vehicle is on, and thus cannot implement subsequent speeding judgments, driver road habits, and other applications based on the vehicle's road information. Therefore, a method is needed that can efficiently and accurately calculate the vehicle's road based on vehicle positioning information. Summary of the invention
[0003] In view of the shortcomings of the above-mentioned prior art, the present application provides a method for quickly calculating the road where a vehicle is located based on vehicle positioning. By marking and storing the road information in detail and using the HashMap data structure for quick query and judgment, the speed and accuracy of calculating the road where the vehicle is located can be greatly improved. For roads of different shapes, a specific latitude and longitude array representation is adopted, so that the present method can better adapt to complex road conditions and improve the versatility and adaptability of the method. The function of mapD to automatically delete key-value pairs that have not been called for a long time optimizes memory usage, avoids the waste of memory resources, and is conducive to the long-term stable operation of the system.
[0004] The technical solution adopted by the present invention is as follows: Step 1: Collect information on major roads across the country and mark each road. The marking content includes road ID, longitude and latitude array, maximum and minimum longitude and latitude values, and associated road ID, and save the road data in the database; Step 2: Create two HashMaps, denoted as mapC and mapD; mapC is used to store data in memory in the form of key-value pairs; mapD has the functions of mapC and also has the function of automatically deleting key-value pairs when the key is not called for a period of time; mapC saves license plate numbers and road ids; mapD saves road ids and road data; Step 3: Determine the road based on the road information stored in the database and the HashMap. The determination process includes the following steps: A1: The target vehicle uploads real-time positioning data (including latitude and longitude, license plate number and speed) named E. The value in mapC is obtained according to the license plate number. If there is a road id and the speed is greater than 0, enter A2; if there is a road id and the speed is 0, the calculation ends and the road id is returned. If there is no road id, enter A6; A2: According to the road id, obtain the corresponding road data in mapD and name it F. If it is not available, obtain the road data F from the database and add the obtained data to mapD. After obtaining the data F, compare the maximum and minimum values of the longitude and latitude of F with those of E to determine whether E is within the maximum and minimum values of the longitude and latitude of F. If so, proceed to A3; if not, proceed to A4. A3: Determine whether E is in the latitude and longitude array of F. If so, the calculation ends and the road ID of F is returned. If not, proceed to A5. A4: Find the ID of the associated road through the road data F. If there is an ID of the associated road, proceed to A5. If not, proceed to A6. A5: Obtain the corresponding road data in mapD by associating the road ID. If the data is not found, search through the database and add it to mapD. If the associated roads F1, F2, and F3 are found, determine whether E is within the maximum and minimum values of the longitude and latitude of F1, F2, and F3. If none of them exists, go to A6. If E is in the maximum and minimum values of longitude and latitude of F1, determine whether E is in the longitude and latitude array of F1. If so, the calculation ends, update mapC (E's license plate, F1's id), and return F1's road id. If not, go to A6. If E is between the maximum and minimum values of longitude and latitude of F1 and F2, the distance between E and F1 is calculated as z1, and the distance between E and F2 is calculated as z2, and the closest distance is taken; if the closest distance is less than 20 meters, the calculation ends, mapC (E's license plate, F2's id) is updated, and F2's id is returned; if the closest distance is greater than 20 meters, enter A6; A6: Compare E's longitude and latitude with the maximum and minimum values of all roads in the database. If E is not in any of them, it is determined that E is not on the road. If E is in the maximum and minimum values of F4's longitude and latitude, calculate the distance between E and F4's longitude and latitude arrays as z. If z is less than 20 meters, update mapC (E's license plate, F4's id) and return F4's road id. If z is greater than 20 meters, it is determined that E is not on the road. If E is in the maximum and minimum values of F5, F6, and F7's longitude and latitude, calculate the minimum distance between E and F5's longitude and latitude arrays as z1, the minimum distance between E and F6's longitude and latitude arrays as z2, and the minimum distance between E and F7's longitude and latitude arrays as z3. Take the minimum value of z1, z2, and z3. If the minimum value is greater than 20 meters, it is determined that E is not on the road. If z3 is less than 20 meters, update mapC (E's license plate, F7's id) and return F7's road id.
[0005] Furthermore, when the road is a straight line, the longitude and latitude array is the longitude and latitude of the starting point and the end point; When the road is an arc, there will be longitude and latitude at the corners, and the line segment formed by the longitude and latitude array is similar to the arc; When the road is a closed arc, the latitude and longitude start point and end point are the same.
[0006] Furthermore, the maximum and minimum values of longitude and latitude are calculated according to the longitude and latitude array of each road.
[0007] Furthermore, after a large amount of road data is obtained, for example, X road data has been obtained, the X data are traversed, and the traversed road A is compared with the remaining roads in turn, and the compared road is B; if A and B have an intersection, when marking, the id of road B is added to the associated road id of road A.
[0008] The beneficial effects of the present invention compared with the prior art are as follows: When determining the road where the vehicle is located, the present invention first quickly obtains the corresponding road id (if any) based on the license plate number in mapC, and then uses the road data cached in mapD or obtains road data from the database when necessary, and quickly determines whether the vehicle is roughly within a certain road range through the maximum and minimum values of longitude and latitude, and then further determines whether the vehicle is actually on the road through a more accurate longitude and latitude array. This process of first rough screening and then accurate judgment can complete the vehicle position judgment in a shorter time and improve the overall computing efficiency.
[0009] At the same time, the pressure on database access is reduced; the present invention uses the mapD caching mechanism for road data to directly obtain the required road data from the memory in most cases, reducing the number of times data is frequently obtained from the database, effectively alleviating the pressure on database access, and enabling the entire system to operate more stably and efficiently when processing a large number of vehicle positioning requests, avoiding performance bottlenecks caused by frequent database access. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] Figure 1 is a flow chart of the present invention; Figure 2 This is a flow chart of step A6 in the present invention. DETAILED DESCRIPTION
[0011] The specific implementation of the present invention is described below in conjunction with the accompanying drawings.
[0012] like Figure 1 and Figure 2 As shown, the present invention includes: Step 1: Collect information on major roads across the country and mark each road. The marking content includes road ID, longitude and latitude array, maximum and minimum longitude and latitude values, and associated road ID, and save the road data in the database; Step 2: Create two HashMaps, denoted as mapC and mapD; mapC is used to store data in memory in the form of key-value pairs; mapD has the functions of mapC and also has the function of automatically deleting key-value pairs when the key is not called for a period of time; mapC saves license plate numbers and road ids; mapD saves road ids and road data; Step 3: Determine the road based on the road information stored in the database and the HashMap. The determination process includes the following steps: A1: The target vehicle uploads real-time positioning data (including latitude and longitude, license plate number and speed) named E. The value in mapC is obtained according to the license plate number. If there is a road id and the speed is greater than 0, enter A2; if there is a road id and the speed is 0, the calculation ends and the road id is returned. If there is no road id, enter A6; A2: According to the road id, obtain the corresponding road data in mapD and name it F. If it is not available, obtain the road data F from the database and add the obtained data to mapD. After obtaining the data F, compare the maximum and minimum values of the longitude and latitude of F with those of E to determine whether E is within the maximum and minimum values of the longitude and latitude of F. If so, proceed to A3; if not, proceed to A4. A3: Determine whether E is in the latitude and longitude array of F. If so, the calculation ends and the road ID of F is returned. If not, proceed to A5. A4: Find the ID of the associated road through the road data F. If there is an ID of the associated road, proceed to A5. If not, proceed to A6. A5: Obtain the corresponding road data in mapD by associating the road ID. If the data is not found, search through the database and add it to mapD. If the associated roads F1, F2, and F3 are found, determine whether E is within the maximum and minimum values of the longitude and latitude of F1, F2, and F3. If none of them exists, go to A6. If E is in the maximum and minimum values of longitude and latitude of F1, determine whether E is in the longitude and latitude array of F1. If so, the calculation ends, update mapC (E's license plate, F1's id), and return F1's road id. If not, go to A6. If E is between the maximum and minimum values of longitude and latitude of F1 and F2, the distance between E and F1 is calculated as z1, and the distance between E and F2 is calculated as z2, and the closest distance is taken; if the closest distance is less than 20 meters, the calculation ends, mapC (E's license plate, F2's id) is updated, and F2's id is returned; if the closest distance is greater than 20 meters, enter A6; A6: Compare E's longitude and latitude with the maximum and minimum values of all roads in the database. If E is not in any of them, it is determined that E is not on the road. If E is in the maximum and minimum values of F4's longitude and latitude, calculate the distance between E and F4's longitude and latitude arrays as z. If z is less than 20 meters, update mapC (E's license plate, F4's id) and return F4's road id. If z is greater than 20 meters, it is determined that E is not on the road. If E is in the maximum and minimum values of F5, F6, and F7's longitude and latitude, calculate the minimum distance between E and F5's longitude and latitude arrays as z1, the minimum distance between E and F6's longitude and latitude arrays as z2, and the minimum distance between E and F7's longitude and latitude arrays as z3. Take the minimum value of z1, z2, and z3. If the minimum value is greater than 20 meters, it is determined that E is not on the road. If z3 is less than 20 meters, update mapC (E's license plate, F7's id) and return F7's road id.
[0013] In one embodiment of the present invention, when the road is a straight line, the longitude and latitude array is the longitude and latitude of the starting point and the end point; When the road is an arc, there will be longitude and latitude at the corners, and the line segment formed by the longitude and latitude array is similar to the arc; When the road is a closed arc, the latitude and longitude start point and end point are the same.
[0014] In one embodiment of the present invention, the maximum and minimum values of longitude and latitude are calculated based on the longitude and latitude array of each road.
[0015] In one embodiment of the present invention, after a large amount of road data is obtained, for example, X road data have been obtained, the X data are traversed, and the traversed road A is compared with the remaining roads in turn, and the compared road is B; if A and B have an intersection, when marking, the id of the B road is added to the associated road id of the A road.
[0016] The preferred implementation of the present invention is: Road information collection and storage Collect information on major roads across the country and use professional geographic information collection tools or map data to provide and obtain detailed information on roads.
[0017] For a straight road, the longitude and latitude of the starting point and the end point are recorded as a longitude and latitude array; for a curved road, the longitude and latitude are recorded at the corners so that the line segment formed by the longitude and latitude array is similar to the arc; for a closed curved road, the longitude and latitude of the starting point and the end point are the same.
[0018] Calculate the maximum and minimum longitude and latitude of each road based on the longitude and latitude array.
[0019] The information such as road ID, longitude and latitude array, maximum and minimum values of longitude and latitude, and associated road ID are saved in the database.
[0020] Create HashMap Use the HashMap data structure of a programming language (such as Java) to create mapC and mapD. During the program initialization phase, frequently accessed data is stored in mapC as key-value pairs for quick reading. At the same time, mapD is set to automatically delete key-value pairs that have not been called for a long time. For example, a time threshold can be set. When a key is not called for more than the time threshold, the corresponding key-value pair is automatically deleted.
[0021] Vehicle road determination A1: The target vehicle uploads real-time positioning data (including latitude and longitude, license plate number and speed) named E. The value in mapC is taken according to the license plate number. If there is a road id and the speed is greater than 0, enter A2; if there is a road id and the speed is 0, the calculation ends and the road id is returned. If there is no road id, enter A6 A2: According to the road id, obtain the corresponding road data in mapD and name it F. If it is not available, obtain the road data F from the database and add the obtained data to mapD. After obtaining the data F, compare the maximum and minimum values of the longitude and latitude of F with those of E to determine whether E is within the maximum and minimum values of the longitude and latitude of F. If so, proceed to A3; if not, proceed to A4. A3: Determine whether E is in the latitude and longitude array of F. If so, the calculation ends and the road ID of F is returned. If not, proceed to A5. A4: Find the ID of the associated road through the road data F. If there is an ID of the associated road, proceed to A5. If not, proceed to A6. A5: Obtain the corresponding road data in mapD by associating the road ID. If the data is not found, search through the database and add it to mapD. If the associated roads F1, F2, and F3 are found, determine whether E is within the maximum and minimum values of the longitude and latitude of F1, F2, and F3. If none of them exists, go to A6. If E is in the maximum and minimum values of longitude and latitude of F1, determine whether E is in the longitude and latitude array of F1. If so, the calculation ends, update mapC (E's license plate, F1's id), and return F1's road id. If not, go to A6. If E is between the maximum and minimum values of longitude and latitude of F1 and F2, the distance between E and F1 is calculated as z1, and the distance between E and F2 is calculated as z2, and the closest distance is taken; if the closest distance is less than 20 meters, the calculation ends, mapC (E's license plate, F2's id) is updated, and F2's id is returned; if the closest distance is greater than 20 meters, enter A6; A6: Compare E's longitude and latitude with the maximum and minimum values of all roads in the database. If E is not in any of them, it is determined that E is not on the road. If E is in the maximum and minimum values of F4's longitude and latitude, calculate the distance between E and F4's longitude and latitude arrays as z. If z is less than 20 meters, update mapC (E's license plate, F4's id) and return F4's road id. If z is greater than 20 meters, it is determined that E is not on the road. If E is in the maximum and minimum values of F5, F6, and F7's longitude and latitude, calculate the minimum distance between E and F5's longitude and latitude arrays as z1, the minimum distance between E and F6's longitude and latitude arrays as z2, and the minimum distance between E and F7's longitude and latitude arrays as z3. Take the minimum value of z1, z2, and z3. If the minimum value is greater than 20 meters, it is determined that E is not on the road. If z3 is less than 20 meters, update mapC (E's license plate, F7's id) and return F7's road id.
[0022] The above description is an explanation of the present invention, not a limitation of the present invention. The scope of the present invention is defined in the claims. Any form of modification may be made within the scope of protection of the present invention.
Claims
1. A method for quickly calculating the road where a vehicle is located based on vehicle positioning, characterized in that: The steps include: Step 1: Collect information on major roads across the country and mark each road. The marking content includes road ID, road longitude and latitude array, maximum and minimum longitude and latitude, and associated road ID, and save the road data in the database; Step 2: Create two HashMaps, denoted as mapC and mapD; mapC is used to store data in memory in the form of key-value pairs; mapD has the functions of mapC and also has the function of automatically deleting key-value pairs when the key is not called for a period of time; mapC saves license plate numbers and road ids; mapD saves road ids and road data; Step 3: Determine the road based on the road information stored in the database and the HashMap. The determination process includes the following steps: A1: The target vehicle uploads real-time positioning data (including latitude and longitude, license plate number and speed) named E. The value in mapC is obtained according to the license plate number. If there is a road id and the speed is greater than 0, enter A2; if there is a road id and the speed is 0, the calculation ends and the road id is returned. If there is no road id, enter A6; A2: According to the road id, obtain the corresponding road data in mapD and name it F. If it is not available, obtain the road data F from the database and add the obtained data to mapD. After obtaining the data F, compare the maximum and minimum values of the longitude and latitude of F with those of E to determine whether E is within the maximum and minimum values of the longitude and latitude of F. If so, proceed to A3; if not, proceed to A4. A3: Determine whether E is in the longitude and latitude array of F. If so, the calculation ends and the road ID of F is returned. If not, proceed to A5; A4: Find the ID of the associated road through the road data F. If there is an ID of the associated road, proceed to A5. If not, proceed to A6. A5: Obtain the corresponding road data in mapD by associating the road ID. If the data is not found, search through the database and add it to mapD. If the associated roads F1, F2, and F3 are found, determine whether E is within the maximum and minimum values of the longitude and latitude of F1, F2, and F3. If none of them exists, go to A6. If E is in the maximum and minimum values of longitude and latitude of F1, determine whether E is in the longitude and latitude array of F1. If so, the calculation ends, update mapC (E's license plate, F1's id), and return F1's road id. If not, proceed to A6; If E is between the maximum and minimum values of longitude and latitude of F1 and F2, the distance between E and F1 is calculated as z1, and the distance between E and F2 is calculated as z2, and the closest distance is taken; if the closest distance is less than 20 meters, the calculation ends, mapC (E's license plate, F2's id) is updated, and F2's id is returned; if the closest distance is greater than 20 meters, enter A6; A6: Compare E's longitude and latitude with the maximum and minimum values of all roads in the database. If E is not in any of them, it is determined that E is not on the road. If E is in the maximum and minimum values of F4's longitude and latitude, calculate the distance between E and F4's longitude and latitude arrays as z. If z is less than 20 meters, update mapC (E's license plate, F4's id) and return F4's road id. If z is greater than 20 meters, it is determined that E is not on the road. If E is in the maximum and minimum values of F5, F6, and F7's longitude and latitude, calculate the minimum distance between E and F5's longitude and latitude arrays as z1, the minimum distance between E and F6's longitude and latitude arrays as z2, and the minimum distance between E and F7's longitude and latitude arrays as z3. Take the minimum value of z1, z2, and z3. If the minimum value is greater than 20 meters, it is determined that E is not on the road. If z3 is less than 20 meters, update mapC (E's license plate, F7's id) and return F7's road id.
2. A method for quickly calculating the road where a vehicle is located based on vehicle positioning as claimed in claim 1, characterized in that: When the road is a straight line, the longitude and latitude array is the longitude and latitude of the starting point and the end point; When the road is an arc, there will be longitude and latitude at the corners, and the line segment formed by the longitude and latitude array is similar to the arc; When the road is a closed arc, the latitude and longitude start point and end point are the same.
3. A method for quickly calculating the road where a vehicle is located based on vehicle positioning as claimed in claim 1, characterized in that: Calculate the maximum and minimum values of longitude and latitude based on the longitude and latitude array of each road.
4. A method for quickly calculating the road where a vehicle is located based on vehicle positioning as claimed in claim 1, characterized in that: After a large amount of road data is obtained, for example, X road data has been obtained, the X data are traversed, and the traversed road A is compared with the remaining roads in turn, and the compared road is B; if A and B have an intersection, when marking, the id of road B is added to the associated road id of road A.