A method and device for calculating trajectory similarity

The trajectory is processed through coordinate filling and redis geo commands, and the problem of inconsistent trajectory density is solved, and the accuracy and accuracy of trajectory similarity calculation is achieved.

CN119150047BActive Publication Date: 2025-07-04BEIJING YUNXING ONLINE SOFTWARE DEV CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411648589.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2025-07-04
Estimated Expiration
2044-11-19

AI Technical Summary

Technical Problem

In the prior art, the trajectory similarity calculation is affected by uneven sampling of trajectory points, resulting in inconsistent density and deviation in the calculation results.

Method used

The coordinate filling algorithm is used to fill the trajectory equally, build circle selection data, and circle selection and mark through the redis geo command to calculate the trajectory similarity.

Benefits of technology

While keeping the original motion characteristics unchanged, the calculation deviation problem caused by inconsistent trajectory density is solved, and the accuracy of trajectory similarity calculation is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119150047B_ABST
    Figure CN119150047B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of trajectory similarity calculation, and specifically relates to a trajectory similarity calculation method and device. Among them, the method first obtains a first trajectory and a second trajectory to be calculated, uses a coordinate filling algorithm to perform equidistant filling on the first trajectory and the second trajectory, constructs circled data according to the filled second trajectory, circles the circled data according to the filled first trajectory, and marks the coordinate points in the filled first trajectory according to the circling result. The trajectory similarity of the second trajectory relative to the first trajectory is calculated according to the marked and unmarked coordinate points in the filled first trajectory. In this application, a coordinate filling algorithm is used to preprocess the original trajectory, and on the premise of keeping the original motion characteristics unchanged, the problem that the trajectory density is inconsistent due to uneven sampling and the calculation result is deviated at present is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of trajectory similarity calculation, and specifically relates to a trajectory similarity calculation method and device. Background Art

[0002] In the online car-hailing industry, it often happens that drivers do not follow the navigation. The reasons may include that the driver takes a detour, the driver goes the wrong way, or the passenger gives directions, etc. In order to improve the platform service experience, a similarity comparison is made between the driver's actual driving trajectory and the navigation trajectory, or the estimated planned trajectory and the billing trajectory, etc. Through the similarity comparison, some problematic orders and drivers are found for immediate risk control processing to improve the platform service experience.

[0003] In the prior art, trajectory similarity evaluation is usually affected by uneven sampling of trajectory points. Traditional methods such as Euclidean distance, dynamic time warping (DTW), etc., although effective to a certain extent, are prone to misjudgment when dealing with trajectories with inconsistent densities. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a trajectory similarity calculation method and device to overcome the problem that the trajectory density is inconsistent due to uneven sampling at present, resulting in deviation of the calculation results.

[0005] To achieve the above purpose, the present invention adopts the following technical solutions:

[0006] On the one hand, the present application provides a trajectory similarity calculation method, including:

[0007] Obtain the first trajectory and the second trajectory to be calculated;

[0008] Use the coordinate filling algorithm to perform equidistant filling on the first trajectory and the second trajectory;

[0009] Construct the circled data according to the filled second trajectory;

[0010] Circle the circled data according to the filled first trajectory, and mark the coordinate points in the filled first trajectory according to the circling result;

[0011] Calculate the trajectory similarity of the second trajectory relative to the first trajectory according to the marked coordinate points and unmarked coordinate points in the filled first trajectory.

[0012] Further, in the above method, the use of the coordinate filling algorithm to perform equidistant filling on the first trajectory and the second trajectory includes:

[0013] Confirm all the coordinate points in the first trajectory and the second trajectory;

[0014] Determine the minimum distance between the first trajectory coordinate point and the second trajectory coordinate point;

[0015] Confirm the filling distance according to the minimum distance;

[0016] According to the filling distance, use the coordinate filling algorithm to perform equidistant filling on the first trajectory and the second trajectory.

[0017] Further, for the method described above, the constructing the selected data according to the filled second trajectory includes:

[0018] Confirm all the coordinate points of the filled second trajectory;

[0019] Use the redis geo command geoadd to store all the coordinate points of the second trajectory into the redis database to generate the selected data.

[0020] Further, for the method described above, the selecting the selected data according to the filled first trajectory and marking the coordinate points in the filled first trajectory according to the selection result includes:

[0021] Confirm all the coordinate points of the filled first trajectory;

[0022] Store all the coordinate points of the filled first trajectory into the map data structure in sequence;

[0023] Confirm the selection distance according to the filling distance;

[0024] Use the redis geo command georedius to select the selected data with the selection distance as the radius and the coordinate points of the filled first trajectory as the center, and mark the selection results of all the coordinate points of the filled first trajectory.

