Trajectory path retrieval method, device, server and storage medium
By hash encoding the feature information of the trajectory path to generate a hash fingerprint and using index technology to search, the problem of DTW technology being computationally expensive in massive trajectory path retrieval is solved, and efficient trajectory path retrieval is achieved.
Patent Information
- Application Number
- CN202010832999.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-18
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2040-08-18
AI Technical Summary
In the prior art, when dynamic time regularization (DTW) technology is used for trajectory path retrieval, the calculation amount is large, making it difficult to search for a large number of trajectory paths to be matched within a preset time.
By using indexing technology and hash fingerprints, the geographical location information, size information and shape information of the trajectory path are hashed to generate a hash fingerprint, and candidate trajectory paths are obtained from the pre-established path index library, and similarity is calculated based on the hash fingerprint.
It reduces the calculation amount, improves the retrieval efficiency, and can quickly screen potential similar trajectory paths, reducing the calculation and time overhead of precise matching.
Smart Images

Figure CN114077617B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information processing, and in particular to a trajectory path retrieval method, device, server and storage medium. Background Art
[0002] In the related technology, the dynamic time warping (DTW) technology is usually used to realize the retrieval of similar trajectory paths. Specifically, the DTW technology is used to determine the similarity between the known trajectory and the trajectory to be matched based on the relative distance between the spatial trajectory points, and then the trajectory path similar to the known trajectory path is selected according to the similarity.
[0003] However, the current problem is that DTW technology mainly performs pairwise calculations on trajectory paths, focusing on accurately quantifying the similarity between two paths. Its calculation amount is large, and when used for massive trajectory paths to be matched, it may not be completed within the preset time. Summary of the invention
[0004] The purpose of this application is to solve one of the above-mentioned technical problems at least to a certain extent.
[0005] Therefore, the first purpose of the present application is to propose a trajectory path retrieval method. The method can speed up the retrieval speed, reduce the amount of calculation, and improve the retrieval efficiency by using index technology and hash fingerprints of trajectory paths to retrieve similar trajectory paths.
[0006] The second objective of the present application is to provide a trajectory path retrieval device.
[0007] The third objective of this application is to provide a server.
[0008] A fourth objective of the present application is to provide a computer-readable storage medium.
[0009] To achieve the above-mentioned purpose, the trajectory path retrieval method proposed in the first embodiment of the present application includes:
[0010] Obtain the geographic location information, size information and shape information of the target trajectory path;
[0011] Performing hash coding on the geographic location information, size information and shape information of the target trajectory path, respectively, to obtain the corresponding first geographic location code value, first trajectory path size code value and first trajectory path shape code value in sequence;
[0012] Generate a hash fingerprint for the target trajectory path according to the first geographic location code value, the first trajectory path size code value, and the first trajectory path shape code value;
[0013] According to the hash fingerprint of the target trajectory path, a predetermined number of candidate trajectory paths for the target trajectory path are obtained from a pre-established path index library;
[0014] According to the hash fingerprint of the target trajectory path and the hash fingerprint of each of the candidate trajectory paths, the similarity between the target trajectory path and each of the candidate trajectory paths is obtained, and according to the similarity and a preset threshold, at least one similar trajectory path for the target trajectory path is obtained from the predetermined number of candidate trajectory paths.
[0015] The trajectory path retrieval device proposed in the second embodiment of the present application includes:
[0016] An acquisition module is used to obtain the geographic location information, size information and shape information of the target trajectory path;
[0017] an encoding module, configured to perform hash encoding on the geographic location information, size information and shape information of the target trajectory path, respectively, to obtain the corresponding first geographic location encoding value, first trajectory path size encoding value and first trajectory path shape encoding value in sequence;
[0018] A generating module, configured to generate a hash fingerprint for the target trajectory path according to the first geographic location code value, the first trajectory path size code value and the first trajectory path shape code value;
[0019] A retrieval module, configured to obtain a predetermined number of candidate trajectory paths for the target trajectory path from a pre-established path index library according to a hash fingerprint of the target trajectory path;
[0020] A screening module is used to obtain the similarity between the target trajectory path and each of the candidate trajectory paths according to the hash fingerprint of the target trajectory path and the hash fingerprint of each of the candidate trajectory paths, and to obtain at least one similar trajectory path for the target trajectory path from the predetermined number of candidate trajectory paths according to the similarity and a preset threshold.
[0021] The server proposed in the third aspect embodiment of the present application includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the trajectory path retrieval method described in the first aspect embodiment of the present application is implemented.
[0022] The computer-readable storage medium proposed in the fourth aspect of the present application stores a computer program thereon, and when the computer program is executed by a processor, the trajectory path retrieval method described in the first aspect of the present application is implemented.
[0023] According to the technical solution of the embodiment of the present application, multiple path feature information of the target trajectory path, such as geographic location information, size information and shape information, can be obtained. Then, the geographic location information, size information and shape information of the target trajectory path can be hash-coded respectively to obtain the corresponding first geographic location code value, first trajectory path size code value and first trajectory path shape code value in turn. Then, according to the first geographic location code value, the first trajectory path size code value and the first trajectory path shape code value, a hash fingerprint for the target trajectory path is generated. Then, according to the hash fingerprint of the target trajectory path, a predetermined number of candidate trajectory paths for the target trajectory path are obtained from a pre-established path index library, and according to the hash fingerprint of the target trajectory path and the hash fingerprint of each candidate trajectory path, the similarity between the target trajectory path and each candidate trajectory path is obtained, and according to the similarity and a preset threshold, at least one similar trajectory path for the target trajectory path is obtained from the predetermined number of candidate trajectory paths. It can be seen that the embodiment of the present application performs hash encoding on feature information such as geographic location information, size information, and shape information that can uniquely represent the target trajectory path to generate a hash fingerprint of the target trajectory path, and then uses the hash fingerprint to retrieve similar trajectory paths. Compared with the method of comparing the similarity between trajectory points in two trajectory paths, the embodiment of the present application performs similarity calculations through the hash fingerprint of the entire trajectory path, which can reduce the amount of calculation and improve the retrieval efficiency; in addition, the present application utilizes indexing technology to quickly perform preliminary screening of potential similar trajectory paths, reduce the calculation and time overhead of precise matching one by one, which can greatly reduce the amount of calculation and greatly improve the retrieval efficiency.
[0024] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0026] Figure 1 is a flow chart of a trajectory path retrieval method according to an embodiment of the present application;
[0027] Figure 2 is a flow chart of a trajectory path retrieval method according to a specific embodiment of the present application;
[0028] Figure 3 is a flow chart of a trajectory path retrieval method according to another embodiment of the present application;
[0029] Figure 4 is a flow chart of a trajectory path retrieval method according to yet another embodiment of the present application;
[0030] Figure 5 is a structural block diagram of a trajectory path retrieval device according to an embodiment of the present application;
[0031] Figure 6 is a structural block diagram of a trajectory path retrieval device according to another embodiment of the present application;
[0032] Figure 7 is a structural block diagram of a trajectory path retrieval device according to another embodiment of the present application;
[0033] Figure 8 It is a structural block diagram of a server according to an embodiment of the present application. DETAILED DESCRIPTION
[0034] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0035] The following describes a trajectory path retrieval method, apparatus, server, and storage medium for a terminal device according to an embodiment of the present application with reference to the accompanying drawings.
[0036] Figure 1 1 is a flow chart of a trajectory path retrieval method according to an embodiment of the present application. It should be noted that the trajectory path retrieval method of the embodiment of the present application can be applied to the trajectory path retrieval device of the embodiment of the present application. The trajectory path retrieval device can be configured on a server.
[0037] like Figure 1 As shown, the trajectory path retrieval method may include:
[0038] Step 101, obtaining geographic location information, size information and shape information of the target trajectory path.
[0039] The target trajectory path can be a trajectory path reported by a mobile terminal or a trajectory path reported by a vehicle terminal. That is to say, the trajectory path retrieval method of the embodiment of the present application can realize the retrieval of similar mobile trajectory paths for mobile terminals or similar mobile trajectory paths for vehicle terminals. It can be understood that only two examples of application scenarios are given here for the convenience of understanding, and it can also be applied to the retrieval of other types of trajectory paths, which is not specifically limited here.
[0040] That is to say, when obtaining the target trajectory path, multiple path feature information of the target trajectory path can be obtained, wherein the path feature information can uniquely represent the trajectory path. It can be understood that the three path features of geographic location information, size information and shape information can uniquely represent a trajectory path. Therefore, when obtaining the target trajectory path, the geographic location information, size information and shape information of the target trajectory path can be obtained.
[0041] It should be noted that, due to the difference in path feature information, the method of obtaining the path feature information of the target trajectory path will also be different. In other words, the geographical location information, size information and shape information of the target trajectory path can be obtained respectively in different ways. The specific implementation method can be referred to the description of the subsequent embodiments.
[0042] In order to ensure the accuracy of the calculation results, the target trajectory path can be cleaned and preprocessed first. Among them, the cleaning preprocessing operation mainly includes the following two operations: 1) Deleting the trajectory points with large deviations in the target trajectory path, and only retaining the trajectory points with intervals within a certain threshold; 2) Simplifying the trajectory points that are too dense in the target trajectory path, and only retaining the trajectory points with a certain interval. In other words, the trajectory points with large deviations in the target trajectory path may be points recorded by the navigation system due to errors, and the trajectory points that are too dense in the target trajectory path may be the trajectory points recorded by the navigation system when the mobile object is on an elevated loop or congested road section. These trajectory points may cause errors in the calculation results. Therefore, it is necessary to delete the trajectory points with large deviations in the target trajectory path and simplify the trajectory points that are too dense in the target trajectory path, so as to ensure the accuracy of the calculation results.
[0043] Step 102 , hash codes are performed on the geographic location information, size information and shape information of the target trajectory path, and the corresponding first geographic location code value, first trajectory path size code value and first trajectory path shape code value are obtained in sequence.
[0044] Optionally, the geographic location information of the target trajectory path is hash-encoded to obtain a corresponding first geographic location code value, and the size information of the target trajectory path is hash-encoded to obtain a corresponding first trajectory path size code value, and the shape information of the target trajectory path is hash-encoded to obtain a corresponding first trajectory path shape code value.
[0045] Step 103: Generate a hash fingerprint for the target trajectory path according to the first geographic location code value, the first trajectory path size code value and the first trajectory path shape code value.
[0046] Optionally, the first geographic location code value, the first track path size code value and the first track path shape code value are concatenated to obtain a hash fingerprint of the target track path. For example, assuming that the first geographic location code value is A1, the first track path size code value is A2, and the first track path shape code value is A3, then A1, A2 and A3 can be concatenated, and the obtained A1A2A3 is used as the hash fingerprint HF of the target track path.
[0047] Step 104 : acquiring a predetermined number of candidate trajectory paths for the target trajectory path from a pre-established path index library according to the hash fingerprint of the target trajectory path.
[0048] It should be noted that in some embodiments of the present application, the above-mentioned path index library is pre-established using multiple sample trajectory paths to be retrieved and their hash fingerprints, wherein, when establishing the path index library, an index is constructed based on the hash fingerprints of multiple sample trajectory paths using indexing technology, so that when searching in the path index library, a predetermined number of candidate trajectory paths for the target trajectory path are first obtained from the path index library based on the hash fingerprint of the target trajectory path and the index in the path index library. Thus, a predetermined number of candidate trajectory paths for the target trajectory path are first screened out from the path index library using the hash fingerprint and the index in the path index library, so that by using the indexing technology, potential similar trajectory paths can be quickly pre-screened, reducing the calculation and time overhead of precise matching one by one, which can greatly reduce the amount of calculation and greatly improve the retrieval efficiency.
[0049] Step 105, obtaining the similarity between the target trajectory path and each candidate trajectory path according to the hash fingerprint of the target trajectory path and the hash fingerprint of each candidate trajectory path, and obtaining at least one similar trajectory path for the target trajectory path from the predetermined number of candidate trajectory paths according to the similarity and a preset threshold.
[0050] Optionally, the hash fingerprint of the target trajectory path and the hash fingerprint of each candidate trajectory path are respectively subjected to XOR Hamming distance calculation to obtain the Hamming distance between the target trajectory path and each candidate trajectory path. Afterwards, each Hamming distance can be compared with a preset threshold. If the Hamming distance is less than or equal to the preset distance threshold, it can be determined that the similarity between the candidate trajectory path corresponding to the hash fingerprint used to calculate the Hamming distance and the target trajectory path is greater than or equal to the preset threshold. In this case, the similarity between the above-mentioned candidate trajectory path and the target trajectory path is relatively large. At this time, the candidate trajectory path whose Hamming distance is less than or equal to the preset distance threshold can be determined as a similar trajectory path that matches the target trajectory path.
[0051] That is to say, after obtaining a predetermined number of candidate trajectory paths for the target trajectory path, the Hamming distance between the target trajectory path and each candidate trajectory path can be calculated based on the hash fingerprint of the target trajectory path and the hash fingerprint of each candidate trajectory path. Then, from the predetermined number of candidate trajectory paths, the candidate trajectory path whose Hamming distance is less than or equal to the preset threshold (or, the Hamming distance is less than the preset threshold) is found and determined as the similar trajectory path.
[0052] Among them, in the embodiments of the present application, the Hamming distance is a distance calculation method for similarity. It can be understood that the Hamming distance between two equal-length strings is the number of different characters in the corresponding positions of the two strings. In other words, it is the number of characters that need to be replaced to transform one string into another. For example: the Hamming distance between 1011101 and 1001001 is 2; the Hamming distance between 2143896 and 2233796 is 3; the Hamming distance between "toned" and "roses" is 3. In this embodiment, the number of 0 or 1 that needs to be replaced in the binary encoding of the hash fingerprint is considered. In this embodiment, the Hamming distance between the hash fingerprints of two trajectory paths is calculated by using the Hamming distance calculation method. The Hamming distance of the hash fingerprint is equivalent to the similarity of the trajectory path. The smaller the distance, the more similar the trajectory.
[0053] In some embodiments of the present application, after obtaining at least one similar trajectory path for the target trajectory path, at least one similar trajectory path can be provided to the user. That is, after obtaining a similar trajectory path for the target trajectory path, the similar trajectory path is provided to the user as a recommended path for the user's reference. For example, if the user is a running enthusiast, after the user runs once in a certain place, the similar trajectory path for the running trajectory path can be found from the path retrieval library based on the trajectory path of this run uploaded by the user, and the similar trajectory path can be recommended to the user for reference, which enriches the user's running route, drives the user's running fun, and thus improves the user's user experience.
[0054] According to the trajectory path retrieval method of the embodiment of the present application, multiple path feature information of the target trajectory path, such as geographic location information, size information and shape information, can be obtained. Then, the geographic location information, size information and shape information of the target trajectory path can be hash-coded respectively to obtain the corresponding first geographic location code value, first trajectory path size code value and first trajectory path shape code value in turn. Then, based on the first geographic location code value, the first trajectory path size code value and the first trajectory path shape code value, a hash fingerprint for the target trajectory path is generated. Then, based on the hash fingerprint of the target trajectory path, a predetermined number of candidate trajectory paths for the target trajectory path are obtained from a pre-established path index library, and based on the hash fingerprint of the target trajectory path and the hash fingerprint of each candidate trajectory path, the similarity between the target trajectory path and each candidate trajectory path is obtained, and based on the similarity and a preset threshold, at least one similar trajectory path for the target trajectory path is obtained from the predetermined number of candidate trajectory paths. It can be seen that the embodiment of the present application performs hash encoding on feature information such as geographic location information, size information, and shape information that can uniquely represent the target trajectory path to generate a hash fingerprint of the target trajectory path, and then uses the hash fingerprint to retrieve similar trajectory paths. Compared with the method of comparing the similarity between trajectory points in two trajectory paths, the embodiment of the present application performs similarity calculations through the hash fingerprint of the entire trajectory path, which can reduce the amount of calculation and improve the retrieval efficiency; in addition, the present application utilizes indexing technology to quickly perform preliminary screening of potential similar trajectory paths, reduce the calculation and time overhead of precise matching one by one, which can greatly reduce the amount of calculation and greatly improve the retrieval efficiency.
[0055] Figure 2 FIG. 1 is a flow chart of a trajectory path retrieval method according to a specific embodiment of the present application. Figure 2 As shown, the trajectory path retrieval method may include:
[0056] Step 201, obtaining geographic location information of the target trajectory path.
[0057] In some embodiments of the present application, the average latitude coordinates and the average longitude coordinates of the target trajectory path can be calculated based on the latitude and longitude coordinates of each trajectory point in the target trajectory path, and the average latitude coordinates and the average longitude coordinates can be combined to serve as the average longitude and latitude coordinates of the target trajectory path, and the average longitude and latitude coordinates can be determined as the geographic location information of the target trajectory path.
[0058] That is to say, a set of trajectory points in the target trajectory path can be obtained, the latitude of each trajectory point in the trajectory point set can be averaged to obtain the average latitude coordinate of the trajectory point set, and the longitude of each trajectory point in the trajectory point set can be averaged to obtain the average longitude coordinate of the trajectory point set. The above average latitude coordinate and the average longitude coordinate are combined as the average longitude and latitude coordinates of the target trajectory path, and the average longitude and latitude coordinates are the above geographic location information.
[0059] Step 202, obtaining size information of the target trajectory path.
[0060] In some embodiments of the present application, in a geographic coordinate system, a minimum enclosing rectangle for the target trajectory path is generated based on the latitude and longitude coordinates of each trajectory point in the target trajectory path, and size information of the target trajectory path is obtained based on the vertex coordinates of the minimum enclosing rectangle; wherein the sides of the minimum enclosing rectangle are parallel or perpendicular to the coordinate axes in the geographic coordinate system.
[0061] As a possible implementation method, the specific implementation method of generating the minimum circumscribed rectangle for the target trajectory path according to the latitude and longitude coordinates of each trajectory point in the target trajectory path may include: obtaining the maximum latitude value, the minimum latitude value, the maximum longitude value and the minimum longitude value from the latitude and longitude coordinates of each trajectory point in the target trajectory path; combining the maximum latitude value, the minimum latitude value, the maximum longitude value and the minimum longitude value as coordinate points to obtain four coordinate points; using the four coordinates as vertices of the rectangle, connecting two adjacent points among the four coordinate points with straight lines, and determining the obtained rectangle as the minimum circumscribed rectangle of the target trajectory path.
[0062] In some embodiments of the present application, after the minimum bounding rectangle of the target trajectory path is obtained, the coordinates of two vertices on any diagonal line of the minimum bounding rectangle may be determined as the size information of the target trajectory path.
[0063] For example, in a geographic coordinate system, according to the longitude and latitude coordinates of each track point in the target track path, a minimum enclosing rectangle is taken, and the four sides of the minimum enclosing rectangle are the maximum values of the east, west, south and north of the track path, and are parallel to the coordinate system respectively. Therefore, the box can be identified by the following four values: a) the maximum latitude of the track point set; b) the minimum latitude of the track point set; c) the maximum longitude of the track point set; d) the minimum longitude of the track point set. Combining the above a and c, we get the coordinates of the corner points in the northeast direction of the minimum enclosing rectangle, and combining the above b and d, we get the coordinates of the corner points in the southwest direction of the minimum enclosing rectangle. The coordinates of the corner points in the northeast direction and the coordinates of the corner points in the southwest direction (i.e., the coordinates of the two vertices on the diagonal line in the minimum enclosing rectangle) can be determined as the size information of the target track path.
[0064] Step 203, obtaining shape information of the target trajectory path.
[0065] In some embodiments of the present application, the above-mentioned minimum enclosing rectangle is divided horizontally and vertically to form N*N grids, and the boundary coordinates of each grid are obtained according to the vertex coordinates of the minimum enclosing rectangle, and according to the boundary coordinates of each grid and the longitude and latitude coordinates of each trajectory point in the target trajectory path, each trajectory point is mapped to N*N grids to obtain the shape information of the target trajectory path.
[0066] In an embodiment of the present application, after obtaining the boundary coordinates of each grid based on the vertex coordinates of the minimum circumscribed rectangle, the latitude and longitude coordinates of each trajectory point in the target trajectory path can be compared with the boundary coordinates of each grid to map each trajectory point to N*N grids, through which the shape information of the target trajectory path can be obtained.
[0067] Step 204 : Hash-code the geographic location information of the target trajectory path to obtain a corresponding first geographic location code value.
[0068] Optionally, the geographic location information is hash-encoded using a target geocoding algorithm to obtain a corresponding first geographic location code value H1. In the embodiment of the present application, the target geocoding algorithm may include but is not limited to GeoHash, Google S2 and other geocoding algorithms.
[0069] For example, taking the target geocoding algorithm as the GeoHash algorithm, different code lengths or code digits represent different ranges. The longer the string or the higher the code digits, the more accurate the range represented. In this embodiment, the number of GeoHash code digits can be selected according to the actual accuracy requirements, preferably between 4 and 12, that is, the complexity of encoding and subsequent similarity calculation can be increased without increasing too much, and higher accuracy can be achieved.
[0070] Specifically, in an application example, for the geographic location information of the target trajectory path ml (that is, the average longitude and latitude coordinates of the target trajectory path ml), it is assumed that the average longitude and latitude coordinates of the target trajectory path ml can be expressed as (lat1, lon1), where lat1 represents the average latitude coordinate and lon1 represents the average longitude coordinate. The average longitude and latitude coordinates can be encoded to form corresponding coded values using GeoHash coding. For example, the coded value obtained after encoding the average longitude and latitude coordinates of trajectory m1 is represented by H1. Among them, the average latitude coordinate lat1 is 39.928167 and the average longitude coordinate lon1 is 116.3907050 as an example for explanation. First, the average latitude coordinate 39.928167 is approximated and encoded, where the earth's latitude interval is [-90, 90]. The interval [-90, 90] is divided into [-90, 0), [0, 90], which are called left and right intervals. It can be determined that 39.928167 belongs to the right interval [0, 90] and is marked as 1. Then the interval [0, 90] is divided into [0, 45), [45, 90]. It can be determined that 39.928167 belongs to the left interval [0, 45), which is marked as 0. Recursively repeating the above process, 39.928167 always belongs to a certain interval [a, b]. With each iteration, the interval [a, b] is always shrinking and getting closer and closer to 39.928167. During the iteration process, if the given average latitude coordinate x(39.928167) belongs to the left interval, record 0, and if it belongs to the right interval, record 1. The length of the encoding sequence is related to the number of given interval divisions, as shown in Table 1 below:
[0071] Table 1
[0072] Latitude range Divide interval 0 Divide interval 1 39.928167 1 [-90,90] [-90,0.0) [0.0,90] 1 2 [0.0,90] [0.0,45.0) [45.0,90] 0 3 [0.0,45.0) [0.0,22.5) [22.5,45.0) 1 4 [22.5,45.0) [22.5,33.75) [33.75,45.0) 1 5 [33.75,45.0) [33.75,39.375) [39.375,45.0) 1 …… …… …… …… …… 15 [39.375,39.9243) [39.9133,39.9188) [39.9188,39.9243) 1
[0073] Similarly, the earth's longitude interval is [-180, 180], and the average longitude coordinate 116.389550 can be encoded. Through the above approximate coding, the encoding value of the average latitude coordinate 39.928167 is 110100101100010, and the encoding generated by the average longitude coordinate is 101110001100011. Secondly, the above average latitude coordinate and average longitude coordinate encoding are merged to obtain a new string 11100111010010001111000001101. Among them, the longitude encoding value is placed in the even-numbered positions in the new string, and the latitude encoding value is placed in the odd-numbered positions. Finally, the new string obtained after the merger is encoded according to base32 to obtain the corresponding encoding value wx4g0e, and the corresponding encoding value wx4g0e is the above-mentioned first geographic location encoding value H1. Among them, GeoHash encoding can also be encoded using other methods such as base64.
[0074] Step 205 , performing hash coding on the size information of the target trajectory path to obtain a corresponding first trajectory path size coding value.
[0075] In some embodiments of the present application, the two vertex coordinates in the size information may be hash-coded according to the target geocoding algorithm to obtain the corresponding first hash code H2 and second hash code H3, and the first trajectory path size coding value may be obtained according to the first hash code H2 and second hash code H3. In the embodiments of the present application, the target geocoding algorithm may include but is not limited to GeoHash, Google S2 and other geocoding algorithms.
[0076] That is to say, the target geocoding algorithm can be used to hash the above two vertex coordinates respectively to obtain the corresponding first hash code H2 and second hash code H3, and the first hash code H2 and second hash code H3 are used as the first trajectory path size encoding value of the target trajectory path. Among them, the encoding method of the two vertex coordinates by the target geocoding algorithm can refer to the encoding method of the geographic location information mentioned above, which will not be repeated here.
[0077] Step 206: Encode the shape information of the target trajectory path to obtain a corresponding first trajectory path shape encoding value.
[0078] In some embodiments of the present application, a matrix with N rows and N columns can be generated according to the number of grids, wherein each element in the matrix corresponds to a grid, and the value of each element in the matrix is 0, and N*N grids are traversed to detect whether there is a trajectory point in the target trajectory path in the current grid. If so, the value of the matrix element corresponding to the current grid is updated to 1; if not, the value of the matrix element corresponding to the current grid remains unchanged; until all N*N grids are traversed, the values of all elements in the current matrix are spliced row by row to obtain an N*N-bit binary number, and the N*N-bit binary number is determined as the first trajectory path shape coding value.
[0079] For example, taking N as 8, after mapping each trajectory point in the target trajectory path to 8*8 grids and obtaining 8*8 grids representing the shape information of the target trajectory path, an 8-row 8-column matrix can be generated according to the number of grids, wherein each element in the matrix corresponds to a grid, and the value of each element in the matrix is 0. Afterwards, the 8*8 grids can be traversed, and according to the boundary coordinates of the grids and the longitude and latitude coordinates of each trajectory point in the target trajectory path, it is detected whether there is a trajectory point in the target trajectory path in the current grid. If it exists, the value of the matrix element corresponding to the current grid is updated to 1. If it does not exist, the value of the matrix element corresponding to the current grid remains unchanged, and the traversal step is repeated until all N*N grids are traversed. Afterwards, the values of all elements in the final matrix can be spliced by row to obtain a 64-bit binary number, and the 64-bit binary number is used as the first trajectory path shape coding value H4 of the target trajectory path.
[0080] Step 207 : Generate a hash fingerprint for the target trajectory path according to the first geographic location code value, the first trajectory path size code value, and the first trajectory path shape code value.
[0081] Step 208 : acquiring a predetermined number of candidate trajectory paths for the target trajectory path from a pre-established path index library according to the hash fingerprint of the target trajectory path.
[0082] Step 209, obtaining the similarity between the target trajectory path and each candidate trajectory path according to the hash fingerprint of the target trajectory path and the hash fingerprint of each candidate trajectory path, and obtaining at least one similar trajectory path for the target trajectory path from a predetermined number of candidate trajectory paths according to the similarity and a preset threshold.
[0083] According to the trajectory path retrieval method of the embodiment of the present application, the characteristic information such as the geographic location information, size information and shape information that can uniquely represent the target trajectory path can be hash-encoded to generate a hash fingerprint of the target trajectory path, and then the hash fingerprint can be used to retrieve similar trajectory paths. Compared with the method of comparing the similarity between trajectory points in two trajectory paths, the embodiment of the present application performs similarity calculation through the hash fingerprint of the entire trajectory path, which can reduce the amount of calculation and improve the retrieval efficiency. In addition, the present application uses indexing technology to quickly screen potential similar trajectory paths, reduce the calculation and time overhead of precise matching one by one, and can greatly reduce the amount of calculation and greatly improve the retrieval efficiency.
[0084] It should be noted that when using indexing technology to construct the index in the path index library, the use of different indexing technologies may result in different ways of using hash fingerprints to retrieve similar trajectory paths in the path index library. Figure 3 and Figure 4 A description is given to construct an index in a path index library using two different indexing techniques, one of which is to construct an index using a locality sensitive hashing algorithm, and the other is to construct a prefix index using a hash fingerprint.
[0085] In some embodiments of the present application, Figure 3 As shown, the trajectory path retrieval method may also include:
[0086] Step 301, obtain multiple sample trajectory paths to be retrieved, and obtain the geographical location information, size information and shape information of each sample trajectory path.
[0087] Among them, the method for obtaining the geographic location information, size information and shape information of each sample trajectory path is similar to the method for obtaining the geographic location information, size information and shape information of the target trajectory path mentioned above. Please refer to the implementation method of obtaining the geographic location information, size information and shape information of the target trajectory path mentioned above, which will not be repeated here.
[0088] Step 302 , hash coding is performed on the geographic location information, size information and shape information of each sample trajectory path, and the corresponding second geographic location coding value, second trajectory path size coding value and second trajectory path shape coding value are obtained in sequence.
[0089] Among them, the encoding method of the geographic location information, size information and shape information of each sample trajectory path is similar to the encoding method of the geographic location information, size information and shape information of the above-mentioned target trajectory path. Please refer to the above-mentioned implementation method of encoding the geographic location information, size information and shape information of the target trajectory path respectively, which will not be repeated here.
[0090] Step 303: Generate a hash fingerprint of each sample trajectory path according to the second geographic location code value, the second trajectory path size code value and the second trajectory path shape code value.
[0091] Optionally, the second geographic location code value, the second trajectory path size code value and the second trajectory path shape code value of each sample trajectory path are concatenated to obtain a hash fingerprint of each sample trajectory path.
[0092] Step 304 : Process the hash fingerprint of each sample trajectory path according to the locality sensitive hashing algorithm to establish an index for the multiple sample trajectory paths.
[0093] For example, a hash function (such as a minimum hash algorithm) in a locality sensitive hashing algorithm LSH may be used to index the hash fingerprints of all sample trajectory paths to construct an index for multiple sample trajectory paths. For example, assuming that there are three sample trajectory paths, the hash fingerprints of these three sample trajectory paths are represented by HF1, HF2 and HF3 respectively. Assuming that HF1 is 00111, HF2 is 01000, and HF3 is 10001, the minimum hash algorithm is used to index HF1, HF2 and HF3, and the index numbers H(HF1)=2, H(HF2)=1, and H(HF3)=0 are obtained. At this time, there are three index numbers, and each index number corresponds to a sample trajectory path. When there are a large number of sample trajectory paths, the minimum hash algorithm is used to perform the above calculation on the hash fingerprint of each sample trajectory path to obtain the corresponding index number. Since the same index number may exist in the large number of sample trajectory paths, the sample trajectory paths with the same index number can be summarized into a set, thereby constructing an index for multiple sample trajectory paths, so that all sample trajectory paths under the index number can be found through the index number, so that the index can be used for subsequent retrieval, thereby greatly speeding up the retrieval speed.
[0094] Step 305 , establishing a path index library according to the indexes of the multiple sample trajectory paths, the hash fingerprint of each sample trajectory path, and the multiple sample trajectory paths.
[0095] Optionally, after constructing the index for multiple sample trajectory paths, the index of multiple sample trajectory paths, the hash fingerprint of each sample trajectory path and multiple sample trajectory paths can be used to establish a path index library. For example, assuming there are 10 sample trajectory paths, such as path A1, path A2, path A3, path A5, path A6, path A7, path A8, path A9 and path A10, wherein the hash fingerprints of these 10 sample trajectory paths are indexed and calculated using the minimum hash algorithm to obtain 3 index numbers, namely index number 1, index number 2 and index number 3, wherein path A1, path A2 and path A3 correspond to the same index number 1, path A5, path A6, path A9 and path A10 correspond to the same index number 2, and path A7 and path A8 correspond to the same index number 3. At this time, an index directory can be established, which includes index numbers and hash fingerprints, wherein the index directory is a two-dimensional data table, wherein the columns represent index numbers and the rows represent hash fingerprints of the sample trajectory paths, and the index directory obtained at this time can be shown in Table 2 below:
[0096] Table 2
[0097]
[0098] After the index directory is established, a two-dimensional data table of sample trajectory paths and their hash fingerprints can be established, where rows represent sample trajectory paths and columns represent hash fingerprints. The two-dimensional data table obtained at this time can be shown in Table 3 below:
[0099] Table 3
[0100]
[0101]
[0102] It can be seen that, according to the above index directory and two-dimensional data table, a path index library for 10 sample trajectory paths can be established.
[0103] It can be seen that by using the minimum hash algorithm in the local sensitive hashing algorithm to construct the index in the path index library for the hash fingerprint of the sample trajectory path, the retrieval speed can be greatly accelerated when using the hash fingerprint to retrieve similar trajectory paths in the path index library.
[0104] Due to the use of different indexing technologies, the methods of using hash fingerprints to retrieve similar trajectory paths in the path index library may also be different. When the minimum hash algorithm is used to build an index, when the hash fingerprint is used to retrieve similar trajectory paths, the minimum hash algorithm must also be used to map the hash fingerprint of the target trajectory path to the corresponding index number. Specifically, in an embodiment of the present application, the specific implementation process of obtaining a predetermined number of candidate trajectory paths for the target trajectory path from a pre-established path index library based on the hash fingerprint of the target trajectory path may include: mapping the hash fingerprint of the target trajectory path according to the hash function in the locally sensitive hashing algorithm to obtain the corresponding index number, and then finding the target index that matches the index number from the index in the path index library, and determining the multiple sample trajectory paths under the target index as the predetermined number of candidate trajectory paths for the target trajectory path.
[0105] For example, the hash fingerprint of the target trajectory path can be mapped using a hash function in a locally sensitive hashing algorithm (such as a minimum hashing algorithm). Assuming that the obtained index number is index number 2, the target index that matches the index number is found from the index in the path index library as "index number 2". At this time, the sample trajectory path under the target index can be determined as a predetermined number of candidate trajectory paths for the target trajectory path. For example, the paths A5, A6, A9, and A10 corresponding to "index number 2" in Table 2 can be determined as candidate trajectory paths for the target trajectory path.
[0106] Therefore, the hash fingerprint of the sample trajectory path in the path index library is indexed by the minimum hash algorithm. Then, the hash fingerprint and index of the target trajectory path are used to retrieve similar paths, which can greatly speed up the initial screening of potential similar paths and reduce the calculation and time overhead of precise matching one by one.
[0107] In some embodiments of the present application, Figure 4 As shown, the trajectory path retrieval method may also include:
[0108] Step 401, obtain multiple sample trajectory paths to be retrieved, and obtain the geographical location information, size information and shape information of each sample trajectory path.
[0109] Among them, the method for obtaining the geographic location information, size information and shape information of each sample trajectory path is similar to the method for obtaining the geographic location information, size information and shape information of the target trajectory path mentioned above. Please refer to the implementation method of obtaining the geographic location information, size information and shape information of the target trajectory path mentioned above, which will not be repeated here.
[0110] Step 402 , hash codes are performed on the geographic location information, size information and shape information of each sample trajectory path, and the corresponding second geographic location code value, second trajectory path size code value and second trajectory path shape code value are obtained in sequence.
[0111] Among them, the encoding method of the geographic location information, size information and shape information of each sample trajectory path is similar to the encoding method of the geographic location information, size information and shape information of the above-mentioned target trajectory path. Please refer to the above-mentioned implementation method of encoding the geographic location information, size information and shape information of the target trajectory path respectively, which will not be repeated here.
[0112] Step 403: Generate a hash fingerprint of each sample trajectory path according to the second geographic location code value, the second trajectory path size code value and the second trajectory path shape code value.
[0113] Optionally, the second geographic location code value, the second trajectory path size code value and the second trajectory path shape code value of each sample trajectory path are concatenated to obtain a hash fingerprint of each sample trajectory path.
[0114] Step 404: construct a first prefix index for the multiple sample trajectory paths according to the second geographic location code value of each sample trajectory path, and construct a second prefix index for the multiple sample trajectory paths according to the second trajectory path size code value of each sample trajectory path.
[0115] That is to say, assuming that the length of the prefix index is M characters, the first M characters of the second geographic location code value of each sample trajectory path can be determined, and the sample trajectory paths corresponding to the second geographic location code value with the same first M characters are grouped into a set, and the M characters are used as the prefix index of the set. The second prefix index is constructed in a similar manner to the first prefix index, and the first M characters of the second trajectory path size code value of each sample trajectory path can be determined, and the sample trajectory paths corresponding to the second geographic location code value with the same first M characters are grouped into a set, and the M characters are used as the prefix index of the set.
[0116] For example, assuming that there are 5 sample trajectory paths, namely path A1, path A2, path A3, path A4 and path A5, the second geographic location code value of path A1 is "123", the second trajectory path size code value of path A1 is "abc", the second geographic location code value of path A2 is "124", the second trajectory path size code value of path A2 is "abd", the second geographic location code value of path A3 is "125", the second trajectory path size code value of path A3 is "aed", the second geographic location code value of path A4 is "231", the second trajectory path size code value of path A4 is "bcd", and the second geographic location code value of path A5 is "235 ", the second trajectory path size encoding value of path A5 is "bca". Assuming that the length of the prefix index is 2, the first prefix indexes "12" and "23" can be constructed using the second geographic location encoding values of the five paths. The second prefix indexes "ab", "ae" and "bc" can be constructed using the second trajectory path size encoding values of the five paths. At this time, the first prefix index "12" corresponds to the hash fingerprints of path 1, path 2 and path 3, the first prefix index "23" corresponds to path 4 and path 5, the second prefix index "ab" corresponds to path 1 and path 2, the second prefix index "ae" corresponds to path 3, and the second prefix index "bc" corresponds to path 4 and path 5.
[0117] Step 405 , establishing a path index library according to the first prefix index for the multiple sample trajectory paths, the second prefix index, the hash fingerprint of each sample trajectory path, and the multiple sample trajectory paths.
[0118] Optionally, after constructing the first prefix index and the second prefix index for multiple sample trajectory paths, a path index library may be established using the first prefix index and the second prefix index for multiple sample trajectory paths, the hash fingerprint of each sample trajectory path, and the multiple sample trajectory paths.
[0119] Therefore, the index in the path index library is constructed by constructing a prefix index, so that when the hash fingerprint is used to search for similar trajectory paths in the path index library, the retrieval speed can be greatly accelerated.
[0120] Due to the use of different indexing technologies, the methods of retrieving similar trajectory paths in the path index library using hash fingerprints may also be different. Specifically, in an embodiment of the present application, the specific implementation process of obtaining a predetermined number of candidate trajectory paths for the target trajectory path from a pre-established path index library based on the hash fingerprint of the target trajectory path may include: obtaining a first trajectory path set from multiple sample trajectory paths based on the first geographic location code value of the target trajectory path and the first prefix index for multiple sample trajectory paths, and obtaining a second trajectory path set from multiple sample trajectory paths based on the first trajectory path size code value of the target trajectory path and the second prefix index for multiple sample trajectory paths, and then performing intersection processing on the first trajectory path set and the second trajectory path set to obtain a predetermined number of candidate trajectory paths for the target trajectory path.
[0121] For example, the example shown in step 404 is continued to be described. Assuming that the first geographic location code value of the target trajectory path is "126", and the first trajectory path size code value of the target trajectory path is "abf", the first prefix index "12" is found from the path index library according to the first geographic location code value "126", and the path 1, path 2 and path 3 corresponding to the first prefix index "12" are combined into a first trajectory path set; according to the first trajectory path size code value "abf", the second prefix index "ab" is found from the path index library, and the path 1 and path 2 corresponding to the second prefix index "ab" are combined into a second trajectory path set. After that, the first trajectory path set and the second trajectory path set are intersected to obtain path 1 and path 2. At this time, path 1 and path 2 can be used as candidate trajectory paths for the target trajectory path.
[0122] It should be noted that, in some embodiments of the present application, since the trajectory path size encoding value includes two encoding values, namely, two encoding values obtained by encoding two vertex coordinates, such as represented by H2 and H3. In an embodiment of the present application, when constructing the prefix index of the path index library, the geographic location encoding value H1 and the two vertex coordinate encoding values H2 and H3 in the hash fingerprint HF of multiple sample trajectory paths can be used to construct prefix indexes I1, I2 and I3 respectively. In this way, when using the target trajectory path to retrieve similar trajectory paths, H1, H2 and H3 in the hash fingerprint HF of the target trajectory path can be used to search in prefix indexes I1, I2 and I3 respectively to find the corresponding prefix index, and t sample trajectory paths are taken from the corresponding prefix index respectively to obtain three trajectory sets S1, S2 and S3, where t can be the number of all sample trajectory paths under the current prefix index, or it can be the number of some sample trajectory paths under the current prefix index. Afterwards, the three trajectory sets S1, S2 and S3 can be subjected to intersection processing, and the paths obtained after the intersection processing are used as the predetermined number of candidate trajectory paths SF of the target trajectory path. Then, for all candidate trajectory paths SF, the hash fingerprint HF of the candidate trajectory path and the hash fingerprint HF of the target trajectory path are subjected to XOR Hamming distance calculation, and the candidate trajectory paths that meet the distance threshold are selected as the similar trajectory paths.
[0123] In order to implement the above embodiment, the present application also proposes a trajectory path retrieval device.
[0124] Figure 5 is a structural block diagram of a trajectory path retrieval device according to an embodiment of the present application. Figure 5 As shown, the trajectory path retrieval device 500 may include: an acquisition module 501 , an encoding module 502 , a generation module 503 , a retrieval module 504 and a screening module 505 .
[0125] Specifically, the acquisition module 501 is used to acquire the geographic location information, size information and shape information of the target trajectory path. In some embodiments of the present application, the specific implementation process of the acquisition module 501 acquiring the geographic location information of the target trajectory path can be as follows: according to the longitude and latitude coordinates of each trajectory point in the target trajectory path, the average latitude coordinate and the average longitude coordinate of the target trajectory path are calculated, and the average latitude coordinate and the average longitude coordinate are combined as the average longitude and latitude coordinates of the target trajectory path, and the average longitude and latitude coordinates are determined as the geographic location information of the target trajectory path.
[0126] In some embodiments of the present application, the specific implementation process of the acquisition module 501 acquiring the size information of the target trajectory path may be as follows: in the geographic coordinate system, based on the latitude and longitude coordinates of each trajectory point in the target trajectory path, a minimum enclosing rectangle for the target trajectory path is generated, and based on the vertex coordinates of the minimum enclosing rectangle, the size information of the target trajectory path is acquired; wherein the sides of the minimum enclosing rectangle are parallel or perpendicular to the coordinate axes in the geographic coordinate system.
[0127] In some embodiments of the present application, the specific implementation process of the acquisition module 501 generating the minimum enclosing rectangle for the target trajectory path according to the longitude and latitude coordinates of each trajectory point in the target trajectory path can be as follows: obtaining the maximum latitude value, the minimum latitude value, the maximum longitude value and the minimum longitude value from the longitude and latitude coordinates of each trajectory point in the target trajectory path; combining the maximum latitude value, the minimum latitude value, the maximum longitude value and the minimum longitude value as coordinate points to obtain four coordinate points; using the four coordinates as the vertices of the rectangle, connecting two adjacent points among the four coordinate points with straight lines, and determining the obtained rectangle as the minimum enclosing rectangle of the target trajectory path.
[0128] In some embodiments of the present application, the specific implementation process of the acquisition module 501 acquiring the size information of the target trajectory path according to the vertex coordinates of the minimum enclosing rectangle can be as follows: the coordinates of two vertices on any diagonal line of the minimum enclosing rectangle are determined as the size information of the target trajectory path.
[0129] In some embodiments of the present application, the specific implementation process of the acquisition module 501 acquiring the shape information of the target trajectory path may be as follows: the minimum enclosing rectangle is divided horizontally and vertically to form N*N grids, and the boundary coordinates of each grid are obtained according to the vertex coordinates of the minimum enclosing rectangle, and according to the boundary coordinates of each grid and the longitude and latitude coordinates of each trajectory point in the target trajectory path, each trajectory point is mapped to N*N grids to obtain the shape information of the target trajectory path.
[0130] The encoding module 502 is used to perform hash encoding on the geographic location information, size information and shape information of the target trajectory path, and obtain the corresponding first geographic location encoding value, first trajectory path size encoding value and first trajectory path shape encoding value in sequence.
[0131] In some embodiments of the present application, the specific implementation process of the encoding module 502 for the first trajectory path shape encoding value of the target trajectory path may be as follows: encode the two vertex coordinates respectively according to the target geocoding algorithm to obtain the corresponding first hash code and second hash code; obtain the first trajectory path size encoding value according to the first hash code and the second hash code.
[0132] In some embodiments of the present application, the specific implementation process of the encoding module 502 for the first trajectory path size encoding value of the target trajectory path can be as follows: generate a matrix of N rows and N columns according to the number of grids, wherein each element in the matrix corresponds to a grid, and the value of each element in the matrix is 0; traverse N*N grids to detect whether there is a trajectory point in the target trajectory path in the current grid; if so, update the value of the matrix element corresponding to the current grid to 1, if not, keep the value of the matrix element corresponding to the current grid unchanged; until all N*N grids are traversed, splice the values of all elements in the current matrix by row to obtain an N*N-bit binary number, and determine the N*N-bit binary number as the first trajectory path shape encoding value.
[0133] The generation module 503 is used to generate a hash fingerprint for the target trajectory path according to the first geographic location code value, the first trajectory path size code value and the first trajectory path shape code value. In some embodiments of the present application, the generation module 503 concatenates the first geographic location code value, the first trajectory path size code value and the first trajectory path shape code value to obtain the hash fingerprint of the target trajectory path.
[0134] The retrieval module 504 is used to obtain a predetermined number of candidate trajectory paths for the target trajectory path from a pre-established path index library according to the hash fingerprint of the target trajectory path.
[0135] The screening module 505 is used to obtain the similarity between the target trajectory path and each candidate trajectory path according to the hash fingerprint of the target trajectory path and the hash fingerprint of each candidate trajectory path, and obtain at least one similar trajectory path for the target trajectory path from a predetermined number of candidate trajectory paths according to the similarity and a preset threshold.
[0136] In some embodiments of the present application, Figure 6As shown, the trajectory path retrieval device 500 may also include: a first path index library establishment module 506. The first path index library establishment module 506 is used to obtain multiple sample trajectory paths to be retrieved, and obtain the geographic location information, size information and shape information of each sample trajectory path, and hash code the geographic location information, size information and shape information of each sample trajectory path respectively, and obtain the corresponding second geographic location code value, second trajectory path size code value and second trajectory path shape code value in turn, and generate a hash fingerprint of each sample trajectory path according to the second geographic location code value, the second trajectory path size code value and the second trajectory path shape code value, and process the hash fingerprint of each sample trajectory path according to the local sensitive hashing algorithm to establish an index for the multiple sample trajectory paths, and establish a path index library according to the indexes of the multiple sample trajectory paths, the hash fingerprint of each sample trajectory path and the multiple sample trajectory paths.
[0137] In an embodiment of the present application, the specific implementation process of the retrieval module 504 obtaining a predetermined number of candidate trajectory paths for the target trajectory path from a pre-established path index library based on the hash fingerprint of the target trajectory path can be as follows: mapping the hash fingerprint of the target trajectory path according to the hash function in the local sensitive hashing algorithm to obtain the corresponding index number; finding the target index matching the index number from the index in the path index library, and determining the multiple sample trajectory paths under the target index as the predetermined number of candidate trajectory paths for the target trajectory path.
[0138] In some embodiments of the present application, Figure 7 As shown, the trajectory path retrieval device 500 may also include: a second path index library establishment module 507. The second path index library establishment module 507 is used to obtain multiple sample trajectory paths to be retrieved, and obtain the geographic location information, size information and shape information of each sample trajectory path, and hash code the geographic location information, size information and shape information of each sample trajectory path respectively, and obtain the corresponding second geographic location code value, second trajectory path size code value and second trajectory path shape code value in turn, and generate a hash fingerprint of each sample trajectory path according to the second geographic location code value, the second trajectory path size code value and the second trajectory path shape code value, and construct a first prefix index for multiple sample trajectory paths according to the second geographic location code value of each sample trajectory path, and construct a second prefix index for multiple sample trajectory paths according to the second trajectory path size code value of each sample trajectory path, and establish a path index library according to the first prefix index for multiple sample trajectory paths, the second prefix index, the hash fingerprint of each sample trajectory path and multiple sample trajectory paths.
[0139] In an embodiment of the present application, the specific implementation process of the retrieval module 504 obtaining a predetermined number of candidate trajectory paths for the target trajectory path from a pre-established path index library based on the hash fingerprint of the target trajectory path can be as follows: obtaining a first trajectory path set from multiple sample trajectory paths based on a first geographic location code value of the target trajectory path and a first prefix index for multiple sample trajectory paths; obtaining a second trajectory path set from multiple sample trajectory paths based on a first trajectory path size code value of the target trajectory path and a second prefix index for multiple sample trajectory paths; performing intersection processing on the first trajectory path set and the second trajectory path set to obtain a predetermined number of candidate trajectory paths for the target trajectory path.
[0140] According to the trajectory path retrieval device of the embodiment of the present application, the feature information such as the geographical location information, size information and shape information that can uniquely represent the target trajectory path is hash-encoded to generate a hash fingerprint of the target trajectory path, and then the hash fingerprint is used to retrieve similar trajectory paths. Compared with the method of comparing the similarity between trajectory points in two trajectory paths, the embodiment of the present application performs similarity calculation through the hash fingerprint of the entire trajectory path, which can reduce the amount of calculation and improve the retrieval efficiency. In addition, the present application uses indexing technology to quickly screen potential similar trajectory paths, reduce the calculation and time overhead of precise matching one by one, and can greatly reduce the amount of calculation and greatly improve the retrieval efficiency.
[0141] In order to implement the above embodiment, the present application also proposes a server.
[0142] Figure 8 is a structural block diagram of a server according to an embodiment of the present application. Figure 8 As shown, the server may include: a memory 801, a processor 802, and a computer program 803 stored in the memory 801 and executable on the processor 802. When the processor 802 executes the computer program 803, the trajectory path retrieval method described in any of the above embodiments of the present application is implemented.
[0143] In order to implement the above embodiments, the present application further proposes a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the trajectory path retrieval method described in any of the above embodiments of the present application is implemented.
[0144] In the description of the present application, it should be understood that the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present application, "plurality" means at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0145] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0146] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0147] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0148] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0149] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0150] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0151] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A trajectory path retrieval method, characterized in that: include: Obtain the geographic location information, size information and shape information of the target trajectory path; Performing hash coding on the geographic location information, size information and shape information of the target trajectory path, respectively, to obtain the corresponding first geographic location code value, first trajectory path size code value and first trajectory path shape code value in sequence; Generate a hash fingerprint for the target trajectory path according to the first geographic location code value, the first trajectory path size code value, and the first trajectory path shape code value; According to the hash fingerprint of the target trajectory path, a predetermined number of candidate trajectory paths for the target trajectory path are obtained from a plurality of sample trajectory paths included in a pre-established path index library, wherein the index of the sample trajectory path is determined according to at least a portion of the hash fingerprint of the sample trajectory path; According to the hash fingerprint of the target trajectory path and the hash fingerprint of each of the candidate trajectory paths, the similarity between the target trajectory path and each of the candidate trajectory paths is obtained, and according to the similarity and a preset threshold, at least one similar trajectory path for the target trajectory path is obtained from the predetermined number of candidate trajectory paths.
2. The trajectory path retrieval method according to claim 1, characterized in that: The acquiring of the geographical location information of the target trajectory path includes: Calculate the average latitude and longitude coordinates of the target trajectory path according to the latitude and longitude coordinates of each trajectory point in the target trajectory path; Combining the average latitude coordinate and the average longitude coordinate to serve as the average longitude and latitude coordinate of the target trajectory path; The average longitude and latitude coordinates are determined as the geographic location information of the target trajectory path.
3. The trajectory path retrieval method according to claim 1 or 2, characterized in that: The step of obtaining the size information of the target trajectory path includes: In a geographic coordinate system, a minimum enclosing rectangle for the target trajectory path is generated according to the latitude and longitude coordinates of each trajectory point in the target trajectory path, and size information of the target trajectory path is obtained according to the vertex coordinates of the minimum enclosing rectangle; wherein the sides of the minimum enclosing rectangle are parallel or perpendicular to the coordinate axes in the geographic coordinate system.
4. The trajectory path retrieval method according to claim 3, characterized in that: The step of generating a minimum circumscribed rectangle for the target trajectory path according to the latitude and longitude coordinates of each trajectory point in the target trajectory path comprises: Obtaining the maximum latitude value, the minimum latitude value, the maximum longitude value, and the minimum longitude value from the latitude and longitude coordinates of each track point in the target track path; Combining the maximum latitude value, the minimum latitude value, the maximum longitude value and the minimum longitude value into coordinate points to obtain four coordinate points; The four coordinates are used as vertices of a rectangle, and two adjacent points among the four coordinate points are connected by straight lines, and the resulting rectangle is determined as the minimum circumscribed rectangle of the target trajectory path.
5. The trajectory path retrieval method according to claim 3, characterized in that: According to the vertex coordinates of the minimum circumscribed rectangle, the size information of the target trajectory path is obtained, including: The coordinates of two vertices on any diagonal line of the minimum circumscribed rectangle are determined as the size information of the target trajectory path.
6. The trajectory path retrieval method according to claim 5, characterized in that: The step of performing hash coding on the size information of the target trajectory path to obtain a corresponding first trajectory path size coding value includes: Encode the two vertex coordinates respectively according to the target geocoding algorithm to obtain corresponding first hash codes and second hash codes; The first trajectory path size encoding value is obtained according to the first hash code and the second hash code.
7. The trajectory path retrieval method according to claim 3, characterized in that: The step of obtaining shape information of the target trajectory path includes: The minimum circumscribed rectangle is divided horizontally and vertically to form N*N grids, and the boundary coordinates of each grid are obtained according to the vertex coordinates of the minimum circumscribed rectangle, and according to the boundary coordinates of each grid and the longitude and latitude coordinates of each trajectory point in the target trajectory path, each trajectory point is mapped to the N*N grids to obtain the shape information of the target trajectory path.
8. The trajectory path retrieval method according to claim 7, characterized in that: Performing hash coding on the shape information of the target trajectory path to obtain a corresponding first trajectory path shape coding value includes: Generate a matrix with N rows and N columns according to the number of the grids, wherein each element in the matrix corresponds to a grid and the value of each element in the matrix is 0; Traversing the N*N grids, and detecting whether there is a trajectory point in the target trajectory path in the current grid; If it exists, the value of the matrix element corresponding to the current grid is updated to 1; if it does not exist, the value of the matrix element corresponding to the current grid remains unchanged; Until all the N*N grids are traversed, the values of all elements in the current matrix are concatenated row by row to obtain an N*N-bit binary number, and the N*N-bit binary number is determined as the first trajectory path shape coding value.
9. The trajectory path retrieval method according to claim 1, characterized in that: The step of generating a hash fingerprint for the target trajectory path according to the first geographic location code value, the first trajectory path size code value, and the first trajectory path shape code value includes: The first geographic location code value, the first trajectory path size code value, and the first trajectory path shape code value are concatenated to obtain a hash fingerprint of the target trajectory path.
10. The trajectory path retrieval method according to claim 1, characterized in that: Also includes: Obtaining the plurality of sample trajectory paths, and obtaining geographic location information, size information, and shape information of each of the sample trajectory paths; Performing hash coding on the geographic location information, size information and shape information of each of the sample trajectory paths, respectively, to obtain the corresponding second geographic location code value, second trajectory path size code value and second trajectory path shape code value in sequence; Generate a hash fingerprint of each of the sample trajectory paths according to the second geographic location code value, the second trajectory path size code value and the second trajectory path shape code value; Processing the hash fingerprint of each of the sample trajectory paths according to a local sensitive hashing algorithm to establish an index for the multiple sample trajectory paths; The path index library is established according to the indexes of the multiple sample trajectory paths, the hash fingerprint of each of the sample trajectory paths and the multiple sample trajectory paths.
11. The trajectory path retrieval method according to claim 10, characterized in that: The step of obtaining a predetermined number of candidate trajectory paths for the target trajectory path from a plurality of sample trajectory paths included in a pre-established path index library according to the hash fingerprint of the target trajectory path comprises: Mapping the hash fingerprint of the target trajectory path according to the hash function in the local sensitive hashing algorithm to obtain a corresponding index number; A target index matching the index number is found from the index in the path index library, and a plurality of sample trajectory paths under the target index are determined as a predetermined number of candidate trajectory paths for the target trajectory path.
12. The trajectory path retrieval method according to claim 1, characterized in that: Also includes: Obtaining the plurality of sample trajectory paths, and obtaining geographic location information, size information, and shape information of each of the sample trajectory paths; Performing hash coding on the geographic location information, size information and shape information of each of the sample trajectory paths, respectively, to obtain the corresponding second geographic location code value, second trajectory path size code value and second trajectory path shape code value in sequence; Generate a hash fingerprint of each of the sample trajectory paths according to the second geographic location code value, the second trajectory path size code value and the second trajectory path shape code value; Constructing a first prefix index for the plurality of sample trajectory paths according to the second geographic location code value of each of the sample trajectory paths, and constructing a second prefix index for the plurality of sample trajectory paths according to the second trajectory path size code value of each of the sample trajectory paths; The path index library is established according to the first prefix index for the multiple sample trajectory paths, the second prefix index, the hash fingerprint of each of the sample trajectory paths, and the multiple sample trajectory paths.
13. The trajectory path retrieval method according to claim 12, characterized in that: The step of obtaining a predetermined number of candidate trajectory paths for the target trajectory path from a plurality of sample trajectory paths included in a pre-established path index library according to the hash fingerprint of the target trajectory path comprises: Acquire a first trajectory path set from the plurality of sample trajectory paths according to a first geographic location code value of the target trajectory path and a first prefix index for the plurality of sample trajectory paths; Acquire a second trajectory path set from the plurality of sample trajectory paths according to a first trajectory path size encoding value of the target trajectory path and a second prefix index for the plurality of sample trajectory paths; The first trajectory path set and the second trajectory path set are subjected to intersection processing to obtain a predetermined number of candidate trajectory paths for the target trajectory path.
14. A trajectory path retrieval device, characterized in that: include: An acquisition module is used to obtain the geographic location information, size information and shape information of the target trajectory path; an encoding module, configured to perform hash encoding on the geographic location information, size information and shape information of the target trajectory path, respectively, to obtain the corresponding first geographic location encoding value, first trajectory path size encoding value and first trajectory path shape encoding value in sequence; A generating module, configured to generate a hash fingerprint for the target trajectory path according to the first geographic location code value, the first trajectory path size code value and the first trajectory path shape code value; a retrieval module, configured to obtain a predetermined number of candidate trajectory paths for the target trajectory path from a plurality of sample trajectory paths included in a pre-established path index library according to a hash fingerprint of the target trajectory path, wherein the index of the sample trajectory path is determined according to at least a portion of the hash fingerprint of the sample trajectory path; A screening module is used to obtain the similarity between the target trajectory path and each of the candidate trajectory paths according to the hash fingerprint of the target trajectory path and the hash fingerprint of each of the candidate trajectory paths, and to obtain at least one similar trajectory path for the target trajectory path from the predetermined number of candidate trajectory paths according to the similarity and a preset threshold.
15. The trajectory path search device according to claim 14, characterized in that: The acquisition module is specifically used for: According to the longitude and latitude coordinates of each trajectory point in the target trajectory path, the average latitude coordinate and the average longitude coordinate of the target trajectory path are calculated, and the average latitude coordinate and the average longitude coordinate are combined as the average longitude and latitude coordinates of the target trajectory path, and the average longitude and latitude coordinates are determined as the geographic location information of the target trajectory path.
16. The trajectory path search device according to claim 14 or 15, characterized in that: The acquisition module is specifically used for: In a geographic coordinate system, a minimum enclosing rectangle for the target trajectory path is generated according to the latitude and longitude coordinates of each trajectory point in the target trajectory path, and size information of the target trajectory path is obtained according to the vertex coordinates of the minimum enclosing rectangle; wherein the sides of the minimum enclosing rectangle are parallel or perpendicular to the coordinate axes in the geographic coordinate system.
17. The trajectory path search device according to claim 16, characterized in that: The acquisition module is specifically used for: Obtaining the maximum latitude value, the minimum latitude value, the maximum longitude value, and the minimum longitude value from the latitude and longitude coordinates of each track point in the target track path; Combining the maximum latitude value, the minimum latitude value, the maximum longitude value and the minimum longitude value into coordinate points to obtain four coordinate points; The four coordinates are used as vertices of a rectangle, and two adjacent points among the four coordinate points are connected by straight lines, and the resulting rectangle is determined as the minimum circumscribed rectangle of the target trajectory path.
18. The trajectory path search device according to claim 16, characterized in that: The acquisition module is specifically used for: The coordinates of two vertices on any diagonal line of the minimum circumscribed rectangle are determined as the size information of the target trajectory path.
19. The trajectory path search device according to claim 18, characterized in that: The encoding module is specifically used for: Encode the two vertex coordinates respectively according to the target geocoding algorithm to obtain corresponding first hash codes and second hash codes; The first trajectory path size encoding value is obtained according to the first hash code and the second hash code.
20. The trajectory path search device according to claim 16, characterized in that: The acquisition module is specifically used for: The minimum circumscribed rectangle is divided horizontally and vertically to form N*N grids, and the boundary coordinates of each grid are obtained according to the vertex coordinates of the minimum circumscribed rectangle, and according to the boundary coordinates of each grid and the longitude and latitude coordinates of each trajectory point in the target trajectory path, each trajectory point is mapped to the N*N grids to obtain the shape information of the target trajectory path.
21. The trajectory path search device according to claim 20, characterized in that: The encoding module is specifically used for: Generate a matrix with N rows and N columns according to the number of the grids, wherein each element in the matrix corresponds to a grid and the value of each element in the matrix is 0; Traversing the N*N grids, and detecting whether there is a trajectory point in the target trajectory path in the current grid; If it exists, the value of the matrix element corresponding to the current grid is updated to 1; if it does not exist, the value of the matrix element corresponding to the current grid remains unchanged; Until all the N*N grids are traversed, the values of all elements in the current matrix are concatenated row by row to obtain an N*N-bit binary number, and the N*N-bit binary number is determined as the first trajectory path shape coding value.
22. The trajectory path search device according to claim 14, characterized in that: The generation module is specifically used for: The first geographic location code value, the first trajectory path size code value, and the first trajectory path shape code value are concatenated to obtain a hash fingerprint of the target trajectory path.
23. The trajectory path search device according to claim 14, characterized in that: Also includes: The first path index library establishment module is used to obtain the multiple sample trajectory paths, and obtain the geographic location information, size information and shape information of each of the sample trajectory paths, and hash code the geographic location information, size information and shape information of each of the sample trajectory paths respectively, and obtain the corresponding second geographic location code value, second trajectory path size code value and second trajectory path shape code value in turn, and generate a hash fingerprint of each of the sample trajectory paths according to the second geographic location code value, the second trajectory path size code value and the second trajectory path shape code value, and process the hash fingerprint of each of the sample trajectory paths according to the local sensitive hashing algorithm to establish an index for the multiple sample trajectory paths, and establish the path index library according to the index of the multiple sample trajectory paths, the hash fingerprint of each of the sample trajectory paths and the multiple sample trajectory paths.
24. The trajectory path search device according to claim 23, characterized in that: The retrieval module is specifically used for: Mapping the hash fingerprint of the target trajectory path according to the hash function in the local sensitive hashing algorithm to obtain a corresponding index number; A target index matching the index number is found from the index in the path index library, and a plurality of sample trajectory paths under the target index are determined as a predetermined number of candidate trajectory paths for the target trajectory path.
25. The trajectory path search device according to claim 14, characterized in that: Also includes: A second path index library establishment module is used to obtain the multiple sample trajectory paths, and obtain the geographic location information, size information and shape information of each of the sample trajectory paths, and hash code the geographic location information, size information and shape information of each of the sample trajectory paths respectively, and obtain the corresponding second geographic location code value, second trajectory path size code value and second trajectory path shape code value in turn, and generate a hash fingerprint of each of the sample trajectory paths according to the second geographic location code value, the second trajectory path size code value and the second trajectory path shape code value, and construct a first prefix index for the multiple sample trajectory paths according to the second geographic location code value of each of the sample trajectory paths, and construct a second prefix index for the multiple sample trajectory paths according to the second trajectory path size code value of each of the sample trajectory paths, and establish the path index library according to the first prefix index for the multiple sample trajectory paths, the second prefix index, the hash fingerprint of each of the sample trajectory paths and the multiple sample trajectory paths.
26. The trajectory path search device according to claim 25, characterized in that: The retrieval module is specifically used for: Acquire a first trajectory path set from the plurality of sample trajectory paths according to a first geographic location code value of the target trajectory path and a first prefix index for the plurality of sample trajectory paths; Acquire a second trajectory path set from the plurality of sample trajectory paths according to a first trajectory path size encoding value of the target trajectory path and a second prefix index for the plurality of sample trajectory paths; The first trajectory path set and the second trajectory path set are subjected to intersection processing to obtain a predetermined number of candidate trajectory paths for the target trajectory path.
27. A server, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the trajectory path retrieval method according to any one of claims 1 to 13 is implemented.
28. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the trajectory path retrieval method according to any one of claims 1 to 13 is implemented.
Citation Information
Patent Citations
Track code-based track query method
CN107291842A
Trajectory similarity measurement method, data processing equipment and storage equipment
CN110443156A