Spatial range query method based on HQuadTree

By using the HQuadTree index structure combined with Hilbert curve and Quadtree in spatial range query, and using a query strategy that combines depth-first combined with finite breadth extension, the inefficiency problem caused by excessive coarse query granularity in the existing technology is solved, and a more efficient spatial range query is achieved.

CN119829690AActive Publication Date: 2025-04-15KUNMING UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510026197.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-04-15
Estimated Expiration
2045-01-08

AI Technical Summary

Technical Problem

The query granularity of the existing spatial-range query algorithm is too coarse, resulting in the query results containing a large number of objects that are not within the query scope, thereby reducing query efficiency.

Method used

A index structure HQuadTree based on the combination of Hilbert curve and Quadtree is designed to drill down the spatial range query moderately by combining depth-first combined with finite breadth expansion to reduce the return number of invalid objects.

Benefits of technology

It effectively reduces the number of returned invalid object IDs, improves query efficiency, and reduces the number of intersect judgment times during drilling down through the fast intersect judgment strategy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119829690A_ABST
    Figure CN119829690A_ABST
Patent Text Reader

Abstract

The invention relates to a spatial range query method based on HQuadTree, and belongs to the technical field of spatial database indexing. The method comprises two parts of spatial index construction and spatial range query. When the index is constructed, the Hilbert curve and the QuadTree are combined, and the HQuadTree index is created. When the query is executed, a query q is given, and the space range query is moderately drilled down by adopting a strategy of combining depth first with limited breadth expansion, so that the number of returned invalid objects can be effectively reduced. In addition, in order to avoid intersection judgment times in the drilling process, a rapid intersection judgment strategy is provided to reduce the judgment times, and therefore the efficiency can be effectively inquired.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a spatial range query method based on HQuadTree, belonging to the field of spatial database and information retrieval. Related knowledge includes: computer technology, database technology, information retrieval technology, etc. Background Art

[0002] A given spatial dataset D consists of a series of objects O containing coordinate information. Each object has a unique identifier O.ID, and the object ID takes values ​​0, 1, ..., |D|-1. A spatial range query is to find all objects O∈D∧O∈q that meet the conditions in the dataset D given a query area q represented by the lower left coordinates P1=(x1, y1) and the upper right coordinates P2=(x2, y2). For example, in a map service, users can specify an area to find points of interest (such as restaurants, gas stations, etc.) in the area.

[0003] Spatial range query is a key operation in spatial databases and geographic information systems (GIS), and is widely used in fields such as geographic data processing, computer vision, and mobile computing. However, with the huge amount of spatial data and high query accuracy requirements, spatial range query requires efficient data structures and algorithms to improve query performance. Traditional index structures such as R-tree, R*-tree, quadtree, etc. will return a large number of objects that are not in the area when the data set is large or the query accuracy is high, which will greatly reduce the query efficiency when verifying these invalid objects.

[0004] Therefore, in big data processing and geographic information systems, coarse-grained spatial range queries are usually used. By dividing spatial data into larger areas, coarse-grained queries can reduce the details that need to be checked, thereby improving query efficiency. In addition, it can quickly exclude irrelevant areas, reduce computing and storage overhead, and improve system performance and response speed. In recent studies, SFC-Quad and ARM-SQ implement coarse-grained queries by returning objects with the smallest node containing the query area. However, the query granularity of the above algorithm is too coarse, resulting in the query results containing a large number of objects that are not within the query range, thereby reducing query efficiency. To solve the above problem, the present invention designs a novel index HQuadTree that combines Hilbert curve and Quadtree, which organizes nodes based on the Hilbert curve and establishes the consistency of the Hilbert curve. On this basis, a spatial coarse-grained range query algorithm (HQuadTree-SQ) based on HQuadTree is implemented. Summary of the invention

[0005] The purpose of the present invention is to provide a spatial range query method based on HQuadTree, aiming to solve the technical problem that the query granularity of the existing algorithm is too coarse, resulting in the query results containing a large number of objects that are not within the query range, thereby reducing the query efficiency.