[0025] Further, for the method described above, the using the redis geo command georedius to select the selected data with the selection distance as the radius and the coordinate points of the filled first trajectory as the center, and marking the selection results of all the coordinate points of the filled first trajectory includes:

[0026] Use the redis geo command georedius to select the selected data with the selection distance as the radius and the coordinate points of the filled first trajectory as the center;

[0027] Confirm all the selected coordinate points of the current coordinate point;

[0028] If there is no circled coordinate point for the current coordinate point, do not mark the current coordinate point and circle the next coordinate point;

[0029] If there is a circled coordinate point for the current coordinate point, mark the current coordinate point and confirm the coordinate point closest to the current coordinate point among the circled coordinate points;

[0030] Delete the coordinate point closest to the current coordinate point from the circled data and circle the next coordinate point.

[0031] Further, for the method described above, calculating the trajectory similarity of the second trajectory relative to the first trajectory based on the marked and unmarked coordinate points in the first trajectory after filling includes:

[0032] Calculate the ratio of the number of marked coordinate points in the first trajectory after filling to the total number of coordinate points in the first trajectory after filling;

[0033] The result of the ratio is the trajectory similarity of the second trajectory relative to the first trajectory.

[0034] On the other hand, the present application provides a trajectory similarity calculation device, including a processor and a memory, the processor is connected to the memory:

[0035] Wherein, the processor is used to call and execute the program stored in the memory;

[0036] The memory is used to store the program, and the program is at least used to execute the trajectory similarity calculation method described in any one of the above.

[0037] The beneficial effect of the present invention is:

[0038] The present application first obtains the first trajectory and the second trajectory to be calculated, uses the coordinate filling algorithm to perform equidistant filling on the first trajectory and the second trajectory, constructs the circled data according to the filled second trajectory, circles the circled data according to the filled first trajectory, marks the coordinate points in the filled first trajectory according to the circling result, and calculates the trajectory similarity of the second trajectory relative to the first trajectory based on the marked and unmarked coordinate points in the filled first trajectory. In the present application, the coordinate filling algorithm is used to preprocess the original trajectory, and the problem of inconsistent trajectory density and deviation in calculation results caused by uneven sampling at present is solved while keeping the original motion characteristics unchanged. Description of the Drawings

[0039] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0040] Figure 1 is a flowchart provided by an embodiment of a method for calculating trajectory similarity of the present invention;

[0041] Figure 2 is a schematic structural diagram provided by an embodiment of a device for calculating trajectory similarity of the present invention. Detailed implementation manners

[0042] To make the objectives, technical solutions, and advantages of the present invention clearer, the following will describe the technical solutions of the present invention in detail. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other implementation manners obtained by those of ordinary skill in the art without creative efforts fall within the scope protected by the present invention.

[0043] Figure 1 is a flowchart provided by an embodiment of a method for calculating trajectory similarity of the present invention. Please refer to Figure 1 , this embodiment may include the following steps:

[0044] S1. Obtain the first trajectory and the second trajectory to be calculated.

[0045] S2. Use the coordinate filling algorithm to perform equidistant filling on the first trajectory and the second trajectory.

[0046] S3. Construct the selected data according to the filled second trajectory.

[0047] S4. Select the selected data according to the filled first trajectory, and mark the coordinate points in the filled first trajectory according to the selection result.

[0048] S5. Calculate the trajectory similarity of the second trajectory relative to the first trajectory according to the marked coordinate points and the unmarked coordinate points in the filled first trajectory.

[0049] It can be understood that in this embodiment, the first trajectory and the second trajectory to be calculated are first obtained, the first trajectory and the second trajectory are equally spaced filled using a coordinate filling algorithm, the selection data is constructed according to the filled second trajectory, the selection data is selected according to the filled first trajectory, and the coordinate points in the filled first trajectory are marked according to the selection result, and the trajectory similarity of the second trajectory relative to the first trajectory is calculated according to the marked coordinate points and unmarked coordinate points in the filled first trajectory. In this embodiment, the coordinate filling algorithm is used to preprocess the original trajectory, and the problem of inconsistent trajectory density caused by uneven sampling and deviation of calculation results is solved on the premise of keeping the original motion characteristics unchanged.

[0050] It should be noted that the number of coordinate points, the length, and the trajectory density of the first trajectory and the second trajectory are unknown.

[0051] Preferably, step S2 includes:

[0052] Confirm all coordinate points in the first trajectory and the second trajectory;

[0053] Determine the minimum distance between the coordinate points of the first trajectory and the coordinate points of the second trajectory;

[0054] Confirm the filling distance according to the minimum distance;

[0055] According to the filling distance, the first trajectory and the second trajectory are equally spaced filled using a coordinate filling algorithm.

[0056] It can be understood that using the coordinate filling algorithm to preprocess the trajectory can solve the problem of inconsistent density caused by uneven sampling on the premise of keeping the original motion characteristics unchanged.

