An offline map data processing method and system
By employing layered key protection and slice encryption technology, the efficiency and security issues of map data processing on embedded devices are resolved, enabling efficient and secure loading of offline maps.
Patent Information
- Application Number
- CN202611344287.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-01
- Publication Date
- 2026-11-24
AI Technical Summary
In existing technologies, embedded devices, with limited storage memory, running memory, and chip computing power, struggle to process offline map data efficiently and securely, resulting in insufficient real-time map display performance and a lack of data security.
A hierarchical key protection mechanism and a location-distributed slice encryption method are adopted. A random number generator generates real keys and meta keys. The map file is partitioned and encrypted using the header key and data key. The meta key is used to decrypt and locate the required data, thus achieving streaming on-demand decryption.
While ensuring the security of map data, it significantly reduces the amount of data and computation required for decryption, and improves the response speed of map loading and the memory utilization efficiency of the device.
Smart Images

Figure CN123157828A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and specifically to an offline map data processing method and system. Background Technology
[0002] With the intelligent development of embedded devices such as cycling computers and fitness trackers, offline map functionality has become an important application scenario for these devices. However, due to the limited storage memory, RAM, and chip computing power of these devices, how to efficiently and securely process offline map data on resource-constrained embedded platforms has become a pressing technical problem that needs to be solved.
[0003] Currently, existing methods for processing offline map data typically employ a general encryption algorithm to encrypt the entire map file, or directly use open-source map building tools to generate an unencrypted standard format map file. When the map is needed, the entire encrypted file must be decrypted and loaded into memory, and then the corresponding part is extracted from the decrypted complete data for rendering according to display requirements.
[0004] In the aforementioned existing technologies, the complex calculation process of general encryption algorithms places high demands on the computing power of the device. When running on low-power embedded platforms such as code tables, it will significantly affect the system response speed and make it difficult to meet the performance requirements of real-time map display. At the same time, directly using unencrypted open-source map formats exposes the data to the risk of being directly extracted or parsed, lacking effective information security protection. In addition, the overall encryption and decryption method requires processing a large amount of irrelevant data each time the map is loaded, resulting in a waste of limited memory and computing power resources. Summary of the Invention
[0005] In view of the shortcomings of the related technologies, the purpose of this invention is to provide an offline map data processing method and system to solve the technical problems in the prior art where the limited computing power of the device makes it difficult to run general encryption and decryption algorithms, and at the same time, the secure storage of map data and real-time efficient loading cannot be achieved simultaneously.
[0006] This invention provides an offline map data processing method, comprising: Data acquisition steps: Obtain the raw geographic data file and convert the raw geographic data file into a standard map file; Key generation steps: Generate a real key and a meta key using a random number generator, and encrypt the real key based on the meta key to obtain a key stream; Data encryption steps: The standard map file is divided into slices based on a preset key length to obtain slice data. Based on the positional distribution of the slice data in the standard map file, the header key or data key from the real key is selected to encrypt the slice data to obtain an encrypted map file. Data loading steps: Decrypt the key stream using the meta-key to obtain the header key and the data key; parse the file header of the encrypted map file based on the header key; determine the position of the data to be loaded in the encrypted map file based on the file header; decrypt the data at the specified position based on the data key to obtain decrypted data; and perform map rendering based on the decrypted data.
[0007] A layered key protection mechanism is implemented by generating a real key and a meta key using a random number generator, and encrypting the real key with the meta key to form a key stream. This ensures that even if the key stream is obtained, the real key cannot be obtained directly. Meanwhile, based on the location distribution of the tile data within the file, either a header key or a data key is selected for encryption, achieving partitioned encryption protection for both the file header and the file data. Dividing the map file into tiles with a preset key length before encryption allows for tile-based decryption, enabling the decryption of only the required data without decrypting the entire file. This significantly reduces the amount of data processed for decryption while ensuring map data security, effectively minimizing the consumption of device memory and computing power.
[0008] In some embodiments of the present invention, the data encryption step specifically includes: If the slice data corresponds to the file header of the standard map file, then the slice data is encrypted using the header key; If the slice data corresponds to file data in the standard map file, then the slice data is encrypted using the data key.
[0009] By mapping slice data to specific areas of the file header and file data, the encryption attribution of slice data is clearly defined. Slice data belonging to the file header area is encrypted with the header key, while slice data belonging to the file data area is encrypted with the data key. This makes the key selection logic during encryption clear and executable. This partition-based encryption method ensures that the inherent format information of the file header and the actual content of the file are protected by different keys. Even if an attacker cracks the key of one area through the file format pattern, they will not be able to decrypt the data in the other area, thus effectively improving the map data's ability to resist known-plaintext attacks.
[0010] In some embodiments of the present invention, the data encryption step further includes: If the byte length of the file header is not an integer multiple of the key length, then based on the byte length of the file header and the key length, the number of bytes remaining after the file header is split according to the key length is calculated to obtain the encryption length to be aligned; Based on the difference between the key length and the encryption length to be aligned, the starting padding length of the file data is calculated, and the byte portion of the file header corresponding to the encryption length to be aligned and the byte portion of the file data corresponding to the starting padding length form a slice of data; In the sliced data, the byte portion corresponding to the alignment encryption length is encrypted using the header key, and the byte portion corresponding to the starting padding length is encrypted using the data key.
[0011] When the file header length is not an integer multiple of the key length, the remaining bytes at the end of the file header are combined with the starting bytes of the file data to form a complete slice of data by calculating the encryption length to be aligned and the starting padding length. Within this slice, bytes belonging to different regions are encrypted with the corresponding keys. This processing method makes the encryption process independent of the integer division relationship between the file header length and the key length, and can flexibly adapt to file headers of any length. At the same time, the cross encryption of two keys is introduced in the same slice, which further breaks the fixed encryption boundary between the file header and the file data.
[0012] In some embodiments of the present invention, the data loading step specifically includes: Obtain the latitude and longitude information and map zoom level of the current display area of the target device, and calculate the map tile row and column number corresponding to the data to be loaded based on the latitude and longitude information and the map zoom level; Extract index information from the file header, and locate the position of the data to be loaded in the encrypted map file based on the map tile row and column numbers in the index information.
[0013] By obtaining the latitude and longitude information of the current display area and calculating the corresponding map tile row and column numbers based on the map zoom level, and then using the row and column numbers as a basis to find the location of the data to be loaded in the encrypted map file from the file header index information, precise spatial positioning of the required data is achieved. This mapping mechanism between spatial index and encrypted data location allows the decryption process to directly locate the data area corresponding to the current viewport without reading and decrypting the entire encrypted map file, thereby significantly reducing the amount of data reading and decryption operations and effectively improving the response speed of map loading.
[0014] In some embodiments of the present invention, the calculation model for the map tile row and column numbers is specifically as follows:
[0015] in, The x-coordinate of the map tile's row and column number; The current longitude in the latitude and longitude information; Adjust the map scaling levels.
[0016] By establishing a mathematical mapping relationship between longitude and the horizontal coordinate of map tile row and column numbers, and utilizing a calculation model between the current longitude, map zoom level, and horizontal coordinate, the latitude and longitude information acquired by the device can be quickly converted into the horizontal index position of the map tile. This calculation model provides an accurate horizontal coordinate reference for spatial positioning, enabling precise matching when searching for corresponding data in the index information, ensuring the efficiency and accuracy of data positioning, and thus improving the overall efficiency of map data loading.
[0017] In some embodiments of the present invention, the calculation model for the map tile row and column numbers further includes:
[0018] in, The vertical coordinate of the map tile row and column number; The latitude is the current latitude in the latitude and longitude information.
[0019] By establishing a mathematical mapping relationship between latitude and the vertical coordinate of map tile row and column numbers, and utilizing a calculation model between the current latitude, map zoom level, and vertical coordinate, the latitude and longitude information acquired by the device can be quickly converted into the vertical index position of the map tile. This calculation model, together with the horizontal coordinate calculation model, constitutes a complete spatial positioning system, providing an accurate vertical coordinate benchmark for data positioning, further ensuring the accuracy of the current viewport data positioning, thereby ensuring the consistency between the map rendering content and the user's actual browsing area.
[0020] Some embodiments of the present invention further provide an offline map data processing system, comprising: The data acquisition module acquires the raw geographic data file and converts the raw geographic data file into a standard map file. The key generation module generates a real key and a meta key through a random number generator, and encrypts the real key based on the meta key to obtain a key stream; The data encryption module divides the standard map file into slices based on a preset key length to obtain slice data. Based on the positional distribution of the slice data in the standard map file, it selects either the header key or the data key from the real key to encrypt the slice data, thereby obtaining an encrypted map file. The data loading module decrypts the key stream using the meta-key to obtain the header key and the data key. Based on the header key, it parses the file header of the encrypted map file, determines the position of the data to be loaded in the encrypted map file based on the file header, decrypts the data at the specified position based on the data key to obtain decrypted data, and performs map rendering based on the decrypted data.
[0021] In some embodiments of the present invention, the data encryption module is further configured to: If the slice data corresponds to the file header of the standard map file, then the slice data is encrypted using the header key; If the slice data corresponds to file data in the standard map file, then the slice data is encrypted using the data key.
[0022] In some embodiments of the present invention, the data encryption module is further configured to: If the byte length of the file header is not an integer multiple of the key length, then based on the byte length of the file header and the key length, the number of bytes remaining after the file header is split according to the key length is calculated to obtain the encryption length to be aligned; Based on the difference between the key length and the encryption length to be aligned, the starting padding length of the file data is calculated, and the byte portion of the file header corresponding to the encryption length to be aligned and the byte portion of the file data corresponding to the starting padding length form a slice of data; In the sliced data, the byte portion corresponding to the alignment encryption length is encrypted using the header key, and the byte portion corresponding to the starting padding length is encrypted using the data key.
[0023] In some embodiments of the present invention, the data loading module is further configured to: Obtain the latitude and longitude information and map zoom level of the current display area of the target device, and calculate the map tile row and column number corresponding to the data to be loaded based on the latitude and longitude information and the map zoom level; Extract index information from the file header, and locate the position of the data to be loaded in the encrypted map file based on the map tile row and column numbers in the index information. Attached Figure Description
[0024] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0025] Figure 1 A flowchart illustrating an offline map data processing method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram illustrating a process for encrypting a standard map file, provided as an embodiment of the present invention. Figure 3 A schematic diagram of the structure of a standard map file provided in an embodiment of the present invention; Figure 4 This is a schematic diagram illustrating a process for encrypting a real key, provided as an embodiment of the present invention. Figure 5 This is a schematic diagram illustrating a process for decrypting an encrypted map file, provided as an embodiment of the present invention. Figure 6 This is a schematic diagram of the structure of an offline map data processing system provided in an embodiment of the present invention. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of this application clearer, the application is described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.
[0027] It should be noted that the terminology used herein is for the purpose of describing particular implementations only and is not intended to limit the exemplary implementations according to this application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. Furthermore, it should be understood that the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product, or apparatus.
[0028] With the intelligent development of embedded devices such as cycling computers and fitness trackers, offline map functionality has become an important application scenario for these devices. However, current mainstream cycling computers, fitness trackers and other devices are at a low level in terms of storage memory, RAM and chip computing power. To implement map encryption and decryption on such performance-limited devices, it is necessary to simultaneously consider multiple constraints such as device storage capacity, chip computing power and real-time map display. Conventional mainstream encryption and decryption methods are difficult to adapt to performance-constrained devices such as code tables due to their high computational complexity and resource consumption, and may even be completely unusable. While existing open-source map data construction methods are widely used, they often overlook the potential risks that common architectures pose to valuable data, resulting in a lack of effective information security guarantees for map data. Some existing encryption and decryption methods can achieve high-security file encryption and decryption. For example, they use quadtree block division and Douglas-Puk algorithm to group vector data, combine frequency domain transformation and selective encryption, encrypt only low-frequency information, and use scrambling keys for scrambling and obfuscation. However, such methods usually involve complex calculations such as frequency domain transformation and multiple iterations, which are difficult to apply well on embedded platforms with limited resources such as code tables. When processing data that needs to be displayed in real time, such as maps, loading and rendering become difficult. In addition, most existing file encryption and decryption solutions focus on enhancing the confidentiality of the encryption and decryption methods themselves, using quantum random numbers to divide and reset keys to achieve key iteration. However, their encryption and decryption processes and key iteration processes are relatively complex and computationally expensive, lacking more lightweight key management strategies.
[0029] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.
[0030] The technical solution of the present invention will be described in detail below with reference to specific embodiments and accompanying drawings.
[0031] like Figure 1 As shown, the present invention provides an offline map data processing method, including: Data acquisition step S1: Obtain the raw geographic data file and convert it into a standard map file; Furthermore, such as Figure 2 As shown, the raw geographic data file is obtained from the open-source geographic data platform. The raw geographic data file is an OpenStreetMap .osm.pbf format file. OpenStreetMap is a world geographic database that can obtain geographic data information files in .osm.pbf format. This format file contains complete vector geographic information such as roads, points of interest, and building boundaries, which is used for subsequent map data production. Subsequently, the acquired raw geographic data files are converted to a new format. Specifically, the Osmosis tool is used to call the Mapsforge map processing library to convert the raw geographic data files in .osm.pbf format into standard map files in Mapsforge binary map format. Mapsforge binary map format is a compact, high-performance storage format specifically designed for offline vector map rendering. Through a carefully designed binary layout and efficient encoding method, it achieves the goals of small size, fast parsing, and strong random access capability, making it especially suitable for running on mobile devices with limited memory and storage resources. Its map file format is as follows: #meta data file header #sub-files for each sub-file #tile index segment tile index header tile index entries #tile data segment for each tile tile header for each POI POI data for each way way propertirs way data; Standard map files are used to provide basic data support for subsequent operations; like Figure 3 As shown, a standard map file contains a file header and file data sequentially in a binary data stream. The file data includes data segments 1 to n, where the file header has a length of [length missing]. The length of data segment 1 is And so on, the length of data segment n is .
[0032] Key generation step S2: Generate a real key and a meta key using a random number generator, and encrypt the real key based on the meta key to obtain a key stream; Furthermore, the real key is generated by a random number generator, and the number of real keys is M. The specific number can be flexibly configured according to the size of the map data and the performance of the target device. The multiple sets of real keys include a header key and at least one data key. The header key is used to encrypt the file header of the map file, and the data key is used to encrypt the file data portion of the map file. The length of each real key can also be flexibly selected to adapt to the computing power of devices of different scales. The longer the key length, the higher the encryption security, but the amount of computation required for encryption and decryption also increases accordingly. Therefore, a reasonable balance needs to be made between the security protection requirements of map data and the actual performance of the code table device. Based on the file structure characteristics of the Mapsforge map format, the file header stores key metadata information such as tile index offsets. The address locations pointed to by these offset data provide natural encryption and segmentation boundaries for the map data. This allows the subsequent file data to be divided into multiple independent data segments after the file header is encrypted, thus providing format-level support for encrypting different data segments using multiple sets of different data keys. The meta-key is generated independently using a random number generator and is used to encrypt the multiple sets of real keys mentioned above. When encrypting the real key with the meta key, either AES symmetric encryption or RSA asymmetric encryption can be used. Different encryption methods can be selected for different parts of the real key. That is, the meta key can be encrypted with different encryption methods for the header key, data key 1, ..., data key N. like Figure 4 As shown, the meta key can be encrypted using encryption method 0 to encrypt the header key, and can be encrypted using encryption method 1 to encrypt the data key 1, and so on, to encrypt the data key N using encryption method N; Using different encryption methods for different real keys can enrich the complexity of the overall key system and further enhance the security of key storage and transmission. The specific encryption method used can be selected based on the actual computing performance of the target device, such as the code table. The selected real key is encrypted using an encryption method whose computational complexity is compatible with the device's processing capabilities. This ensures the security of the key itself and avoids unnecessary performance burden on the device due to overly complex encryption algorithms. Since the actual key itself is relatively short in byte length, even if a relatively strict encryption operation is performed on it, the amount of computation is still limited and will not have a substantial impact on the decryption performance of the device. After encryption is complete, the meta-key is written to the code storage area or an unreadable secure storage area of the code table device, and a corresponding version number is configured for the meta-key. The real key stream, encrypted with the metakey, is stored in a key file accessible by the code table device, and a mapping relationship is established between the key stream and the version number of the metakey. In this way, when the code table device loads the map file in a later stage, it can read the key stream of the corresponding version from the key file according to the version number of the current map file, and decrypt it with the built-in meta key to restore the correct real key; Through the aforementioned hierarchical key management mechanism, this application achieves the separate storage of real keys and meta keys. Meta keys, as higher-level keys, are embedded in the device, while real keys exist only in key files in encrypted form. Even if the key file is obtained, attackers cannot directly obtain the real keys, thereby significantly improving the security of key management and the flexibility of key version control.
[0033] Data encryption step S3: Divide the standard map file into slices based on the preset key length to obtain slice data. Based on the positional distribution of the slice data in the standard map file, select the header key or data key from the real key to encrypt the slice data and obtain an encrypted map file. In some embodiments, the data encryption step S3 specifically comprises: If the tile data corresponds to the header of a standard map file, then the tile data is encrypted using the header key; If the tile data corresponds to file data in a standard map file, then the tile data is encrypted using a data key.
[0034] By mapping slice data to specific areas of the file header and file data, the encryption attribution of slice data is clearly defined. Slice data belonging to the file header area is encrypted with the header key, while slice data belonging to the file data area is encrypted with the data key. This makes the key selection logic during encryption clear and executable. This partition-based encryption method ensures that the inherent format information of the file header and the actual content of the file are protected by different keys. Even if an attacker cracks the key of one area through the file format pattern, they will not be able to decrypt the data in the other area, thus effectively improving the map data's ability to resist known-plaintext attacks.
[0035] In some embodiments, the data encryption step S3 further includes: If the length of the file header is not an integer multiple of the key length, then based on the length of the file header and the key length, calculate the number of bytes remaining after the file header is split according to the key length, and obtain the encryption length to be aligned; Based on the difference between the key length and the encryption length to be aligned, the starting padding length of the file data is calculated. The byte portion of the file header corresponding to the encryption length to be aligned and the byte portion of the file data corresponding to the starting padding length form a slice of data. In the sliced data, the byte portion corresponding to the length to be aligned is encrypted using the header key, and the byte portion corresponding to the starting padding length is encrypted using the data key.
[0036] When the file header length is not an integer multiple of the key length, the remaining bytes at the end of the file header are combined with the starting bytes of the file data to form a complete slice of data by calculating the encryption length to be aligned and the starting padding length. Within this slice, bytes belonging to different regions are encrypted with the corresponding keys. This processing method makes the encryption process independent of the integer division relationship between the file header length and the key length, and can flexibly adapt to file headers of any length. At the same time, the cross encryption of two keys is introduced in the same slice, which further breaks the fixed encryption boundary between the file header and the file data.
[0037] Furthermore, during the file header encryption process, the file header portion of the standard map file is extracted, and the file header is divided into slices according to the key length of the header key. Then, the header key is used to encrypt the divided file header slices. The encryption method can be XOR encryption. XOR operation has symmetric properties, that is, after performing XOR operation on the same value twice, it can be restored to the value itself. This property makes the decryption process use the same operation as the encryption process, without the need to design an additional decryption algorithm. Meanwhile, the XOR operation only involves bitwise logical operations, making the calculation process extremely lightweight and significantly improving the decryption speed of code table devices, thus fully adapting to the computing power of resource-constrained embedded devices. After encrypting the file header, the last slice of data in the file header is further aligned byte by byte according to the key length of the header key. Since the length of the file header is usually not an integer multiple of the key length, there will be a portion of bytes left at the end of the file header that is less than the length of a complete key. Set the key length to The file header length is Then the encryption length to be aligned can be calculated. The calculation formula is as follows:
[0038] During byte alignment, the beginning and end of the file are aligned. The first byte of file data. Each byte is combined to form a complete slice of data, where the beginning and end of the file are... Each byte is encrypted with a header key, starting with the file data. Each byte is encrypted with a data key; This byte alignment method allows encryption to be completed without the file header length being a strict integer multiple of the key length. Different map files, even with different file header lengths, can all use the same encryption process, effectively improving the compatibility and versatility of the solution. Taking a 512-byte key length as an example, when the file header of a standard map file occupies 600 bytes in binary data, the first 512 bytes of the file are encrypted with the header key, the first 88 bytes of the second 512 bytes are encrypted with the header key, and the remaining 424 bytes in the second 512 bytes are encrypted with the corresponding data key. This achieves a smooth transition between the file header and the file data at the boundaries of adjacent tiles. After completing the file header encryption and byte alignment, all remaining file data in the standard map file is encrypted. Specifically, the remaining file data is divided into slices according to the selected key length, and each slice is encrypted sequentially using the corresponding data key based on the selected number of real key groups. The number of data keys used can be flexibly configured according to actual needs. If only one data key is planned to be used as the encryption key for the remaining file data, then the entire map file can be divided into multiple slices according to the key length, and encryption can be performed starting from the slice where file data first appears. At this time, due to the byte alignment process, the first half of the cross-boundary slice is encrypted with the header key and the second half is encrypted with the data key. If multiple data keys are planned to be used in the future, it is necessary to ensure that different data keys can be correctly identified and segmented through the offset information in the map file. The header of the Mapsforge map format contains the offsets of multiple map layers. These map layer data are stored in the form of binary byte streams and have a clear order. Therefore, taking three data keys as an example, after encrypting the file header, the first layer map data is encrypted with data key 1, the second layer map data is encrypted with data key 2, and the third layer map data is encrypted with data key 3. The intersection between two adjacent data segments is processed using the same byte alignment method as mentioned above. Based on the above encryption process, all bytes belonging to the file header in the entire standard map file are encrypted with the header key, and all bytes belonging to the file data are encrypted with the corresponding data key. Furthermore, through the slicing and byte alignment mechanism, flexible switching of multiple keys and smooth transition of boundaries are achieved, ensuring encryption security while also taking into account the device's computing performance requirements.
[0039] Data loading step S4: Decrypt the key stream using the meta-key to obtain the header key and the data key. Parse the file header of the encrypted map file based on the header key. Determine the position of the data to be loaded in the encrypted map file based on the file header. Decrypt the data at the position based on the data key to obtain the decrypted data. Perform map rendering based on the decrypted data.
[0040] In some embodiments, the data loading step S4 specifically includes: Obtain the latitude and longitude information of the current display area of the target device and the map zoom level, and calculate the map tile row and column number corresponding to the data to be loaded based on the latitude and longitude information and the map zoom level; Extract index information from the file header, and locate the position of the data to be loaded in the encrypted map file based on the map tile row and column numbers.
[0041] By obtaining the latitude and longitude information of the current display area and calculating the corresponding map tile row and column numbers based on the map zoom level, and then using the row and column numbers as a basis to find the location of the data to be loaded in the encrypted map file from the file header index information, precise spatial positioning of the required data is achieved. This mapping mechanism between spatial index and encrypted data location allows the decryption process to directly locate the data area corresponding to the current viewport without reading and decrypting the entire encrypted map file, thereby significantly reducing the amount of data reading and decryption operations and effectively improving the response speed of map loading.
[0042] In some embodiments, the calculation model for map tile row and column numbers is specifically as follows:
[0043] in, The x-coordinate of the map tile's row and column number; The current longitude in the latitude and longitude information; Adjust the map scaling levels.
[0044] By establishing a mathematical mapping relationship between longitude and the horizontal coordinate of map tile row and column numbers, and utilizing a calculation model between the current longitude, map zoom level, and horizontal coordinate, the latitude and longitude information acquired by the device can be quickly converted into the horizontal index position of the map tile. This calculation model provides an accurate horizontal coordinate reference for spatial positioning, enabling precise matching when searching for corresponding data in the index information, ensuring the efficiency and accuracy of data positioning, and thus improving the overall efficiency of map data loading.
[0045] In some embodiments, the calculation model for map tile row and column numbers further includes:
[0046] in, The vertical coordinate of the map tile row and column number; This refers to the current latitude in the latitude and longitude information.
[0047] By establishing a mathematical mapping relationship between latitude and the vertical coordinate of map tile row and column numbers, and utilizing a calculation model between the current latitude, map zoom level, and vertical coordinate, the latitude and longitude information acquired by the device can be quickly converted into the vertical index position of the map tile. This calculation model, together with the horizontal coordinate calculation model, constitutes a complete spatial positioning system, providing an accurate vertical coordinate benchmark for data positioning, further ensuring the accuracy of the current viewport data positioning, thereby ensuring the consistency between the map rendering content and the user's actual browsing area.
[0048] Furthermore, such as Figure 5 As shown, when the code table device decrypts and loads map data, it first performs the real key acquisition operation; Since the metakey is pre-written into the code storage area or an unreadable secure storage area of the code table device, the code table device reads the metakey from this area and decrypts the encrypted key stream stored in the key file using the metakey to restore the header key and each data key. This hierarchical key acquisition mechanism ensures that the real key always exists in encrypted form in the storage medium accessible to the device. Even if the key file is illegally obtained, the attacker cannot decrypt the real header key and data key because they cannot obtain the metakey embedded in the device, thus effectively protecting the security of the key itself. After obtaining the header key and data key, the code table device uses the header key to decrypt the header of the encrypted map file and parse out the index information stored in the header. This index information records the offset address and data length of each tile data in the encrypted map file. At the same time, the odometer device obtains the latitude and longitude information corresponding to the current display area and the current map zoom level through its built-in positioning module; Based on the Mercator projection principle, the codebook device substitutes latitude and longitude information and map zoom level into the map tile row and column number calculation model to calculate the row and column numbers corresponding to the map tiles that need to be loaded for the current viewport. Specifically, and These are the longitude and latitude of a corner point in the current display area, such as the top left corner, or the northwest corner. Adjust the map zoom levels; The expression is:
[0049] The expression is:
[0050] Based on the two parameters mentioned above, the row and column numbers of the map tiles required to cover the current display area are calculated using the Mercator projection formula. A map tile can be uniquely identified by its row and column numbers (x, y, z), and then the specific offset position of the tile in the encrypted map file can be found from the index information in the file header. After locating the offset position of the tile data required for the current viewport in the encrypted map file, the code table device calculates the slice data to which the offset position belongs based on the preset key length, that is, determines which key length slice the tile data is located in. Then, the slice data is decrypted with the corresponding data key to obtain the plaintext tile data. Since the encryption process is based on dividing the entire map file into tiles according to the key length and encrypting each tile individually, decryption only requires locating the one or a few tiles containing the required tile data, without needing to decrypt the entire encrypted map file. This streaming on-demand decryption method greatly reduces the amount of data that needs to be decrypted each time the map is loaded, effectively reducing the memory usage and computing resource consumption of the code table device, and significantly improving the response speed of map loading. Finally, the codebook device renders the corresponding map elements such as roads, points of interest, and terrain onto the device interface based on the decrypted tile data, completing the real-time display of the offline map.
[0051] Based on the above offline map data processing method, a real key and a meta key are generated by a random number generator. The meta key is used to encrypt the real key to form a key stream, which realizes a layered key protection mechanism, so that even if the key stream is obtained, the real key cannot be obtained directly. Meanwhile, based on the location distribution of slice data in the file, either the header key or the data key is selected for encryption, thus achieving partitioned encryption protection of the file header and file data; By dividing the map file into tiles with a preset key length before encryption, decryption can be performed by locating the tiles and decrypting only the required data, without having to decrypt the entire file. This significantly reduces the amount of data to be processed for decryption while ensuring the security of the map data, effectively reducing the use of device memory and the consumption of computing power.
[0052] like Figure 6 As shown, this embodiment of the invention also provides an offline map data processing system, including: The data acquisition module acquires raw geographic data files and converts them into standard map files. The key generation module generates a real key and a meta key through a random number generator, and encrypts the real key based on the meta key to obtain a key stream; The data encryption module divides the standard map file into slices based on a preset key length to obtain slice data. Based on the location distribution of the slice data in the standard map file, it selects either the header key or the data key from the real key to encrypt the slice data, thus obtaining an encrypted map file. The data loading module decrypts the key stream using the meta-key to obtain the header key and the data key. Based on the header key, it parses the file header of the encrypted map file, determines the position of the data to be loaded in the encrypted map file based on the file header, decrypts the data at the position based on the data key to obtain the decrypted data, and performs map rendering based on the decrypted data.
[0053] In some embodiments, the data encryption module is further configured to: If the tile data corresponds to the header of a standard map file, then the tile data is encrypted using the header key; If the tile data corresponds to file data in a standard map file, then the tile data is encrypted using a data key.
[0054] In some embodiments, the data encryption module is further configured to: If the length of the file header is not an integer multiple of the key length, then based on the length of the file header and the key length, calculate the number of bytes remaining after the file header is split according to the key length, and obtain the encryption length to be aligned; Based on the difference between the key length and the encryption length to be aligned, the starting padding length of the file data is calculated. The byte portion of the file header corresponding to the encryption length to be aligned and the byte portion of the file data corresponding to the starting padding length form a slice of data. In the sliced data, the byte portion corresponding to the length to be aligned is encrypted using the header key, and the byte portion corresponding to the starting padding length is encrypted using the data key.
[0055] In some embodiments, the data loading module is also used for: Obtain the latitude and longitude information of the current display area of the target device and the map zoom level, and calculate the map tile row and column number corresponding to the data to be loaded based on the latitude and longitude information and the map zoom level; Extract index information from the file header, and locate the position of the data to be loaded in the encrypted map file based on the map tile row and column numbers.
[0056] It should be noted that the above is a reference method and system for offline map data processing, and the present invention is not limited thereto.
[0057] The embodiments of the present invention realize the secure storage and on-demand efficient loading of offline map data on resource-constrained devices such as code tables. Through a hierarchical key system, location-distributed slice encryption, and streaming on-demand decryption mechanism, it solves the technical problems in the prior art, such as the high computational complexity of general encryption and decryption algorithms making them difficult to run on performance-constrained devices, the waste of memory and computing resources caused by overall encryption and decryption, and the insufficient security of single-key encryption.
[0058] Finally, it should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0059] The above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them; although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications can still be made to the specific implementation of the present invention or equivalent substitutions can be made to some technical features without departing from the spirit of the technical solutions of the present invention, and all such modifications and substitutions should be covered within the scope of the technical solutions claimed in the present invention.
Claims
1. An offline map data processing method, characterized by, include: Data acquisition steps: Obtain the raw geographic data file and convert the raw geographic data file into a standard map file; Key generation steps: Generate a real key and a meta key using a random number generator, and encrypt the real key based on the meta key to obtain a key stream; Data encryption steps: The standard map file is divided into slices based on a preset key length to obtain slice data. Based on the positional distribution of the slice data in the standard map file, the header key or data key from the real key is selected to encrypt the slice data to obtain an encrypted map file. Data loading steps: Decrypt the key stream using the meta-key to obtain the header key and the data key; parse the file header of the encrypted map file based on the header key; determine the position of the data to be loaded in the encrypted map file based on the file header; decrypt the data at the specified position based on the data key to obtain decrypted data; and perform map rendering based on the decrypted data.
2. The off-line map data processing method according to claim 1, characterized by, The data encryption steps are as follows: If the slice data corresponds to the file header of the standard map file, then the slice data is encrypted using the header key; If the slice data corresponds to file data in the standard map file, then the slice data is encrypted using the data key.
3. The off-line map data processing method according to claim 2, characterized by, The data encryption step also includes: If the byte length of the file header is not an integer multiple of the key length, then based on the byte length of the file header and the key length, the number of bytes remaining after the file header is split according to the key length is calculated to obtain the encryption length to be aligned; Based on the difference between the key length and the encryption length to be aligned, the starting padding length of the file data is calculated, and the byte portion of the file header corresponding to the encryption length to be aligned and the byte portion of the file data corresponding to the starting padding length form a slice of data; In the sliced data, the byte portion corresponding to the alignment encryption length is encrypted using the header key, and the byte portion corresponding to the starting padding length is encrypted using the data key.
4. The off-line map data processing method according to claim 1, characterized by, The data loading steps are as follows: Obtain the latitude and longitude information and map zoom level of the current display area of the target device, and calculate the map tile row and column number corresponding to the data to be loaded based on the latitude and longitude information and the map zoom level; Extract index information from the file header, and locate the position of the data to be loaded in the encrypted map file based on the map tile row and column numbers in the index information.
5. The off-line map data processing method according to claim 4, characterized by, The specific calculation model for the map tile row and column numbers is as follows: wherein, is a horizontal coordinate for a map tile row number; is a current longitude in the longitude and latitude information; is a map zoom level.
6. The offline map data processing method according to claim 5, characterized in that, The calculation model for the map tile row and column numbers also includes: in, The vertical coordinate of the map tile row and column number; The latitude is the current latitude in the latitude and longitude information.
7. An offline map data processing system, characterized in that, include: The data acquisition module acquires the raw geographic data file and converts the raw geographic data file into a standard map file. The key generation module generates a real key and a meta key through a random number generator, and encrypts the real key based on the meta key to obtain a key stream; The data encryption module divides the standard map file into slices based on a preset key length to obtain slice data. Based on the positional distribution of the slice data in the standard map file, it selects either the header key or the data key from the real key to encrypt the slice data, thereby obtaining an encrypted map file. The data loading module decrypts the key stream using the meta-key to obtain the header key and the data key. Based on the header key, it parses the file header of the encrypted map file, determines the position of the data to be loaded in the encrypted map file based on the file header, decrypts the data at the specified position based on the data key to obtain decrypted data, and performs map rendering based on the decrypted data.
8. The offline map data processing system according to claim 7, characterized in that, The data encryption module is also used for: If the slice data corresponds to the file header of the standard map file, then the slice data is encrypted using the header key; If the slice data corresponds to file data in the standard map file, then the slice data is encrypted using the data key.
9. The offline map data processing system according to claim 8, characterized in that, The data encryption module is also used for: If the byte length of the file header is not an integer multiple of the key length, then based on the byte length of the file header and the key length, the number of bytes remaining after the file header is split according to the key length is calculated to obtain the encryption length to be aligned; Based on the difference between the key length and the encryption length to be aligned, the starting padding length of the file data is calculated, and the byte portion of the file header corresponding to the encryption length to be aligned and the byte portion of the file data corresponding to the starting padding length form a slice of data; In the sliced data, the byte portion corresponding to the alignment encryption length is encrypted using the header key, and the byte portion corresponding to the starting padding length is encrypted using the data key.
10. The offline map data processing system according to claim 7, characterized in that, The data loading module is also used for: Obtain the latitude and longitude information and map zoom level of the current display area of the target device, and calculate the map tile row and column number corresponding to the data to be loaded based on the latitude and longitude information and the map zoom level; Extract index information from the file header, and locate the position of the data to be loaded in the encrypted map file based on the map tile row and column numbers in the index information.