[0006] To achieve the above purpose, the technical solution of the present invention is: a spatial range query method based on HQuadTree, firstly, the Hilbert curve and Quadtree are combined to construct a new index structure HQuadTree, and HQuadTree organizes nodes based on the Hilbert curve, thereby establishing the consistency of HQuadTree and Hilbert curve. Based on HQuadTree, given a query q, a depth-first combined with limited breadth expansion strategy is used to appropriately drill down the spatial range query during the query, which can effectively reduce the number of invalid object IDs returned, thereby improving the query efficiency. The specific steps include:

[0007] Step 1: In the spatial index construction phase, given the spatial dataset D, construct an index structure HQuadTree that combines the Hilbert curve and QuadTree;

[0008] Step 2: In the spatial range query phase, given a query q, a coarse-grained spatial range query is implemented based on the created index structure HQuadTree. The ID ranges corresponding to all nodes intersecting with q are queried in the dataset D and stored in the result set RS.

[0009] The Step 1 is specifically as follows:

[0010] Step 1.1: Hilbert curve state view construction: The Hilbert curve is a curve that maps multidimensional data to a one-dimensional integer domain. Its first-order state is divided into four states according to the opening direction of the curve: 0 (opening downward), 1 (opening to the left), 2 (opening upward) and 3 (opening to the right). Given a first-order state value, the corresponding coordinate values ​​in the four states and the next-order state are as follows:

[0011] State 0: physical coordinates: (0,0), (0,1), (1,1), (1,0); next-order states: 1, 0, 0, 3;

[0012] State 1: physical coordinates: (0,0), (1,0), (1,1), (0,1); next-order state: 0, 1, 1, 2;

[0013] State 2: physical coordinates: (1,1), (1,0), (0,0), (0,1); next-order state: 3, 2, 2, 1;

[0014] State 3: physical coordinates: (1,1), (0,1), (0,0), (1,0); next-order state: 2, 3, 3, 0;

[0015] Step 1.2: Object ID reassignment: Renumber the objects in dataset D in the order of Hilbert coding values, and assign IDs ranging from 0 to |D|-1;

[0016] Step 1.3: HQuadTree construction: Construct the spatial index structure HQuadTree that combines Hilbert curve and QuadTree;

[0017] Step 1.3.1: Node structure: Each node N of HQuadTree contains the following attributes: N.IDR: represents the object ID interval contained in the current node, N.IDR[0] and N.IDR[1] represent the lower and upper bounds of the corresponding ID interval respectively; N.Leaf represents whether it is a leaf node; N.Region: is the region represented by the node N, which is a spatial region represented by the lower left corner coordinate P1=(x1,y1) and the upper right corner coordinate P2=(x2,y2); N.State: represents the Hilbert state of the current node N.

[0018] Step 1.3.2: The root node of the HQuadTree structure represents the entire data space. Each non-leaf node N contains four children, which represent the four equal divisions of the space area corresponding to N. During the construction process, the order and state of the four child nodes are determined according to the node's N.State, so that the i-th child node N.Ni of the node N corresponds to the i-th Quadrant in the Hilbert space, ensuring the consistency of the HQuadTree with the Hilbert curve.

[0019] The Step 2 is specifically as follows:

[0020] Step 2.1: Query the smallest node that contains q: Starting from the root node N of HQuadTree, determine whether q is contained in a child node N of N i If so, recursively determine whether q is included in N i In a child node of i That is, it is the smallest node that contains q, and this node is denoted as MCN. The depth of the node corresponding to MCN is set to d=0.

[0021] Step 2.2: Since the object interval (IDR) of the MCN node may be large, a limited m-level drill-down is performed on it. By drilling down to return the IDR interval of the child node of the MCN that intersects with q, the IDR range can be effectively narrowed. Since there may be multiple IDR intervals after drilling down, I is used to store these intervals, and adjacent IDRs are merged to reduce the number of intervals.

[0022] Step 2.3: When drilling down, based on the depth-first search, a limited breadth expansion is performed; first, a stack S is introduced. Initially, the MCN node N and its level d=0 are pushed into the stack (ie, S.push(N,0)), and then Step 2.3.1 to Step 2.3.2 are executed.