[0057] Preferably, step S3 includes:

[0058] Confirm all coordinate points of the filled second trajectory;

[0059] All coordinate points of the second trajectory are stored in the redis database using the redis geo command geoadd to generate selection data.

[0060] It can be understood that redis is a high-performance in-memory database. There is a data structure in redis called zset. Zset is an ordered set data structure that contains three attributes: key, value, and score. key = "sampleB1", value = the serial number n of the coordinate (x, y) in the B1 trajectory, and score is the value calculated using the redis geo command geohash(x, y).

[0061] Preferably, step S4 includes:

[0062] Confirm all coordinate points of the first track after filling;

[0063] Successively store all coordinate points of the first track after filling into the map data structure;

[0064] Confirm the selection distance according to the filling distance;

[0065] Use the redis geo command georedius to select the data within a circle with the selection distance as the radius and the coordinate points of the first track after filling as the center, and mark the selection results of all coordinate points of the first track after filling.

[0066] Preferably, use the redis geo command georedius to select the data within a circle with the selection distance as the radius and the coordinate points of the first track after filling as the center, and mark the selection results of all coordinate points of the first track after filling, including:

[0067] Use the redis geo command georedius to select the data within a circle with the selection distance as the radius and the coordinate points of the first track after filling as the center;

[0068] Confirm all selected coordinate points of the current coordinate point;

[0069] If there are no selected coordinate points for the current coordinate point, do not mark the current coordinate point and select the next coordinate point;

[0070] If there are selected coordinate points for the current coordinate point, mark the current coordinate point and confirm the coordinate point closest to the current coordinate point among the selected coordinate points;

[0071] Delete the coordinate point closest to the current coordinate point from the selected data and select the next coordinate point.

[0072] Preferably, step S5 includes:

[0073] Calculate the ratio of the number of marked coordinate points in the first track after filling to the number of all coordinate points in the first track after filling;

[0074] The ratio result is the track similarity of the second track relative to the first track.

[0075] In specific practice, to calculate the similarity of trajectory B relative to trajectory A, first, use the coordinate filling algorithm for trajectories A and B to fill the two trajectories at equal intervals d, where d is less than or equal to half of the minimum distance between points on trajectories A and B, so that the densities of trajectories A and B are similar, obtaining new trajectories A1 and B1 with similar trajectory densities. Then, store all the coordinates (x, y) in trajectory B1 using the redisgeo command geoadd(key, value, score). For example, key = "sampleB1", value = the serial number n of the coordinate (x, y) in trajectory B1, and score is the value calculated using the redis geo command geohash(x, y). And so on, until all points in B are traversed. Traverse the coordinate points in A1, store the coordinate points in A1 into the map data structure in sequence. The key of the map is [A1_coordinate serial number], and the value is flag, which represents 1 or 0. At the same time, use the coordinate points (p, q) in A1 in sequence and use the redis geo radius command to circle the coordinates in B1 with a radius less than or equal to d / 2 in the data constructed in step 1. The circle selection results are output in ascending order of distance. The first coordinate of the output result is the coordinate in B1 that is closest to the coordinate point (p, q) in A1 and meets the circle selection radius. Obtain the serial number of this point, and use the redis zset command zrem to delete the data with the value of this serial number in the circle selection data. And so on, until all points in A1 are traversed. If the circle selection result of the coordinate point in A1 is not empty, find the value of the coordinate point (p, q) in the map storing the coordinates of A1 and rewrite it as 1. Otherwise, mark it as 0. After marking, it represents that there are coordinates in B1 that are similar to the point (p, q) in A1. Calculate the ratio of the number of coordinate points with flag marked as 1 in A1 to the total number of coordinate points in A1. The result is the trajectory similarity of the original trajectory B relative to the original A.

[0076] It can be understood that this embodiment can be extended to the analysis of various types of moving objects, including fields such as vehicle monitoring, motion path planning, and group behavior analysis.

[0077] It shows excellent performance when processing large-scale location data and can support applications such as intelligent transportation systems and location services in complex urban environments.

[0078] Using geo circle selection simplifies the spatial data structure and reduces the computational complexity, making the method applicable to real-time and big data. At the same time, compared with the hexagonal honeycomb grid algorithm, geo circle selection is more accurate, has a wider coverage, and is more suitable for the online car-hailing scenario.

[0079] The present invention also provides a trajectory similarity calculation device for implementing the above method embodiments. Figure 2 It is a structural schematic diagram provided by an embodiment of a trajectory similarity calculation device of the present invention. AsFigure 2 As shown in the figure, a trajectory similarity calculation device according to this embodiment includes a processor 21 and a memory 22, and the processor 21 is connected to the memory 22. Among them, the processor 21 is used to call and execute the program stored in the memory 22; the memory 22 is used to store the program, and the program is at least used to execute a trajectory similarity calculation method in the above embodiments.

