Spatial region retrieval matching method, device, equipment, storage medium and product
By constructing an R-tree index and optimizing vector calculations, the problem of real-time matching under large-scale AOI was solved, achieving fast and accurate spatial region retrieval and matching, and improving query efficiency and throughput.
Patent Information
- Application Number
- CN202611278787.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-21
- Publication Date
- 2026-11-27
AI Technical Summary
Existing technologies, when faced with massive AOIs and ultra-high concurrency query requests, traverse all AOIs one by one and perform ray casting calculations, resulting in huge computational overhead and failing to meet the real-time matching requirements of large-scale AOIs.
An R-tree spatial index structure is constructed, candidate entities are filtered by querying bounding boxes, visibility is determined by combining the cosine of the included angle and spatial distance, entity matching is optimized by using Euclidean distance and an improved R-tree node splitting strategy, and a vector calculation optimization mechanism is introduced for accurate matching.
It enables fast and accurate spatial region retrieval and matching under large-scale AOI, meets real-time requirements, reduces computational load, and improves query efficiency and throughput.
Smart Images

Figure CN123178699A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of spatial indexing and data processing technology, and in particular to a spatial region retrieval and matching method, apparatus, device, storage medium, and product. Background Technology
[0002] With the widespread application of LBS (Location Based Services), how to quickly determine whether a user's coordinates, such as GPS (Global Positioning System) coordinates, are located within a preset AOI (Area of Interest, also known as a regional geographic area or electronic fence) has become a key technical requirement for high-concurrency real-time location service applications, such as electronic fence alarms and location-based personalized recommendations.
[0003] Currently, the main algorithm used is the Point-in-Polygon (PIP) matching algorithm, such as the ray casting method, to determine whether the user's coordinates fall within a preset Area of Interest (AOI). However, when faced with a massive number of AOIs and extremely high concurrent query requests, traversing all AOIs one by one and performing ray casting calculations on each AOI results in enormous computational overhead, which cannot meet the real-time matching requirements of large-scale AOIs. Summary of the Invention
[0004] To address the problems existing in the prior art, embodiments of the present invention provide a spatial area retrieval and matching method, apparatus, device, storage medium, and product, which can realize rapid AOI retrieval and matching and meet the real-time matching requirements under large-scale AOI.
[0005] In a first aspect, embodiments of the present invention provide a spatial region retrieval and matching method, including: Construct a query bounding box based on the first location information and the first field of view parameter of the query object; Based on the query bounding box, a pre-constructed R-tree spatial index structure is queried to filter out candidate entities corresponding to the smallest bounding box that intersects with the query bounding box, thus obtaining a candidate entity set; wherein, the R-tree spatial index structure is used to store the smallest bounding box of each entity, and the smallest bounding box is used to indicate the spatial coverage area of the corresponding entity; Based on the first location information of the query object and the second location information of each candidate entity in the candidate entity set, calculate the cosine value of the angle between the query object and each of the candidate entities and the spatial distance; Based on the cosine of the angle between the query object and each of the candidate entities and the spatial distance, the visibility of the target entity within the field of view of the query object is determined, and the target entity is selected from the candidate entities.
[0006] As an improvement to the above solution, the method further includes: Based on the coverage geometry information of each entity, the minimum bounding box of each entity is calculated; wherein, the coverage geometry information includes: the second position information, boundary radius, and second field of view parameter of the entity; An R-tree spatial index structure is constructed using the minimum bounding box and entity identifier of each entity as index entries.
[0007] As an improvement to the above scheme, before calculating the cosine of the angle and the spatial distance between the query object and each of the candidate entities, the method further includes: Based on the first location information of the query object and the second location information of each candidate entity in the candidate entity set, calculate the Euclidean distance between the query object and each of the candidate entities. Based on the Euclidean distance between the query object and each of the candidate entities, candidate entities whose Euclidean distance exceeds the preset field of view distance are excluded, resulting in a filtered set of candidate entities.
[0008] As an improvement to the above scheme, based on the first location information of the query object and the second location information of each candidate entity in the candidate entity set, the cosine value of the angle between the query object and each of the candidate entities and the spatial distance are calculated, including: Based on the first location information of the query object and the second location information of each candidate entity, calculate the relative position vector from the query object to each candidate entity; Based on the orientation unit vector of the query object and the relative position vector of each candidate entity, calculate the cosine value of the angle between the query object and each candidate entity; Based on the first location information of the query object and the second location information of each candidate entity, the spatial distance between the query object and each candidate entity is calculated.
[0009] As an improvement to the above scheme, visual visibility is determined based on the cosine of the angle between the query object and each of the candidate entities and the spatial distance, and target entities within the visual range of the query object are selected from the candidate entities, including: Compare the cosine of the angle between the query object and each of the candidate entities with the cosine of the field of view angle of the query object; wherein, the first field of view parameter includes the field of view angle and the field of view distance; Compare the spatial distance between the query object and each of the candidate entities with the visual distance of the query object; Candidate entities whose included angle cosine value is greater than or equal to the field of view angle cosine value and whose spatial distance is less than or equal to the field of view distance are selected as target entities.
[0010] As an improvement to the above solution, the method further includes: When any entity moves, detect whether the corresponding entity crosses the node boundary of the source R-tree node in which it resides; wherein, the node boundary is used to indicate the outer minimum bounding box of the minimum bounding box of all entities within the corresponding R-tree node. If not, update the second location information of the corresponding entity; If so, update the second location information of the corresponding entity and migrate the index entry of the corresponding entity from the source R-tree node to the target R-tree node; wherein the updated second location information of the corresponding entity and its minimum bounding box fall within the range of the outer minimum bounding box of the target R-tree node.
[0011] Secondly, embodiments of the present invention provide a spatial region retrieval and matching device, comprising: The query bounding box construction module is used to construct the query bounding box based on the first location information and the first field of view parameter of the query object; The R-tree retrieval module is used to query a pre-built R-tree spatial index structure based on the query bounding box, and filter out candidate entities corresponding to the smallest bounding box that intersects with the query bounding box to obtain a set of candidate entities; wherein, the R-tree spatial index structure is used to store the smallest bounding box of each entity, and the smallest bounding box is used to indicate the spatial coverage area of the corresponding entity. The location vector calculation module is used to calculate the cosine of the angle between the query object and each of the candidate entities and the spatial distance based on the first location information of the query object and the second location information of each candidate entity in the candidate entity set. The visibility determination module is used to determine visibility based on the cosine of the angle between the query object and each of the candidate entities and the spatial distance, and to filter out the target entity within the range of the query object from the candidate entities.
[0012] Thirdly, embodiments of the present invention provide a spatial region retrieval and matching device, comprising: a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to implement the spatial region retrieval and matching method as described in any one of the first aspects.
[0013] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the spatial region retrieval and matching method as described in any one of the first aspects.
[0014] Fifthly, embodiments of the present invention provide a computer program product, including a computer program or instructions, which, when executed by a processor, implement the spatial region retrieval and matching method as described in any one of the first aspects.
[0015] Compared to existing technologies, this invention provides a spatial region retrieval and matching method, apparatus, device, storage medium, and product. It constructs a query bounding box based on the first location information and first field-of-view parameters of the query object; then, it queries a pre-constructed R-tree spatial index structure based on the query bounding box to filter out candidate entities corresponding to the smallest bounding box intersecting the query bounding box, thus obtaining a candidate entity set. The R-tree spatial index structure stores the smallest bounding box of each entity, and the smallest bounding box indicates the spatial coverage area of the corresponding entity. Next, based on the first location information of the query object and the second location information of each candidate entity in the candidate entity set, it calculates the cosine of the angle between the query object and each candidate entity and the spatial distance. Finally, it performs a field-of-view visibility determination based on the cosine of the angle between the query object and each candidate entity and the spatial distance, filtering out target entities within the field of view of the query object from the candidate entities. This enables rapid AOI retrieval and matching, meeting the real-time matching requirements of large-scale AOI. Attached Figure Description
[0016] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a flowchart of a spatial region retrieval and matching method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the R-tree spatial index structure provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of vector calculation optimization provided in an embodiment of the present invention; Figure 4 This is a flowchart of the dynamic update strategy provided in an embodiment of the present invention; Figure 5This is an overall flowchart of AOI fast retrieval and matching based on R-tree indexing and vector calculation optimization provided in the embodiments of the present invention; Figure 6 This is a structural block diagram of a spatial region retrieval and matching device provided in an embodiment of the present invention; Figure 7 This is a structural block diagram of a spatial region retrieval and matching device provided in an embodiment of the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] It is understood that the various numerical designations used in the embodiments of this invention are merely for descriptive convenience and are not intended to limit the scope of this application. The order of the process numbers does not imply the order of execution; the execution order of each process should be determined by its function and internal logic.
[0020] In embodiments of the invention, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, without necessarily requiring or implying any such actual relationship or order between these entities or operations. The terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising" does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element. The term "a plurality or several" refers to two or more.
[0021] See Figure 1 , Figure 1 This is a flowchart of a spatial region retrieval and matching method provided in an embodiment of the present invention. The spatial region retrieval and matching method specifically includes: S11: Construct a query bounding box based on the first location information and the first field of view parameter of the query object; The query object can be a user, an intelligent sensing device such as a robot, or a virtual character, etc., and is not limited in this embodiment of the invention.
[0022] The first field of view parameters include the field of view angle and the field of view distance, which can be customized. For example, the field of view angle can be set to 120° and the field of view distance can be set to 5 meters. The first location information of the query object is the current location coordinates of the query object, such as latitude and longitude. Specifically, it can be determined according to the different types and locations of the query object, such as through GPS positioning, indoor Bluetooth positioning, virtual scene coordinate reading, etc., and is not limited in this embodiment of the invention.
[0023] In this embodiment of the invention, taking the user as the query object as an example, and using the user's field of vision distance as the radius and the field of vision angle as the total subtended angle, a field of vision region centered on the location coordinates of the query object can be constructed according to the user's orientation. The smallest bounding rectangle enclosing this field of vision region is the query bounding box of the query object. This query bounding box defines the maximum area that the query object may see and is the basis for subsequent retrieval operations. For a circular field of vision, such as a field of vision angle of 360°, the query bounding box is a square or cube centered on the query object with a side length of twice the field of vision distance. For a sector or cone-shaped field of vision, such as a field of vision angle of 120°, the query bounding box is the smallest bounding rectangle or cube of a sector or cone region centered on the query object with a radius equal to the field of vision distance.
[0024] For example, a user can send a query request to find the three gas stations with the lowest prices within a 5-kilometer radius. A square query bounding box can then be constructed, centered on the user and with sides 10 times the field of view. This query bounding box will be used for R-tree retrieval, which can quickly narrow down the candidate entity range. Further, the AOI boundary information data corresponding to the query bounding box is shown in the table below:
[0025] The specific calculation process for the query bounding box is as follows: Get the location coordinates and distance from the viewpoint of the queried object; Subtract the view distance from the x-coordinate of the query object's location to obtain the minimum x-coordinate of the bounding box; Add the view distance to the x-coordinate of the query object's location to obtain the maximum x-coordinate of the bounding box; Subtract the view distance from the ordinate of the query object's location to obtain the minimum ordinate of the bounding box; Add the view distance to the ordinate of the query object's location to obtain the maximum ordinate of the bounding box; The query bounding box is composed of the minimum x-coordinate, the maximum x-coordinate, the minimum y-coordinate, and the maximum y-coordinate.
[0026] S12: Based on the query bounding box, query the pre-built R-tree spatial index structure to filter out candidate entities corresponding to the smallest bounding box that intersects with the query bounding box, and obtain a set of candidate entities; wherein, the R-tree spatial index structure is used to store the smallest bounding box of each entity, and the smallest bounding box is used to indicate the spatial coverage area of the corresponding entity; The entities can be communication devices with spatial coverage capabilities, such as base stations, wireless access points, IoT gateways, signal repeaters, and edge communication nodes, but this embodiment of the invention does not limit them.
[0027] In this embodiment of the invention, a base station is used as an example. An R-tree spatial index structure is constructed using the R-tree index algorithm to store the minimum bounding box corresponding to the spatial coverage area of all entities. Similarly, the minimum bounding box can be represented by the coordinates of the four vertex corners of the bounding box. For details, please refer to the query bounding box above. It will not be repeated here.
[0028] Furthermore, this R-tree spatial index structure can also store all spatial information of an entity, including minimum bounding box, entity identifier, boundary radius, viewing angle, orientation angle, secondary location information, etc., and use the minimum bounding box and entity identifier as index entries; subsequently, related entities can be found by searching and matching the minimum bounding box and / or searching the entity identifier.
[0029] S13: Based on the first location information of the query object and the second location information of each candidate entity in the candidate entity set, calculate the cosine value of the angle between the query object and each of the candidate entities and the spatial distance; S14: Based on the cosine of the angle between the query object and each of the candidate entities and the spatial distance, visual visibility is determined, and target entities within the visual range of the query object are selected from the candidate entities.
[0030] This invention uses a query bounding box as the retrieval window to search for the smallest bounding box in the R-tree spatial index structure. It initially filters out entities corresponding to the smallest bounding boxes intersecting with the query bounding box as candidate entities, obtaining a candidate entity set. Then, based on the current location coordinates of the query object (first location information) and the location coordinates of the candidate entities (second location information), it calculates the cosine of the angle between them and the spatial distance to determine visibility. It determines whether a candidate entity is within the query object's field of view; if so, it is considered a target entity; otherwise, it is not. By traversing all candidate entities in the candidate entity set, all target entities within the query object's field of view can be found. The geographical location covered by the smallest bounding box corresponding to these target entities is the user's Region of Interest (AOI), thus completing the AOI spatial region retrieval and matching. This invention, through R-tree index construction, can quickly filter candidate entities, narrowing the scope of entity matching and reducing subsequent matching calculations. The visibility determination based on the cosine of the angle and spatial distance enables fast and accurate matching of AOI spatial regions, meeting the real-time matching requirements of large-scale AOIs.
[0031] Furthermore, the method also includes: Based on the coverage geometry information of each entity, the minimum bounding box of each entity is calculated; wherein, the coverage geometry information includes: the second position information, boundary radius, and second field of view parameter of the entity; An R-tree spatial index structure is constructed using the minimum bounding box and entity identifier of each entity as index entries.
[0032] For example, firstly, spatial information of all base station entities is collected, including but not limited to: the current location coordinates of the base station, i.e., the second location information, such as latitude and longitude; the boundary radius of the base station, such as the effective signal coverage radius of the base station; the second field-of-view parameters of the base station, such as the field-of-view angle of the base station, which can be determined based on the horizontal lobe angle of the base station's antenna signal; and entity identifiers, such as the base station identifier. Then, all location coordinates are transformed into a unified coordinate system to ensure that the entire system uses a consistent coordinate reference system. For each entity, a minimum bounding box is calculated based on its location coordinates and boundary radius. This is the smallest rectangular or cubic region that can completely contain the signal coverage area of the base station. For specific calculations, please refer to the calculation of the query bounding box above, which will not be repeated here.
[0033] The calculation of the minimum bounding box lays the foundation for the subsequent construction of the R-tree spatial index structure. The detailed base station cell resource dimension table is shown in the table below:
[0034] After the above preprocessing, standardized entity spatial information for each base station entity can be obtained, as shown in the table below:
[0035] Then, based on the standardized entity spatial information, the entities are represented by minimum bounding rectangles (MBRs). These minimum bounding rectangles are then organized hierarchically using an R-tree to construct an R-tree spatial index structure.
[0036] It is understood that an R-tree is a balanced tree structure used to index multidimensional spatial data. This invention employs an improved variant of the R-tree, such as R... - Tree variants construct R tree-space index structures. R - The tree variant considers overlapping area and perimeter factors when splitting nodes, resulting in a better index structure; the construction process starts by creating an empty root node, and then inserts the minimum bounding boxes of entities one by one; when the node capacity reaches the upper limit, that is, when the number of minimum bounding boxes inserted by the node reaches the preset maximum value, R... The tree does not split immediately; instead, it first attempts to force a re-insertion. If the node still overflows after re-insertion, a split operation is performed, thus proactively optimizing the tree structure and ensuring the tree remains balanced.
[0037] Forced Reinsertion: Removes p = 30% of the entries from the overflow node N, which are the minimum bounding boxes of the entities. The removed entries are not randomly selected, but rather those whose center point is furthest from the center of the outer minimum bounding box of node N, i.e., outliers. These removed entries are then reinserted into the tree like new entries. Here, p represents the proportion of the node's maximum capacity to the number of entries participating in forced reinsertion.
[0038] Multidimensional Sort-Based Split Algorithm: If splitting is necessary, R... - The tree uses the following strategy to find the optimal split axis and split point: Step 1: Sort along each axis. For a set of M+1 entries to be split, sort along both the X and Y axes. There are two possible sorting strategies: Sort by lower bound of dimension: sort_by(entry.min_x) and sort_by(entry.min_y); sort by the minimum bounding box of the entity in ascending order and then in descending order; Sort by dimension center point: sort_by((entry.min_x+entry.max_x) / 2) and sort_by((entry.min_y+entry.max_y) / 2); the mean values of the minimum and maximum x-coordinates, minimum and maximum y-coordinates of the entity's bounding box are sorted in ascending order and then in descending order. Both strategies described above yield two sorted lists: an ordered list S_x obtained by sorting along the X-axis and an ordered list S_y obtained by sorting along the Y-axis.
[0039] Step 2: Generate candidate distribution schemes. For each sorted list (S_x and S_y), try (k, M+1-k) distribution schemes. Here, k usually ranges from [m, M+1-m], representing the number of entries taken from the front of the sorted list and assigned to the first child node; M represents the maximum capacity of the node; m is the minimum fill factor of the node, usually m=0.4M.
[0040] For example, if M=50 and m=20, then for each axis, 11 distribution schemes will be tried, with k ranging from 20 to 30, meaning the split point is after the kth entry. There are 11 such schemes for both axes. There are 22 candidate solutions.
[0041] Step 3: Select the optimal distribution scheme. For each candidate distribution scheme, i.e., a specific axis and a split point k, divide the entries into two groups: Group1={entries[1..k]} and Group2={entries[k+1..M+1]}. Then calculate the following three optimization metrics: Overlap-Value: overlap_value=area(MBR(Group1)∩MBR(Group2)), where MBR(Group1) and MBR(Group2) represent the minimum bounding boxes of Group 1 and Group 2, respectively. That is, the overlap-value is equal to the area of the intersection of the minimum bounding boxes of the two groups after splitting. Total area (area_value): area_value = area(MBR(Group1)) + area(MBR(Group2)), that is, the total area is equal to the sum of the areas of the two smallest bounding boxes after splitting; Total perimeter (margin_value): margin_value = margin(MBR(Group1)) + margin(MBR(Group2)), that is, the total perimeter is equal to the sum of the perimeters of the two smallest bounding boxes after splitting.
[0042] Step 4: Choose a strategy. First, select the option with the smallest overlap value among all candidate options.
[0043] If there is a tie, that is, multiple solutions have the same overlap value, then the solution with the smallest total area among these tie solutions is selected.
[0044] If the score is tied again, choose the option with the smallest total perimeter.
[0045] If the score is still tied, you can choose any option, such as the option with the smallest k.
[0046] In this embodiment of the invention, an empty R-tree is initialized, and by traversing each entity, the minimum bounding box and entity identifier of the entity are extracted. Following the above process, the insertion operation is performed one by one. After all entities are inserted, a usable R-tree spatial index structure is obtained.
[0047] The R-tree spatial index structure consists of several R-tree nodes. The node structure is defined as follows: A boolean flag is used to distinguish leaf nodes from intermediate nodes; intermediate nodes maintain a list of child nodes and record the overall minimum bounding box corresponding to all child objects; leaf nodes no longer contain child nodes, but instead store a list of entity numbers, and record the overall minimum bounding box of the group of entities as well as the minimum bounding box of each individual entity, such as... Figure 2 As shown.
[0048] The calculation process for the minimum bounding rectangle (MBR) of each R-tree node in the R-tree spatial index structure is as follows: Iterate through all child objects of the node, such as entities and child nodes, and collect the lower bound of the X-axis of all child objects, i.e. the minimum horizontal coordinate, as the minimum horizontal coordinate of the outermost bounding rectangle of the node. Traverse all child objects of the node and collect the upper bound of the X-axis of all child objects, i.e. the maximum x-coordinate, as the maximum x-coordinate of the minimum bounding rectangle of the outermost bounding rectangle of the node. Traverse all child objects of the node and collect the lower bound of the Y-axis of all child objects, i.e. the minimum ordinate, as the minimum ordinate of the outermost bounding rectangle of the node; Traverse all child objects of the node and collect the upper Y-axis bound of all child objects, i.e. the maximum ordinate, as the maximum ordinate of the minimum bounding rectangle of the node's outer wrapper. The minimum bounding box of a node is formed by the minimum x-coordinate, maximum x-coordinate, minimum y-coordinate, and maximum y-coordinate of its outer minimum bounding rectangle.
[0049] This invention's embodiments construct an improved R-tree index, such as R... - The R-tree, relying on an optimized node splitting strategy and a forced re-insertion mechanism, effectively reduces the overlap between the minimum bounding boxes of index nodes. This can reduce unnecessary branch traversal during spatial range queries, quickly filter out candidate sets of spatially intersecting entities, and improve the efficiency of large-scale AOI region matching retrieval. At the same time, the R-tree index structure has a relatively low memory footprint and can also be stored using memory mapping, making it suitable for processing large-scale spatial data scenarios and adaptable to the needs of large-scale spatial data processing.
[0050] Furthermore, before calculating the cosine of the angle between the query object and each of the candidate entities and the spatial distance, the method further includes: Based on the first location information of the query object and the second location information of each candidate entity in the candidate entity set, calculate the Euclidean distance between the query object and each of the candidate entities. Based on the Euclidean distance between the query object and each of the candidate entities, candidate entities whose Euclidean distance exceeds the preset field of view distance are excluded, resulting in a filtered set of candidate entities.
[0051] In this embodiment of the invention, after constructing the R-tree spatial index structure, all entity minimum bounding boxes intersecting with the query bounding box can be quickly retrieved. The R-tree, through its hierarchical structure, efficiently excludes minimum bounding boxes that cannot intersect, significantly reducing the number of entities that need to be checked.
[0052] Specifically, starting from the root node, the algorithm recursively checks whether the minimum bounding box (MBR) of each node intersects with the query bounding box. If they intersect, it continues to check their child nodes; if they do not intersect, the entire subtree is excluded, eventually reaching the leaf node, where the entity identifiers corresponding to all MBRs that intersect with the query bounding box are collected. The entities corresponding to the MBRs that intersect with the query bounding box are used as candidate entities, and a candidate entity set is constructed for subsequent visibility determination.
[0053] In this embodiment of the invention, the query bounding box is used as the AOI region to be queried. Using R-tree query, all entities intersecting with the query bounding box can be quickly retrieved, candidate entities can be initially screened, the number of entities to be processed can be reduced, and query efficiency can be improved.
[0054] After the initial filtering and coarse screening described above, the resulting set of candidate entities may still be large. To quickly reduce the number of entities requiring fine-grained calculations, we first filter based on the Euclidean distance between the query object and each candidate entity, excluding those candidate entities that are clearly outside the query object's field of vision. For candidate entities with directional fields of vision, such as fan-shaped or cone-shaped fields of vision, R-tree retrieval can also perform coarse directional filtering to exclude those candidate entities that are clearly not in the field of vision direction.
[0055] The Euclidean distance is calculated as follows: (1); Among them, (x) A y A , z A ), (x B y B , z B ) represent the location coordinates of query object A and candidate entity B, respectively.
[0056] In an optional embodiment, based on the first location information of the query object and the second location information of each candidate entity in the candidate entity set, the cosine value of the angle between the query object and each of the candidate entities and the spatial distance are calculated, including: Based on the first location information of the query object and the second location information of each candidate entity, calculate the relative position vector from the query object to each candidate entity; Based on the orientation unit vector of the query object and the relative position vector of each candidate entity, calculate the cosine value of the angle between the query object and each candidate entity; Based on the first location information of the query object and the second location information of each candidate entity, the spatial distance between the query object and each candidate entity is calculated.
[0057] To achieve accurate matching of AOI regions, this invention introduces a vector calculation optimization mechanism for precise matching, such as... Figure 3 As shown, the specific process is as follows: Calculate the relative position vector: Calculate the relative position vector from query object A to candidate entity B, and normalize this relative position vector to a unit vector. The relative position vector represents the positional relationship of subsequent entity B relative to query object A. Normalization facilitates subsequent direction calculation and comparison. This calculation provides basic data for subsequent view direction determination. The calculation process of the relative position vector is as follows: (2); Relative position vector normalization: (3); in, This represents the distance from the query object A to the candidate entity B.
[0058] Calculation of the angle of view direction; by calculating the orientation unit vector of the query object A. dot product with the normalized relative position vector This yields the cosine value of the angle between the two vectors. This cosine value reflects the directional relationship between the candidate entity B and the query object A.
[0059] Cosine value of included angle The calculation is as follows: (4); in, These represent the orientation unit vectors of query object A. The magnitude of the normalized relative position vector.
[0060] Since the relative position vector has been normalized, formula (4) simplifies to: (5); Specifically, visibility is determined based on the cosine of the angle between the query object and each of the candidate entities and the spatial distance, and target entities within the visual field of the query object are selected from the candidate entities, including: Compare the cosine of the angle between the query object and each of the candidate entities with the cosine of the view angle of the query object; Compare the spatial distance between the query object and each of the candidate entities with the visual distance of the query object; Candidate entities whose included angle cosine value is greater than or equal to the field of view angle cosine value and whose spatial distance is less than or equal to the field of view distance are selected as target entities.
[0061] Based on the above calculation, the cosine value of the included angle Spatial distance, such as Euclidean distance, is used to determine whether a candidate entity is within the view of the query object.
[0062] First, calculate the cosine value of the field of view angle based on the field of view angle of the query object. For example, the cosine value of the field of view angle corresponding to a 120° field of view angle is cos(field of view angle / 2) = cos60° = 0.5. Then, compare whether the cosine value of the included angle is greater than or equal to this cosine value of the field of view angle.
[0063] At the same time, check whether the spatial distance is less than or equal to the visual distance of the queried object.
[0064] Only candidate entities that simultaneously meet the direction condition (that is, the cosine of the included angle is greater than or equal to the cosine of the field of view angle) and the distance condition (that is, the spatial distance is less than or equal to the field of view distance of the query object) are identified as visible target entities.
[0065] The embodiments of the present invention optimize vector calculation as described above, taking into account not only the distance between entities, but also factors such as direction and field of view shape, making AOI matching more accurate; at the same time, the R-tree index and vector calculation optimization algorithm support distributed deployment, which can dynamically adjust the computing load according to entity density and adapt to virtual environments of different scales.
[0066] Furthermore, the method also includes: When any entity moves, detect whether the corresponding entity crosses the node boundary of the source R-tree node in which it resides; wherein, the node boundary is used to indicate the outer minimum bounding box of the minimum bounding box of all entities within the corresponding R-tree node. If not, update the second location information of the corresponding entity; If so, update the second location information of the corresponding entity and migrate the index entry of the corresponding entity from the source R-tree node to the target R-tree node; wherein the updated second location information of the corresponding entity and its minimum bounding box fall within the range of the outer minimum bounding box of the target R-tree node.
[0067] In this embodiment of the invention, when an entity moves, it is necessary to detect whether it crosses the boundary of an R-tree node in order to perform dynamic updates and incremental retrieval of the R-tree spatial index structure, such as... Figure 4 As shown. If an entity moves only within the same node, only the entity's position coordinates, i.e., the second position information, need to be updated. If the entity crosses the node boundary, in addition to updating the entity's position coordinates, i.e., the second position information, the R-tree spatial index structure also needs to be updated. The entity is removed from the old node and added to the new node to ensure that the R-tree spatial index structure always reflects the latest spatial distribution of the entity, providing an accurate basis for subsequent retrieval operations.
[0068] Specifically, based on the old position coordinates of the moved entity, find its currently inserted node, i.e., the old node; Based on the new position coordinates of the moved entity, find the node it has now fallen into, i.e., the new node; Determine if the old node and the new node are the same node: If not, it means that the entity moved across the node boundary of its R-tree node, that is, beyond the range covered by the minimum bounding box of the R-tree node. Remove the entity identifier from the old node; update the entity's position coordinates and minimum bounding box; add the entity identifier and its minimum bounding box to the new node; If so, it means that the entity is only moving within the same node, and only the entity's position coordinates and minimum bounding box are updated.
[0069] Furthermore, when entity movement causes changes in node boundaries—for example, if the minimum bounding box of an entity moving to a new node is not completely contained within the new node's outer minimum bounding box (MBR), resulting in overlap; or if the old node after the moved entity is removed, or an entity moving within the same old node causes the old node's outer minimum bounding box to shrink—an incremental update is performed on the affected nodes / regions to avoid global reconstruction of the R-tree index. Specifically, it checks whether the affected nodes need rebalancing, such as splitting or merging. If so, the corresponding adjustment operations are performed. The update operation starts from the leaf nodes and propagates upwards to the root node, updating the outer minimum bounding boxes (MBR) of all nodes along the path. For details on the forced reinsertion and multidimensional sorting splitting mechanisms described above, these will not be repeated here.
[0070] Furthermore, after completing the incremental update of the R-tree index, the visible target entities can be updated based on the updated R-tree spatial index structure.
[0071] Compared to existing technologies, the embodiments of this invention utilize R-tree indexing and vector calculation optimization for fast AOI retrieval and matching, such as... Figure 5 As shown, by improving the node splitting strategy and insertion algorithm of the R-tree, an index tree with lower MBR overlap and better tree height is constructed. This allows for faster and more accurate location of the fewest candidate entities during the retrieval phase, significantly reducing the number of candidate entities requiring precise calculation. Simultaneously, a multi-level fast pre-judgment mechanism is introduced, such as Euclidean distance filtering and R-tree filtering, to pre-determine or eliminate a large number of candidates with minimal computational cost. Subsequent vector calculations are only performed on uncertain subsequent entities, greatly reducing computational load. Visibility determination through vector calculations accurately filters out target entities deemed visible, significantly improving retrieval speed and computational efficiency. This effectively addresses the retrieval problems of massive AOI data and solves the efficiency bottleneck problem of spatial queries in large-scale virtual environments.
[0072] The embodiments of the present invention reduce the number of candidate sets through efficient R-tree indexing and optimize vector calculation, thereby reducing the CPU time and computing resource consumption of a single query request. This enables the entire system to process more concurrent requests with fewer resources, achieving low latency and high throughput service capabilities.
[0073] The optimizations in this embodiment of the invention do not depend on specific hardware, and its vectorization part can automatically benefit from the enhancement of the CPU instruction set. This design enables the algorithm to have good forward compatibility and scalability, and improves the algorithm's versatility and scalability.
[0074] See Figure 6 , Figure 6 This is a structural block diagram of a spatial region retrieval and matching device provided in an embodiment of the present invention. The spatial region retrieval and matching device includes: The query bounding box construction module 11 is used to construct a query bounding box based on the first location information and the first field of view parameter of the query object; R-tree retrieval module 12 is used to query a pre-constructed R-tree spatial index structure based on the query bounding box, filter out candidate entities corresponding to the smallest bounding box that intersects with the query bounding box, and obtain a candidate entity set; wherein, the R-tree spatial index structure is used to store the smallest bounding box of each entity, and the smallest bounding box is used to indicate the spatial coverage area of the corresponding entity. The location vector calculation module 13 is used to calculate the cosine value of the angle between the query object and each of the candidate entities and the spatial distance based on the first location information of the query object and the second location information of each candidate entity in the candidate entity set. The visibility determination module 14 is used to determine the visibility based on the cosine of the angle between the query object and each of the candidate entities and the spatial distance, and to filter out the target entity within the range of the query object from the candidate entities.
[0075] In an optional embodiment, the device further includes: The entity bounding box calculation module is used to calculate the minimum bounding box of each entity based on the coverage geometry information of each entity; wherein, the coverage geometry information includes: the second position information, boundary radius, and second field of view parameter of the entity; The R-tree building module is used to construct an R-tree spatial index structure using the minimum bounding box and entity identifier of each entity as index entries.
[0076] In an optional embodiment, the device further includes: The Euclidean distance calculation module is used to calculate the Euclidean distance between the query object and each of the candidate entities based on the first position information of the query object and the second position information of each candidate entity in the candidate entity set before calculating the cosine value of the included angle and the spatial distance between the query object and each of the candidate entities. The entity filtering module is used to exclude candidate entities whose Euclidean distance exceeds a preset field of view distance based on the Euclidean distance between the query object and each of the candidate entities, thereby obtaining a filtered set of candidate entities.
[0077] In one optional embodiment, the position vector calculation module 13 includes: The relative position vector calculation unit is used to calculate the relative position vector from the query object to each candidate entity based on the first position information of the query object and the second position information of each candidate entity. The cosine angle calculation unit is used to calculate the cosine angle between the query object and each candidate entity based on the orientation unit vector of the query object and the relative position vector of each candidate entity. The spatial distance calculation unit is used to calculate the spatial distance between the query object and each of the candidate entities based on the first location information of the query object and the second location information of each candidate entity.
[0078] In one optional embodiment, the field-of-view visibility determination module 14 includes: The first comparison unit is used to compare the cosine value of the angle between the query object and each of the candidate entities and the cosine value of the field of view angle of the query object; wherein, the first field of view range parameter includes the field of view angle and the field of view distance; The second comparison unit is used to compare the spatial distance between the query object and each of the candidate entities and the visual distance of the query object; The entity matching unit is used to filter out candidate entities whose included angle cosine value is greater than or equal to the field angle cosine value and whose spatial distance is less than or equal to the field distance, and use them as target entities.
[0079] In an optional embodiment, the device further includes: The node boundary detection module is used to detect whether an entity crosses the node boundary of its source R-tree node when any entity moves; wherein, the node boundary is used to indicate the outer minimum bounding box of the minimum bounding box of all entities within the corresponding R-tree node. The first update module is used to update the second position information of the corresponding entity if not; The second update module is used to update the second position information of the corresponding entity if the condition is met, and to migrate the index entry of the corresponding entity from the source R-tree node to the target R-tree node; wherein the updated second position information of the corresponding entity and its minimum bounding box fall within the range of the outer minimum bounding box of the target R-tree node.
[0080] It should be noted that the working process of each module in the spatial region retrieval and matching device described in the embodiments of the present invention can refer to the working process of the spatial region retrieval and matching method described in the above embodiments, and the technical effect achieved is the same as that of the spatial region retrieval and matching method described in the above embodiments, so it will not be repeated here.
[0081] See Figure 7 , Figure 7This is a structural block diagram of a spatial region retrieval and matching device provided in an embodiment of the present invention. The spatial region retrieval and matching device includes a processor 21, a memory 22, and a computer program stored in the memory 22 and executable on the processor 21. When the processor 21 executes the computer program, it implements the steps in the above-described embodiments of the spatial region retrieval and matching methods, such as steps S11 to S14.
[0082] For example, the computer program may be divided into one or more modules or units, which are stored in the memory 22 and executed by the processor 21 to complete the present invention. The one or more modules or units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in retrieving matching devices in the spatial region.
[0083] The spatial region retrieval and matching device may include, but is not limited to, a processor 21 and a memory 22. Those skilled in the art will understand that the schematic diagram is merely an example of a spatial region retrieval and matching device and does not constitute a limitation on the device. It may include more or fewer components than illustrated, or combine certain components, or use different components. For example, the spatial region retrieval and matching device may also include input / output devices, network access devices, buses, etc.
[0084] The processor 21 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor. The processor 21 is the control center of the spatial region retrieval and matching device, connecting various parts of the device via various interfaces and lines.
[0085] The memory 22 can be used to store the computer programs and / or modules. The processor 21, by running or executing the computer programs and / or modules stored in the memory 22 and calling the data stored in the memory 22, realizes various functions of the spatial region retrieval and matching device. The memory 22 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.), etc. In addition, the memory 22 may include high-speed random access memory, and may also include non-volatile memory, such as hard disk, memory, plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0086] If the modules or units integrated into the spatial region retrieval and matching device are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by the processor 21, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc.
[0087] It should be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be specifically implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without any creative effort.
[0088] The above description represents the preferred embodiments of the present invention. It should be noted that, for those skilled in the art, various improvements and modifications can be made without departing from the principles of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A spatial region retrieval and matching method, characterized in that, include: Construct a query bounding box based on the first location information and the first field of view parameter of the query object; Based on the query bounding box, a pre-constructed R-tree spatial index structure is queried to filter out candidate entities corresponding to the smallest bounding box that intersects with the query bounding box, thus obtaining a candidate entity set; wherein, the R-tree spatial index structure is used to store the smallest bounding box of each entity, and the smallest bounding box is used to indicate the spatial coverage area of the corresponding entity; Based on the first location information of the query object and the second location information of each candidate entity in the candidate entity set, calculate the cosine value of the angle between the query object and each of the candidate entities and the spatial distance; Based on the cosine of the angle between the query object and each of the candidate entities and the spatial distance, the visibility of the target entity within the field of view of the query object is determined, and the target entity is selected from the candidate entities.
2. The spatial region retrieval and matching method as described in claim 1, characterized in that, The method further includes: Based on the coverage geometry information of each entity, the minimum bounding box of each entity is calculated; wherein, the coverage geometry information includes: the second position information, boundary radius, and second field of view parameter of the entity; An R-tree spatial index structure is constructed using the minimum bounding box and entity identifier of each entity as index entries.
3. The spatial region retrieval and matching method as described in claim 1, characterized in that, Before calculating the cosine of the angle and the spatial distance between the query object and each of the candidate entities, the method further includes: Based on the first location information of the query object and the second location information of each candidate entity in the candidate entity set, calculate the Euclidean distance between the query object and each of the candidate entities. Based on the Euclidean distance between the query object and each of the candidate entities, candidate entities whose Euclidean distance exceeds the preset field of view distance are excluded, resulting in a filtered set of candidate entities.
4. The spatial region retrieval and matching method as described in claim 1 or 3, characterized in that, Based on the first location information of the query object and the second location information of each candidate entity in the candidate entity set, calculate the cosine of the angle between the query object and each of the candidate entities and the spatial distance, including: Based on the first location information of the query object and the second location information of each candidate entity, calculate the relative position vector from the query object to each candidate entity; Based on the orientation unit vector of the query object and the relative position vector of each candidate entity, calculate the cosine value of the angle between the query object and each candidate entity; Based on the first location information of the query object and the second location information of each candidate entity, the spatial distance between the query object and each candidate entity is calculated.
5. The spatial region retrieval and matching method as described in claim 1, characterized in that, Based on the cosine of the angle between the query object and each of the candidate entities and the spatial distance, a visual visibility determination is performed, and target entities within the visual range of the query object are selected from the candidate entities, including: Compare the cosine of the angle between the query object and each of the candidate entities with the cosine of the field of view angle of the query object; wherein, the first field of view parameter includes the field of view angle and the field of view distance; Compare the spatial distance between the query object and each of the candidate entities with the visual distance of the query object; Candidate entities whose included angle cosine value is greater than or equal to the field of view angle cosine value and whose spatial distance is less than or equal to the field of view distance are selected as target entities.
6. The spatial region retrieval and matching method as described in claim 1, characterized in that, The method further includes: When any entity moves, detect whether the corresponding entity crosses the node boundary of the source R-tree node in which it resides; wherein, the node boundary is used to indicate the outer minimum bounding box of the minimum bounding box of all entities within the corresponding R-tree node. If not, update the second location information of the corresponding entity; If so, update the second location information of the corresponding entity and migrate the index entry of the corresponding entity from the source R-tree node to the target R-tree node; wherein the updated second location information of the corresponding entity and its minimum bounding box fall within the range of the outer minimum bounding box of the target R-tree node.
7. A spatial region retrieval and matching device, characterized in that, include: The query bounding box construction module is used to construct the query bounding box based on the first location information and the first field of view parameter of the query object; The R-tree retrieval module is used to query a pre-built R-tree spatial index structure based on the query bounding box, and filter out candidate entities corresponding to the smallest bounding box that intersects with the query bounding box to obtain a set of candidate entities; wherein, the R-tree spatial index structure is used to store the smallest bounding box of each entity, and the smallest bounding box is used to indicate the spatial coverage area of the corresponding entity. The location vector calculation module is used to calculate the cosine of the angle between the query object and each of the candidate entities and the spatial distance based on the first location information of the query object and the second location information of each candidate entity in the candidate entity set. The visibility determination module is used to determine visibility based on the cosine of the angle between the query object and each of the candidate entities and the spatial distance, and to filter out the target entity within the range of the query object from the candidate entities.
8. A spatial region retrieval and matching device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein the processor, when executing the computer program, implements the spatial region retrieval and matching method as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein, when the computer program is executed, it controls the device on which the computer-readable storage medium is located to perform the spatial region retrieval and matching method as described in any one of claims 1 to 6.
10. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the spatial region retrieval and matching method according to any one of claims 1 to 6.