[0023] Step 2.3.1: If the stack is not empty, pop the top node N and its level d. If N satisfies the following conditions: 1) d = m; 2) N is a leaf node; 3) N is included in q, there is no need to drill down further. Let maxID represent the maximum ID of the last IDR in I. If N.IDR[0]-maxID=1, merge it into the last IDR of I and update maxID←N.IDR[1]. Otherwise, add N.IDR to I, that is, I←I∪N.IDR, and update maxID←N.IDR[1].

[0024] Step 2.3.2: If the top node N does not meet the above conditions, use the following steps to detect N's child node N i (i∈{1,2,3,4}) intersects with q, thereby drilling down the query to layer d=d+1. In order to reduce the number of intersection judgments during detection, the following two steps are performed according to the level of the current node N:

[0025] Step 2.3.2.1: When d = 0, that is, when the current top node of the stack is MCN node N, the FSFO strategy is used for intersection judgment: First, q is intersected with N's child nodes N1 and N2, and f i When it represents node N i The flag indicating whether it intersects with q, 1 means intersecting, 0 means not intersecting. When f1 and f2 are not all 1, we can directly obtain f3 = f1, f4 = f2, otherwise f4 = f3 = O(N.N3,q).

[0026] Step 2.3.2.2: When d>1, that is, when the current top node N is a non-MCN node, that is, when d>0, FSFO is used +The strategy for intersection judgment is: first, make an intersection judgment on q with N1 and N2. If f1f2=11, continue to make a coverage judgment on N3; if f1f2=00, continue to judge whether q and N3 intersect. If f3=1, further judge N4; if f1f2=10 or f1f2=01, it is necessary to add a coverage judgment on N4 or N3.

[0027] Step 2.3.3: Set f i = 1 and its depth d are pressed into S;

[0028] Step 2.4: Region verification: After the above steps, we get the object interval I composed of multiple segments. Then, we traverse each segment in I in turn and check whether the coordinates of each object O are located in the rectangular query box q. If they are, we add them to the result set RS, that is, RS←RS∪{O}.

[0029] The beneficial effects of the present invention are as follows: providing a spatial range query method based on HQuadTree, combining Hilbert curve and QuadTree to create HQuadTree index when index is constructed. When query is executed, given a query q, a depth-first combined with limited breadth expansion strategy is adopted to perform moderate drilling down on the spatial range query, which can effectively reduce the number of invalid objects returned. In addition, in order to avoid the number of intersection judgments in the drilling process, a fast intersection judgment strategy is proposed to reduce the number of judgments, thereby effectively improving query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 is a flow chart of the steps of the present invention;

[0031] Figure 2 These are the four states of the first-order Hilbert curve of the present invention;

[0032] Figure 3 is a spatial distribution diagram of example data of the present invention;

[0033] Figure 4 HQuadTree index created for the example data of the present invention. DETAILED DESCRIPTION

[0034] In order to make the objectives, technical solutions and advantages of the present invention more clear, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings and examples.

[0035] Example 1: Figure 1 As shown in the figure, a spatial range query method based on HQuadTree is shown in the figure. The specific steps are as follows:

[0036] Given the example dataset shown in Table 1, the spatial distribution of the sample dataset is as follows Figure 3 As shown, given the query q = <(3,2), (6,3)>, Figure 3 As shown in the red rectangle.

[0037] Table 1 Example data

[0038]

[0039] The spatial range query includes Step 1 index HQuadTree construction and Step 2 spatial range query method based on HQuadTree, specifically:

[0040] Step 1: In the spatial index construction phase, the Hilbert curve is combined with the quadtree to construct a quadtree structure (HQuadTree) that is consistent with the order of the Hilbert curve.

[0041] Step 1.1: Hilbert curve state view construction: The Hilbert curve is a curve that maps multidimensional data to a one-dimensional integer domain. Its first-order state is divided into the following according to the opening direction of the curve: Figure 2 The four states shown are: 0 (opening downward), 1 (opening to the left), 2 (opening upward) and 3 (opening to the right). Given a 1st-order state value, the corresponding coordinate values ​​in the 4 states and the next-order state are as follows:

