Spatiotemporal grid index query method and system based on degenerate quadtree
Through the spatiotemporal grid index method based on degenerated quadtree, combined with DQG multi-scale encoding and ST_DQG and B+ tree index, the efficient organization and management of spatiotemporal trajectory data is solved, and rapid retrieval and data visualization are realized to adapt to large data scenes.
Patent Information
- Application Number
- CN202310859128.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-13
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2043-07-13
AI Technical Summary
The existing technology is difficult to efficiently organize and manage spatiotemporal trajectory data, and the search efficiency is low, and traditional indexing methods are difficult to meet the management needs of high real-time and large-scale data.
The spatial and temporal mesh index method based on degenerated quadtree is adopted, and the DQG multi-scale encoding structure is combined with time and space coding, and the time encoding is stored using key-value storage, and combined with ST_DQG and B+ tree indexes to achieve rapid conversion and retrieval of spatiotemporal data.
It improves the search efficiency of spatiotemporal trajectory point data, has high efficiency, flexibility, data visualization and compatibility, and is suitable for different types of spatiotemporal data indexing, and can adapt to scene changes of large data volumes.
Smart Images

Figure CN116775971B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of spatiotemporal data management and query technology, and in particular to a spatiotemporal grid index query method and system based on a degenerate quadtree. Background Art
[0002] Geotemporal data, which refers to data containing both geographic location and time, possesses significant application value in natural, social, economic, and environmental fields. With the continuous advancement of science and technology and the development of data acquisition techniques, we can more accurately record and analyze the changes and evolution of various phenomena on Earth, such as climate change, urban expansion, and population mobility. The study of geotemporal data can help us better understand and predict these changes, supporting decision-making and providing a data foundation for applications in various fields. Therefore, the research and application of geotemporal data has become a topic of considerable interest and importance across various fields worldwide. Spatiotemporal trajectory data contains rich spatiotemporal information that can dynamically reflect the operational status of cities. High-value-added information can be mined from it, providing decision-making support for efficient urban management, smooth social operations, and improved social service efficiency.
[0003] Currently, traditional object-centric data indexing methods are commonly used in the organization and management of spatiotemporal trajectory data. Within this category, many classic indexes have been proposed by scholars both domestically and internationally. Most of these indexes derive three-dimensional entity-oriented indexes from spatial index structures, such as RT trees, 3DR trees, STR trees, MTSB trees, and PH trees. This traditional approach is no longer suitable for processing high-speed spatiotemporal trajectory point data, making it difficult to achieve real-time or near-real-time business requirements. Furthermore, data modeling methods struggle to meet the requirements for efficient organization and management of large-scale trajectory stream data.
[0004] Currently, indexing methods based on spatiotemporal partitioning have become a hot topic in geoscience research. These methods extend the Earth grid, which uses the Earth's essential space—the sphere (surface)—as its spatial partitioning object. This grid can be infinitely subdivided without changing its shape. When subdivided to a certain degree, it can simulate the Earth. The Earth grid serves as a unified spatiotemporal data organization framework, integrating data from diverse sources. Furthermore, the grid's hierarchical nature makes it suitable for organizing, managing, and analyzing multi-resolution data, as well as for expressing localized clustering characteristics in dynamic, continuous trajectory data.
[0005] There are two main research directions for indexing methods based on time and space partitioning: one is a single index, i.e., a spatiotemporal integrated grid; the other is to establish separate indexes for time and space, and query them separately. A single index is specifically an index established for a single field, which contains both spatial and temporal information and is obtained by combining geographic grid encoding with temporal information. A single index not only increases the data storage space and index structure space, but also limits the efficiency of index queries. Based on the indexing method of time and space partitioning, Cheng Chengqi (2019) divided trajectories into sub-trajectories and established a quadtree spatial index. For sub-trajectories located at the same node of the quadtree, a time index was established based on their time information; this enabled efficient queries in spatial regions with large time spans, but limited query performance in the time dimension.
[0006] The DQG grid is a variable latitude and longitude grid characterized by continuous hierarchical subdivision, nested parent-child units, and continuous grid encoding. Compared to traditional latitude and longitude GeoHash, DQG does not suffer from significant grid deformation in high-latitude regions, and boasts high grid indexing efficiency. The DQG grid is also derived along the height dimension, undergoing a binary recursive partitioning in the height dimension. The DQG_3D grid is explored based on a degenerate octree subdivision method, and encoding is used to represent three-dimensional objects as one-dimensional grids. This approach inherits the advantages of the two-dimensional DQG grid while expressing the position of aerial objects in grid space.
[0007] In summary, to better organize highly dynamic and concurrent data, an indexing method based on spatiotemporal partitioning is a better choice. Furthermore, the DQG grid-coded indexing approach is more adaptable, enabling the encoding of trajectory data at different scales and establishing a spatiotemporal index for trajectory points and lines. Summary of the Invention
[0008] The present invention addresses the problem that the existing technology is difficult to efficiently organize and manage trajectory data and has slow search efficiency, and provides a space-time grid index query method and system based on a degenerate quadtree. On the DQG multi-scale coding structure, time partitions are established for time coding, unnecessary time nodes are removed, and a fusion method is adopted to establish space-time coding on the time and space scales. The time coding is stored in a key-value storage manner, thereby proposing a three-dimensional space-time grid coding structure and achieving rapid conversion with space-time data. A space-time partition table is established in the database postgresql, and a space-time index is established using a degenerate quadtree-based space-time grid ST_DQG (Spatiotemporal Degenerate Quadtree Grids, ST_DQG) combined with a B+ tree index, and DQG multi-scale node range query is used to perform space-time data retrieval. ST_DQG coding can achieve rapid conversion with space-time data and has multi-scale characteristics, thereby improving the efficiency of space-time trajectory point data search.
[0009] In order to achieve the above object of the invention, the technical solution adopted by the present invention is as follows:
[0010] A degenerate quadtree-based spatiotemporal grid index query method includes: spatiotemporal grid code conversion, spatiotemporal data gridding, and spatiotemporal query of spatiotemporal trajectory points.
[0011] The space-time grid coding conversion includes:
[0012] The DQG multi-scale spatial grid structure is used to encode grid cells. Grid cells of different scales are represented by a spatiotemporal grid coding structure, with each spatiotemporal code corresponding to a grid cell, thus achieving the integration of time and space.
[0013] The Z-ordering algorithm, a fill curve, is used within the spatiotemporal grid structure to connect the three-dimensional space-time grid into a continuous curve according to a specific connection order. This algorithm converts the three-dimensional space into a one-dimensional encoding, enabling rapid access to geographic data through binary search.
[0014] Based on the generated space-time grid code and the actual space-time location information, a space-time grid code conversion algorithm was designed. This algorithm converts the space-time location information into the corresponding space-time grid code according to the coding rules, and can also convert the space-time grid code into the corresponding space-time location information. When searching for space-time point data, the space-time grid code conversion algorithm can be used to quickly retrieve trajectory point data from the database.
[0015] The spatiotemporal data gridding includes:
[0016] Spatial Gridding: The query area is spatially divided into a series of grid cells at a certain spatial resolution. Grid cells are identified by a structure consisting of row and column coordinates and an octant code. The size of the grid cells depends on the accuracy of the spatial resolution; smaller spatial resolutions result in smaller grid cells.
[0017] Time Scale Gridding: Divide the query area into a series of time periods at a certain time resolution, using a 32-bit unsigned integer as the time scale identifier. The time scale can be determined based on the characteristics of the actual data, such as one minute, one hour, or one day.
[0018] Space-time grid code sets: Combine spatial and temporal grid divisions, identify them using space-time coordinates, and create a complete space-time grid code set. Z-ordering curves are then used to reduce the number of space-time code sets. This space-time grid code set allows for efficient search and query performance when querying space-time data, improving query efficiency.
[0019] The spatiotemporal query of the spatiotemporal trajectory points includes:
[0020] The input PointM type is converted into a spatiotemporal code and stored in a suitable database table. Then, an equal value or spatiotemporal area query is performed on the spatiotemporal trajectory point data. The query range is determined according to the spatiotemporal query area gridding method and the corresponding spatiotemporal table is searched. Finally, the trajectory point data that meets the conditions is retrieved through a database range query.
[0021] Furthermore, the spatiotemporal index structure in the spatiotemporal grid coding conversion utilizes a joint spatiotemporal information encoding, and the time coding utilizes a partition key and sort key design. Specifically, it is divided into a spatiotemporal partition key and a spatiotemporal integrated coding. The spatiotemporal partition key is determined jointly by the octant code and the time coding partition key. The spatiotemporal integrated coding utilizes a Morton code, obtained by intersecting the spatial row and column numbers and the time sort key, and is converted into a multi-scale code using a marker bit. The time granularity is calculated based on factors such as data size, sampling frequency, and database constraints. The spatial hierarchy is determined based on factors such as route element distribution, storage cost, and query time. The spatial latitude can be not only two-dimensional but also three-dimensional, and the time coding utilizes an extended dichotomy method.
[0022] Furthermore, the converting of the spatiotemporal position information into the corresponding spatiotemporal grid code comprises the following steps:
[0023] S11: Given the latitude, longitude, altitude coordinate and time information (L, B, H, T), determine the octant corresponding to the space-time unit based on the relationship between the longitude and latitude and the octant.
[0024] S12: Calculate the latitude difference ΔB according to the given spatial subdivision level level, and thus obtain the row number i.
[0025] S13: Calculate the longitude difference ΔL of the i-th row of cells at a given spatial subdivision level Level.
[0026] S14: Calculate the column number j based on the longitude difference ΔL and the longitude L.
[0027] S15: Calculate the height difference ΔH according to the spatial subdivision level and obtain the layer number h.
[0028] S16: Convert the time t into a time structure pg_tm tm, and convert it into a time code TCode according to the time expansion dichotomy method.
[0029] S17: Based on the time granularity T, the time code TCode is divided into a partition key FTCode and a sort key PTCode, and the time partition key and the octant code are combined into a spatiotemporal partition key FST_Code, and the time sort key is transformed.
[0030] S18: Cross-select the row number i, column number j, layer number h, and time sorting key PTCode to obtain the binary space-time code stcode, add the spatial decomposition level to form a multi-scale code, combine FST_Code, space-time code stcode, time granularity T and time level TLevel, and thus generate the space-time structure STcode_FP64.
[0031] Furthermore, the step of converting the spatiotemporal grid code into corresponding spatiotemporal position information comprises the following steps:
[0032] S21: From the space-time structure STcode_FP64, obtain the time granularity T, the time segmentation level TLevel, and the space segmentation level Level;
[0033] S22: Based on the time-space partition key, extract the octant code (octant) with the highest bits of the first three digits in the uint32_t type, and obtain the time partition key ft based on the time granularity T and the time code.
[0034] S23: Solve the spatiotemporal code stcode according to the Morton code using a lookup table to find row number i, column number j, level number h, and time sort key t. Obtain pt based on TLevel and T;
[0035] S24: Calculate the latitude difference ΔB according to the spatial subdivision level Level and calculate the latitude B of the center point;
[0036] S25: Calculate the longitude difference ΔL and the longitude L of the center point;
[0037] S26: Calculate the longitude difference ΔH and the longitude H of the center point;
[0038] S27: Calculate the actual latitude and longitude coordinates L, B, H according to the octant code;
[0039] S28: Calculate the time code based on T, t and pt, convert it into pg_tm, and calculate the time information t.
[0040] Furthermore, the specific steps for gridding the spatiotemporal query area are as follows:
[0041] S31: Use the DQG scan line filling algorithm to perform gridding in the spatial dimension, represent the spatiotemporal query area in the form of a grid, obtain the row and column coordinate set (i, j) on the spatiotemporal query space area, and realize single-scale gridding at a limited level N.
[0042] S32: Gridding is performed on the time dimension, and the time range on the time dimension is Time min and Time max, converted into binary time codes Tmin and Tmax on the TLevel level, dividing the space-time area into M = Tmax-Tmin+1 identical space areas, that is, performing equal-interval gridding in the time dimension to ensure that data with the same time granularity can be included in the same space-time grid.
[0043] S33: Convert the row and column coordinate set (i, j) and M time codes of the query area into a space-time grid code set (i, j, t), and obtain the space-time code corresponding to the space-time query area in the grid environment for subsequent processing.
[0044] S34: Z-ordering curve aggregation is performed on the space-time grid code to achieve merging at a limited level N0. The four grids and four virtual grids are merged into a single grid, and the virtual grids that remain after the merge are eliminated. The high-order bits in the space-time grid code are sorted according to the Z-ordering curve until the merged level reaches N. This results in a multi-scale gridded result for the space-time query area based on N levels, where each grid corresponds to a fixed level in the range [N0, N]. The scale grid is used to quickly query space-time data and evaluate and analyze the query results.
[0045] Furthermore, the specific steps of the spatiotemporal point data query and retrieval are as follows:
[0046] S41: First, convert the input PointM type into the spatiotemporal code STcode_FP. Then select the appropriate database table according to the spatiotemporal code STcode_FP constant.
[0047] S42: Perform an equivalue query in a manner similar to searching for point data, and output the queried trajectory spatiotemporal point data.
[0048] S43: Performing a space-time region query on the trajectory point data. For example, when querying the trajectory point data included in the space-time surface data, it is actually a query on the time period and the surface data.
[0049] S44: Perform spatiotemporal gridding on the spatiotemporal query area, and determine the time granularity T and the time segmentation level TLevel that includes the time period to be queried.
[0050] S45: Find the parent node of the year and month of the time period to be queried, and retrieve the corresponding space-time table.
[0051] S46: Performing a spatiotemporal query through a database range query method to retrieve trajectory point data that meets the query conditions.
[0052] A degenerate quadtree-based spatiotemporal grid index query system can be used to implement the above-mentioned degenerate quadtree-based spatiotemporal grid index query method, specifically including: a spatiotemporal grid encoding conversion module, a spatiotemporal data gridding module and a spatiotemporal trajectory point spatiotemporal query module.
[0053] Spatiotemporal grid coding conversion module: This module implements the multi-scale coding and space-filling curve Z-ordering algorithm under the DQG spatial grid structure, and uses the spatiotemporal grid coding conversion algorithm to quickly determine the position of point data in the spatiotemporal grid index when querying and retrieving spatiotemporal point data.
[0054] Spatiotemporal Data Gridding Module: This module implements gridding methods for both spatial and temporal scales, combining them to create a complete spatiotemporal grid code set. This module allows for efficient search and retrieval of spatiotemporal data, improving query efficiency.
[0055] Spatiotemporal Track Point Query Module: This module first converts the input track point data into spatiotemporal codes and selects the appropriate database table. It then performs equal-value or spatiotemporal region queries, using a spatiotemporal query region gridding method to determine the query range and search the corresponding spatiotemporal table. Finally, it retrieves the track point data that meets the requirements through a database range query.
[0056] The present invention also discloses a computer device, including a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the program, the above-mentioned degenerate quadtree-based spatiotemporal grid index query method is implemented.
[0057] The present invention also discloses a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the degenerate quadtree-based spatiotemporal grid index query method is implemented.
[0058] Compared with the prior art, the advantages of the present invention are:
[0059] 1. Efficiency: The use of spatiotemporal grid indexing allows for rapid determination of query scope, avoiding the need to scan the entire dataset. Furthermore, gridding at both the temporal and spatial levels further improves query efficiency.
[0060] 2. Flexibility: Temporal and spatial gridding can be configured based on data characteristics and query requirements, offering high flexibility. This approach can solve problems that traditional query methods cannot, such as querying data across different time periods and spatial ranges.
[0061] 3. Data Visualization: The spatiotemporal grid index provides a grid-based data representation method and a data visualization solution. Spatial grid analysis can be used to visualize the spatial distribution and temporal characteristics of data.
[0062] 4. Compatibility: This method can be applied to indexing of various types of spatiotemporal data, including point data, line data, surface data, and trajectory data.
[0063] 5. Scalability: The spatiotemporal grid index has good scalability and can adapt to changing data sizes and query requirements. At the same time, multi-scale spatiotemporal coding optimizes the efficiency of data distribution and processing, making it better suited to scenarios with large data volumes.
[0064] 6. It can realize efficient conversion between spatiotemporal data and spatiotemporal grid codes, and can reduce the time of spatiotemporal information retrieval in PostgreSQL database. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 This is a technical roadmap of the spatiotemporal grid index query method according to an embodiment of the present invention;
[0066] Figure 2 This is a schematic diagram of the structure of the spatiotemporal grid coding code according to an embodiment of the present invention;
[0067] Figure 3 This is a time flow chart of converting grid code to longitude, latitude and altitude according to an embodiment of the present invention;
[0068] Figure 4 The embodiment of the present invention is a schematic diagram of dividing the spatiotemporal query area into multiple time period areas;
[0069] Figure 5 This is a flow chart of trajectory point query according to an embodiment of the present invention. DETAILED DESCRIPTION
[0070] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and examples.
[0071] The present invention discloses a degenerate quadtree-based spatiotemporal grid index query method (ST_DQG spatiotemporal grid index query) comprising three parts: a spatiotemporal grid coding structure and coding / decoding algorithm, a spatiotemporal query region gridding method, and a spatiotemporal trajectory point spatiotemporal query. The spatiotemporal grid coding is based on the DQG spatial grid multi-scale coding structure, and develops a spatiotemporal integrated grid organization method based on the space-filling curve Z-ordering. On this basis, a fast conversion algorithm between spatiotemporal data and the spatiotemporal grid is designed. The gridding of the spatiotemporal query region is the basis for spatiotemporal data query. The spatiotemporal query region is divided into a spatial scale gridding and a temporal scale gridding, and finally merged and converted into a spatiotemporal grid coding set, thereby utilizing the spatiotemporal coding calculation and query method to improve the efficiency of spatiotemporal query. The spatiotemporal query of spatiotemporal trajectory points introduces the classification of different spatiotemporal trajectory point data for the first time by establishing a spatiotemporal partition table based on the simulated Beijing spatiotemporal pedestrian trajectory point data. Then, a cross-level degenerate quadtree index and B+ tree are used to construct an index for spatiotemporal coding, and a multi-scaling method is adopted to verify the efficiency of the method of the present invention. Figure 1 Describes the technical route for space-time grid index query based on ST_DQG.
[0072] Space-time grid code conversion
[0073] The spatiotemporal index structure utilizes a combined encoding of spatiotemporal information, with a series of modifications based on the MLS3 index: The time code is split into a partition key and a sort key as shown in Table 1. The optimal spatiotemporal granularity is determined based on sampling frequency, data size, and database constraints. The optimal spatial granularity is determined by considering the distribution of route elements, storage cost, and query time.
[0074] Among them, it is extended by MLS3 index
[58] . The time code adopts the extended dichotomy method and is divided into time partition key and time sort key as shown in Table 3.3. The space code adopts DQG_3D grid code or two-dimensional DQG grid code. The space-time grid index includes two parts: space-time partition key and space-time integrated code. The space-time partition key is determined by the octant code and the time code partition key; the space-time integrated code stcode is composed of the time code and the code of spatial information at the spatial level. The overall space-time code data structure is as follows: Figure 2 shown.
[0075] Table 1 Time information coding
[0076]
[0077] Figure 2In the _stcode_ format, stcode represents the 3D or 4D spatiotemporal code, level represents the time segmentation level, Tlevel represents the time granularity, and ftimecode represents the partition key and octave code of the time code. In the same scenario, only the spatiotemporal code and the time partition key change.
[0078] Latitude, longitude, altitude and time to grid coding algorithm
[0079] The basic principle of converting the latitude and longitude of a given space-time grid unit into space-time grid encoding is:
[0080] Step 1: Given the latitude, longitude, altitude, and time coordinate information (L, B, H, T), determine the octant corresponding to the space-time unit based on the latitude and longitude coordinate information and the relationship between the latitude and longitude and the octant;
[0081] Step 2: According to the given spatial subdivision level, calculate the latitude difference ΔB by formula 1, and then calculate the row number i;
[0082]
[0083] Where, For the rounding operation
[0084] Step 3: Calculate the longitudinal difference ΔL of the i-th row of cells at a given spatial subdivision level Level:
[0085] ΔL=log2(i+1)+1 (2)
[0086] In the formula, log2() is the logarithm with base 2
[0087] Step 4: Calculate column number j based on the longitude difference ΔL and the longitude L;
[0088]
[0089] Step 5: Calculate the height difference ΔH and the layer number h according to the spatial subdivision level;
[0090]
[0091] Step 6: Convert the time t (double type) into the time structure pg_tm tm, and convert it into the time code TCode according to the time expansion dichotomy method.
[0092] TCode=y<<26+M<<22+d<<17+h<<12+m<<6+ss (5)
[0093] Where y represents year, M represents month, d represents day, h represents hour, m represents minute, and s represents second.
[0094] Step 7: Based on the time granularity T, the time code TCode is divided into the partition key FTCode and the sort key PTCode according to Table 1. The time partition key and the octant code are combined into the spatiotemporal partition key FST_Code, and the time sort key is transformed.
[0095] PTCode=PTCode>>(32-TLevel)) (6)
[0096] Step 8: Cross-place the row number i, column number j, layer number h, and time sorting key PTCode to obtain the binary space-time code stcode. Add the spatial decomposition level according to Formula 7 to form a multi-scale code. Combine FST_Code, space-time code stcode, time granularity T and time level TLevel to generate the space-time structure STcode_FP64.
[0097] stcode=stcode<<(63-2×Level)+1ull<<(63-2×Level)) (7)
[0098] Grid code conversion algorithm for longitude, latitude, altitude and time
[0099] For a given spatiotemporal code, its conversion into spatiotemporal information is as follows Figure 3 The specific steps are as follows:
[0100] Step 1: From the space-time structure STcode_FP64, obtain the time granularity T and the time segmentation level TLevel, and obtain the spatial segmentation level Level according to the algorithm in Table 1;
[0101] Step 2: Based on the time and space partition key, extract the octant code (octant) with the highest bit as the first three digits in the uint32_t type. Based on the time granularity T, obtain the time partition key ft according to Table 1.
[0102] Step 3: Solve the space-time code stcode according to the Morton code using the lookup table method to obtain the row number i, column number j, layer number h, and time sort key t. According to TLevel and T, get pt;
[0103] Step 4: Calculate the latitude difference ΔB according to the spatial segmentation level Level according to Formula 1, and calculate the center point latitude B according to Formula 9;
[0104] B=(j+0.5)×ΔB (9)
[0105] Step 5: Calculate the longitude difference ΔL according to formula 8 and calculate the longitude L of the center point;
[0106] L=(i+0.5)×ΔL (8)
[0107] Step 6: Calculate the difference in longitude ΔH according to Formula 10, and calculate the longitude H of the center point;
[0108] H = (h + 0.5) × ΔH (10)
[0109] Step 7: Calculate the actual longitude, latitude and height coordinates L, B, H according to the octant code according to the formula;
[0110] Step 8: Calculate the time code according to T, t and pt, convert it to pg_tm, and calculate the time information t (double type).
[0111] Grid-based spatio-temporal query area
[0112] This section proposes a method for grid-based spatio-temporal query area based on a degenerated quadtree, aiming to improve the efficiency of spatio-temporal area query. The main idea of this method is:
[0113] Step 1: Grid the spatio-temporal query area in the spatial dimension using the DQG scan-line filling algorithm to obtain the set of row and column number coordinates (i, j) on the spatio-temporal query space area, and achieve the single-scale grid-based of Area at the specified level N.
[0114] Step 2: The grid in the time dimension specifically converts the time range Time min and Time max , into the binary time codes Tmin and Tmax at the TLevel level, and divide the spatio-temporal area into M = Tmax - Tmin + 1 identical spatial areas Area.
[0115] Step 3: Finally, convert the set of row and column number coordinates (i, j) of the query area and the M time codes into the spatio-temporal grid code set (i, j, t).
[0116] Step 4: After spatio-temporal grid-based, achieve Z-ordering curve aggregation under the specified level N0 (N0 < N). The main work in the Z curve merging is to merge eight grids into four grids, four grids and four virtual grids into one grid, and eliminate the existing virtual grids after merging, to obtain the multi-scale grid-based result of the spatio-temporal query area based on the N level, and its level range is [N0, N].
[0117] As Figure 4 shown, through the above spatio-temporal grid-based method, it is possible to represent the spatio-temporal query area with fewer spatio-temporal grids, thereby reducing the number of coding queries and improving the spatio-temporal query efficiency of data.
[0118] Spatio-temporal point data query and retrieval
[0119] The point type of PostGIS supports multidimensional types such as PointZ, PointM and PointZM. In the present invention, PostGis's PointM is selected as the storage data structure for three-dimensional spatiotemporal data. To establish the spatiotemporal index of spatiotemporal trajectory point data, it is only necessary to use the geometry field in the data table, convert the longitude and latitude time into space-time grid coding through the extended plug-in function, and establish a one-dimensional index such as B+ tree for the stcode in the STcode_FP64 structure to establish a one-dimensional space-time coding index. If the other variables of the spatiotemporal coding STcode_FP64 of the trajectory point data are consistent, the other variables of the structure are stored as constants in the table, otherwise the data is divided into tables according to the constants in the structure (Note: the premise is that the amount of data is large enough), and table mapping is performed. The other variables of STcode_FP64 are stored in the config table. The types in the Config system table are as follows:
[0120]
[0121] fqcode represents the combination of the time partition key and the octant code, Tlevel represents the time partition level, and T represents the time granularity.
[0122] The process of querying spatiotemporal trajectory point data is as follows:
[0123] Step 1: First, convert the input pointM type into the spatiotemporal code STcode_FP. Then select the appropriate database table based on the spatiotemporal code STcode_FP constant.
[0124] Step 2: Then perform an equivalue query in a similar way to searching for point data, and output the queried trajectory spatiotemporal point data.
[0125] Step 3: Query the trajectory point data in the spatiotemporal area. For example, querying the trajectory point data contained in the spatiotemporal surface data is actually a query of the time period and the surface data.
[0126] Step 3: First, follow the spatiotemporal query area gridding method in the previous section to determine the time granularity T and time segmentation level TLevel that include the time period to be queried.
[0127] Step 4: Find the parent node of the year and month of the time period to be queried, and then find the corresponding space-time table.
[0128] Step 5: Perform spatiotemporal query through database range query.
[0129] The other variables of the spatiotemporal encoding structure of the trajectory point data in the experiment are consistent. This index converts the high-dimensional spatiotemporal index into a one-dimensional encoding index, which is conducive to the correspondence between different spatial scales and time scales, and is conducive to the efficient spatiotemporal query of trajectory point data based on the st_DQG space-time grid.
[0130] The flow chart of space-time trajectory point data query is as follows Figure 5 As shown;
[0131] Experimental data: Beijing was used as the research scope, and POI points in Beijing before June 2020 were used as simulation points. Data was obtained from the open-source Baidu Map API interface to simulate pedestrian trajectory point data. The reference model for storing trajectory point data table structure is shown in Table 3. In the table, _id is the identifier of a trajectory point record, POI_id is the identifier of the Beijing POI point in the association table, and the association table structure includes storage of spatial data geometry, lon longitude, lat latitude, time is the time of arrival at the POI trajectory location, and the data expression type is timestamp. Attributes represents the attribute information in the record. Two queries are designed: spatiotemporal point query and spatiotemporal query area. The spatiotemporal point query quickly queries the person_id at a specific point at a certain time, and the spatiotemporal area query quickly queries the person_id in a specific area within a certain time period.
[0132] Table 3 Spatiotemporal trajectory point data structure
[0133]
[0134]
[0135] To verify the effectiveness of the spatiotemporal index and query method for querying spatiotemporal grid trajectory points, a comparative experiment on the spatiotemporal query efficiency of Beijing trajectory points was designed. The specific steps are as follows:
[0136] Step 1: Based on the built Postgre platform, create two trajectory point data tables for ST_DQG and independent query methods according to the format of Table 3. The table names are TDDTA and TDDTB respectively.
[0137] Step 2: Import the simulated experimental data (5,449,989 trajectory points) into tables named TDDTA and TDDTB, and calculate the spatiotemporal code for each point in table TDDTA and store it in the stcode field. In this process, the POI spatial data grid base level is set to 21, and the time code base level is set to 22. The spatial resolution of the spatiotemporal grid at this level is approximately 5m×5m, and the time resolution is 1 hour. This can well meet the data query application requirements of the spatiotemporal code index of POI spatiotemporal trajectory points;
[0138] Step 3: Refer to the method of establishing spatiotemporal index and, based on it, establish the ST_DQG spatiotemporal grid index;
[0139] Step 4: Based on the two spatiotemporal coding indexes, two sets of spatiotemporal trajectory point data are used to conduct spatiotemporal point query experiments on trajectory points. The average query time of ST_DQG and independent query methods for each set of different data volumes is calculated. The comparison results are shown in Table 4.
[0140] Step 5: Based on the space-time grid index proposed in the present invention, two groups of space-time query methods are used in the experiment to conduct space-time query experiments on trajectory points and space-time region query experiments on trajectory points. Then, the average query time for each group of polygon space-time query areas of the ST_DQG grid and the independent query method is counted. The comparison results are shown in Table 5.
[0141] Table 4 Comparison table of space-time trajectory point queries
[0142]
[0143] Table 5 Comparison of spatiotemporal region query efficiency
[0144]
[0145] The present invention's spatiotemporal trajectory point query strategy is more efficient than a single query strategy. To verify the effectiveness of the present invention's spatiotemporal network, two sets of experiments were designed. The spatiotemporal query experiment for trajectory points in this experimental scenario showed that the present invention's query efficiency increased by an average of approximately three times compared to a single query. The results of the spatiotemporal region query experiment for trajectory points in this experiment also showed that the present invention's method increased the spatiotemporal region query efficiency by an average of approximately three times compared to a single index.
[0146] In another embodiment of the present invention, a degenerate quadtree-based spatiotemporal grid index query system is provided. The system can be used to implement the above-mentioned degenerate quadtree-based spatiotemporal grid index query method, and specifically includes: a spatiotemporal grid encoding conversion module, a spatiotemporal data gridding module, and a spatiotemporal trajectory point spatiotemporal query module.
[0147] Spatiotemporal grid coding conversion module: This module implements the multi-scale coding and space-filling curve Z-ordering algorithm under the DQG spatial grid structure, and uses the spatiotemporal grid coding conversion algorithm to quickly determine the position of point data in the spatiotemporal grid index when querying and retrieving spatiotemporal point data.
[0148] Spatiotemporal Data Gridding Module: This module implements gridding methods for both spatial and temporal scales, combining them to create a complete spatiotemporal grid code set. This module allows for efficient search and retrieval of spatiotemporal data, improving query efficiency.
[0149] Spatiotemporal trajectory point query module: This module converts input point data into spatiotemporal codes and selects appropriate database tables. It then performs equal-value or spatiotemporal region queries, using a spatiotemporal query region gridding method to determine the query range and search the corresponding spatiotemporal table. Finally, it retrieves trajectory point data that meets the requirements through a database range query.
[0150] In another embodiment of the present invention, a terminal device is provided, comprising a processor and a memory, wherein the memory is used to store a computer program, the computer program including program instructions, and the processor is used to execute the program instructions stored in the computer storage medium. The processor may be a central processing unit (CPU), or may 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, etc. It is the computing core and control core of the terminal, which is suitable for implementing one or more instructions, specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding function; the processor described in the embodiment of the present invention can be used for the operation of a degenerate quadtree-based spatiotemporal grid index query method.
[0151] In another embodiment of the present invention, the present invention further provides a storage medium, specifically a computer-readable storage medium (Memory), which is a memory device in a terminal device for storing programs and data. It can be understood that the computer-readable storage medium here can include both the built-in storage medium in the terminal device and, of course, the extended storage medium supported by the terminal device. The computer-readable storage medium provides a storage space, which stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor are also stored in the storage space. These instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory.
[0152] The processor may load and execute one or more instructions stored in the computer-readable storage medium to implement corresponding steps of the degenerate quadtree-based spatiotemporal grid index query method in the above embodiment.
[0153] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0154] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0155] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0156] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0157] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the implementation methods of the present invention, and it should be understood that the scope of protection of the present invention is not limited to such specific descriptions and embodiments. Those skilled in the art can make various other specific variations and combinations based on the technical teachings disclosed in the present invention without departing from the essence of the present invention, and such variations and combinations are still within the scope of protection of the present invention.
Claims
1. A spatiotemporal grid index query method based on degenerate quadtree, characterized in that: include: Space-time grid code conversion, space-time data gridding, and space-time trajectory point space-time query; The space-time grid coding conversion includes: Using the DQG spatial grid structure, grid cells are encoded at multiple scales; using the DQG multi-scale spatial grid structure, grid cells are encoded; grid cells of different scales are represented by the spatiotemporal grid coding structure, and each spatiotemporal grid code corresponds to a grid cell, thus achieving the integration of time and space; In the space-time integrated grid structure, the filling curve Z-ordering algorithm is used to connect the three-dimensional space-time grid into a continuous curve according to a certain connection order; the filling curve Z-ordering algorithm is used to convert the three-dimensional space into a one-dimensional coding mode; Design a space-time grid code conversion algorithm based on the generated space-time grid code and the actual space-time position information; the space-time grid code conversion algorithm converts the space-time position information into the corresponding space-time grid code according to the coding rules, or converts the space-time grid code into the corresponding space-time position information; The spatiotemporal data gridding includes: Gridding of spatial scale: The query area is spatially divided into a series of grid cells at a certain spatial resolution, and a structure in the form of row and column coordinates + octant code is used as the identifier of the grid cell; Time scale gridding: The query area is divided into a series of time periods according to a certain time resolution, and a 32-bit unsigned integer is used as the time scale identifier; Space-time grid code set: Combine the grid division of spatial scale and time scale, use space-time coordinates for identification, obtain a complete space-time grid code set, and reduce the number of space-time code sets through Z-ordering curve merging; The spatiotemporal query of the spatiotemporal trajectory points includes: converting the input PointM type into a spatiotemporal code and selecting a suitable database table, then performing an equal value or spatiotemporal area query on the spatiotemporal point data, determining the query range according to the spatiotemporal query area gridding method and searching the corresponding spatiotemporal table, and finally retrieving the trajectory point data that meets the conditions through a database range query method.
2. The degenerate quadtree-based spatiotemporal grid index query method according to claim 1, characterized in that: In the spatiotemporal grid coding conversion, the spatiotemporal index structure adopts the joint coding of spatiotemporal information, and the time coding adopts the design of partition key and sort key, which is specifically divided into spatiotemporal partition key and spatiotemporal integrated coding. The spatiotemporal partition key is jointly determined by the octant code and the time coding partition key; the spatiotemporal integrated coding adopts Morton code, which is obtained by cross-sampling the spatial row and column numbers and the time sort key, and is converted into a multi-scale code by using the mark bit method; the time granularity is calculated based on factors such as data size, sampling frequency, and database constraints, and the spatial level is determined based on factors such as route element distribution, storage cost, and query time; the spatial latitude can be not only two-dimensional but also three-dimensional space, and the time coding adopts extended dichotomy.
3. The degenerate quadtree-based spatiotemporal grid index query method according to claim 1, characterized in that: The converting of the spatiotemporal position information into the corresponding spatiotemporal grid code comprises the following steps: S11: Given the latitude, longitude, altitude coordinate and time information (L, B, H, T), determine the octant corresponding to the space-time unit based on the relationship between longitude and latitude and octant; S12: Calculate the latitude difference ΔB according to the given spatial subdivision level, and thus obtain the row number i; S13: Calculate the longitude difference ΔL of the i-th row of cells at a given spatial subdivision level Level; S14: Calculate column number j based on the longitude difference ΔL and the longitude L; S15: Calculate the height difference ΔH according to the spatial subdivision level and obtain the layer number h; S16: Convert the time t into a time structure pg_tm tm, and convert it into a time code TCode according to the time extension dichotomy method; S17: Based on the time granularity T, the time code TCode is divided into a partition key FTCode and a sort key PTCode. The time partition key and the octant code are combined into a spatiotemporal partition key FST_Code, and the time sort key is transformed. S18: Cross-select the row number i, column number j, layer number h, and time sorting key PTCode to obtain the binary space-time code stcode, add the spatial decomposition level to form a multi-scale code, combine FST_Code, space-time code stcode, time granularity T and time level TLevel, and thus generate the space-time structure STcode_FP64.
4. The degenerate quadtree-based spatiotemporal grid index query method according to claim 1, characterized in that: The step of converting the spatiotemporal grid code into corresponding spatiotemporal position information comprises the following steps: S21: From the space-time structure STcode_FP64, obtain the time granularity T, the time segmentation level TLevel, and the space segmentation level Level; S22: Based on the time-space partition key, extract the octant code (octant) with the highest bits of the first three digits in the uint32_t type, and obtain the time partition key ft based on the time granularity T and the time code. S23: Solve the spatiotemporal code stcode according to the Morton code using a lookup table to obtain row number i, column number j, layer number h, and time sort key t; obtain pt according to TLevel and T; S24: Calculate the latitude difference ΔB according to the spatial subdivision level Level and calculate the latitude B of the center point; S25: Calculate the longitude difference ΔL and the longitude L of the center point; S26: Calculate the longitude difference ΔH and the longitude H of the center point; S27: Calculate the actual latitude and longitude coordinates L, B, H according to the octant code; S28: Calculate the time code based on T, t and pt, convert it into pg_tm, and calculate the time information t.
5. The degenerate quadtree-based spatiotemporal grid index query method according to claim 1, characterized in that: The specific steps for gridding the spatiotemporal query area are as follows: S31: Use the DQG scan line filling algorithm to perform gridding in the spatial dimension, represent the spatiotemporal query area in the form of a grid, obtain the row and column coordinate set (i, j) of the spatiotemporal query space area, and realize single-scale gridding at a limited level N; S32: Gridding is performed on the time dimension, and the time range on the time dimension is Time min and Time max , convert it into binary time codes Tmin and Tmax at the TLevel level, and divide the space-time region into M = Tmax - Tmin + 1 identical space regions, that is, perform equal-interval gridding in the time dimension to ensure that data with the same time granularity can be included in the same space-time grid; S33: Convert the row and column coordinate set (i, j) and M time codes of the query area into a space-time grid code set (i, j, t), and obtain the space-time code corresponding to the space-time query area in the grid environment; S34: Perform Z-ordering curve aggregation on the space-time grid code to achieve merging under the limited level N0; merge the four grids and the four virtual grids into one grid, and remove the virtual grids that exist after the merger; sort the high bits in the space-time grid code according to the Z-ordering curve until the merged level reaches N levels, and obtain a multi-scale gridding result of the space-time query area based on N levels, where each grid corresponds to a fixed level, and its level range is [N0, N].
6. The degenerate quadtree-based spatiotemporal grid index query method according to claim 1, characterized in that: The specific steps of the spatiotemporal point data query and retrieval are as follows: S41: First, convert the input PointM type into the spatiotemporal code STcode_FP; then select the appropriate database table according to the spatiotemporal code STcode_FP constant; S42: Perform an equivalue query in a manner similar to searching for point data, and output the queried trajectory spatiotemporal point data; S43: querying trajectory point data in a spatiotemporal area; S44: performing spatiotemporal gridding on the spatiotemporal query area, and determining the time granularity T and the time segmentation level TLevel that include the time period to be queried; S45: Find the parent node of the year and month of the time period to be queried, and retrieve the corresponding space-time table; S46: Performing a spatiotemporal query through a database range query method to retrieve trajectory point data that meets the query conditions.
7. A degenerate quadtree-based spatiotemporal grid index query system, characterized by: The system can be used to implement a degenerate quadtree-based spatiotemporal grid index query method according to any one of claims 1 to 6, specifically comprising: a spatiotemporal grid encoding conversion module, a spatiotemporal data gridding module, and a spatiotemporal trajectory point spatiotemporal query module; Space-time grid coding conversion module: This module implements the multi-scale coding and filling curve Z-ordering algorithm under the space-time grid structure based on the degenerate quadtree, and uses the space-time grid coding conversion algorithm to quickly determine the position of point data in the space-time grid index during space-time point data query and retrieval; Spatiotemporal data gridding module: This module implements gridding methods for spatial and temporal scales, and combines the two to obtain a complete spatiotemporal grid code set; in the query and retrieval of spatiotemporal data, this module can be used to perform efficient retrieval and improve query efficiency; Spatiotemporal query module for spatiotemporal trajectory points: This module converts the input point data into spatiotemporal codes and selects the appropriate database table. It then performs equal value or spatiotemporal area queries and uses the spatiotemporal query area gridding method to determine the query range and search for the corresponding spatiotemporal table. Finally, the trajectory point data that meets the conditions is retrieved through database range queries.
8. A computer device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a degenerate quadtree-based spatiotemporal grid index query method according to one of claims 1 to 6 is implemented.
9. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the program is executed by a processor, the method for searching a spatiotemporal grid index based on a degenerate quadtree as claimed in any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Space-time coding method, space-time index and query method and device
CN109992636A
Spatio-temporal big data grid coding efficient visualization method and system
CN111782745A