A road network data processing method and device, computer equipment and storage medium
By parsing and preprocessing road network data files, generating in-memory data structures, and loading the preprocessed road network files, the problems of long loading time and large storage space for road network data are solved, thus improving the efficiency of map services.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-03
- Publication Date
- 2026-04-14
AI Technical Summary
In existing technologies, the loading time for road network data is too long and the storage space required is too large, resulting in low efficiency of map services.
The road network data file is parsed to generate an in-memory data structure, and a preprocessed road network file is generated based on this structure. Finally, the preprocessed road network data is loaded into the target road network data.
It effectively shortens the time for map services to load road network data, reduces the overall storage space requirement, and improves the efficiency of road network data loading.
Smart Images

Figure CN116028457B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer and data processing technology, specifically to a road network data processing method, apparatus, computer equipment, and storage medium. Background Technology
[0002] Today, with the rapid development of smart devices and mobile internet technology, more and more application functions need to be based on map services. Most map services require loading road network data to support the subsequent deployment of map services. However, because road network data needs to be continuously updated, the amount of road network data is becoming increasingly large, resulting in longer loading times for each map service and a corresponding increase in the required road network storage space.
[0003] Therefore, how to shorten the road network data loading time and reduce the amount of road network storage space occupied has become a major problem that needs to be solved by those skilled in the art.
[0004] The preceding description is intended to provide general background information and does not necessarily constitute prior art. Summary of the Invention
[0005] To address the aforementioned technical problems, this application provides a road network data processing method, apparatus, computer equipment, and storage medium, which can effectively shorten the time for map services to load road network data, reduce the storage space required for the overall road network, reduce the memory occupied when loading road network data, and thus improve the efficiency of road network data loading.
[0006] To address the aforementioned technical problems, this application provides a road network data processing method, comprising the following steps:
[0007] Read the road network data file;
[0008] The road network data file is parsed to generate a corresponding memory data structure;
[0009] Based on the memory data structure, a corresponding preprocessed road network file is generated;
[0010] Load the preprocessed road network file and output the corresponding target road network data.
[0011] Optionally, the road network data file includes an H3 index, an array of road segments that intersect with each H3 grid, and road data and route shape points corresponding to each road segment in the road segment array.
[0012] Optionally, parsing the road network data file to generate a corresponding in-memory data structure includes:
[0013] The road network data file is parsed to obtain a first memory data structure, a second memory data structure, and a third memory data structure. The first memory data structure is a hash mapping of H3 index encoding and road segment array as key-value pairs. The second memory data structure is a hash mapping of road segments and their corresponding road data as key-value pairs. The third memory data structure is a hash mapping of road segments and their corresponding route shape points as key-value pairs.
[0014] Optionally, generating the corresponding preprocessed road network file based on the memory data structure includes:
[0015] The corresponding road segment array is obtained by H3 index encoding;
[0016] Traverse the road segment array corresponding to the H3 index code to obtain the road segment data and route shape points corresponding to each road segment in the road segment array;
[0017] Based on the road segment data and route shape points corresponding to each road segment in the road segment array, a hash mapping of the road data of the H3 index code and the hexagonal grid corresponding to the H3 index code is constructed.
[0018] The corresponding preprocessed road network file is generated based on the hash mapping.
[0019] Optionally, the format of the preprocessed road network file includes a custom header, map array size, number of map elements, H3 index encoding, number of loops of road data, byte array size, and byte array content; the custom header includes the file magic number, file generation time, original file name, and file author information.
[0020] Optionally, loading the preprocessed road network file and outputting the corresponding target road network data includes:
[0021] Read the custom header of the preprocessed road network file and extract the corresponding file magic number;
[0022] After determining that the type of the preprocessed road network file is the target file type based on the file magic number, the verification value of the preprocessed road network file is obtained;
[0023] After determining that the preprocessed road network file is the desired target file based on the verification value, the contents of the preprocessed road network file excluding the custom header are read, and the target road network data of the corresponding memory data structure is output.
[0024] Optionally, the step of reading the content of the preprocessed road network file excluding the custom header and outputting the target road network data of the corresponding memory data structure includes:
[0025] Load and read the first byte, and read the content corresponding to the length of the first byte as the size of the map array;
[0026] Load and read the second byte, and read the content corresponding to the length of the second byte as the number of map elements to determine the number of loops for the H3 index code and its corresponding road data that need to be read.
[0027] Load and read the third byte, and read the content of the corresponding third byte length as H3 index encoding;
[0028] Load and read the fourth byte, and read the content corresponding to the length of the fourth byte as the loop count for the road segment data corresponding to the target road segment array;
[0029] Load and read the fifth byte, and read the content corresponding to the length of the fifth byte as the size of the byte array to be read;
[0030] Read the corresponding byte data content according to the size of the byte array;
[0031] After reading the required H3 index codes and their corresponding road data, the target road network data of the corresponding memory data structure is output.
[0032] Accordingly, this application also provides a road network data processing apparatus, comprising:
[0033] The reading module is used to read road network data files;
[0034] The parsing module is used to parse the road network data file and generate the corresponding memory data structure;
[0035] The preprocessing module is used to generate a corresponding preprocessed road network file based on the memory data structure.
[0036] The loading module is used to load the preprocessed road network file and output the corresponding target road network data.
[0037] This application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the road network data processing method described above.
[0038] This application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the road network data processing method described above.
[0039] Implementing the embodiments of the present invention has the following beneficial effects:
[0040] As described above, this application provides a road network data processing method, apparatus, computer equipment, and storage medium. The method includes: reading a road network data file; parsing the road network data file to generate a corresponding in-memory data structure; generating a corresponding preprocessed road network file based on the in-memory data structure; loading the preprocessed road network file; and outputting the corresponding target road network data. This road network data processing scheme first parses the road network data file to obtain the corresponding in-memory data structure before generating a preprocessed road network file. This preprocesses multiple road network data files into a single, final-use data structure road network data file, reducing the size of the road network file and lowering the overall storage space required for the road network. Furthermore, outputting the corresponding target road network data based on the loaded preprocessed road network file effectively shortens the time for map services to load road network data, reduces the memory required for loading road network data, and thus improves the efficiency of road network data loading. Attached Figure Description
[0041] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on these drawings without any creative effort.
[0042] Figure 1 This is a schematic flowchart of the road network data processing method provided in the embodiments of this application;
[0043] Figure 2 This is a flowchart illustrating step S3 provided in an embodiment of this application;
[0044] Figure 3 This is a schematic diagram of the preprocessed road network file format provided in the embodiments of this application;
[0045] Figure 4 This is a flowchart illustrating step S4 provided in an embodiment of this application;
[0046] Figure 5 This is a flowchart illustrating step S43 provided in an embodiment of this application;
[0047] Figure 6 This is a schematic diagram of the binary encoding of the preprocessed road network file provided in the embodiments of this application;
[0048] Figure 7 This is a schematic diagram of the structure of the road network data processing device provided in the embodiments of this application;
[0049] Figure 8This is a schematic diagram of the structure of the computer device provided in the embodiments of this application.
[0050] The realization of the objectives, functional features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. The accompanying drawings have illustrated specific embodiments of this application, which will be described in more detail below. These drawings and textual descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concepts of this application to those skilled in the art through reference to specific embodiments. Implementation
[0051] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0052] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, components, features, and elements with the same names in different embodiments of this application may have the same meaning or different meanings, the specific meaning of which must be determined by its interpretation in that specific embodiment or further in conjunction with the context of that specific embodiment.
[0053] It should be understood that although the terms first, second, third, etc., may be used herein to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this document, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word “if” as used herein may be interpreted as “when…” or “in response to determination”. Furthermore, as used herein, the singular forms “a,” “an,” and “the” are intended to also include the plural forms unless the context indicates otherwise. It should be further understood that the terms “comprising,” “including,” indicate the presence of the stated feature, step, operation, element, component, item, kind, and / or group, but do not exclude the presence, occurrence, or addition of one or more other features, steps, operations, elements, components, items, kinds, and / or groups. Please use terms such as “or,” “and / or,” and “including at least one of the following”, which may be interpreted as inclusive or mean any one or any combination thereof. For example, “including at least one of the following: A, B, C” means “any one of the following: A; B; C; A and B; A and C; B and C; A and B and C”, or “A, B, or C” or “A, B, and / or C” means “any one of the following: A; B; C; A and B; A and C; B and C; A and B and C”. Exceptions to this definition will only occur if the combination of elements, functions, steps, or operations is inherently mutually exclusive in some way.
[0054] It should be understood that although the steps in the flowcharts of this application's embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least a portion of the sub-steps or stages of other steps.
[0055] Depending on the context, the words “if” or “suppose” as used here can be interpreted as “when” or “in response to determination” or “in response to detection.” Similarly, depending on the context, the phrases “if determination” or “if detection (of the stated condition or event)” can be interpreted as “when determination” or “in response to determination” or “when detection (of the stated condition or event)” or “in response to detection (of the stated condition or event).”
[0056] It should be noted that step designations such as S1 and S2 are used in this document for the purpose of more clearly and concisely describing the corresponding content, and do not constitute a substantial limitation on the order. In specific implementation, those skilled in the art may execute S2 first and then S1, etc., but these should all be within the protection scope of this application.
[0057] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0058] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustrative purposes and has no specific meaning in itself. Therefore, "module," "part," or "unit" may be used interchangeably.
[0059] The embodiments of this application can be applied to servers. The server can be an independent server or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.
[0060] First, this application introduces the application scenarios it can provide, such as a method, apparatus, computer equipment, and storage medium for road network data processing for H3 spatial index retrieval. By preprocessing multiple road network data files into a road network data file with a final usable data structure, it can effectively shorten the time for map services to load road network data, reduce the storage space required for the overall road network, and reduce the memory required when loading road network data.
[0061] Please see Figure 1 , Figure 1 This is a flowchart illustrating a first embodiment of the road network data processing method provided in this application. Specifically, the road network data processing method may include:
[0062] S1. Read the road network data file.
[0063] Optionally, in some embodiments, the road network data file includes an H3 index, an array of road segments that intersect with each H3 grid, and road data and route shape points corresponding to each road segment in the road segment array.
[0064] Specifically, for step S1, the road network data file to be processed is first obtained. This file can be downloaded from a server or retrieved from a local database. In a specific embodiment, the system software reads the national road network data file via a file stream. The road network data file includes an H3 index, the corresponding H3 grids, a set of linkids (i.e., a road segment array) that intersect with the H3 grids, and the road data and route shape points (coordinate point strings corresponding to road segments) corresponding to each linkid in the linkid set.
[0065] S2. Parse the road network data file to generate the corresponding in-memory data structure.
[0066] Specifically, for step S2, after reading the road network data file, the road network data file is parsed into a corresponding memory data structure. In this embodiment, after parsing the road network data file, it will be parsed into three hashmap data structures.
[0067] Optionally, in some embodiments, step S2 may specifically include:
[0068] The road network data file is parsed to obtain a first memory data structure, a second memory data structure, and a third memory data structure. The first memory data structure is a hash mapping of H3 index encoding and road segment array as key-value pairs. The second memory data structure is a hash mapping of road segments and their corresponding road data as key-value pairs. The third memory data structure is a hash mapping of road segments and their corresponding route shape points as key-value pairs.
[0069] Specifically, after parsing the road network data file, three hashmap data structures are obtained: one is a hash map with H3 index codes and road segment arrays as key-value pairs (i.e., the key is H3code and the value is the linkid array); another is a hash map with road segments and their corresponding road data as key-value pairs (i.e., the key is linkid and the value is the road information corresponding to linkid); and the third is a hash map with road segments and their corresponding route shape points as key-value pairs (i.e., the key is linkid and the value is the coordinate shape point corresponding to linkid). By parsing the road network data file to obtain the corresponding in-memory data structures, and then constructing a preprocessed road network file based on the in-memory data structures, a large amount of data describing road network relationships can be omitted, the overall road network storage space can be compressed, and the memory required for the service to load the road network file can be reduced.
[0070] S3. Generate the corresponding preprocessed road network file based on the memory data structure.
[0071] Specifically, for step S3, the corresponding preprocessed road network file is generated by preprocessing the memory data structure obtained from step S2 through offline preprocessing.
[0072] Optionally, such as Figure 2 As shown, in some embodiments, step S3 may specifically include:
[0073] S31. Obtain the corresponding road segment array through H3 index encoding;
[0074] S32. Traverse the road segment array corresponding to the H3 index code, and obtain the road segment data and route shape points corresponding to each road segment in the road segment array;
[0075] S33. Based on the road segment data and route shape points corresponding to each road segment in the road segment array, construct a hash mapping of the road data of the H3 index code and the hexagonal grid corresponding to the H3 index code;
[0076] S34. Generate the corresponding preprocessed road network file based on the hash mapping.
[0077] In a specific embodiment, based on the three hashmap data structures parsed in step S2, the linkid array corresponding to the H3code (H3 index encoding) is first obtained through H3code. Then, the linkid array corresponding to the H3code is iterated through in a loop. In each loop, the route shape point corresponding to the linkid and the road data corresponding to the linkid are obtained through the linkid in the array. A hashmap mapping relationship between the H3code and the road data of the hexagonal grid corresponding to the H3code is established. Finally, a preprocessed road network file is generated through this hashmap. This embodiment can be applied to obtain local road network data around latitude and longitude, and the size of the obtained local road network data can be flexibly controlled through the H3 grid level. In addition, filling a certain area (different granularities such as province, city, district, street, etc.) with a regular hexagonal grid can divide the road network data into a smaller grid granularity. On the other hand, through the mapping relationship between latitude and longitude, H3 grid and road network data, not only can the storage space be reduced, but the corresponding road network data can also be obtained quickly and efficiently.
[0078] The format of the preprocessed road network file in this embodiment is as follows: Figure 3As shown, it includes a custom header, the size of the map array, the number of map elements, the H3 index encoding, the number of loops of road data, the size of the byte array, and the content of the byte array. Among them, the custom header includes the file magic number and the file generation time, and can also include the original file name and file author information. In this embodiment, by adding a custom header to the preprocessed road network file, it is used to describe the general situation of the preprocessed road network file, such as information about the file type, creation time, file author, etc., and can be used for file verification, such as verifying whether the file is complete and whether the file has been tampered with, etc.
[0079] S4. Load the preprocessed road network file and output the corresponding target road network data.
[0080] Specifically, for step S4, the preprocessed road network file stored in the disk is loaded through the map service, so as to output the target road network data corresponding to the preprocessed road network file into the memory, and complete the loading process of the preprocessed road network file. Among them, the target road network data can include H3code and the road data corresponding to the H3 hexagonal grid spatial index, and the manifestation form can be hashMap<h3code, linkid corresponding road information>.
[0081] Optionally, as Figure 4 shown, in some embodiments, step S4 may specifically include:
[0082] S41. Read the custom header of the preprocessed road network file and extract the corresponding file magic number;
[0083] S42. After judging that the type of the preprocessed road network file is the target file type based on the file magic number, obtain the check value of the preprocessed road network file;
[0084] S43. After judging that the preprocessed road network file is the expected target file based on the check value, read the content of the preprocessed road network file except the custom header and output the target road network data of the corresponding memory data structure.
[0085] In a specific embodiment, step S4 includes the following process: First, read the custom header of the preprocessed road network file. The custom header is 256 bytes in size and is used to describe the detailed information of the road network file, including but not limited to the file magic number, file generation time, original file name, file author, etc. This custom header is used to trace back file-related issues; by reading the preset byte content of the custom header (e.g., the first 4 bytes), the file magic number of the preprocessed road network file is obtained; based on the extracted file magic number, verify whether the file type of the preprocessed road network file to be loaded is the target file type. If the file type of the preprocessed road network file is not the target file type, the verification is performed. If a file loading error occurs, a feedback message is displayed. If the file type of the preprocessed road network file is verified to be the target file type, the verification value (e.g., MD5 value) of the entire preprocessed road network file is obtained. By comparing the MD5 value of the currently read preprocessed road network file with the MD5 value of the expected file to be loaded, the integrity of the entire preprocessed road network file is verified. Only when the file type is verified to be the target file type and the file integrity verification passes can the currently read preprocessed road network file be determined to be the expected target file, thus proceeding to the next step of reading the preprocessed road network file. Finally, the target road network data of the data structure corresponding to the preprocessed road network file is output. This embodiment, by describing the size and content of the data to be read next in the preprocessed file, and reading the data into memory according to the rules described in the file, can effectively reduce the automatic expansion of the map data structure, thereby reducing the memory occupied during map data loading.
[0086] Optionally, such as Figure 5 As shown, in some embodiments, step S43 may specifically include:
[0087] S431. Load and read the first byte, and read the content corresponding to the length of the first byte as the size of the map array;
[0088] S432. Load and read the second byte, and read the content corresponding to the length of the second byte as the number of map elements to determine the number of loops for the H3 index code and its corresponding road data that need to be read.
[0089] S433. Load and read the third byte, and read the content of the corresponding length of the third byte as the H3 index encoding;
[0090] S434. Load and read the fourth byte, and read the content corresponding to the length of the fourth byte as the loop count for the road segment data corresponding to the target road segment array;
[0091] S435. Load and read the fifth byte, and read the content corresponding to the length of the fifth byte as the size of the byte array to be read;
[0092] S436. Read the corresponding byte data content according to the size of the byte array;
[0093] S437. After reading the required H3 index codes and their corresponding road data, output the target road network data of the corresponding memory data structure.
[0094] Specifically, for step S43, after reading the custom header of the file and passing the verification, the first byte is loaded and read, for example, 1 byte A. The literal of byte A is used to describe the byte length of the next data to be read. Then, the content is read according to the specified byte length obtained from reading the first byte, which serves as the size of the node array of the Map. The next byte B (the second byte) is read, and the literal of byte B is used to describe the byte length of the next data to be read. The content is then read according to the specified byte length obtained from reading the second byte, which serves as the number of elements in the Map, guiding the number of loops to read the h3code and corresponding road information. The next byte C (the third byte) is read, and the literal of byte C is used to describe the byte length of the next data to be read. The content is then read according to the specified byte length obtained from reading the third byte, which serves as the H3code (H3 index code). (Code); Continue reading the next byte D (the fourth byte). The literal of byte D describes the length of the next byte of data to be read. Then, read the content according to the specified byte length obtained from reading the fourth byte, and use this content as the size of the list collection (this list collection is used to store the road information corresponding to the link). This size is used to guide the number of loops to read the road information corresponding to the link. Continue reading the next byte E (the fifth byte). The literal of byte E describes the length of the next byte of data to be read. Then, read the content according to the specified byte length obtained from reading the fifth byte. This content is used as the size of the byte array to be read next. According to the specified byte array size, read the byte data content (that is, the road information corresponding to the link), and finally generate the target road network data of the memory data structure corresponding to the preprocessed file. Then, output the target road network data to memory for subsequent loading or processing.
[0095] To facilitate understanding of the above steps, this embodiment also provides an explanation of the preprocessing of road network files, for example...
[0096] {
[0097] 1234567891011: [[1011,0101],[0101,0101,0101],
[0101] ]
[0098] }
[0099] The map above contains the following content in Java:
[0100] (1) The size of the table array in the Map is 16, and the key-value pair is 1;
[0101] (2) 1234567891011 is the h3 spatial index encoding of type long, and [1011,0101] is the byte array of road information corresponding to a single linkid;
[0102] (3) [[1011,0101],[0101,0101,0101],
[0101] ] is a list of road information corresponding to linkids of variable length;
[0103] (4) File generation time: 2022-07-04 22:43:46.
[0104] The preprocessed road network file is encoded in binary, specifically as follows: Figure 6 As shown.
[0105] In summary, the road network data processing method provided in this application includes: reading a road network data file; parsing the road network data file to generate a corresponding in-memory data structure; generating a corresponding preprocessed road network file based on the in-memory data structure; loading the preprocessed road network file and outputting the corresponding target road network data. This application first parses the road network data file to obtain the corresponding in-memory data structure before generating the preprocessed road network file. Multiple road network data files are preprocessed into a single, final-use data structure road network data file using an offline preprocessing method, reducing the size of the road network file and lowering the overall storage space required for the road network. Furthermore, the corresponding target road network data is output based on the loaded preprocessed road network file. The preprocessed road network file describes the size and content of the data to be read subsequently. When reading road network data into memory according to the file description rules, the time for map services to load road network data can be effectively shortened, and the memory required for loading road network data can be reduced, thereby improving the efficiency of road network data loading.
[0106] To better implement the road network data processing method of this application embodiment, this application embodiment also provides a road network data processing device based on the above road network data processing method, wherein the meanings of the terms are the same as in the above road network data processing method, and specific implementation details can be referred to the description in the method embodiment.
[0107] Please see Figure 7 , Figure 7This is a schematic diagram of the structure of a road network data processing device provided in an embodiment of this application. The road network data processing device may include a reading module 100, a parsing module 200, a preprocessing module 300, and a loading module 400.
[0108] Reading module 100 is used to read road network data files.
[0109] Specifically, for the reading module 100, the first step is to obtain the road network data file to be processed. This road network data file can be downloaded from a server or retrieved from a local database. In a specific embodiment, the system software reads the national road network data file via a file stream. The road network data file includes an H3 index, the corresponding H3 grids, a set of linkids (i.e., a road segment array) that intersect with the H3 grids, and the road data and route shape points (coordinate point strings corresponding to road segments) corresponding to each linkid in the linkid set.
[0110] The parsing module 200 is used to parse the road network data file and generate a corresponding memory data structure.
[0111] Specifically, for the parsing module 200, after reading the road network data file, it parses the road network data file into a corresponding memory data structure. In this embodiment, after parsing the road network data file, it will parse the road network data file into 3 hashmap data structures.
[0112] The preprocessing module 300 is used to generate a corresponding preprocessed road network file based on the memory data structure.
[0113] Specifically, the preprocessing module 300 mainly generates the corresponding preprocessed road network file by preprocessing the parsed memory data structure through offline preprocessing.
[0114] Optionally, in some embodiments, the preprocessing module 300 may specifically include:
[0115] The first preprocessing unit is used to obtain the corresponding road segment array through H3 index encoding;
[0116] The second preprocessing unit is used to traverse the road segment array corresponding to the H3 index code and obtain the road segment data and route shape points corresponding to each road segment in the road segment array.
[0117] The third preprocessing unit is used to construct a hash mapping of road data with H3 index encoding and the corresponding hexagonal grid based on the road segment data and route shape points corresponding to each road segment in the road segment array;
[0118] The fourth preprocessing unit is used to generate the corresponding preprocessed road network file based on the hash mapping.
[0119] The loading module 400 is used to load the preprocessed road network file and output the corresponding target road network data.
[0120] Specifically, for the loading module 400, the preprocessed road network file stored on the disk is loaded through the map service, and the target road network data corresponding to the preprocessed road network file is output to the memory, thus completing the loading process of the preprocessed road network file. The target road network data may include road data corresponding to H3code and H3 hexagonal grid spatial index.
[0121] Optionally, in some embodiments, the loading module 400 may specifically include:
[0122] The extraction unit is used to read the custom header of the preprocessed road network file and extract the corresponding file magic number;
[0123] The verification unit is used to obtain the verification value of the preprocessed road network file after determining that the type of the preprocessed road network file is the target file type based on the file magic number;
[0124] The output unit is used to read the contents of the preprocessed road network file, excluding the custom header, and output the target road network data of the corresponding memory data structure after determining that the preprocessed road network file is the expected target file based on the check value.
[0125] In summary, the road network data processing apparatus provided in this application includes: a reading module 100 for reading road network data files; a parsing module 200 for parsing the road network data files and generating corresponding memory data structures; a preprocessing module 300 for generating corresponding preprocessed road network files based on the memory data structures; and a loading module 400 for loading the preprocessed road network files and outputting corresponding target road network data. This application first parses the road network data files to obtain the corresponding memory data structures before generating preprocessed road network files. Multiple road network data files are preprocessed into a single, final-use data structure road network data file using offline preprocessing, reducing the size of the road network files and lowering the overall storage space required for the road network. Furthermore, the corresponding target road network data is output based on the loaded preprocessed road network file. The preprocessed road network file describes the size and content of the data to be read subsequently. When reading road network data into memory according to the file description rules, the loading time of map services for road network data can be effectively shortened, and the memory required for loading road network data can be reduced, thereby improving the efficiency of road network data loading.
[0126] Furthermore, embodiments of this application also provide a computer device, such as... Figure 8As shown, it illustrates a structural schematic diagram of the computer device involved in the embodiments of this application, specifically:
[0127] The computer device may include components such as a processor 301 with one or more processing cores, a memory 302 with one or more computer-readable storage media, a power supply 303, and an input unit 304. Those skilled in the art will understand that... Figure 8 The computer device structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:
[0128] The processor 301 is the control center of the computer device. It connects various parts of the computer device via various interfaces and lines, and performs various functions and processes data by running or executing software programs and / or modules stored in the memory 302, and by calling data stored in the memory 302, thereby providing overall monitoring of the computer device. Optionally, the processor 301 may include one or more processing cores; preferably, the processor 301 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 301.
[0129] The memory 302 can be used to store software programs and modules. The processor 301 executes various functional applications and road network data processing by running the software programs and modules stored in the memory 302. The memory 302 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 302 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 302 may also include a memory controller to provide the processor 301 with access to the memory 302.
[0130] The computer device also includes a power supply 303 that supplies power to the various components. Preferably, the power supply 303 can be logically connected to the processor 301 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 303 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0131] The computer device may also include an input unit 304, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0132] Although not shown, the computer device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 301 in the computer device loads the executable files corresponding to the processes of one or more applications into the memory 302 according to the following instructions, and the processor 301 runs the applications stored in the memory 302 to realize various functions, as follows:
[0133] Read the road network data file; parse the road network data file to generate the corresponding in-memory data structure; generate the corresponding preprocessed road network file based on the in-memory data structure; load the preprocessed road network file and output the corresponding target road network data.
[0134] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0135] This application embodiment parses road network data files to obtain corresponding memory data structures before generating preprocessed road network files. By preprocessing multiple road network data files into a single data structure road network data file in a final usable state, the size of the road network files is reduced, thus lowering the overall storage space required for the road network. Furthermore, by outputting the corresponding target road network data based on the loaded preprocessed road network file, the loading time of map services for road network data can be effectively shortened, the memory required for loading road network data can be reduced, and the loading efficiency of road network data can be improved.
[0136] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0137] Therefore, embodiments of this application provide a storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the road network data processing methods provided in embodiments of this application. For example, the instructions can execute the following steps:
[0138] Read the road network data file; parse the road network data file to generate the corresponding in-memory data structure; generate the corresponding preprocessed road network file based on the in-memory data structure; load the preprocessed road network file and output the corresponding target road network data.
[0139] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0140] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0141] Since the instructions stored in the storage medium can execute the steps of any of the road network data processing methods provided in the embodiments of this application, the beneficial effects that any of the road network data processing methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.
[0142] The foregoing has provided a detailed description of a road network data processing method, apparatus, computer equipment, and storage medium provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A road network data processing method, characterized in that, Includes the following steps: Read the road network data file; The road network data file is parsed to generate a corresponding memory data structure; Based on the memory data structure, a corresponding preprocessed road network file is generated; Load the preprocessed road network file and output the corresponding target road network data; The step of parsing the road network data file to generate a corresponding in-memory data structure includes: The road network data file is parsed to obtain a first memory data structure, a second memory data structure, and a third memory data structure. The first memory data structure is a hash mapping of H3 index encoding and road segment array as key-value pairs; the second memory data structure is a hash mapping of road segments and their corresponding road data as key-value pairs; and the third memory data structure is a hash mapping of road segments and their corresponding route shape points as key-value pairs. The step of generating the corresponding preprocessed road network file based on the memory data structure includes: The corresponding road segment array is obtained by H3 index encoding; Traverse the road segment array corresponding to the H3 index code to obtain the road segment data and route shape points corresponding to each road segment in the road segment array; Based on the road segment data and route shape points corresponding to each road segment in the road segment array, a hash mapping of the road data of the H3 index code and the hexagonal grid corresponding to the H3 index code is constructed. Generate a corresponding preprocessed road network file based on the hash mapping; The loading of the preprocessed road network file and the output of the corresponding target road network data include: Read the custom header of the preprocessed road network file and extract the corresponding file magic number; After determining that the type of the preprocessed road network file is the target file type based on the file magic number, the verification value of the preprocessed road network file is obtained; After determining that the preprocessed road network file is the desired target file based on the verification value, the contents of the preprocessed road network file excluding the custom header are read, and the target road network data of the corresponding memory data structure is output.
2. The road network data processing method according to claim 1, characterized in that, The road network data file includes an H3 index, an array of road segments that intersect with each H3 grid, and road data and route shape points corresponding to each road segment in the road segment array.
3. The road network data processing method according to claim 1, characterized in that, The format of the preprocessed road network file includes a custom header, map array size, number of map elements, H3 index encoding, number of loops of road data, byte array size, and byte array content; the custom header includes the file magic number, file generation time, original file name, and file author information.
4. The road network data processing method according to claim 1, characterized in that, The step of reading the contents of the preprocessed road network file excluding the custom header and outputting the target road network data of the corresponding memory data structure includes: Load and read the first byte, and read the content corresponding to the length of the first byte as the size of the map array; Load and read the second byte, and read the content corresponding to the length of the second byte as the number of map elements to determine the number of loops for the H3 index code and its corresponding road data that need to be read. Load and read the third byte, and read the content of the corresponding third byte length as H3 index encoding; Load and read the fourth byte, and read the content corresponding to the length of the fourth byte as the loop count for the road segment data corresponding to the target road segment array; Load and read the fifth byte, and read the content corresponding to the length of the fifth byte as the size of the byte array to be read; Read the corresponding byte data content according to the size of the byte array; After reading the required H3 index codes and their corresponding road data, the target road network data of the corresponding memory data structure is output.
5. A road network data processing device, characterized in that, include: The reading module is used to read road network data files; The parsing module is used to parse the road network data file and generate corresponding memory data structures, including: parsing the road network data file to obtain a first memory data structure, a second memory data structure, and a third memory data structure; wherein, the first memory data structure is a hash mapping of H3 index encoding and road segment array as key-value pairs, the second memory data structure is a hash mapping of road segments and corresponding road data as key-value pairs, and the third memory data structure is a hash mapping of road segments and corresponding route shape points as key-value pairs; The preprocessing module is used to generate a corresponding preprocessed road network file based on the memory data structure, including: obtaining the corresponding road segment array through H3 index encoding; traversing the road segment array corresponding to the H3 index encoding to obtain the road segment data and route shape points corresponding to each road segment in the road segment array; constructing a hash mapping of the road data of the H3 index encoding and the hexagonal grid corresponding to the H3 index encoding based on the road segment data and route shape points corresponding to each road segment in the road segment array; and generating the corresponding preprocessed road network file based on the hash mapping. The loading module is used to load the preprocessed road network file and output the corresponding target road network data, including: reading the custom header of the preprocessed road network file and extracting the corresponding file magic number; after determining that the type of the preprocessed road network file is the target file type based on the file magic number, obtaining the check value of the preprocessed road network file; after determining that the preprocessed road network file is the expected target file based on the check value, reading the content of the preprocessed road network file excluding the custom header, and outputting the target road network data of the corresponding memory data structure.
6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the road network data processing method as described in any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the road network data processing method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Method for creating Paramics road network based on XML (Extensive Markup Language) road network data
CN104679949A