[0042] State 0: physical coordinates: (0,0), (0,1), (1,1), (1,0); next-order states: 1, 0, 0, 3;

[0043] State 1: physical coordinates: (0,0), (1,0), (1,1), (0,1); next-order state: 0, 1, 1, 2;

[0044] State 2: physical coordinates: (1,1), (1,0), (0,0), (0,1); next-order state: 3, 2, 2, 1;

[0045] State 3: physical coordinates: (1,1), (0,1), (0,0), (1,0); next-order state: 2, 3, 3, 0;

[0046] Step 1.2: Object ID reassignment: Renumber the objects in dataset D in the order of Hilbert coding values, and assign IDs ranging from 0 to |D|-1.

[0047] Step 1.3: HQuadTree construction: Construct the spatial index structure HQuadTree that combines Hilbert curve and QuadTree;

[0048] Step 1.3.1: Node structure: Each node N of HQuadTree contains the following attributes: N.IDR: represents the object ID interval contained in the current node, N.IDR[0] and N.IDR[1] represent the lower and upper bounds of the corresponding ID interval respectively; N.Leaf represents whether it is a leaf node; N.Region: is the region represented by the node N, which is a spatial region represented by the lower left corner coordinate P1=(x1,y1) and the upper right corner coordinate P2=(x2,y2); N.State: represents the Hilbert state of the current node N.

[0049] Step 1.3.2: The root node of the HQuadTree structure represents the entire data space. Each non-leaf node N contains four children, which represent the four equal divisions of the space area corresponding to N. During the construction process, the order and state of the four child nodes are determined according to the node's N.State, so that the i-th child node N.Ni of the node N corresponds to the i-th Quadrant in the Hilbert space, ensuring the consistency of the HQuadTree with the Hilbert curve.

[0050] Given the sample data set in Table 1, the constructed HQuadTree is as follows Figure 4 As shown in the figure, the four child nodes of the root node divide the entire Hilbert space into four equal parts, and each node represents a quadrant of the entire Hilbert space. Since the state of the root node is 0, its four child nodes are arranged in the order of SW, NW, NE, and SE. The first child node of the root node (the blue circular node) corresponds to the lower left quadrant of the Hilbert region. Since the state of this node is 1, its four child nodes are arranged in the order of SW, SE, NE, and NW.

[0051] Step 2: Given a query q, a coarse-grained spatial range query is implemented based on the created index HQuadTree. The ID ranges (IDR) corresponding to all nodes intersecting with q are queried in the dataset D and stored in the result set RS.

[0052] Step 2.1: Query the smallest node that contains q: Starting from the root node N of HQuadTree, determine whether q is contained in a child node N of N i If so, recursively determine whether q is included in N i In a child node of i That is, it is the smallest node that contains q, and this node is denoted as MCN. The depth of the node corresponding to MCN is set to d=0.

[0053] like Figure 4 , starting from the root node, find the smallest node that contains the query area, which is the root node.

[0054] Step 2.2: Since the object interval (IDR) of the MCN node may be large, a limited m-level drill-down is performed on it. By drilling down to return the IDR interval of the child node of the MCN that intersects with q, the IDR range can be effectively narrowed. Since there may be multiple IDR intervals after drilling down, I is used to store these intervals, and adjacent IDRs are merged to reduce the number of intervals.

[0055] Step 2.3: When drilling down, based on the depth-first search, a limited breadth expansion is performed; first, a stack S is introduced. Initially, the MCN node N and its level d=0 are pushed into the stack (ie, S.push(N,0)), and then Step 2.3.1 to Step 2.3.2 are executed.

[0056] Step 2.3.1: If the stack is not empty, pop the top node N and its level d. If N satisfies the following conditions: 1) d = m; 2) N is a leaf node; 3) N is included in q, there is no need to drill down further. Let maxID represent the maximum ID of the last IDR in I. If N.IDR[0]-maxID=1, merge it into the last IDR of I and update maxID←N.IDR[1]. Otherwise, add N.IDR to I, that is, I←I∪N.IDR, and update maxID←N.IDR[1].

