Ship historical trajectory region retrieval method
By adjusting the Google S2 encoding method and building indexes, combined with the Google S2 area coverage algorithm and the leftmost prefix matching principle, the problem of slow retrieval of ship trajectory data is solved, and the effect of rapid retrieval and reduced database burden is achieved.
Patent Information
- Application Number
- CN202411240892.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2025-02-07
AI Technical Summary
In the prior art, when storing and retrieving ship trajectory data, it is difficult to effectively organize and quickly retrieve data, resulting in excessive burden on the database and slow response speed.
By adjusting the Google S2 encoding method, combining positioning time to build an index with the B-Tree data structure, and using the Google S2 area coverage algorithm to decompose the geospatial area, and using the leftmost prefix matching principle for quick search.
Reduces the number of queries, speeds up database response, reduces the storage pressure of indexes, and realizes rapid retrieval of historical trajectories.
Smart Images

Figure CN119397110A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of ship track area retrieval, and in particular to a ship historical track area retrieval method. Background Art
[0002] With the advent of the big data era and the development of satellite navigation systems such as GPS and BeiDou, the amount of trajectory data has increased substantially. Trajectory data is large in volume and multi-dimensional, and has high requirements for data storage and calculation. Therefore, the database storing trajectory data needs to support the rapid storage of large amounts of data and the retrieval of large amounts of data from the database in a short time for analysis.
[0003] In order to efficiently support the storage and query of spatiotemporal data, it is necessary to introduce spatiotemporal indexing technology to facilitate the management of multidimensional spatiotemporal data and design and optimize efficient query methods. At present, the indexing of spatiotemporal data is mainly implemented by GeoHash technology. The spatial encoding of GeoHash is represented by the Z curve. Although the Z curve has local order preservation, it also has mutation. It is not the most ideal spatiotemporal indexing technology and is difficult to adapt to regional retrieval scenarios. Another commonly used spatial indexing technology is Google S2 technology, which maps spherical longitude and latitude into one-dimensional coding units. The existing coding level is fixed to the indexing level. If you need to search at a certain level, you must build an index at this level. This method has poor flexibility. For the unindexed level, it can only be decomposed into higher-level codes. Often, a large number of queries are required at a higher level, which increases the burden on the database. If more indexes are established to alleviate this problem, the storage efficiency of the database will be affected, affecting the response speed of the database, and Google The S2 algorithm must specify the level of coding units and cannot use the prefix query method of GeoHash technology, which reduces the flexibility of index construction and increases the number of database queries. Therefore, how to effectively organize and retrieve trajectory data has become a difficult problem to solve. Summary of the invention
[0004] In order to solve the problems existing in the prior art, the present invention provides a method for retrieving a historical track area of a ship, so as to solve the problem of how to effectively organize and retrieve track data.
[0005] To solve the above problems, the technical solution of the present invention is as follows: A method for retrieving a ship's historical track area comprises the following steps:
[0006] S1. Build index;
[0007] S2, historical trajectory area retrieval;
[0008] The S2 includes: (1) the user gives a geographic space area and a time range as query conditions;
[0009] (2) Adjust the encoding method of Google S2;
[0010] (3) Using Google S2’s area coverage algorithm to decompose the user-inputted geographic spatial area, a set of geocoding values containing the area is obtained;
[0011] (4) The obtained geocoding values are converted, and the leftmost prefix matching principle of the database constructed by S1 is used to perform fuzzy query for fast retrieval, and the database provides trajectory data that meets the conditions.
[0012] Further, the step S1 includes:
[0013] (1) Use MySql as the database to store trajectory data;
[0014] (2) Adjust the encoding method of Google S2;
[0015] (3) Use the Google S2 algorithm to encode the longitude and latitude, combine them with the positioning time, and build an index using the B-Tree data structure.
[0016] Furthermore, in step (2) of S1, the encoding format of Google S2 is modified to a 49-bit string format for storage.
[0017] Furthermore, step (3) in S1, encoding the longitude and latitude using the Google S2 algorithm includes converting the spherical longitude and latitude into three-dimensional coordinates using the Google S2 algorithm, and then converting them into corrected three-dimensional coordinates on the projection surface of the circumscribed cube, and finally transforming the geographic grid into a one-dimensional coded value through the Hilbert curve.
[0018] Furthermore, in step (3) of S1, the encoding level of the Google S2 algorithm is divided into 23 levels, and each level represents a different precision.
[0019] Furthermore, in step (2) of S2, the encoding format of Google S2 is modified to a 49-bit string format for storage.
[0020] Furthermore, in step (4) of S2, the obtained geocoding value is converted using MaxCells, MaxLevel, and MinLevel, wherein MaxCells determines the maximum number of cells in the coverage area, and MaxLevel and MinLevel determine the maximum and minimum levels of the coding of the coverage area, respectively.
[0021] Compared with the prior art, the present invention has the following beneficial effects: starting from the data structure of Google S2 encoding, the present application adjusts its encoding method and uses it to construct a database index, while adopting the regional coverage algorithm of Google S2 algorithm and modifying the encoding in the same way, thereby reducing the number of required queries, and combining concurrent queries to speed up the response speed of the database and reduce the storage pressure of the index.
[0022] This application uses geographic coordinate codes combined with positioning time as database indexes. When performing regional retrieval of historical trajectories, the regional coverage algorithm of the Google S2 algorithm is used to divide the area to be retrieved into grids of different sizes, extract the coordinate codes of the grids, and extract the prefix of the regional code as the query condition based on the data structure of the regional code. The leftmost prefix matching principle of the index is used to realize rapid retrieval of historical trajectories using concurrent queries. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a schematic diagram of the process of the present invention;
[0024] Figure 2 This is a schematic diagram of the area coverage of the Google S2 algorithm of the present invention;
[0025] Figure 3 This is a schematic diagram of the Google S2 encoding data structure of the present invention. DETAILED DESCRIPTION
[0026] like Figure 1 As shown, a method for retrieving a ship's historical track area includes the following steps:
[0027] S1. Build index
[0028] This application uses MySql as the database for storing trajectory data. MySql is highly versatile and has low deployment cost. It is sufficient to support historical trajectory area retrieval under big data when appropriate indexes and query algorithms are designed.
[0029] The Google S2 algorithm is used to encode the coordinates of the longitude and latitude of the trajectory. The Google S2 technology is mainly used to solve the problem of multi-dimensional space point indexing. It converts the spherical longitude and latitude into three-dimensional coordinates, and then converts them into corrected three-dimensional coordinates on the projection surface of the circumscribed cube. Finally, the geographic grid is transformed into a one-dimensional coded value (S2 cellID) through the Hilbert curve. The coding level of Google S2 is divided into 30 levels, and the accuracy of each level is different (the accuracy of the first level is 5000km, and the accuracy of the 30th level is 3.7cm). The accuracy of each level of Google S2 changes relatively slowly, and users have more room to choose. In terms of level selection, this application uses level 23 as the highest level of the index (longitude 0.12m), uses the Google S2 algorithm to encode the longitude and latitude, and combines the positioning time to build an index with a B-Tree data structure.
[0030] The encoding format of Google S2 is 64-bit binary. This application adjusts the encoding method of Google S2 and changes it to a 49-bit string format for storage and index construction.
[0031] S2. Historical trajectory area retrieval
[0032] Historical trajectory area retrieval means that the user gives a geographic space area and a time range as query conditions, and the system queries the trajectory data that meets the conditions. This application uses the Google S2 area coverage algorithm to decompose the geographic space area input by the user. The main purpose of the Google S2 area coverage algorithm is to find an approximate optimal solution that can cover the specified polygon area and return a set of geocoding values containing the area. There are three main conversion conditions: MaxCells, MaxLevel, and MinLevel. MaxCells determines the maximum number of cells in the coverage area, and MaxLevel and MinLevel determine the maximum and minimum levels of the coding of the coverage area, respectively. Figure 2 This is a schematic diagram of the area coverage of the Google S2 algorithm. The area coverage method of Google S2 includes multiple different levels of encoding. Under the premise of accurate return values, the number of encodings is reduced as much as possible, and the amount of data read from the database is reduced during query.
[0033] This application starts with the data structure of Google S2 encoding and modifies the encoding method. The data structure of Google S2 encoding is as follows Figure 3As shown, the encoding of Google S2 is a fixed 64-bit number. The first three bits represent one of the six faces of the cube mapped to the earth's geographic coordinates. The last bit 1 is reserved intentionally to quickly find the number of bits in the middle. Search forward from the last bit at the end to find the first non-zero position, that is, find the first 1. The bit before this bit to the fourth bit at the beginning (because the first three bits are occupied) are all available numbers. Each level is represented by two digits. For a certain area and its subordinate areas, the prefixes are the same when encoding.
[0034] From the data structure of Google S2 encoding, it can be seen that we only need to truncate the code generated in the area coverage algorithm to the last digit 1, and we can follow the leftmost prefix matching principle of the database and use fuzzy query for fast retrieval. This application selects 23 levels of encoding when building the index. The required length is the first three digits plus 2 digits for each of the 23 levels. The final length is 49 bits, which is appropriately reduced compared to the original 64 bits. The length reduces the storage pressure without affecting the query accuracy. Finally, for the areas decomposed in the area coverage algorithm, a thread pool is established to design concurrent queries to speed up the response.
[0035] The ship trajectory data is connected through MySql. After obtaining the trajectory data, the index is established based on the longitude and latitude coordinates using the improved Google S2 encoding method combined with time. When the user makes a query, he enters the required query area and time range. This patent decomposes the area entered by the user through the area coverage algorithm, and encodes the decomposed series of areas with an improved encoding algorithm, performs prefix matching on the index in the database, and combines concurrent queries to achieve a fast response effect.
[0036] The above specific implementation methods are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to examples, a person skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the scope of the technical solution of the present invention, which should be included in the scope of the claims of the present invention.
Claims
1. A method for retrieving a ship's historical track area, characterized in that: The following steps are involved: S1. Build index; S2, historical trajectory area retrieval; The S2 includes: (1) the user gives a geographic space area and a time range as query conditions; (2) Adjust the encoding method of Google S2; (3) Using Google S2’s area coverage algorithm to decompose the user-inputted geographic spatial area, a set of geocoding values containing the area is obtained; (4) The obtained geocoding values are converted, and the leftmost prefix matching principle of the database constructed by S1 is used to perform fuzzy query for fast retrieval, and the database provides trajectory data that meets the conditions.
2. The search method according to claim 1, characterized in that: The steps of S1 include: (1) Use MySql as the database to store trajectory data; (2) Adjust the encoding method of Google S2; (3) Use the Google S2 algorithm to encode the longitude and latitude, combine them with the positioning time, and build an index using the B-Tree data structure.
3. The search method according to claim 2, characterized in that: In step (2) of S1, the encoding format of Google S2 is modified to a 49-bit string format for storage.
4. The search method according to claim 3, characterized in that: Step (3) in S1, encoding the longitude and latitude using the Google S2 algorithm, includes converting the spherical longitude and latitude into three-dimensional coordinates using the Google S2 algorithm, and then converting them into corrected three-dimensional coordinates on the projection surface of the circumscribed cube, and finally transforming the geographic grid into a one-dimensional coded value using the Hilbert curve.
5. The search method according to claim 4, characterized in that: In step (3) of S1, the encoding level of the Google S2 algorithm is divided into 23 levels, and each level represents a different precision.
6. The search method according to claim 1, characterized in that: In step (2) of S2, the encoding format of Google S2 is modified to a 49-bit string format for storage.
7. The search method according to claim 6, characterized in that: In step (4) of S2, the obtained geocoding value is converted using MaxCells, MaxLevel, and MinLevel, wherein MaxCells determines the maximum number of cells in the coverage area, and MaxLevel and MinLevel determine the maximum level and minimum level of the coding of the coverage area, respectively.
Citation Information
Cited By
Cross-border trade planning method and device and electronic equipment
CN121961379A