[0080] The specific implementation of a trajectory similarity calculation device provided by an embodiment of the present application can refer to the implementation manner of a trajectory similarity calculation method in any of the above embodiments, and will not be elaborated here.

[0081] It can be understood that the same or similar parts in the above embodiments can be referred to each other, and the content not detailed in some embodiments can be seen in the same or similar content in other embodiments.

[0082] It should be noted that in the description of the present invention, terms such as "first" and "second" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of the present invention, unless otherwise specified, the meaning of "plurality" refers to at least two.

[0083] Any process or method description shown in the flowchart or described in other ways herein can be understood as representing a module, segment, or part of code including one or more executable instructions for implementing a specific logical function or process, and the scope of the preferred embodiments of the present invention includes additional implementations, where the functions can be executed in a substantially simultaneous manner or in a reverse order according to the functions involved, rather than in the order shown or discussed, which should be understood by those skilled in the technical field of the embodiments of the present invention.

[0084] It should be understood that each part of the present invention can be implemented by hardware, software, firmware, or a combination thereof. In the above 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, any one or a combination of the following well-known technologies in the art can be used: discrete logic circuits with logic gate circuits for implementing logical functions on data signals, application-specific integrated circuits with appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0085] Those of ordinary skill in the technical field of the present invention can understand that all or part of the steps carried by the methods in the above embodiments can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.

[0086] In addition, each functional unit in various embodiments of the present invention may be integrated into a processing module, may exist physically alone for each unit, 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. When 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.

[0087] The above-mentioned storage medium may be a read-only memory, a magnetic disk, an optical disc, or the like.

[0088] 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 connection with the embodiment or example are included in at least one embodiment or example of the present invention. 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.

[0089] Although the embodiments of the present invention have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present invention.

Claims

1. A method for calculating trajectory similarity, characterized in that, Including: Obtain the first trajectory and the second trajectory to be calculated; Use a coordinate filling algorithm to perform equidistant filling on the first trajectory and the second trajectory; Confirm all coordinate points of the second trajectory after filling; Use the redisgeo command geoadd to store all coordinate points of the second trajectory into the redis database to generate selected data; Confirm all coordinate points of the first trajectory after filling; Successively store all coordinate points of the first trajectory after filling into a map data structure; Confirm the selection distance according to the filling distance; Use the redis geo command georedius to circle the selected data with the filling distance as the radius and the coordinate points of the first trajectory after filling as the center, and mark the selection results of all coordinate points of the first trajectory after filling; Calculate the trajectory similarity of the second trajectory relative to the first trajectory according to the marked coordinate points and unmarked coordinate points in the first trajectory after filling; Among them, the step of using the redis geo command georedius to circle the selected data with the filling distance as the radius and the coordinate points of the first trajectory after filling as the center, and mark the selection results of all coordinate points of the first trajectory after filling includes: Use the redis geo command georedius to circle the selected data with the filling distance as the radius and the coordinate points of the first trajectory after filling as the center; Confirm all selected coordinate points of the current coordinate point; If there are no selected coordinate points for the current coordinate point, do not mark the current coordinate point and circle the next coordinate point; If there are selected coordinate points for the current coordinate point, mark the current coordinate point, and among the selected coordinate points, confirm the coordinate point closest to the current coordinate point; Delete the coordinate point closest to the current coordinate point from the selected data and circle the next coordinate point.

2. The method according to claim 1, characterized in that, The step of using a coordinate filling algorithm to perform equidistant filling on the first trajectory and the second trajectory includes: Confirm all coordinate points in the first trajectory and the second trajectory; Determine the minimum distance between the coordinate points of the first trajectory and the coordinate points of the second trajectory; Confirm the filling distance according to the minimum distance; According to the filling distance, use a coordinate filling algorithm to perform equidistant filling on the first trajectory and the second trajectory.

3. The method according to claim 1, characterized in that, The step of calculating the trajectory similarity of the second trajectory relative to the first trajectory according to the marked coordinate points and unmarked coordinate points in the first trajectory after filling includes: Calculate the ratio of the number of marked coordinate points in the first trajectory after filling to the number of all coordinate points in the first trajectory after filling; The result of the ratio is the trajectory similarity of the second trajectory relative to the first trajectory.

4. A trajectory similarity calculation device, characterized in that, Including a processor and a memory, the processor is connected to the memory: Among them, the processor is used to call and execute the program stored in the memory; The memory is used to store the program, and the program is at least used to execute the trajectory similarity calculation method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • GPS trajectory similarity matching algorithm based on time

    CN108508465A

  • Vehicle classification trajectory error correction method based on map matching

    CN113505187A

  • Track prediction method, system and equipment based on track similarity

    CN116701951A