Trajectory query method and system, and readable storage medium
By dividing and diluting the trajectory data in the back-end device and sending the results to the front-end device for rendering and displaying, the problems of high pressure and poor display effects in the prior art are solved, and high-performance and good-effect track query and display effects are achieved.
Patent Information
- Application Number
- CN202411447418.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-10-16
AI Technical Summary
When the prior art handles large data trajectory query, the front-end pressure is huge, making it difficult to meet the needs of trajectories at different map levels, resulting in poor display results.
By dividing the trajectory according to the map level and visual range in the back-end device, and applying multiple dilution algorithms (such as Douglas dilution, time dilution, distance dilution or customized dilution of business rules) to dilute the trajectory segments to generate trajectory dilution results, and send the results to the front-end device for rendering and displaying.
It has achieved high performance and good results for querying and displaying large data trajectories of millions of points and above. The trajectories displayed at different visual ranges at all levels are good, the front-end drawing pressure is small, the dilution algorithm is rich and chain-called, achieving both performance and effect.
Smart Images

Figure CN119336861B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of trajectory query technology, and in particular to a trajectory query method and system, and a readable storage medium. Background Art
[0002] For the display of trajectories with different levels and different visual ranges of large data volumes (more than one million points), the front-end and back-end data interaction: mainly through the front-end query of the full data of a section of trajectory, multiple traversals of data thinning and screening at different map levels, and then drawing, the disadvantage is that the pressure on the front-end is huge, and if the data volume is slightly large, it will be stuck or even crash. Pre-thinning the data, thinning the data when the data is stored, filtering it when the back-end is queried, and giving the front-end the already thinned data, but the problem with pre-thinning is that the same thinning algorithm cannot meet the requirements of different map levels for trajectories. At low map levels, it is hoped that the data will be thinner to avoid too much drawing pressure caused by too much data volume, while at high map levels, it is hoped that the data will be thinned more densely or even not thinned at all to achieve a better display effect. Summary of the invention
[0003] This application aims to solve or improve the above technical problems.
[0004] To this end, the first objective of the present application is to provide a trajectory query method.
[0005] The second objective of the present application is to provide a trajectory query system.
[0006] The third objective of the present application is to provide a trajectory query system.
[0007] The fourth object of the present application is to provide a readable storage medium.
[0008] To achieve the first purpose of the present application, the technical solution of the first aspect of the present application provides a trajectory query method for a geographic information system, the geographic information system including a front-end device and a back-end device, the trajectory query method including: obtaining a first trajectory query request through the front-end device; querying the maximum longitude and latitude range of the trajectory according to the first trajectory query request; determining the map level and the visible range according to the maximum longitude and latitude range, and sending the map level and the visible range to the back-end device; dividing the trajectory into multiple trajectory segments according to the map level and the visible range through the back-end device, each trajectory segment containing the first and last points outside the visible range; thinning the multiple trajectory segments according to multiple thinning algorithms through the back-end device, obtaining trajectory thinning results, and sending the trajectory thinning results to the front-end device, wherein the thinning algorithm includes one of the following: Douglas thinning, time thinning, distance thinning or business rule customized thinning, and multiple thinning algorithms support chain calls; rendering and displaying the trajectory thinning results through the front-end device.
[0009] According to the trajectory query method provided by the present application, firstly, the first trajectory query request is obtained through the front-end device, and the maximum latitude and longitude range of the trajectory is queried according to the first trajectory query request, so as to select the appropriate map level and visible range to display the thinned trajectory based on the full-time trajectory. Then, the trajectory is divided into multiple trajectory segments according to the map level and the visible range by the back-end device, and each trajectory segment contains the first and last points outside the visible range. The back-end device thins out the multiple trajectory segments according to multiple thinning algorithms respectively to obtain the trajectory thinning result, which can achieve both performance and effect. Among them, the thinning algorithm includes one of the following: Douglas thinning, time thinning, distance thinning or business rule customized thinning, and multiple thinning algorithms support chain calls. Finally, the trajectory thinning result is rendered and displayed by the front-end device. Through the trajectory query method provided by the present application, a high-performance and good overall implementation solution is provided for the query and display of large data volumes of millions of points and above. The trajectory display of different visible ranges at all levels has a good display effect, and the front-end drawing pressure is extremely small, the thinning algorithm is rich in implementation, and the chain call can achieve the effect of both performance and effect.
[0010] In addition, the technical solution provided by this application may also have the following additional technical features:
[0011] In some technical solutions, optionally, the trajectory query method also includes: obtaining a second trajectory query request after the map level changes or the visible range changes through the front-end device; querying the multi-level cache data according to the second trajectory query request, and obtaining the final thinning result of the trajectory according to the multi-level cache data, the multi-level cache data including the original trajectory cache and the thinning result cache; rendering and displaying the final thinning result of the trajectory through the front-end device.
[0012] In the technical solution, the trajectory query method also includes first obtaining a second trajectory query request after the map level changes or the visible range changes through the front-end device. Then, the multi-level cache data is queried according to the second trajectory query request, and the final thinning result of the trajectory is obtained according to the multi-level cache data, and the multi-level cache data includes the original trajectory cache and the thinning result cache. Finally, the final thinning result of the trajectory is rendered and displayed through the front-end device. Among them, the keys of the two caches are composed of the fields md5 (MD5 Message-Digest Algorithm, message digest algorithm) such as the ship MMSI (Maritime Mobile Service Identity), start time, end time, and whether the flying point is included. The value of the original trajectory cache is composed of different levels of cache of the trajectory corresponding to the key, specifically up to 1-18 levels, each level has a visible range cache, where level 1 is a full trajectory cache, and the visible range is the maximum longitude and latitude range of the trajectory. The multi-level cache has a high hit rate and significantly improves performance.
[0013] In some technical solutions, optionally, querying multi-level cache data according to the second trajectory query request, and obtaining the final thinning result of the trajectory according to the multi-level cache data, includes: determining whether the second trajectory query request is in the thinning result cache; if the second trajectory query request is in the thinning result cache, determining the final thinning result according to the thinning result cache.
[0014] In this technical solution, multi-level cache data is queried according to the second trajectory query request, and the final trajectory thinning result is obtained according to the multi-level cache data, specifically, whether the second trajectory query request is in the thinning result cache. If the second trajectory query request is in the thinning result cache, the final thinning result is determined according to the thinning result cache.
[0015] In some technical solutions, optionally, querying multi-level cache data according to the second trajectory query request, and obtaining the final trajectory thinning result according to the multi-level cache data, further includes: if the second trajectory query request is not in the thinning result cache, determining whether the second trajectory query request is in the original trajectory cache; if the second trajectory query request is in the original trajectory cache, thinning the original trajectory to obtain the final thinning result; if the second trajectory query request is not in the original trajectory cache, cyclically searching whether there is an original trajectory cache at the previous map level until the first map level, and thinning the original trajectory when there is an original trajectory cache to obtain the final thinning result.
[0016] In this technical solution, multi-level cache data is queried according to the second trajectory query request, and the final thinning result of the trajectory is obtained according to the multi-level cache data. It also includes if the second trajectory query request is not in the thinning result cache, then it is determined whether the second trajectory query request is in the original trajectory cache. If the second trajectory query request is in the original trajectory cache, the original trajectory is thinned to obtain the final thinning result. If the second trajectory query request is not in the original trajectory cache, then a loop is made to find out whether there is an original trajectory cache in the previous map level, until the first map level, and the original trajectory is thinned when there is an original trajectory cache, to obtain the final thinning result. Specifically, the cache operation process is to check whether there is an available thinning result cache according to the key, and directly return the result if the cache is hit. If it is not hit, then check whether there is an available original trajectory cache, and if it fails to hit, then loop to find out whether there is an available cache in the previous map level, until the level 1 original trajectory cache, use the available cache to generate the current level original trajectory cache, and then return the original trajectory thinned.
[0017] In some technical solutions, optionally, multi-level cache data is queried according to the second trajectory query request, and the final trajectory thinning result is obtained according to the multi-level cache data, and it also includes: when there is no original trajectory cache at the first map level, the trajectory is read from the database, and the stop event, flying point mark, maximum range and maximum range processing are calculated.
[0018] In this technical solution, multi-level cache data is queried according to the second trajectory query request, and the final trajectory thinning result is obtained according to the multi-level cache data. It also includes reading the trajectory from the database and calculating the stay event, flying point mark, maximum range and maximum range when there is no original trajectory cache at the first map level. Specifically, if there is no level 1 original trajectory cache, the trajectory is read from the database, and the stay event, flying point mark, maximum range and maximum range are calculated for subsequent use.
[0019] In some technical solutions, optionally, multiple trajectory segments are thinned out respectively according to multiple thinning algorithms by a back-end device to obtain trajectory thinning results, including: thinning out the trajectory segments by time thinning to obtain a first thinning result; obtaining a trajectory thinning result; wherein the thinning points include speed event points, flying points and ordinary points, the speed event points include slow speeds, suspected stops, and stop points, and the flying points include points that do not match the actual navigation conditions of the ship.
[0020] In this technical solution, multiple trajectory segments are thinned out respectively according to multiple thinning algorithms by the back-end device to obtain trajectory thinning results. Specifically, the trajectory segments are thinned out by time thinning to obtain the first thinning result. Then, the thinning points of the first thinning result are thinned out according to the preset priority by customized thinning according to business rules to obtain the trajectory thinning result. Among them, the thinning points include speed event points, flying points and ordinary points. The speed event points include slow speed, suspected stop, and stop points. The flying points include points that do not match the actual navigation conditions of the ship, and the rest are ordinary points. The three points are processed in order of priority. It can be understood that the trajectory segment is first thinned out with the highest performance in time to ensure that the final point quantity is not greater than the expected value, and then the business rule customized thinning is used to ensure the thinning effect. Each thinning algorithm retains the first and last two points of each segment of the trajectory.
[0021] In some technical solutions, optionally, the thinning points of the first thinning result are thinned out according to a preset priority through customized thinning according to business rules, including: judging whether the thinning point of the first thinning result is a speed event point; when the thinning point is a speed event point, processing is performed according to the speed event retention rule specified in the request parameter, and the processing method includes full retention, random extraction and retaining the first of the same type of speed event points; judging whether the thinning point is a flying point; when the thinning point is a flying point, processing is performed according to whether the flying point needs to be included as specified in the request parameter, when the flying point does not need to be included, all the flying points are discarded, and when the flying point needs to be included, regional thinning is performed on the flying points; judging whether the thinning point is an ordinary point; when the thinning point is an ordinary point, replacing the last reserved point with an ordinary point with a speed of 0, and calculating the distance and track difference between other ordinary points and the last reserved point, when the distance is greater than the distance threshold and / or the track difference is greater than the track difference threshold, retain the ordinary point, otherwise remove the ordinary point.
[0022] In the technical scheme, the thinning points of the first thinning result are thinned according to the preset priority through customized thinning according to business rules, specifically, whether the thinning points of the first thinning result are speed event points is determined, if it is a speed event point: full retention, random extraction and retention of the first speed event point of the same type are processed according to the speed event retention rules specified in the request parameters; if it is a flying point, it is processed according to whether the flying point is included as specified in the request parameters, when it is not necessary to include the flying point, all the flying points are discarded, when it is necessary to include the flying point, the flying point is regionally thinned, that is, only one flying point is retained in a certain geographical area; if it is an ordinary point, the point with a speed of 0 is preferentially retained, specifically, the point with a speed of 0 is used to replace the last reserved point, and the distance and track difference between other points and the last reserved point are calculated, and each map level has different distance thresholds and track difference thresholds. If any one of the two items is greater than the corresponding threshold, the point is retained, otherwise it is extracted.
[0023] In some technical solutions, optionally, the track query method also includes: caching through thread-safe collections and distributed locks; and / or sending requests from different ships to different loads through a gateway.
[0024] In this technical solution, the track query method also includes caching through thread-safe collections and distributed locks. Or the requests of different ships are sent to different loads through a gateway. The cache implemented using thread-safe collections and various locks can support concurrency. The gateway is used to send different ship requests to different loads to achieve the same key cache management in the same load, thereby supporting horizontal expansion.
[0025] In some technical solutions, optionally, the key of the original trajectory cache includes one of the following or a combination thereof: ship MMSI, start time, end time, and whether it contains a flying point; the key of the thinning result cache includes one of the following or a combination thereof: ship MMSI, start time, end time, and whether it contains a flying point; the value of the original trajectory cache includes different levels of cache of the trajectory corresponding to the key, each level has a visible range cache, level 1 is a full trajectory cache, and the visible range is the maximum longitude and latitude range of the trajectory; the value of the thinning result cache includes the final thinning result of the trajectory corresponding to the key.
[0026] In this technical solution, the keys of the original trajectory cache and the thinning result cache are composed of the ship's MMSI (Maritime Mobile Service Identity), start time, end time, and whether it contains flying points and other fields md5 (MD5 Message-Digest Algorithm). The value of the original trajectory cache is composed of different levels of cache of the trajectory corresponding to the key, specifically up to 1-18 levels, each level has a visible range cache, where level 1 is the full trajectory cache, and the visible range is the maximum longitude and latitude range of this segment of the trajectory. The value of the thinning result cache is composed of the final thinning result of the trajectory corresponding to the key.
[0027] To achieve the second purpose of the present application, the technical solution of the second aspect of the present application provides a trajectory query system, including: an acquisition module, used to obtain a first trajectory query request through a front-end device; a range query module, used to query the maximum longitude and latitude range of the trajectory according to the first trajectory query request; a level determination module, used to determine the map level and the visible range according to the maximum longitude and latitude range, and send the map level and the visible range to the back-end device; a trajectory segmentation module, used to divide the trajectory into multiple trajectory segments according to the map level and the visible range through the back-end device, each trajectory segment contains the first and last points outside the visible range; a thinning module, used to thin out the multiple trajectory segments according to multiple thinning algorithms through the back-end device, obtain trajectory thinning results, and send the trajectory thinning results to the front-end device, wherein the thinning algorithm includes one of the following: Douglas thinning, time thinning, distance thinning or business rule customized thinning, and multiple thinning algorithms support chain calls; a display module, used to render and display the trajectory thinning results through the front-end device.
[0028] According to the trajectory query system provided by the present application, it includes an acquisition module, a range query module, a level determination module, a trajectory segmentation module, a thinning module and a display module. Among them, the acquisition module is used to obtain a first trajectory query request through a front-end device. The range query module is used to query the maximum longitude and latitude range of the trajectory according to the first trajectory query request. The level determination module is used to determine the map level and the visible range according to the maximum longitude and latitude range. The trajectory segmentation module is used to divide the trajectory into multiple trajectory segments according to the map level and the visible range through the back-end device, and each trajectory segment contains the first and last points outside the visible range. The thinning module is used to thin out multiple trajectory segments according to multiple thinning algorithms through the back-end device, obtain trajectory thinning results, and send the trajectory thinning results to the front-end device, wherein the thinning algorithm includes one of the following: Douglas thinning, time thinning, distance thinning or business rule customized thinning, and multiple thinning algorithms support chain calls. The display module is used to render and display the trajectory thinning results through the front-end device. The trajectory query system provided in this application provides a high-performance, effective overall implementation solution for trajectory query and display of large amounts of data such as one million points or more. The trajectory displays at different levels and in different visual ranges have good display effects, and the front-end drawing pressure is extremely small. The thinning algorithm is rich in implementation, and can be chained to achieve a balance between performance and effect.
[0029] To achieve the third purpose of the present application, the technical solution of the third aspect of the present application provides a trajectory query system, including: a memory and a processor, wherein the memory stores a program or instruction that can be run on the processor, and when the processor executes the program or instruction, the trajectory query method of any one of the technical solutions of the first aspect is implemented, so it has the technical effect of any one of the technical solutions of the first aspect above, which will not be repeated here.
[0030] In order to achieve the fourth purpose of the present application, the technical solution of the fourth aspect of the present application provides a readable storage medium on which a program or instruction is stored. When the program or instruction is executed by the processor, the steps of the trajectory query method of any one of the technical solutions of the first aspect are implemented, so it has the technical effect of any of the technical solutions of the first aspect above, which will not be repeated here.
[0031] Additional aspects and advantages of the present application will become apparent in the following description or will be learned through practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0033] Figure 1 A schematic diagram of the steps of a trajectory query method according to an embodiment of the present application;
[0034] Figure 2A schematic diagram of the steps of a trajectory query method according to an embodiment of the present application;
[0035] Figure 3 A schematic diagram of the steps of a trajectory query method according to an embodiment of the present application;
[0036] Figure 4 A schematic diagram of the steps of a trajectory query method according to an embodiment of the present application;
[0037] Figure 5 A schematic diagram of the steps of a trajectory query method according to an embodiment of the present application;
[0038] Figure 6 A schematic diagram of the steps of a trajectory query method according to an embodiment of the present application;
[0039] Figure 7 A schematic diagram of the steps of a trajectory query method according to an embodiment of the present application;
[0040] Figure 8 A schematic diagram of the steps of a trajectory query method according to an embodiment of the present application;
[0041] Fig. 9 This is a schematic block diagram of the structure of a trajectory query system according to an embodiment of the present application;
[0042] Fig.10 This is a schematic block diagram of the structure of a trajectory query system according to an embodiment of the present application;
[0043] Fig.11 This is an interactive schematic diagram of a trajectory query method according to an embodiment of the present application;
[0044] Fig.12 A schematic diagram of a thinning scheme of a trajectory query method according to an embodiment of the present application;
[0045] Fig.13 A schematic diagram of a cache architecture of a trajectory query method according to an embodiment of the present application;
[0046] Fig.14 A schematic diagram of the cache action process of a trajectory query method according to an embodiment of the present application;
[0047] Fig.15 This is a schematic block diagram of the structure of a geographic information system of a trajectory query method according to an embodiment of the present application.
[0048] in, Fig. 9 , Fig.10 and Fig.15 The corresponding relationship between the reference numerals and component names in the figure is:
[0049] 10: track query system; 110: acquisition module; 120: range query module; 130: level determination module; 140: track segmentation module; 150: thinning module; 160: display module; 20: track query system; 300: memory; 400: processor; 50: geographic information system; 510: front-end device; 520: back-end device. DETAILED DESCRIPTION
[0050] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0051] In the following description, many specific details are set forth to facilitate a full understanding of the present application. However, the present application may also be implemented in other ways different from those described herein. Therefore, the scope of protection of the present application is not limited to the specific embodiments disclosed below.
[0052] Refer to the following Figures 1 to 15 The present invention describes a trajectory query method and system, and a readable storage medium according to some embodiments of the present application.
[0053] like Figure 1 As shown, an embodiment of the first aspect of the present application provides a trajectory query method for a geographic information system, the geographic information system includes a front-end device and a back-end device, and the trajectory query method includes the following steps:
[0054] Step S102: obtaining a first trajectory query request through a front-end device;
[0055] Step S104: querying the maximum longitude and latitude range of the trajectory according to the first trajectory query request;
[0056] Step S106: determining the map level and visible range according to the maximum latitude and longitude range, and sending the map level and visible range to the backend device;
[0057] Step S108: dividing the track into multiple track segments according to the map level and the visible range through the back-end device, each track segment contains the first and last points outside the visible range;
[0058] Step S110: thinning multiple trajectory segments according to multiple thinning algorithms through the backend device to obtain trajectory thinning results, and sending the trajectory thinning results to the front-end device, wherein the thinning algorithm includes one of the following: Douglas thinning, time thinning, distance thinning or business rule customized thinning, and chain calls are supported between multiple thinning algorithms;
[0059] Step S112: Rendering and displaying the trajectory thinning result through the front-end device.
[0060] According to the trajectory query method provided in this embodiment, firstly, the first trajectory query request is obtained through the front-end device, and the maximum latitude and longitude range of the trajectory is queried according to the first trajectory query request, so as to select the appropriate map level and visible range to display the thinned trajectory based on the full-time trajectory. Then, the trajectory is divided into multiple trajectory segments according to the map level and the visible range by the back-end device, and each trajectory segment contains the first and last points outside the visible range. The back-end device thins out the multiple trajectory segments according to multiple thinning algorithms respectively to obtain the trajectory thinning result, which can achieve both performance and effect. Among them, the thinning algorithm includes one of the following: Douglas thinning, time thinning, distance thinning or business rule customized thinning, and multiple thinning algorithms support chain calls. Finally, the trajectory thinning result is rendered and displayed by the front-end device. Through the trajectory query method provided by this application, a high-performance and good overall implementation solution is provided for the query and display of large-scale trajectories with millions of points or more. The trajectory display of different visible ranges at each level has a good display effect, and the front-end drawing pressure is extremely small, the thinning algorithm is rich in implementation, and the chain call can achieve the effect of both performance and effect.
[0061] like Figure 2 As shown, the trajectory query method according to an embodiment of the present application further includes the following steps:
[0062] Step S202: obtaining, through the front-end device, a second track query request after the map level changes or the visible range changes;
[0063] Step S204: querying the multi-level cache data according to the second trajectory query request, and obtaining the final trajectory thinning result according to the multi-level cache data, wherein the multi-level cache data includes the original trajectory cache and the thinning result cache;
[0064] Step S206: Rendering and displaying the final thinning result of the trajectory through the front-end device.
[0065] In this embodiment, the trajectory query method also includes first obtaining a second trajectory query request after the map level changes or the visible range changes through the front-end device. Then, the multi-level cache data is queried according to the second trajectory query request, and the final thinning result of the trajectory is obtained according to the multi-level cache data, and the multi-level cache data includes the original trajectory cache and the thinning result cache. Finally, the final thinning result of the trajectory is rendered and displayed through the front-end device. Among them, the keys of the two caches are composed of the md5 fields such as the ship MMSI, start time, end time, whether it contains flying points, etc. The value of the original trajectory cache is composed of different levels of cache of the trajectory corresponding to the key, specifically a visible range cache of each level from 1 to 18 levels, where level 1 is a full trajectory cache, and the visible range is the maximum longitude and latitude range of this segment of the trajectory. The multi-level cache hit rate is high, and the performance is significantly improved.
[0066] like Figure 3 As shown, according to a trajectory query method of an embodiment proposed in the present application, multi-level cache data is queried according to a second trajectory query request, and a final trajectory thinning result is obtained according to the multi-level cache data, specifically including the following steps:
[0067] Step S302: determining whether the second trajectory query request is in the thinning result cache;
[0068] Step S304: If the second trajectory query request is in the thinning result cache, determine the final thinning result according to the thinning result cache.
[0069] In this embodiment, the backend device queries the multi-level cache data according to the map level change request and the visual thinning result cache to determine the final thinning result range change request, and obtains the final thinning result of the track according to the multi-level cache data, specifically, judging whether the second track query request is in the thinning result cache. If the second track query request is in the thinning result cache, the final thinning result is determined according to the thinning result cache.
[0070] like Figure 4 As shown, according to a trajectory query method of an embodiment proposed in the present application, multi-level cache data is queried according to a second trajectory query request, and a final trajectory thinning result is obtained according to the multi-level cache data, and the following steps are also included:
[0071] Step S402: if the second trajectory query request is not in the thinning result cache, determine whether the second trajectory query request is in the original trajectory cache;
[0072] Step S404: if the second trajectory query request is in the original trajectory cache, thinning the original trajectory to obtain a final thinning result;
[0073] Step S406: If the second trajectory query request is not in the original trajectory cache, then loop to find out whether there is an original trajectory cache in the previous map level until the first map level, and if there is an original trajectory cache, thin out the original trajectory to obtain the final thinning result.
[0074] In this embodiment, the multi-level cache data is queried according to the second trajectory query request, and the final thinning result of the trajectory is obtained according to the multi-level cache data. It also includes if the second trajectory query request is not in the thinning result cache, then it is determined whether the second trajectory query request is in the original trajectory cache. If the second trajectory query request is in the original trajectory cache, the original trajectory is thinned to obtain the final thinning result. If the second trajectory query request is not in the original trajectory cache, then it is cyclically searched whether there is an original trajectory cache in the previous map level until the first map level, and the original trajectory is thinned when there is an original trajectory cache to obtain the final thinning result. Specifically, the cache operation process is to check whether there is an available thinning result cache according to the key, and directly return the result if the cache is hit. If it is not hit, then check whether there is an available original trajectory cache. If it fails to hit, then it is cyclically searched whether there is an available cache in the previous map level until the level 1 original trajectory cache, and the available cache is used to generate the current level original trajectory cache, and then the original trajectory is thinned and returned.
[0075] like Figure 5 As shown, according to a trajectory query method of an embodiment proposed in the present application, multi-level cache data is queried according to a second trajectory query request, and a final trajectory thinning result is obtained according to the multi-level cache data, and the following steps are also included:
[0076] Step S502: When there is no original track cache at the first map level, the track is read from the database, and the stay event, flying point mark, maximum range and maximum range are calculated.
[0077] In this embodiment, the multi-level cache data is queried according to the second trajectory query request, and the final trajectory thinning result is obtained according to the multi-level cache data, and the trajectory is read from the database when there is no original trajectory cache at the first map level, and the stay event, flying point mark, maximum range and maximum range are calculated. Specifically, if there is no level 1 original trajectory cache, the trajectory is read from the database, and the stay event, flying point mark, maximum range and maximum range are calculated for subsequent use.
[0078] like Figure 6 As shown, according to a trajectory query method of an embodiment proposed in the present application, a backend device thins out multiple trajectory segments according to multiple thinning algorithms to obtain a trajectory thinning result, which specifically includes the following steps:
[0079] Step S602: thinning the trajectory segments by time thinning to obtain a first thinning result;
[0080] Step S604: thinning out the thinning points of the first thinning result according to the preset priority through customized thinning by business rules to obtain a trajectory thinning result;
[0081] Among them, the rarefied points include speed event points, flying points and ordinary points. Speed event points include slow speed, suspected stop and stop points. Flying points include points that do not match the actual navigation conditions of the ship.
[0082] In this embodiment, multiple trajectory segments are thinned out respectively according to multiple thinning algorithms by the back-end device to obtain trajectory thinning results. Specifically, the trajectory segments are thinned out by time thinning first to obtain a first thinning result. Then, the thinning points of the first thinning result are thinned out according to the preset priority by business rule customized thinning to obtain a trajectory thinning result. Among them, the thinning points include speed event points, flying points and ordinary points. The speed event points include slow speed, suspected stop, and stop points. The flying points include points that do not match the actual navigation conditions of the ship, and the rest are ordinary points. The three points are processed in turn according to priority. It can be understood that the trajectory segment is first thinned out with the highest performance in time to ensure that the final point quantity is not greater than the expected value, and then the business rule customized thinning is used to ensure the thinning effect. Each thinning algorithm retains the first and last two points of each segment of the trajectory.
[0083] like Figure 7 As shown, the trajectory query method according to an embodiment of the present application further includes the following steps:
[0084] Step S702: caching through thread-safe collections and distributed locks; and / or sending requests from different ships to different loads through a gateway.
[0085] In this embodiment, the track query method also includes caching through thread-safe collections and distributed locks. Or sending requests from different ships to different loads through a gateway. The cache implemented using thread-safe collections and various locks can support concurrency. Using a gateway to send requests from different ships to different loads, the same key cache is managed in the same load, thereby supporting horizontal expansion.
[0086] like Figure 8 As shown, the trajectory query method according to an embodiment of the present application further includes the following steps:
[0087] Step S902: determining whether the thinning point of the first thinning result is a speed event point;
[0088] Step S904: when the thinning point is a speed event point, processing is performed according to the speed event retention rule specified in the request parameters, and the processing methods include full retention, random sampling, and retaining the first speed event point of the same type;
[0089] Step S906: Determine whether the thinned point is a flying point;
[0090] Step S908: when the thinned out points are flying points, processing is performed according to whether the flying points need to be included as specified in the request parameters. When the flying points do not need to be included, all the flying points are discarded. When the flying points need to be included, regional thinning is performed on the flying points.
[0091] Step S910: Determine whether the thinned point is a common point;
[0092] Step S912: When the thinned point is an ordinary point, use an ordinary point with a speed of 0 to replace the last reserved point, and calculate the distance and track difference between other ordinary points and the last reserved point. When the distance is greater than the distance threshold and / or the track difference is greater than the track difference threshold, retain the ordinary point, otherwise remove the ordinary point.
[0093] In this embodiment, the thinning points of the first thinning result are thinned out according to the preset priority through customized thinning by business rules, specifically, whether the thinning points of the first thinning result are speed event points is determined, if it is a speed event point: full retention, random extraction and retention of the first speed event point of the same type are processed according to the speed event retention rule specified in the request parameter; if it is a flying point, it is processed according to whether the flying point is included as specified in the request parameter, when it is not necessary to include the flying point, all the flying points are discarded, when it is necessary to include the flying point, the flying point is regionally thinned out, that is, only one flying point is retained in a certain geographical area; if it is an ordinary point, the point with a speed of 0 is preferentially retained, specifically, the point with a speed of 0 is used to replace the last reserved point, and the distance and track difference between other points and the last reserved point are calculated, and each map level has different distance thresholds and track difference thresholds. If any one of the two items is greater than the corresponding threshold, the point is retained, otherwise it is extracted.
[0094] In some embodiments, optionally, the keys of the original trajectory cache and the thinning result cache are composed of the md5 fields such as the ship MMSI, start time, end time, and whether the flying point is included. The value of the original trajectory cache is composed of different levels of caches of the trajectory corresponding to the key, specifically a visible range cache for each level of 1-18, where level 1 is a full trajectory cache, and the visible range is the maximum longitude and latitude range of the trajectory. The value of the thinning result cache is composed of the final thinning result of the trajectory corresponding to the key.
[0095] like Fig. 9As shown, an embodiment of the second aspect of the present application provides a trajectory query system 10, including: an acquisition module 110, used to acquire a first trajectory query request through a front-end device; a range query module 120, used to query the maximum longitude and latitude range of the trajectory according to the first trajectory query request; a level determination module 130, used to determine the map level and the visible range according to the maximum longitude and latitude range, and send the map level and the visible range to the back-end device; a trajectory segmentation module 140, used to segment the trajectory into multiple trajectory segments according to the map level and the visible range through the back-end device, each trajectory segment contains the first and last points outside the visible range; a thinning module 150, used to thin out the multiple trajectory segments according to multiple thinning algorithms through the back-end device, obtain trajectory thinning results, and send the trajectory thinning results to the front-end device, wherein the thinning algorithm includes one of the following: Douglas thinning, time thinning, distance thinning or business rule customized thinning, and multiple thinning algorithms support chain calls; a display module 160, used to render and display the trajectory thinning results through the front-end device.
[0096] According to the trajectory query system 10 provided in this embodiment, it includes an acquisition module 110, a range query module 120, a level determination module 130, a trajectory segmentation module 140, a thinning module 150 and a display module 160. Among them, the acquisition module 110 is used to obtain a first trajectory query request through a front-end device. The range query module 120 is used to query the maximum longitude and latitude range of the trajectory according to the first trajectory query request. The level determination module 130 is used to determine the map level and the visible range according to the maximum longitude and latitude range. The trajectory segmentation module 140 is used to divide the trajectory into multiple trajectory segments according to the map level and the visible range through the back-end device, and each trajectory segment contains the first and last points outside the visible range. The thinning module 150 is used to thin out the multiple trajectory segments according to multiple thinning algorithms through the back-end device, obtain the trajectory thinning results, and send the trajectory thinning results to the front-end device, wherein the thinning algorithm includes one of the following: Douglas thinning, time thinning, distance thinning or business rule customized thinning, and multiple thinning algorithms support chain calls. The display module 160 is used to render and display the trajectory thinning results through the front-end device. Through the trajectory query system provided by this application, a high-performance and effective overall implementation solution is provided for the query and display of trajectories with a large amount of data of one million points or more. The trajectory display of different visual ranges at all levels has a good display effect, and the front-end drawing pressure is extremely small. The thinning algorithm is rich in implementation, and the chain call can achieve the effect of taking into account both performance and effect.
[0097] like Fig.10As shown, an embodiment of the third aspect of the present application provides a trajectory query system 20, including: a memory 300 and a processor 400, wherein the memory 300 stores a program or instruction that can be run on the processor 400, and when the processor 400 executes the program or instruction, the steps of the trajectory query method of any one of the embodiments of the first aspect are implemented, so it has the technical effect of any one of the embodiments of the first aspect above, which will not be repeated here.
[0098] The embodiment of the fourth aspect of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the trajectory query method of any one of the embodiments of the first aspect are implemented, so it has the technical effect of any one of the embodiments of the first aspect above, which will not be repeated here.
[0099] like Fig.11 , Fig.12 , Fig.13 , Fig.14 , Fig.15 As shown, a trajectory query method according to a specific embodiment provided by the present application is used in a geographic information system 50, and the geographic information system 50 includes a front-end device 510 and a back-end device 520. The trajectory query method involves trajectory display of different levels and different visual ranges of a large amount of data (more than one million points), and is mainly explained from the aspects of front-end and back-end data interaction, back-end sparseness algorithm, cache, concurrency and expansion, and other processing.
[0100] Front-end and back-end data interaction:
[0101] The backend interface provides two types of queries: the maximum latitude and longitude range of a track; a track is divided into multiple tracks by the visible range at a specific map level, and each track contains the first and last points outside the visible range.
[0102] The front end first queries the maximum range of the trajectory to select the appropriate map level and visual range to display the sparse trajectory based on the full-time trajectory.
[0103] The front end queries the trajectory through the back end device according to the map level and visible range, and renders it.
[0104] When the front-end map level changes (user zoom operation) or the visible range changes (user drag operation), the front-end requests the new map level and track data of the visible range again and renders it.
[0105] Specifically, Fig.11 As shown:
[0106] 1. The user initiates a trajectory query request;
[0107] 2. Maximum range of front-end request traces;
[0108] 3. The front end selects the appropriate map level and visible range based on the maximum range and requests the trajectory;
[0109] 4. The front end displays the track to the user at a specific map level and visual range;
[0110] 5. The user adjusts the map level and visible range;
[0111] 6. Query the trajectory of the new map layer or visual range;
[0112] 7. The front end displays the trajectory to the user at the current map level and visible range.
[0113] like Fig.12 As shown, the backend thinning algorithm:
[0114] What the backend ultimately returns is a track segment divided into multiple tracks by the visible range at a specific map level. Each track segment contains the first and last points outside the visible range. Therefore, it is necessary not only to consider the thinning effect of each track segment, but also to ensure that the overall thinning result can meet the performance requirements of the front-end drawing.
[0115] This embodiment currently implements four thinning methods: Douglas thinning, time thinning, distance thinning, and business rule customized thinning, and thinning algorithms support chain calls. For example, the thinning chain finally adopted by this solution is: first perform the highest performance time thinning on the trajectory segment to ensure that the final point volume is not greater than the expected value, and then use business rule customized thinning to ensure the thinning effect. Each thinning algorithm retains the first and last two points of each segment of the trajectory and will not be repeated here. The details are as follows:
[0116] Douglas thinning: Douglas-Peucker thinning is performed on each trajectory segment.
[0117] Time thinning: You can configure the final expected number of thinning result points, and calculate the number of thinning result points for each segment of the trajectory based on the number of points before thinning. When thinning a single segment of the trajectory, thinning is performed only when the number of points before thinning is greater than the expected number of result points. The time thinning threshold is calculated based on the trajectory time period and the expected number of thinning result points. The trajectory segments are traversed. If the time interval between two points exceeds the threshold, the latter point is removed. The time thinning threshold is corrected after each point is processed.
[0118] Distance thinning: You can configure the final expected thinning result quantity, and calculate the thinning result point quantity of each track segment based on the thinning point quantity before each track segment. When thinning a single track segment, thinning is performed only when the thinning point quantity before thinning is greater than the expected result point quantity. The distance thinning threshold is calculated based on the total track range and the expected thinning result point quantity. The track segment is traversed. If the distance between two points exceeds the threshold, the next point is removed. The distance thinning threshold is corrected after each point is processed.
[0119] Business rule customized thinning: Points are divided into three types: speed event points, flying points, and ordinary points. Among them, speed event points are divided into slow speed, suspected stop, and stop points, and each has a corresponding calculation rule; flying points are points that do not match the actual navigation situation of the ship; the rest are ordinary points. The three points are processed in order of priority. If it is a speed event point: according to the speed event retention rules specified in the request parameters, full retention, random extraction, and the first retention of similar speed event points are processed; if it is a flying point, it is processed according to whether the flying point is included in the request parameters. When it is not necessary to include flying points, all flying points are discarded. When it is necessary to include flying points, flying points are regionally thinned, that is, only one flying point is retained in a certain geographical area; if it is an ordinary point, points with a speed of 0 are retained first, specifically using points with a speed of 0 to replace the last reserved point, and other points are calculated with the last reserved point. The distance and track difference values, each map level has different distance thresholds and track difference thresholds, and any one of the two items is greater than the corresponding threshold. The point is retained, otherwise it is extracted.
[0120] like Fig.13 and Fig.14 As shown, cache:
[0121] In this embodiment, the cache is based on memory, and cache cleaning is performed based on two configurations: the maximum cache quantity and the cache expiration time.
[0122] The cache data is divided into original trajectory cache and sparse result cache.
[0123] The keys of both caches are composed of the ship's MMSI (Maritime Mobile Service Identity), start time, end time, and whether to include flight points and other fields MD5 (Message Digest Algorithm MD5).
[0124] The value of the original trajectory cache is composed of different levels of cache of the trajectory corresponding to the key, specifically, a visible range cache for each level from 1 to 18, where level 1 is the full trajectory cache, and the visible range is the maximum longitude and latitude range of the trajectory.
[0125] The value of the thinning result cache consists of the final thinning result of the track corresponding to the key.
[0126] The cache process is as follows: check whether there is an available rarefaction result cache according to the key, and return the result directly if the cache is hit. If it is not hit, check whether there is an available original track cache. If it is not hit, loop to find whether there is an available cache in the previous map layer until the level 1 original track cache is found. Use the available cache to generate the current level original track cache, and then rarefaction the original track and return it. If there is no level 1 original track cache, read the track from the database, and calculate the stop event, flight point mark, maximum range and maximum range for subsequent use.
[0127] Specifically, Fig.14 As shown, the principle of the cache process is as follows: S802: There is a cache. If yes, go to S804, if not, go to S812; S804: Query the sparse trajectory cache; S806: There is a cache under the key map level. If yes, go to S808, if not, go to S820; S808: The key visible range contains the cache visible range. If yes, go to S810, if not, go to S820; S810: Get the cache; S812: Query the database; S814: Calculate events / flying points and other processing; S816: Generate a level 1 original trajectory cache; S818: Generate a level 1 sparse trajectory cache; S820: Query Original trajectory cache; S822: There is a cache under the key map level, if so, enter S824, if not, enter S834; S824: The key visible range contains the cache visible range, if so, enter S826, if not, enter S834; S826: Get the cache; S828: The key map level is equal to the cache map level; S830: Thin out the trajectory; S832: Cache the thinning result; S834: Key map level -1; S836: The map level is equal to 1, if so, enter S838, if not, enter S822; S838: Generate the original trajectory cache of the key map level visible range.
[0128] Concurrency and horizontal expansion support:
[0129] The cache is implemented using thread-safe collections and various locks to support concurrency.
[0130] Use the gateway to send different ship requests to different loads to achieve the same key cache management in the same load, thus supporting horizontal expansion.
[0131] In summary, the beneficial effects of the embodiments of the present application are:
[0132] 1. To cope with large-scale trajectory queries of millions of points or more, the interface performance is extremely high: millisecond-level return.
[0133] 2. The trajectory display of different visible ranges at each level has a good display effect, and the front-end drawing pressure is extremely small.
[0134] 3. The thinning algorithm is rich in implementation and can be chained to achieve a balance between performance and effect.
[0135] 4. The multi-level cache has a high hit rate, which significantly improves performance.
[0136] 5. Support for concurrency and horizontal expansion can easily cope with various usage scenarios.
[0137] In this application, the terms "first", "second", and "third" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance; the term "plurality" refers to two or more, unless otherwise expressly defined. Terms such as "installed", "connected", "connected", and "fixed" should be understood in a broad sense. For example, "connected" can be a fixed connection, a detachable connection, or an integral connection; "connected" can be a direct connection or an indirect connection through an intermediate medium. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to the specific circumstances.
[0138] In the description of the present application, it should be understood that the terms "upper", "lower", "front", "rear", etc., indicating directions or positional relationships, are based on the directions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or module referred to must have a specific direction, be constructed and operated in a specific direction, and therefore, should not be understood as a limitation on the present application.
[0139] In the description of this specification, the description of the terms "one embodiment", "some embodiments", "specific embodiments", 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 representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0140] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A trajectory query method, characterized in that: Used in a geographic information system (50), the geographic information system (50) comprising a front-end device (510) and a back-end device (520), the trajectory query method comprising: Acquire a first trajectory query request through the front-end device; Querying the maximum longitude and latitude range of the trajectory according to the first trajectory query request; Determine a map level and a visible range according to the maximum latitude and longitude range, and send the map level and the visible range to the backend device; The backend device divides the track into a plurality of track segments according to the map level and the visible range, each of the track segments including the first and last points outside the visible range; The back-end device thins the plurality of trajectory segments according to a plurality of thinning algorithms to obtain trajectory thinning results, and sends the trajectory thinning results to the front-end device, wherein the thinning algorithms include one of the following: Douglas thinning, time thinning, distance thinning or business rule customized thinning, and chain calls are supported between the plurality of thinning algorithms; The trajectory thinning result is rendered and displayed through the front-end device.
2. The trajectory query method according to claim 1, characterized in that: Also includes: Acquiring, by the front-end device, a second track query request after a map level change or a visual range change; querying multi-level cache data according to the second trajectory query request, and obtaining a final trajectory thinning result according to the multi-level cache data, wherein the multi-level cache data includes an original trajectory cache and a thinning result cache; The final thinning result of the trajectory is rendered and displayed through the front-end device.
3. The trajectory query method according to claim 2, characterized in that: The querying of multi-level cache data according to the second trajectory query request and obtaining a final trajectory thinning result according to the multi-level cache data includes: Determining whether the second trajectory query request is in the thinning result cache; If the second trajectory query request is in the thinning result cache, a final thinning result is determined according to the thinning result cache.
4. The trajectory query method according to claim 3, characterized in that: The querying of multi-level cache data according to the second trajectory query request, and obtaining a final trajectory thinning result according to the multi-level cache data, further includes: If the second trajectory query request is not in the thinning result cache, determining whether the second trajectory query request is in the original trajectory cache; If the second trajectory query request is in the original trajectory cache, thinning the original trajectory to obtain a final thinning result; If the second trajectory query request is not in the original trajectory cache, a loop is performed to find whether there is an original trajectory cache in the previous map level until the first map level, and the original trajectory is thinned out when there is an original trajectory cache to obtain a final thinning result.
5. The trajectory query method according to claim 4, characterized in that: The querying of multi-level cache data according to the second trajectory query request, and obtaining a final trajectory thinning result according to the multi-level cache data, further includes: When there is no original track cache at the first map level, the track is read from the database, and the stay events, flying point marks, maximum range and maximum range are calculated.
6. The trajectory query method according to any one of claims 1 to 5, characterized in that: The thinning out of the plurality of trajectory segments by the back-end device according to a plurality of thinning algorithms to obtain a trajectory thinning result includes: Thinning the trajectory segments by time thinning to obtain a first thinning result; The thinning points of the first thinning result are thinned according to a preset priority by customized thinning according to business rules to obtain a trajectory thinning result; The thinned points include speed event points, flying points and ordinary points. The speed event points include slow speed, suspected stop and stop points. The flying points include points that are inconsistent with the actual navigation conditions of the ship.
7. The trajectory query method according to claim 6, characterized in that: The thinning out of the thinning points of the first thinning out result according to a preset priority by customizing thinning out through business rules includes: Determining whether a thinning point of the first thinning result is a speed event point; When the thinning point is a speed event point, it is processed according to the speed event retention rule specified in the request parameter, and the processing methods include full retention, random sampling, and retaining the first speed event point of the same type; Determine whether the thinning point is a flying point; When the thinned-out points are flying points, processing is performed according to whether the flying points need to be included as specified in the request parameters, when the flying points do not need to be included, all the flying points are discarded, and when the flying points need to be included, regional thinning is performed on the flying points; Determine whether the thinning point is a common point; When the thinned point is a common point, a common point with a speed of 0 is used to replace the last reserved point, and the distance and track difference between other common points and the last reserved point are calculated. When the distance is greater than the distance threshold and / or the track difference is greater than the track difference threshold, the common point is retained, otherwise the common point is removed.
8. The trajectory query method according to any one of claims 1 to 5, characterized in that: Also includes: Caching through thread-safe collections and distributed locks; and / or Requests from different ships are sent to different loads through the gateway.
9. The trajectory query method according to any one of claims 2 to 5, characterized in that: The keys of the original trajectory cache include one or a combination of the following: ship MMSI, start time, end time and whether to include a flying point; The keys of the rarefaction result cache include one or a combination of the following: ship MMSI, start time, end time and whether to include a flying point; The value of the original track cache includes different levels of cache of the track corresponding to the key, each level has a visible range cache, level 1 is the full track cache, and the visible range is the maximum longitude and latitude range of the track; The value of the thinning result cache includes the final thinning result of the trajectory corresponding to the key.
10. A trajectory query system, characterized in that: include: An acquisition module (110), configured to acquire a first trajectory query request through a front-end device; A range query module (120), configured to query the maximum longitude and latitude range of a trajectory according to the first trajectory query request; A level determination module (130), used to determine a map level and a visible range according to the maximum latitude and longitude range, and send the map level and the visible range to a backend device; A track segmentation module (140), used to segment the track into a plurality of track segments according to the map level and the visible range through the back-end device, each track segment including the first and last points outside the visible range; A thinning module (150) is used to thin the plurality of trajectory segments respectively according to a plurality of thinning algorithms through the back-end device to obtain trajectory thinning results, and send the trajectory thinning results to the front-end device, wherein the thinning algorithm includes one of the following: Douglas thinning, time thinning, distance thinning or business rule customized thinning, and chain calls are supported between the plurality of thinning algorithms; A display module (160) is used to render and display the trajectory thinning result through the front-end device.
11. A trajectory query system, characterized in that: include: A memory (300) and a processor (400), wherein the memory (300) stores a program or instruction that can be run on the processor (400), and when the processor (400) executes the program or the instruction, the steps of the trajectory query method according to any one of claims 1 to 9 are implemented.
12. A readable storage medium having a program or instruction stored thereon, characterized in that: When the program or the instruction is executed by a processor, the steps of the trajectory query method according to any one of claims 1 to 9 are implemented.
Citation Information
Patent Citations
Track data processing method and device, readable storage medium and electronic equipment
CN113806426A
Sea route track construction method and system, ship and ship management system
CN113868362A