[0057] Step 2.3.2: If the top node N does not meet the above conditions, use the following steps to detect N's child node N i (i∈{1,2,3,4}) intersects with q, thereby drilling down the query to layer d=d+1. In order to reduce the number of intersection judgments during detection, the following two steps are performed according to the level of the current node N:

[0058] Step 2.3.2.1: When d = 0, that is, when the current top node of the stack is MCN node N, the FSFO strategy is used for intersection judgment: First, q is intersected with N's child nodes N1 and N2, and f i When it represents node N i The flag indicating whether it intersects with q, 1 means intersecting, 0 means not intersecting. When f1 and f2 are not all 1, we can directly obtain Otherwise f4=f3=O(N.N3,q).

[0059] Step 2.3.2.2: When d>1, that is, when the current top node N is a non-MCN node, that is, when d>0, FSFO is used +The strategy for intersection judgment is: first, make an intersection judgment on q with N1 and N2. If f1f2=11, continue to make a coverage judgment on N3; if f1f2=00, continue to judge whether q and N3 intersect. If f3=1, further judge N4; if f1f2=10 or f1f2=01, it is necessary to add a coverage judgment on N4 or N3.

[0060] Step 2.3.3: Set f i = 1 and its depth d are pressed into S;

[0061] like Figure 3 , given q = <(3,2), (6,3)>, we know that MCN is the root node, and the corresponding object interval IDR is [0,12]. When drilling down to layer l1, calling the FSFO algorithm to obtain N.N1 and N.N4 and q to cover the final I is {[0,3], [9,12]}. The returned ID range is smaller than the IDR [0,12] corresponding to MCN directly. When drilling down further to layer l2, we get [1,2] (corresponding Figure 4 The left-slashed area), [9,9] (corresponding to Figure 4 Middle horizontal line area), [10,11] (corresponding to Figure 4 Since the maximum ID of the second IDR and the minimum ID of the third IDR are adjacent, they can be merged, and the final return value is {[1,2],[9,11]}. When drilling down to level l3, two IDRs [2,2] and [9,11] are returned.

[0062] Step 2.4: Region verification: After the above steps, we get the object interval I composed of multiple segments. Then, we traverse each segment in I in turn and check whether the coordinates of each object O are located in the rectangular query box q. If they are, we add them to the result set RS, that is, RS←RS∪{O};

[0063] For a given data set and query area q, when m = 2, the candidate set C = {1, 2, 9, 10, 11} is obtained by Step 2.3. After verification, it is found that the coordinates of the objects with IDs 1 and 9 are not in q, so the result set RS = {2, 10, 11} is finally returned.

[0064] The specific implementation modes of the present invention are described in detail above with reference to the figures and tables, but the present invention is not limited to the above implementation modes, and various changes can be made within the knowledge scope of ordinary technicians in this field without departing from the purpose of the present invention.

Claims

1. A spatial range query method based on HQuadTree, characterized by: Step 1: In the spatial index construction phase, given the spatial dataset D, construct an index structure HQuadTree that combines the Hilbert curve and QuadTree; Step 2: In the spatial range query phase, given a query q, a coarse-grained spatial range query is implemented based on the created index structure HQuadTree. The ID ranges corresponding to all nodes intersecting with q are queried in the dataset D and stored in the result set RS.

2. A spatial range query method based on HQuadTree according to claim 1, characterized in that: The Step 1 is specifically as follows: Step 1.1: Construct the Hilbert curve state view. The Hilbert curve is a curve that maps multidimensional data to a one-dimensional integer domain. Its first-order state is divided into four states according to the opening direction of the curve: 0 opens downward, 1 opens to the left, 2 opens upward, and 3 opens to the right. Given a first-order state value, the corresponding coordinate values ​​in the four states and the next-order state are as follows: State 0: physical coordinates are (0,0), (0,1), (1,1), (1,0); next-order states: 1, 0, 0, 3; State 1: physical coordinates are (0,0), (1,0), (1,1), (0,1); next-order states: 0, 1, 1, 2; State 2: physical coordinates are (1,1), (1,0), (0,0), (0,1); next-order states: 3, 2, 2, 1; State 3: physical coordinates are (1,1), (0,1), (0,0), (1,0); next-order states: 2, 3, 3, 0; Step 1.2: Reassign object IDs. Renumber the objects in dataset D in the order of Hilbert coding values, and assign IDs ranging from 0 to |D|-1. Step 1.3: Construct the spatial index structure HQuadTree which combines Hilbert curve and QuadTree.

3. A spatial range query method based on HQuadTree according to claim 2, characterized in that: The Step 1.3 is specifically as follows: Step 1.3.1: Each node N of HQuadTree contains the following attributes: N.IDR: indicates the object ID interval contained in the current node. N.IDR[0] and N.IDR[1] respectively indicate the lower and upper bounds of the corresponding ID interval. N.Leaf indicates whether it is a leaf node. N.Region: The region represented by node N, which is a spatial region represented by the lower left corner coordinates P1 = (x1, y1) and the upper right corner coordinates P2 = (x2, y2); N.State: represents the Hilbert state of the current node N; Step 1.3.2: The root node of the HQuadTree structure represents the entire data space. Each non-leaf node N contains four children, which represent the four equal divisions of the spatial area corresponding to N. During the construction process, the order and state of the four child nodes are determined according to the node's N.State, so that the i-th child node N.Ni of the node N corresponds to the i-th Quadrant in the Hilbert space.

4. The spatial range query method according to claim 1, characterized in that: The Step 2 is specifically as follows: Step 2.1: Query the smallest node that contains q. Starting from the root node N of HQuadTree, determine whether q is contained in a child node N of N. i If so, recursively determine whether q is included in N i In a child node of i That is, it is the smallest node that contains q, and this node is called MCN. Let the depth of the node corresponding to MCN be d=0; Step 2.2: Drill down the MCN node to a limited m-layer level, return the object interval IDR of the child node of the MCN that intersects with q by drilling down, narrow the IDR range, use I to store multiple IDR intervals after drilling down, and merge adjacent IDRs to reduce the number of intervals; Step 2.3: When drilling down, based on the depth-first search, a limited breadth expansion is performed; first, a stack S is introduced, and initially, the MCN node N and its level d=0 are pushed into the stack, and then Step 2.3.1 to Step 2.3.2 are executed; Step 2.3.1: If the stack is not empty, pop the top node N and its level d. If N satisfies the following conditions: 1) d = m; 2) N is a leaf node; 3) N is included in q, then there is no need to drill down further. Let maxID represent the maximum ID of the last IDR in I. If N.IDR[0]-maxID=1, merge it into the last IDR of I and update maxID←N.IDR[1]. Otherwise, add N.IDR to I and update maxID←N.IDR[1]; Step 2.3.2: If the top node N does not meet the above conditions, use the following steps to detect N's child node N i (i∈{1,2,3,4}) intersects with q, thereby drilling down the query to layer d=d+1. According to the level of the current node N, the following two steps are performed to reduce the number of intersection judgments: Step 2.3.2.1: When d = 0, the current top node of the stack is MCN node N, and the FSFO strategy is used for intersection judgment: First, q is intersected with N's child nodes N1 and N2, and f i Represents node N i The flag of whether it intersects with q, where 1 means intersecting and 0 means not intersecting. When f1 and f2 are not all 1, directly obtain Otherwise f4 = f3 = O(N.N3,q); Step 2.3.2.2: When d>1, the current top node N is a non-MCN node and FSFO is used. + The strategy is used for intersection judgment: first, q is judged to intersect with N1 and N2. If f1f2=11, N3 is judged to cover. If f1f2=00, q is judged to intersect with N3. If f3=1, N4 is judged. If f1f2=10 or f1f2=01, N4 or N3 is judged to cover. Step 2.3.3: Set f i = 1 and its depth d are pressed into S; Step 2.4: After the above steps, we get the object interval I composed of multiple segments. Then, we traverse each segment in I in turn and check whether the coordinates of each object O are located in the rectangular query box q. If so, we add it to the result set RS.

Citation Information

Patent Citations

  • Spatio-temporal data indexing method in non-relational database

    CN107423368A

  • Efficient space keyword query method based on association rule mining

    CN116501775A