Trajectory data processing method and device
By receiving natural language query information during trajectory data processing and converting it into database query statements, and using multi-level indexes and large language models to extract trajectory data in non-relational databases, the query efficiency of trajectory segments and entire trajectories in the existing technology is solved. It solves the problems of low efficiency and poor query convenience, and realizes efficient and convenient trajectory data query.
Patent Information
- Application Number
- CN202311437980.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-31
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2043-10-31
AI Technical Summary
Existing trajectory data processing methods cannot efficiently query trajectory segments or entire trajectories, and cannot simultaneously satisfy multiple query conditions based on time range and/or spatial range. Query convenience is poor and requires operators to be proficient in database query languages.
Provide a trajectory data processing method that receives natural language query information, converts it into database query statements, uses multi-level indexes to extract target trajectory data in a non-relational trajectory storage database, and supports a variety of time ranges and/or spatial ranges. For query conditions, a large language model is used to convert natural language into database query language, reducing the operator's reliance on professional skills.
It improves the efficiency and convenience of trajectory data query, can meet the efficient execution of various common trajectory queries, reduces system operating costs, and enhances the value of trajectory application.
Smart Images

Figure CN117591757B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of trajectory data processing, and in particular to a trajectory data processing method and device. Background Art
[0002] Trajectory data is data with dual attributes of time and space generated by relevant sensor devices (such as mobile phones) during the movement of people, vehicles, and objects in the city. Trajectory data can reveal the movement patterns of people, vehicles, and objects. In recent years, it has been widely used in various fields of smart cities such as smart transportation, smart tourism, and social security. Trajectory data has the significant feature of massiveness. How to store massive trajectories and realize efficient trajectory retrieval is of great value for the analysis and application of trajectory data.
[0003] At present, in the existing trajectory data processing method, in order to improve the query efficiency, some scholars use HBase as the trajectory storage database, and use the row key (RowKey) to use the regional index and time as the database index to solve the problem of the integration of ship trajectory and meteorological data.
[0004] However, although the above trajectory data processing method can meet the needs of fast query of a single trajectory point, it cannot solve the query problem of trajectory segments and the entire trajectory. At the same time, the existing trajectory data processing method cannot simultaneously meet the efficient execution of multiple query conditions based on time range and / or spatial range. In addition, the existing technical solutions usually require operators to master the corresponding database query language, and trajectories have a wide range of applications in various fields of smart cities. Therefore, the existing trajectory data processing method still has the problem of poor query convenience. Summary of the invention
[0005] In view of this, embodiments of the present application provide a trajectory data processing method and apparatus to eliminate or improve one or more defects existing in the prior art.
[0006] One aspect of the present application provides a trajectory data processing method, comprising:
[0007] receiving natural language query information for a non-relational trajectory storage database, and converting the natural language query information into a target query request formed by a database query statement;
[0008] According to the query keyword containing the time range and / or the space range extracted from the target query request, corresponding target trajectory data for a single object or multiple objects are extracted from the non-relational trajectory storage database based on a preset multi-level index.
[0009] In some embodiments of the present application, the non-relational trajectory storage database includes: an HBase database;
[0010] The multi-level index includes: a row key corresponding to the HBase track table in the HBase database and a secondary index table;
[0011] The row key includes: the corresponding relationship between the trajectory generation date, the trajectory segment start time index, the trajectory segment end time index and the spatial range index;
[0012] The HBase trajectory table further includes: an identification column cluster and a detail column cluster; wherein the identification column cluster includes: a unique number of the trajectory and a unique identifier of the object generating the trajectory; the detail column cluster includes: the original trajectory position sequence and the original trajectory time sequence corresponding to the spatial range index and the trajectory segments respectively;
[0013] The secondary index table is used to store the corresponding relationship between the object unique identifier, the spatial range index and the row key.
[0014] In some embodiments of the present application, the original trajectory position sequence is used to store the geographic number corresponding to the longitude and latitude data;
[0015] The original trajectory time series is used to store the difference between each timestamp and the time represented by the trajectory segment start time index.
[0016] In some embodiments of the present application, before receiving natural language query information for the non-relational trajectory storage database, the method further includes:
[0017] Collecting each initial trajectory sample, wherein the initial trajectory sample contains the correspondence between the object unique identifier, the spatial longitude and latitude data and the sampling time;
[0018] Grouping the initial trajectory samples according to different unique identifiers of the object, and sorting the initial trajectory samples in each group according to the sampling time, so as to obtain trajectory data corresponding to each unique identifier of the object;
[0019] Calculate the residence time of each position point in each of the trajectory data, and based on a preset preprocessing rule, delete, retain or segment each of the position points according to the residence time to obtain a plurality of trajectory segments corresponding to the trajectory data, and perform noise filtering on each trajectory segment;
[0020] The trajectory segments corresponding to the trajectory data are stored in the HBase database to construct or update the HBase trajectory table and the secondary index table.
[0021] In some embodiments of the present application, receiving natural language query information for a non-relational trajectory storage database and converting the natural language query information into a target query request formed by a database query statement includes:
[0022] receiving natural language query information for a non-relational trajectory storage database;
[0023] Inputting the natural language query information into a preset database query statement conversion model, so that the database query statement conversion model outputs a database query statement corresponding to the natural language query information as a current target query request;
[0024] The database query statement conversion model is formed by fine-tuning a pre-trained large language model based on a plurality of preset natural language query information and preset database query statements corresponding to each of the preset natural language query information.
[0025] In some embodiments of the present application, if the target query request includes: a key object trajectory query request using an object unique identifier and a time range as keywords;
[0026] Correspondingly, according to the query keyword containing the time range and / or the spatial range extracted from the target query request, the corresponding target trajectory data for a single object or multiple objects is extracted from the non-relational trajectory storage database based on a preset multi-level index, including:
[0027] Determine a first row key range corresponding to the time range in the target query request, and search the HBase trajectory table for a first trajectory data set corresponding to the first row key range;
[0028] According to the object unique identifier in the target query request, obtain the corresponding second row key range in the secondary index table, and search the HBase trajectory table for a second trajectory data set corresponding to the second row key range;
[0029] An intersection of the first trajectory data set and the second trajectory data set is obtained, and trajectory data in the intersection is used as target trajectory data for the target query request.
[0030] In some embodiments of the present application, if the target query request includes: a first key area trajectory query request with a spatial range as a keyword;
[0031] Correspondingly, according to the query keyword containing the time range and / or the spatial range extracted from the target query request, the corresponding target trajectory data for a single object or multiple objects is extracted from the non-relational trajectory storage database based on a preset multi-level index, including:
[0032] Generate a corresponding target spatial range index according to the spatial range in the target query request;
[0033] Searching for a corresponding third row key range from the secondary index table according to the target spatial range index;
[0034] A corresponding third trajectory data set is searched from the HBase table based on the third row key range to serve as target trajectory data for the target query request.
[0035] In some embodiments of the present application, if the target query request includes: a second key area trajectory query request with spatial range and time range as keywords;
[0036] Correspondingly, according to the query keyword containing the time range and / or the spatial range extracted from the target query request, the corresponding target trajectory data for a single object or multiple objects is extracted from the non-relational trajectory storage database based on a preset multi-level index, including:
[0037] Determine a corresponding fourth row key range according to the time range in the target query request, and search the HBase trajectory table for a fourth trajectory data set corresponding to the fourth row key range;
[0038] Generate a corresponding target spatial range index according to the spatial range in the target query request, search for a corresponding fifth row key range from the secondary index table based on the target spatial range index, and search for a fifth trajectory data set corresponding to the fifth row key range from the HBase trajectory table;
[0039] An intersection of the fourth trajectory data set and the fifth trajectory data set is obtained, and trajectory data in the intersection is used as target trajectory data for the target query request.
[0040] In some embodiments of the present application, if the target query request includes: an accompanying trajectory query request with trajectory similarity deviation information, time range and space range as keywords, wherein the trajectory similarity deviation information includes: a unique identifier of the trajectory, a time deviation threshold and a distance deviation threshold;
[0041] Correspondingly, according to the query keyword containing the time range and / or the spatial range extracted from the target query request, the corresponding target trajectory data for a single object or multiple objects is extracted from the non-relational trajectory storage database based on a preset multi-level index, including:
[0042] Determine the query start time, query end time and spatial range corresponding to the target query request according to the unique identifier of the trajectory in the target query request, the time deviation threshold and the distance deviation threshold;
[0043] According to the query start time, query end time and spatial range corresponding to the target query request, the corresponding trajectory data is obtained from the HBase trajectory table to form a trajectory similarity calculation candidate set;
[0044] Based on a preset trajectory similarity algorithm and based on the original trajectory data corresponding to the unique identifier of the trajectory, calculating a similarity result of each trajectory data in the trajectory similarity calculation candidate set compared with the original trajectory data;
[0045] According to the similarity result, one of the trajectory similarity calculation candidate sets is selected as the target trajectory data for the target query request.
[0046] Another aspect of the present application provides a trajectory data processing device, comprising:
[0047] A request conversion module, configured to receive natural language query information for a non-relational trajectory storage database, and convert the natural language query information into a target query request formed by a database query statement;
[0048] The spatiotemporal index query module is used to extract corresponding target trajectory data for a single object or multiple objects from the non-relational trajectory storage database based on a preset multi-level index according to the query keyword containing the time range and / or space range extracted from the target query request.
[0049] A third aspect of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the trajectory data processing method when executing the computer program.
[0050] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the trajectory data processing method when executed by a processor.
[0051] The trajectory data processing method provided by the present application receives natural language query information for a non-relational trajectory storage database, and converts the natural language query information into a target query request formed by a database query statement; according to the query keyword containing a time range and / or a space range extracted from the target query request, the corresponding target trajectory data for a single object or multiple objects are extracted from the non-relational trajectory storage database based on a preset multi-level index, so that trajectory data query for a single object or multiple objects can be realized on the basis of improving the efficiency of trajectory data query, and a plurality of common trajectory queries can be efficiently realized based on a data storage, thereby satisfying the efficient execution of a plurality of query conditions based on the time range and / or the space range. At the same time, the method can support trajectory query based on natural language, which can greatly reduce the dependence of the method on the professional skills of the operator, thereby effectively improving the convenience and reliability of trajectory data query, which is of great significance for improving the application value of trajectory and reducing the operating cost of related systems.
[0052] Additional advantages, purposes, and features of the present application will be partially described in the following description, and will become partially apparent to those skilled in the art after studying the following, or may be learned from the practice of the present application. The purposes and other advantages of the present application can be achieved and obtained by the structures specifically pointed out in the specification and the drawings.
[0053] Those skilled in the art will understand that the purposes and advantages that can be achieved by the present application are not limited to the above specific description, and the above and other purposes that can be achieved by the present application will be more clearly understood based on the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] The drawings described herein are used to provide a further understanding of the present application, constitute a part of the present application, and do not constitute a limitation of the present application. The components in the drawings are not drawn to scale, but are only for the purpose of illustrating the principles of the present application. In order to facilitate the illustration and description of some parts of the present application, the corresponding parts in the drawings may be enlarged, that is, they may become larger relative to other components in the exemplary device actually manufactured according to the present application. In the drawings:
[0055] Figure 1 Schematic diagram of a first flow chart of a trajectory data processing method in an embodiment of the present application.
[0056] Figure 2 Schematic diagram of a second flow chart of a trajectory data processing method in an embodiment of the present application.
[0057] Figure 3 This is a schematic diagram of the execution logic of the trajectory data processing process in an example of the present application.
[0058] Figure 4 Schematic diagram of a first structure of a trajectory data processing device in an embodiment of the present application.
[0059] Figure 5 Schematic diagram of the second structure of the trajectory data processing device in one embodiment of the present application. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the implementation modes and the accompanying drawings. Here, the illustrative implementation modes and descriptions of the present application are used to explain the present application, but are not intended to limit the present application.
[0061] It should also be noted here that in order to avoid obscuring the present application due to unnecessary details, only the structures and / or processing steps closely related to the scheme according to the present application are shown in the accompanying drawings, while other details that are not very relevant to the present application are omitted.
[0062] It should be emphasized that the term “include / comprises” when used herein refers to the presence of features, elements, steps or components, but does not exclude the presence or addition of one or more other features, elements, steps or components.
[0063] It should also be noted that, unless otherwise specified, the term “connection” herein may refer not only to a direct connection but also to an indirect connection involving an intermediate.
[0064] Hereinafter, embodiments of the present application will be described with reference to the accompanying drawings. In the accompanying drawings, the same reference numerals represent the same or similar components, or the same or similar steps.
[0065] Traditional relational databases, such as MySQL Spatial and PostGIS, create indexes for spatial data based on technologies such as R-tree and KD-tree, and support the storage and operation of spatial data types. However, it is difficult to solve the scalability problem of storing massive trajectory data. Therefore, some researchers use the distributed framework Hadoop to store and analyze trajectory data to solve the scalability problem of massive data, such as SpatialHadoop. However, this type of solution requires frequent access to the disk, and the data read and write efficiency is low. In recent years, storing trajectory data based on NoSQL databases has become a mainstream solution. For example, GeoMesa converts multi-dimensional trajectory data into one-dimensional key values for efficient query by spatially filling counties. However, when the time range of the data to be queried is large and the spatial range is small, the existing solution still needs to scan a large number of key values, and the query efficiency is low.
[0066] Therefore, in order to improve query efficiency, some scholars use HBase as the trajectory storage database, and use the row key (RowKey) as the regional index and time as the database index to solve the problem of integrating ship trajectories and meteorological data. However, although the trajectory data processing method can meet the fast query requirements of a single trajectory point, it cannot solve the query problem of trajectory segments and the entire trajectory. At the same time, the existing trajectory data processing method cannot simultaneously meet the efficient execution of multiple query conditions based on time range and / or spatial range. In addition, the existing technical solutions usually require operators to be proficient in the corresponding database query language, and trajectories are widely used in various fields of smart cities. Therefore, the existing trajectory data processing method still has the problem of poor query convenience.
[0067] Based on this, in order to solve the problem that it is impossible to simultaneously ensure efficient query of trajectory data and to realize query of trajectory segments and entire trajectories, and the existing trajectory data processing method cannot simultaneously meet the efficient execution of multiple query conditions based on time range and / or space range, and the query convenience is poor, the embodiments of the present application respectively provide a trajectory data processing method, a trajectory data processing device for executing the trajectory data processing method, an electronic device and a computer-readable storage medium, which can realize trajectory data query for a single or multiple objects on the basis of improving the efficiency of trajectory data query, and can meet the efficient execution of multiple query conditions based on time range and / or space range, and can effectively improve the convenience and reliability of trajectory data query.
[0068] The details are described in detail through the following examples.
[0069] Based on this, the present application embodiment provides a trajectory data processing method that can be implemented by a trajectory data processing device, see Figure 1 , the trajectory data processing method specifically includes the following contents:
[0070] Step 100: receiving natural language query information for a non-relational trajectory storage database, and converting the natural language query information into a target query request formed by a database query statement.
[0071] Specifically, the target query request is used to query the trajectory data of a corresponding single or multiple objects from the dimensions of time and / or space.
[0072] In one or more embodiments of the present application, the target query request may include at least the following four types:
[0073] (1) A key object trajectory query request using the object unique identifier and time range as keywords;
[0074] The key object trajectory query request is applicable to the trajectory query of key devices / people: the trajectory data is queried based on the device / user ID and time interval;
[0075] (2) a first key area trajectory query request using the spatial range as a keyword;
[0076] Wherein, the first key area trajectory query request is applicable to key area trajectory query: querying trajectory data based on spatial range;
[0077] (3) a second key area trajectory query request using spatial range and time range as keywords;
[0078] Wherein, the second key area trajectory query request is also applicable to key area trajectory query: querying trajectory data based on spatial and temporal ranges;
[0079] (4) Accompanying trajectory query request with trajectory similarity deviation information, time range and spatial range as keywords.
[0080] The accompanying trajectory query request is suitable for accompanying trajectory query: querying trajectory data based on trajectory similarity.
[0081] However, the existing trajectory data processing method cannot simultaneously meet the efficient execution of the above four query conditions. Therefore, the embodiment of the present application solves this problem by setting the following step 200.
[0082] Step 200: according to the query keyword containing the time range and / or space range extracted from the target query request, corresponding target trajectory data for a single object or multiple objects are extracted from the non-relational trajectory storage database based on a preset multi-level index.
[0083] In one or more embodiments of the present application, the object refers to an object that has generated or is still generating trajectory data during movement. The object may refer to a person, a vehicle, an object, etc., and may be set according to actual needs.
[0084] From the above description, it can be seen that the trajectory data processing method provided in the embodiment of the present application can realize trajectory data query for a single or multiple objects on the basis of improving the efficiency of trajectory data query, and can meet the efficient implementation of multiple common trajectory queries based on a data storage, thereby meeting the efficient execution of multiple query conditions based on time range and / or space range. At the same time, the method can support trajectory query based on natural language, which can greatly reduce the dependence of the method on the professional skills of the operator, thereby effectively improving the convenience and reliability of trajectory data query, which is of great significance for improving the application value of trajectory and reducing the operating costs of related systems.
[0085] In order to further improve the efficiency, effectiveness and reliability of trajectory data query and storage, in a trajectory data processing method provided in an embodiment of the present application, the non-relational trajectory storage database in the trajectory data processing method can specifically adopt an HBase database; the multi-level index includes: the row key corresponding to the HBase trajectory table in the HBase database and the secondary index table. In a specific implementation, the NoSQL database HBase can be selected for trajectory storage, and ElasticSearch can be selected for secondary index storage.
[0086] First, the row key includes: the correspondence between the trajectory generation date, the trajectory segment start time index, the trajectory segment end time index and the spatial range index.
[0087] Specifically, HBase row key design: To support flexible and efficient trajectory query requirements, the present invention designs the row key of the trajectory storage table as:
[0088] "Date::StartTimeBin::EndTimeBin::XZ2(lat_min,lng_min,lat_max,lng_max)"
[0089] Among them, "::" indicates the splicing operation, "Date" indicates the date when the trajectory is generated, such as 20230919, "XZ2" is the spatial two-dimensional index in the open source engine GeoMesa, and XZ2 (lat_min, lng_min, lat_max, lng_max) can also be written as a spatial range index. "StartTimeBin" and "EndTimeBin" represent the start time index and end time index of the trajectory segment respectively; "lat" refers to the spatial latitude of the trajectory, "lat_min" and "lat_max" are the minimum and maximum spatial latitude of the trajectory respectively; "lng" refers to the spatial longitude of the trajectory, and "lng_min" and "lng_max" are the minimum and maximum spatial longitude of the trajectory respectively.
[0090] In one example, taking 1 minute as a time bin, we have:
[0091] "StartTimeBin = time.localtime(StartTimestamp).tm_min" and
[0092] "EndTimeBin=time.localtime(EndTimestamp).tm_min";
[0093] Where "time.localtime" is the time processing function in Python, "StartTimestamp" represents the start timestamp of the trajectory segment, and "EndTimestamp" represents the end timestamp of the trajectory segment.
[0094] Secondly, the HBase trajectory table also includes: an identification column cluster and a detail column cluster; wherein the identification column cluster includes: a unique number of the trajectory and a unique identifier of the object generating the trajectory; the detail column cluster includes: the original trajectory position sequence and the original trajectory time sequence corresponding to the spatial range index and the trajectory segments respectively.
[0095] Specifically, the identity column cluster can be written as the id column cluster, and the detail column cluster can be written as the detail column cluster.
[0096] The id column cluster contains: the trajectory number "id:tid" which is the unique number of the trajectory and the moving target number "id:oid" which is the unique identifier of the object that generates the trajectory; the detail column cluster contains: the spatial range index of the trajectory "detail:XZ2(lat_min,lng_min,lat_max,lng_max)", the original trajectory position sequence "detail:traj_s" and the original trajectory time series "detail:traj_t".
[0097] Thirdly, the secondary index table is used to store the correspondence between the object unique identifier, the spatial range index and the row key.
[0098] Specifically, in order to support more flexible trajectory query, this application further designs a secondary index table of trajectories, which contains three fields:
[0099] The object unique identifier "oid", the spatial range index "XZ2(lat_min,lng_min,lat_max,lng_max)" and the row key (RowKey).
[0100] In a specific example, the secondary index table can be stored in Elasticsearch, and the row key (RowKey) of the corresponding trajectory data can be quickly obtained according to "oid" and "XZ2 (lat_min, lng_min, lat_max, lng_max)", and then other trajectory data can be quickly obtained from the HBase trajectory table based on the row key (RowKey).
[0101] In order to further improve the efficiency of trajectory data query and storage, in a trajectory data processing method provided in an embodiment of the present application, the original trajectory position sequence in the trajectory data processing method is used to store the geographic number corresponding to the longitude and latitude data; the original trajectory time sequence is used to store the difference between each timestamp and the time represented by the start time index of the trajectory segment.
[0102] Specifically, in order to reduce the storage space requirement of the trajectory, the original trajectory position sequence "detail:traj_s" does not store the original longitude and latitude data, but stores its corresponding geographic code, such as Geohash code, Google S2 code. In this embodiment, a 10-bit Geohash code is selected, which can greatly reduce the space storage overhead of the trajectory compared to the original 2 double-precision data storage.
[0103] The original trajectory time series "detail:traj_t" stores the difference between each timestamp and the time represented by "StartTimeBin". For example, "StartTimeBin" is 100, which means 1:40 on the same day. The first timestamp in the trajectory sequence represents 1:40:30 on the same day, so only the difference of 30 seconds is stored, which greatly reduces the time storage overhead.
[0104] In order to further improve the efficiency, reliability and effectiveness of trajectory data query and storage, in a trajectory data processing method provided in an embodiment of the present application, see Figure 2 and Figure 3 The trajectory query in step 100 of the trajectory data processing method also specifically includes trajectory preprocessing, trajectory storage, and trajectory index construction, which specifically include the following contents:
[0105] Step 010: Collect each initial trajectory sample, wherein the initial trajectory sample contains the correspondence between the object unique identifier, spatial longitude and latitude data and sampling time.
[0106] Specifically, based on the open source Seatunnel data synchronization engine, trajectory data from sources such as Kafka, Hive, FTP, and Clickhouse can be accessed. Each piece of data includes: the object unique identifier "oid", the correspondence between the spatial longitude and latitude data "lat" and "lng" and the sampling time "t" of the trajectory point.
[0107] Step 020: Grouping the initial trajectory samples according to different object unique identifiers, and sorting the initial trajectory samples in each group according to the sampling time to obtain trajectory data corresponding to each object unique identifier.
[0108] Step 030: Calculate the residence time of each position point in each of the trajectory data, and based on a preset preprocessing rule, delete, retain or segment each of the position points according to the residence time to obtain multiple trajectory segments corresponding to the trajectory data, and perform noise filtering on each trajectory segment.
[0109] Step 040: Store each of the trajectory segments corresponding to each of the trajectory data into the HBase database to construct or update the HBase trajectory table and the secondary index table.
[0110] Specifically, the accessed trajectory data are grouped according to "oid", and within each group, they are sorted according to the trajectory point sampling time t to obtain a complete trajectory T;
[0111] Calculate the dwell time s of trajectory T at each position, where s = t next -t prev ;
[0112] t prev Indicates the time of trajectory T at the current position; t next Indicates the time when the trajectory T is at the next position point;
[0113] Keep the starting and ending points of trajectory T, and detect each intermediate point accordingly. If the residence time s of a point is less than Δ t , and the position distance between this point and its neighboring trajectory points does not exceed Δ d , it is considered that the valuable information contained in the trajectory point is small and can be deleted, thereby reducing the storage overhead of the trajectory and obtaining a simplified trajectory T′. In an example, the threshold Δ t and Δ d You can take 60 seconds and 3 kilometers respectively;
[0114] If the target stays at a certain point for a time s>Δ′ t , then the trajectory is segmented with the position point as the dividing point to obtain several trajectory segments with stronger continuity. In one example, the threshold Δ′ t The value is taken for 30 minutes;
[0115] For each trajectory segment, the trajectory noise is filtered out based on the trajectory noise reduction algorithm. In this embodiment, the trajectory noise is filtered out based on the speed anomaly method. First, the moving speed v of the target at each trajectory point is calculated:
[0116] v = Dist(lat next ,lng next ,lat prev ,lng prev ) / (t next -tprev ), Dist represents the general spherical distance calculation formula; lat prev Indicates the spatial latitude of the current location; lat next Indicates the spatial latitude of the next location point; lng prev Indicates the spatial longitude of the current location; lng next Indicates the spatial longitude of the next location point.
[0117] If v>Δ v , then the second trajectory point is considered to be a noise point and needs to be filtered out.
[0118] In order to further improve the efficiency and convenience of trajectory data query, in a trajectory data processing method provided in an embodiment of the present application, see Figure 2 , step 100 in the trajectory data processing method specifically includes the following contents:
[0119] Step 110: Receive natural language query information for a non-relational trajectory storage database.
[0120] Step 120: Input the natural language query information into a preset database query statement conversion model, so that the database query statement conversion model outputs a database query statement corresponding to the natural language query information as the current target query request; wherein the database query statement conversion model is formed after fine-tuning a pre-trained large language model based on multiple preset natural language query information and preset database query statements corresponding to each of the preset natural language query information.
[0121] Specifically, a natural language query and a corresponding SQL statement data set are pre-constructed, and fine-tuning training is performed based on an open source pre-trained large language model to form a fine-tuned pre-trained large language model. The fine-tuned pre-trained large language model can be referred to as a database query statement conversion model in an embodiment of the present application, which is used to realize the conversion from natural language to database query language. In one example, an open source pre-trained model Falcon-7b can be selected and further fine-tuned in combination with the LoRA method, and the dropout of LoRa can be set to 0.05.
[0122] In social security applications, the following trajectory query requirements usually need to be addressed: (1) trajectory query of key devices / people: query trajectory data based on device / user ID and time interval; (2) trajectory query of key areas: query trajectory data based on spatial range, or spatial and temporal range; (3) accompanying trajectory query: query trajectory data based on trajectory similarity. However, existing methods cannot simultaneously meet the efficient execution of the above four query conditions.
[0123] Based on this, in order to achieve efficient query of the trajectory of key equipment / person, in a trajectory data processing method provided in an embodiment of the present application, see Figure 2 , step 200 in the trajectory data processing method specifically includes the following contents:
[0124] Step 210: If the target query request includes: a key object trajectory query request with an object unique identifier and a time range as keywords, determine the corresponding first row key range according to the time range in the target query request, and search the HBase trajectory table for a first trajectory data set corresponding to the first row key range; obtain the corresponding second row key range in the secondary index table according to the object unique identifier in the target query request, and search the HBase trajectory table for a second trajectory data set corresponding to the second row key range; take the intersection of the first trajectory data set and the second trajectory data set, and use the trajectory data in the intersection as the target trajectory data for the target query request.
[0125] The first trajectory data set may be written as S1, and the second trajectory data set may be written as S2.
[0126] Specifically, the first row key range can be determined according to the time range, and then the scan query interface of HBase can be called to determine the first trajectory data set S1 that needs to be queried in the HBase trajectory table according to the first row key range. Then, the second row key (RowKey) range that needs to be queried is obtained from the secondary index table in ElasticSearch according to "oid", and the get query interface of HBase is called to find the second trajectory data set S2 corresponding to the second row key range from the HBase trajectory table, and the intersection of S1 and S2 is taken as the final trajectory data result that needs to be queried.
[0127] Step 220: If the target query request includes: a first key area trajectory query request with a spatial range as a keyword, a corresponding target spatial range index is generated according to the spatial range in the target query request; a corresponding third row key range is searched from the secondary index table according to the target spatial range index; and a corresponding third trajectory data set is searched from the HBase table based on the third row key range as the target trajectory data for the target query request.
[0128] The third trajectory data set may be written as S3.
[0129] Specifically, the target spatial region index can be constructed based on the input spatial range:
[0130] "XZ2(lat_min,lng_min,lat_max,lng_max)",
[0131] The third row key (RowKey) range to be queried is obtained from the secondary index table in ElasticSearch, and then the get query interface of HBase is called to search the third trajectory data set S3 corresponding to the third row key range from the HBase trajectory table.
[0132] Step 230: If the target query request includes: a second key area trajectory query request with a spatial range and a time range as keywords, then determine the corresponding fourth row key range according to the time range in the target query request, and search for a fourth trajectory data set corresponding to the fourth row key range from the HBase trajectory table; generate a corresponding target spatial range index according to the spatial range in the target query request, search for a corresponding fifth row key range from the secondary index table based on the target spatial range index, and search for a fifth trajectory data set corresponding to the fifth row key range from the HBase trajectory table; take the intersection of the fourth trajectory data set and the fifth trajectory data set, and use the trajectory data in the intersection as the target trajectory data for the target query request.
[0133] The fourth trajectory data set may be written as S4, and the fifth trajectory data set may be written as S5.
[0134] Specifically, the corresponding fourth row key range can be determined according to the time range, and the scan query interface of HBase can be called to determine the fourth trajectory data set S4 that needs to be queried initially from the HBase trajectory table according to the fourth row key range, and then the target spatial range index is constructed based on the input spatial range:
[0135] "XZ2(lat_min,lng_min,lat_max,lng_max)",
[0136] The query obtains the fifth row key (RowKey) range to be queried from the binary index table in ElasticSearch, and calls the HBase get query interface to find the fifth trajectory data set S5 corresponding to the fifth row key range from the HBase trajectory table, and takes the intersection of S4 and S5 as the final trajectory data result to be queried.
[0137] In addition, some scholars in the prior art have proposed a trajectory similarity query method based on device number and spatial grid index. This method needs to calculate the upper bound of the similarity between all trajectories and the trajectory to be queried before pruning. When the trajectory data scale is large, it still has a high computational complexity and cannot efficiently meet the query requirements of the trajectory of a certain device within a certain period of time. Based on this, in order to solve this technical problem, step 200 of the present application also specifically includes the following content:
[0138] Step 240: If the target query request includes: an accompanying trajectory query request with trajectory similarity deviation information, a time range and a spatial range as keywords, wherein the trajectory similarity deviation information includes: a unique identifier of the trajectory, a time deviation threshold and a distance deviation threshold, then according to the unique identifier of the trajectory in the target query request, the time deviation threshold and the distance deviation threshold, determine the query start time, query end time and spatial range corresponding to the target query request; according to the query start time, query end time and spatial range corresponding to the target query request, obtain corresponding trajectory data from the HBase trajectory table to form a trajectory similarity calculation candidate set; based on a preset trajectory similarity algorithm, based on the original trajectory data corresponding to the unique identifier of the trajectory, calculate the similarity result of each trajectory data in the trajectory similarity calculation candidate set compared with the original trajectory data; according to the similarity result, select one in the trajectory similarity calculation candidate set as the target trajectory data for the target query request.
[0139] Specifically, firstly, the start and end time of the query, as well as the spatial range, are determined according to the input trajectory, the time deviation threshold ∈, and the distance deviation threshold δ.
[0140] Query time range: [StartTimeBin-∈, EndTimeBin+∈];
[0141] The spatial index range of the query: XZ2(lat min -δ,lng min -δ,lat max +δ,lng max +δ);
[0142] The scanning range of the row key is set accordingly, and the corresponding trajectory data is obtained as a candidate set for trajectory similarity calculation. Then, according to the trajectory similarity calculation method, the trajectory similarity is calculated based on the original trajectory data, and the most similar trajectory is returned as the query result.
[0143] Among them, the optional trajectory similarity calculation methods include traditional DTW, similarity calculation based on deep trajectory representation learning, etc. In this embodiment, the DTW algorithm is selected.
[0144] That is to say, the trajectory data processing method provided in the embodiment of the present application realizes natural language-based trajectory query based on a large language model, which can effectively reduce the technical requirements of trajectory query applications on operators; and creates a new spatiotemporal indexing method to effectively improve the efficiency of multi-dimensional trajectory retrieval.
[0145] Specifically, based on the large language model, natural language-based trajectory queries are supported. This application is based on the NoSQL database to create a new spatiotemporal indexing solution, which can meet the efficient implementation of the above four types of common trajectory queries based on a single data storage. In addition, the existing methods can only provide services for people with certain database operation skills, and this application can support natural language-based trajectory queries by introducing large language model-related technologies, greatly reducing the method's dependence on the professional skills of operators.
[0146] From the software level, the present application also provides a trajectory data processing device for executing all or part of the trajectory data processing method, see Figure 4 , the trajectory data processing device specifically includes the following contents:
[0147] A request conversion module 10, configured to receive natural language query information for a non-relational trajectory storage database, and convert the natural language query information into a target query request formed by a database query statement;
[0148] The spatiotemporal index query module 20 is used to extract corresponding target trajectory data for a single object or multiple objects from the non-relational trajectory storage database based on a preset multi-level index according to the query keyword containing the time range and / or space range extracted from the target query request.
[0149] The embodiment of the trajectory data processing device provided in the present application can be specifically used to execute the processing flow of the embodiment of the trajectory data processing method in the above embodiment. Its functions are not described in detail here, and reference can be made to the detailed description of the embodiment of the trajectory data processing method.
[0150] The part of the trajectory data processing device that processes the trajectory data can be executed in the server or in the client device. The specific selection can be made based on the processing capability of the client device and the limitations of the user's usage scenario. This application does not limit this. If all operations are completed in the client device, the client device may also include a processor for specific processing of the trajectory data processing.
[0151] The client device may have a communication module (i.e., a communication unit) that can communicate with a remote server to achieve data transmission with the server. The server may include a server on the task scheduling center side, and other implementation scenarios may also include a server on an intermediate platform, such as a server on a third-party server platform that has a communication link with the task scheduling center server. The server may include a single computer device, or a server cluster consisting of multiple servers, or a server structure of a distributed device.
[0152] The server and the client device may communicate with each other using any suitable network protocol, including network protocols that have not yet been developed on the date of filing this application. The network protocols may include, for example, TCP / IP, UDP / IP, HTTP, HTTPS, etc. Of course, the network protocols may also include, for example, RPC (Remote Procedure Call Protocol) and REST (Representational State Transfer) protocols used on top of the above protocols.
[0153] From the above description, it can be seen that the trajectory data processing device provided in the embodiment of the present application can realize trajectory data query for a single or multiple objects on the basis of improving the efficiency of trajectory data query, and can meet the efficient implementation of multiple common trajectory queries based on a data storage, thereby meeting the efficient execution of multiple query conditions based on time range and / or space range. At the same time, the method can support trajectory query based on natural language, which can greatly reduce the dependence of the method on the professional skills of the operator, thereby effectively improving the convenience and reliability of trajectory data query, which is of great significance for improving the application value of trajectory and reducing the operating costs of related systems.
[0154] In a specific application example of the above trajectory data processing device, see Figure 5 , the request conversion module 10 and the spatiotemporal index query module 20 can together form a trajectory query module 4. On this basis, the trajectory data processing device can also include a trajectory data access module 1, a trajectory preprocessing module 2 and a trajectory storage and indexing module 3;
[0155] The trajectory data access module 1 is used to execute step 010, build a data connector based on a distributed, massive data integration framework, and access real-time or offline massive trajectory data.
[0156] The trajectory preprocessing module 2 is used to execute steps 020 and 030, and performs data preprocessing on massive trajectories based on a real-time, offline data processing engine, filters trajectory noise, identifies trajectory residence points, and performs trajectory segmentation.
[0157] The trajectory storage and indexing module 3 is used to execute step 040, storing the original trajectory data and its feature data based on the NoSQL database, creating a new spatiotemporal indexing scheme to achieve efficient trajectory retrieval, and realizing natural language-based trajectory query based on the large language model.
[0158] The trajectory query module 4 is used to execute step 100 and step 200 to realize trajectory query based on user ID and time, trajectory query based on spatial range, trajectory query based on spatiotemporal range, and trajectory query based on similarity.
[0159] The embodiment of the present application further provides an electronic device, which may include a processor, a memory, a receiver and a transmitter, wherein the processor is used to execute the trajectory data processing method mentioned in the above embodiment, wherein the processor and the memory may be connected via a bus or other means, such as by bus connection. The receiver may be connected to the processor and the memory via wired or wireless means.
[0160] The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.
[0161] As a non-transitory computer-readable storage medium, the memory can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as program instructions / modules corresponding to the trajectory data processing method in the embodiment of the present application. The processor executes various functional applications and data processing of the processor by running the non-transitory software programs, instructions and modules stored in the memory, that is, the trajectory data processing method in the above method embodiment is implemented.
[0162] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0163] The one or more modules are stored in the memory, and when executed by the processor, the trajectory data processing method in the embodiment is executed.
[0164] In some embodiments of the present application, the user equipment may include a processor, a memory, and a transceiver unit, which may include a receiver and a transmitter. The processor, memory, receiver, and transmitter may be connected through a bus system. The memory is used to store computer instructions, and the processor is used to execute the computer instructions stored in the memory to control the transceiver unit to send and receive signals.
[0165] As an implementation method, the functions of the receiver and the transmitter in the present application can be considered to be implemented through a transceiver circuit or a dedicated chip for transceiver, and the processor can be considered to be implemented through a dedicated processing chip, a processing circuit or a general chip.
[0166] As another implementation method, it is possible to use a general-purpose computer to implement the server provided in the embodiment of the present application, that is, to store the program code for implementing the functions of the processor, receiver, and transmitter in a memory, and the general-purpose processor implements the functions of the processor, receiver, and transmitter by executing the code in the memory.
[0167] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the aforementioned trajectory data processing method are implemented. The computer-readable storage medium can be a tangible storage medium, such as a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a floppy disk, a hard disk, a removable storage disk, a CD-ROM, or any other form of storage medium known in the technical field.
[0168] It should be understood by those skilled in the art that the exemplary components, systems and methods described in conjunction with the embodiments disclosed herein can be implemented in hardware, software or a combination of the two. Whether it is specifically performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link via a data signal carried in a carrier.
[0169] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0170] In the present application, features described and / or illustrated for one embodiment may be used in the same manner or in a similar manner in one or more other embodiments, and / or combined with features of other embodiments or replace features of other embodiments.
[0171] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the embodiments of 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 data processing method, characterized in that: include: receiving natural language query information for a non-relational trajectory storage database, and converting the natural language query information into a target query request formed by a database query statement; According to the query keyword containing the time range and / or the space range extracted from the target query request, corresponding target trajectory data for a single object or multiple objects are extracted from the non-relational trajectory storage database based on a preset multi-level index; The non-relational trajectory storage database includes: an HBase database; The multi-level index includes: a row key corresponding to the HBase track table in the HBase database and a secondary index table; The row key includes: the corresponding relationship between the trajectory generation date, the trajectory segment start time index, the trajectory segment end time index and the spatial range index; The HBase trajectory table further includes: an identification column cluster and a detail column cluster; wherein the identification column cluster includes: a unique number of the trajectory and a unique identifier of the object generating the trajectory; the detail column cluster includes: the original trajectory position sequence and the original trajectory time sequence corresponding to the spatial range index and the trajectory segments respectively; The secondary index table is used to store the correspondence between the object unique identifier, the spatial range index and the row key; If the target query request includes: a first key area trajectory query request with spatial range as a keyword; Correspondingly, according to the query keyword containing the time range and / or the spatial range extracted from the target query request, the corresponding target trajectory data for a single object or multiple objects is extracted from the non-relational trajectory storage database based on a preset multi-level index, including: Generate a corresponding target spatial range index according to the spatial range in the target query request; Searching for a corresponding third row key range from the secondary index table according to the target spatial range index; Based on the third row key range, searching the HBase trajectory table for a corresponding third trajectory data set as target trajectory data for the target query request; If the target query request includes: an accompanying trajectory query request with trajectory similarity deviation information, time range and space range as keywords, wherein the trajectory similarity deviation information includes: a unique identifier of the trajectory, a time deviation threshold and a distance deviation threshold; Correspondingly, according to the query keyword containing the time range and / or the spatial range extracted from the target query request, the corresponding target trajectory data for a single object or multiple objects is extracted from the non-relational trajectory storage database based on a preset multi-level index, including: Determine the query start time, query end time and spatial range corresponding to the target query request according to the unique identifier of the trajectory in the target query request, the time deviation threshold and the distance deviation threshold; According to the query start time, query end time and spatial range corresponding to the target query request, the corresponding trajectory data is obtained from the HBase trajectory table to form a trajectory similarity calculation candidate set; Based on a preset trajectory similarity algorithm and based on the original trajectory data corresponding to the unique identifier of the trajectory, calculating a similarity result of each trajectory data in the trajectory similarity calculation candidate set compared with the original trajectory data; According to the similarity result, one of the trajectory similarity calculation candidate sets is selected as the target trajectory data for the target query request.
2. The trajectory data processing method according to claim 1, characterized in that: The original trajectory position sequence is used to store the geographic number corresponding to the longitude and latitude data; The original trajectory time series is used to store the difference between each timestamp and the time represented by the trajectory segment start time index.
3. The trajectory data processing method according to claim 1, characterized in that: Before receiving the natural language query information for the non-relational trajectory storage database, the method further includes: Collecting each initial trajectory sample, wherein the initial trajectory sample contains the correspondence between the object unique identifier, the spatial longitude and latitude data and the sampling time; Grouping the initial trajectory samples according to different unique identifiers of the object, and sorting the initial trajectory samples in each group according to the sampling time, so as to obtain trajectory data corresponding to each unique identifier of the object; Calculate the residence time of each position point in each of the trajectory data, and based on a preset preprocessing rule, delete, retain or segment each of the position points according to the residence time to obtain a plurality of trajectory segments corresponding to the trajectory data, and perform noise filtering on each trajectory segment; The trajectory segments corresponding to the trajectory data are stored in the HBase database to construct or update the HBase trajectory table and the secondary index table.
4. The trajectory data processing method according to claim 1, characterized in that: The receiving of natural language query information for a non-relational trajectory storage database and converting the natural language query information into a target query request formed by a database query statement includes: receiving natural language query information for a non-relational trajectory storage database; Inputting the natural language query information into a preset database query statement conversion model, so that the database query statement conversion model outputs a database query statement corresponding to the natural language query information as a current target query request; The database query statement conversion model is formed by fine-tuning a pre-trained large language model based on a plurality of preset natural language query information and preset database query statements corresponding to each of the preset natural language query information.
5. The trajectory data processing method according to claim 1, characterized in that: If the target query request includes: a key object trajectory query request using the object unique identifier and time range as keywords; Correspondingly, according to the query keyword containing the time range and / or the spatial range extracted from the target query request, the corresponding target trajectory data for a single object or multiple objects is extracted from the non-relational trajectory storage database based on a preset multi-level index, including: Determine a first row key range corresponding to the time range in the target query request, and search the HBase trajectory table for a first trajectory data set corresponding to the first row key range; According to the object unique identifier in the target query request, obtain the corresponding second row key range in the secondary index table, and search the HBase trajectory table for a second trajectory data set corresponding to the second row key range; An intersection of the first trajectory data set and the second trajectory data set is obtained, and trajectory data in the intersection is used as target trajectory data for the target query request.
6. The trajectory data processing method according to claim 1, characterized in that: If the target query request includes: a second key area trajectory query request with spatial range and time range as keywords; Correspondingly, according to the query keyword containing the time range and / or the spatial range extracted from the target query request, the corresponding target trajectory data for a single object or multiple objects is extracted from the non-relational trajectory storage database based on a preset multi-level index, including: Determine a corresponding fourth row key range according to the time range in the target query request, and search the HBase trajectory table for a fourth trajectory data set corresponding to the fourth row key range; Generate a corresponding target spatial range index according to the spatial range in the target query request, search for a corresponding fifth row key range from the secondary index table based on the target spatial range index, and search for a fifth trajectory data set corresponding to the fifth row key range from the HBase trajectory table; An intersection of the fourth trajectory data set and the fifth trajectory data set is obtained, and trajectory data in the intersection is used as target trajectory data for the target query request.
7. A trajectory data processing device, characterized in that: include: A request conversion module, configured to receive natural language query information for a non-relational trajectory storage database, and convert the natural language query information into a target query request formed by a database query statement; A spatiotemporal index query module, configured to extract corresponding target trajectory data for a single object or multiple objects from the non-relational trajectory storage database based on a preset multi-level index according to a query keyword containing a time range and / or a spatial range extracted from the target query request; The non-relational trajectory storage database includes: an HBase database; The multi-level index includes: a row key corresponding to the HBase track table in the HBase database and a secondary index table; The row key includes: the corresponding relationship between the trajectory generation date, the trajectory segment start time index, the trajectory segment end time index and the spatial range index; The HBase trajectory table further includes: an identification column cluster and a detail column cluster; wherein the identification column cluster includes: a unique number of the trajectory and a unique identifier of the object generating the trajectory; the detail column cluster includes: the original trajectory position sequence and the original trajectory time sequence corresponding to the spatial range index and the trajectory segments respectively; The secondary index table is used to store the correspondence between the object unique identifier, the spatial range index and the row key; If the target query request includes: a first key area trajectory query request with spatial range as a keyword; Correspondingly, according to the query keyword containing the time range and / or the spatial range extracted from the target query request, the corresponding target trajectory data for a single object or multiple objects is extracted from the non-relational trajectory storage database based on a preset multi-level index, including: Generate a corresponding target spatial range index according to the spatial range in the target query request; Searching for a corresponding third row key range from the secondary index table according to the target spatial range index; Based on the third row key range, searching the HBase trajectory table for a corresponding third trajectory data set as target trajectory data for the target query request; If the target query request includes: an accompanying trajectory query request with trajectory similarity deviation information, time range and space range as keywords, wherein the trajectory similarity deviation information includes: a unique identifier of the trajectory, a time deviation threshold and a distance deviation threshold; Correspondingly, according to the query keyword containing the time range and / or the spatial range extracted from the target query request, the corresponding target trajectory data for a single object or multiple objects is extracted from the non-relational trajectory storage database based on a preset multi-level index, including: Determine the query start time, query end time and spatial range corresponding to the target query request according to the unique identifier of the trajectory in the target query request, the time deviation threshold and the distance deviation threshold; According to the query start time, query end time and spatial range corresponding to the target query request, the corresponding trajectory data is obtained from the HBase trajectory table to form a trajectory similarity calculation candidate set; Based on a preset trajectory similarity algorithm and based on the original trajectory data corresponding to the unique identifier of the trajectory, calculating a similarity result of each trajectory data in the trajectory similarity calculation candidate set compared with the original trajectory data; According to the similarity result, one of the trajectory similarity calculation candidate sets is selected as the target trajectory data for the target query request.
