CN115630203B - Method for generating n-ary tree and method and device for determining intersection relationship - Google Patents
Method for generating n-ary tree and method and device for determining intersection relationship Download PDFInfo
- Publication number
- CN115630203B CN115630203B CN202211589987.6A CN202211589987A CN115630203B CN 115630203 B CN115630203 B CN 115630203B CN 202211589987 A CN202211589987 A CN 202211589987A CN 115630203 B CN115630203 B CN 115630203B
- Authority
- CN
- China
- Prior art keywords
- spatial data
- nodes
- node
- stored
- intersection
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/901—Indexing; Data structures therefor; Storage structures
- G06F16/9027—Trees
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/29—Geographical information databases
Landscapes
- Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Remote Sensing (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The specification provides a method for generating an n-ary tree and a method and a device for determining an intersection relationship, wherein the n-ary tree is used for storing spatial data; the method comprises the following steps: acquiring spatial data to be stored in a plurality of spatial data, wherein each spatial data in the plurality of spatial data corresponds to an external frame; searching for intersecting nodes in all leaf nodes of the n-ary tree; the external frame corresponding to the spatial data stored in the intersected node has an intersection relation with the external frame corresponding to the spatial data to be stored; and under the condition that more than two intersecting nodes are found, splitting the space data to be stored into subspace data respectively corresponding to the more than two intersecting nodes based on the intersecting relationship, and respectively storing the subspace data to the corresponding intersecting nodes.
Description
Technical Field
The present disclosure relates to the field of big data technologies, and in particular, to a method and an apparatus for generating an n-ary tree and determining an intersection relationship.
Background
The spatial data is used for representing information of various aspects such as position, size distribution and the like of an object, and is quantitative description of things and phenomena which have positioning significance and exist in the world. The intersection of the spatial data refers to the intersection of two pieces of spatial data, for example, the planned construction land conflicts with the planned agriculture land.
In the prior art, the spatial data are compared pairwise to determine whether the spatial data intersect with each other. This method is perhaps intuitive and easy to understand when the amount of data is small, but when there is a lot of spatial data, the amount of computation will increase linearly, and the resource consumption caused by spatial computation will be immeasurable.
Disclosure of Invention
In order to overcome the problems in the related art, the present specification provides a method for generating an n-ary tree and a method and an apparatus for determining an intersection relationship.
According to a first aspect of embodiments of the present specification, there is provided a method for generating an n-ary tree, where the n-ary tree is used for storing spatial data; the method comprises the following steps:
acquiring spatial data to be stored in a plurality of pieces of spatial data, wherein each piece of spatial data corresponds to an external frame;
searching for intersecting nodes in all leaf nodes of the n-ary tree; an external frame corresponding to the spatial data stored in the intersected node and an external frame corresponding to the spatial data to be stored have an intersection relation;
and under the condition that more than two intersected nodes are found, splitting the to-be-stored space data into subspace data respectively corresponding to the more than two intersected nodes based on the intersection relation, and respectively storing the subspace data to the corresponding intersected nodes.
Optionally, the method further includes:
and under the condition that one intersected node is found, storing the data of the space to be stored into the intersected node.
Optionally, the method further includes:
traversing father nodes of all leaf nodes under the condition that the intersected nodes are not found, and selecting father nodes which can completely contain external frames corresponding to the spatial data to be stored; the spatial data stored by the father node is a union of the spatial data stored by all the child nodes;
determining a target father node from the selected father nodes, wherein the area of an outer frame corresponding to spatial data stored by the target father node is the smallest in the selected father nodes;
generating child nodes of the target parent node;
and storing the data of the space to be stored to the generated child node.
Optionally, the generating a child node of the target parent node includes:
under the condition that the number of the child nodes corresponding to the target parent node is smaller than a preset threshold value, generating the child nodes of the target parent node aiming at the to-be-stored space data;
under the condition that the number of the child nodes corresponding to the target parent node reaches the preset threshold value, generating the child nodes of the target parent node, and splitting the target parent node into a first target parent node and a second target parent node;
and respectively storing all the child nodes corresponding to the target parent node to the first target parent node or the second target parent node, so that the number of the child nodes corresponding to the first target parent node and the second target parent node does not exceed the preset threshold value.
According to a second aspect of embodiments of the present specification, there is provided a method of determining an intersection relationship, the method including:
acquiring a plurality of spatial data of an intersection relation to be determined, wherein each piece of spatial data corresponds to an external frame;
generating an n-ary tree according to any one of the n-ary tree generation methods in the first aspect based on the plurality of spatial data; the n-branch tree comprises a plurality of leaf nodes and father nodes of the leaf nodes; the leaf node stores at least one piece of spatial data, and under the condition that the leaf node stores more than two pieces of spatial data, the external frames corresponding to the more than two pieces of spatial data have an intersection relation;
determining an intersection relationship for spatial data within leaf nodes contained by the n-ary tree.
Optionally, the determining an intersection relationship for spatial data in leaf nodes included in the n-ary tree includes:
in the leaf nodes included in the n-branch tree, pairwise comparison is carried out on the spatial data in the target leaf node storing more than two pieces of spatial data;
and determining the two pieces of spatial data with intersection as having an intersection relation.
Optionally, pairwise comparing the spatial data in the target leaf node in which more than two pieces of spatial data are stored includes:
any two pieces of spatial data in the spatial data stored by the target leaf node are extracted;
and performing intersection operation on the arbitrary two pieces of spatial data, wherein if the arbitrary two pieces of spatial data are intersected, the intersection exists between the arbitrary two pieces of spatial data.
According to a third aspect of embodiments of the present specification, there is provided a generating apparatus of an n-ary tree, the n-ary tree being used for storing spatial data; the device comprises:
an acquisition unit: acquiring spatial data to be stored in a plurality of pieces of spatial data, wherein each piece of spatial data corresponds to an external frame;
a search unit: searching for intersecting nodes in all leaf nodes of the n-ary tree; an external frame corresponding to the spatial data stored in the intersected node and an external frame corresponding to the spatial data to be stored have an intersection relation;
splitting a unit: and under the condition that more than two intersected nodes are found, splitting the to-be-stored space data into subspace data respectively corresponding to the more than two intersected nodes based on the intersection relation, and respectively storing the subspace data to the corresponding intersected nodes.
According to a fourth aspect of embodiments herein, there is provided an apparatus for determining an intersection relationship, the apparatus comprising:
an acquisition unit: acquiring a plurality of spatial data of an intersection relation to be determined, wherein each piece of spatial data corresponds to an external frame;
a generation unit: generating an n-ary tree according to any one of the n-ary tree generation methods in the first aspect based on the plurality of spatial data; the n-branch tree comprises a plurality of leaf nodes and father nodes of the leaf nodes; the leaf node stores at least one piece of spatial data, and under the condition that the leaf node stores two or more pieces of spatial data, the external frames corresponding to the two or more pieces of spatial data have an intersection relation;
a determination unit: determining an intersection relationship for spatial data within leaf nodes contained by the n-ary tree.
According to a fifth aspect of embodiments herein, there is provided an electronic apparatus including:
a processor; a memory for storing processor-executable instructions; wherein the processor is configured to implement the steps of the first or second aspect described above.
According to a sixth aspect of embodiments herein, there is provided a computer-readable storage medium having stored thereon executable instructions; wherein the instructions, when executed by a processor, implement the steps of the first or second aspect.
The technical scheme provided by the embodiment of the specification can have the following beneficial effects:
in the embodiment of the present specification, since the spatial data corresponding to the intersection of the bounding box is stored in the same leaf node in the process of generating the n-ary tree, and the spatial data may have an intersection relationship only in the case that the bounding boxes intersect, the spatial data that may have an intersection relationship in the n-ary tree is stored in the same leaf node. Therefore, when the intersection relationship is determined, the two pieces of spatial data with the intersection can be determined to have the intersection relationship only by taking the leaf nodes storing two or more pieces of spatial data in the n-ary tree as target leaf nodes and comparing the two pieces of spatial data stored in the target leaf nodes pairwise. According to the method, all spatial data which possibly have intersection are stored in the same leaf node by establishing the n-branch tree, so that the division and the treatment calculation of the intersection calculation are realized, the calculation amount is greatly reduced, and the retrieval efficiency is improved.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the specification.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with this specification and, together with the description, serve to explain the principles of the specification.
FIG. 1 is a flow chart illustrating a method for generating an n-ary tree in accordance with an exemplary embodiment of the present description.
Fig. 2a is a schematic diagram of a development area land planning in an embodiment of the present specification.
Fig. 2b is a schematic diagram of a generation circumscribed frame in an embodiment of this specification.
Fig. 3a is a schematic diagram of generating an n-ary tree in an embodiment of the present specification.
Fig. 3b is a schematic diagram of another n-ary tree generation in the embodiment of the present specification.
Fig. 3c is a schematic diagram of another n-ary tree generation in the embodiment of the present specification.
Fig. 3d is a schematic diagram of an n-ary tree in the case that the preset threshold is 2 in the embodiment of the present specification.
Fig. 4 is a schematic diagram of a space object in an embodiment of the present specification.
Fig. 5a is a schematic diagram of two intersecting nodes in an embodiment of the present specification.
Fig. 5b is a schematic diagram of an n-ary tree in the case of two intersecting nodes in the embodiment of the present specification.
FIG. 6 is a flow chart illustrating a method for determining an intersection relationship in accordance with an exemplary embodiment of the present description.
Fig. 7 is a hardware configuration diagram of a computer device in which a spatial data search device having an intersection relationship according to an embodiment of the present specification is located.
Fig. 8 is a block diagram of a generation apparatus storing an n-ary tree according to an exemplary embodiment.
Fig. 9 is a block diagram of an apparatus for determining an intersection relationship shown in the present specification according to an exemplary embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. The following description refers to the accompanying drawings in which the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present specification. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the specification, as detailed in the appended claims.
The terminology used in the description herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the description. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, the first information may also be referred to as second information, and similarly, the second information may also be referred to as first information, without departing from the scope of the present specification. The word "if" as used herein may be interpreted as "at" \8230; "or" when 8230; \8230; "or" in response to a determination ", depending on the context.
The following provides a detailed description of examples of the present specification.
Fig. 1 is a flowchart illustrating a method for generating an n-ary tree according to an exemplary embodiment, as shown in fig. 1, where the method at least includes the following steps:
102, acquiring spatial data to be stored in a plurality of pieces of spatial data, wherein each piece of spatial data corresponds to an external frame.
All the spatial data in the plurality of spatial data may be respectively used as spatial data to be stored, or one or more spatial data in the plurality of spatial data may be acquired and respectively used as spatial data to be stored. One piece of spatial data may refer to spatial data corresponding to one spatial object under a real condition, for example: position and size information corresponding to a playground or a hospital.
The bounding box may refer to a rectangular box on the lower boundary of the maximum abscissa, the minimum abscissa, the maximum ordinate, and the minimum ordinate in each vertex of a given two-dimensional shape in a two-dimensional coordinate system. The bounding box corresponding to the spatial data may refer to a minimum bounding rectangle of the spatial object corresponding to the spatial data in the two-dimensional coordinate system. There are at least two situations in the acquired data of the space to be stored: the frame carries with it when obtaining, does not have the frame when obtaining. And under the condition that no external frame exists during acquisition, generating a corresponding external frame according to the coordinate of the space data to be stored in the two-dimensional coordinate system.
The generation of the external frame is described in detail below by taking the planning land shown in fig. 2a as an example:
as shown in fig. 2a, fig. 2a is a schematic diagram of a land for development area planning shown in the present specification according to an exemplary embodiment, and the schematic diagram includes: a park plot 201, a housing plot 202, and industrial plots 203, 204, 205. Due to unreasonable planning, planning conflicts exist between the park land 201 and the housing land 202, and the situation does not exist in the rest of land. And establishing a two-dimensional coordinate system for the place in the image of fig. 2a, regarding each place in the image of fig. 2a as a space object, and regarding the position information of each place in the coordinate system as the space data corresponding to the place. Establishing a corresponding bounding box according to each spatial object in fig. 2a, resulting in fig. 2b, where fig. 2b is a schematic diagram of a generation bounding box shown in this specification according to an exemplary embodiment, and the schematic diagram includes: an external frame B1 corresponding to the park site 201, an external frame B2 corresponding to the housing site 202, an external frame B3 corresponding to the industrial site 203, an external frame B4 corresponding to the industrial site 204, and an external frame B5 corresponding to the industrial site 205. In order to clarify the position of the circumscribed frame in the coordinate system, the coordinate information of two points, the lower left corner and the upper right corner of the rectangular frame, is used to represent the position information of the circumscribed frame, for example: the coordinate information of two points at the lower left corner and the upper right corner of the external frame B1 corresponding to the park site 201 are (4, 7) and (13, 13), respectively, and then the position information of B1 is B1{ (4, 7), (13, 13) }. Therefore, the position information of each outline frame is: b1{ (4, 7), (13, 13) }, B2{ (11.5, 7), (15, 10) }, B3{ (2, 2), (7, 6) }, B4{ (18, 8), (27, 16) }, B5{ (24, 4.5), (32, 10) }.
The intersection node means: and if the external frames corresponding to the spatial data stored in the two nodes are intersected, the two nodes are intersected nodes. Taking fig. 2b as an example, if a node stores spatial data corresponding to the park site 201, another node stores spatial data corresponding to the housing site 202, and the external frame corresponding to the park site 201 intersects with the external frame corresponding to the housing site 202, the two nodes are intersected nodes.
The method for searching the intersected node can comprise the following steps: establishing a coordinate system, determining four vertex coordinates of an external frame corresponding to the spatial data to be stored, determining four vertex coordinates of the external frame corresponding to the spatial data stored by each node, judging whether one of the four vertex coordinates corresponding to the spatial data to be stored is positioned between the four vertex coordinates corresponding to the nodes, if so, determining that the node is an intersected node, and if not, determining that the node is not the intersected node. Of course, the search method is not limited to the above method, and the description does not limit this method.
And 106, under the condition that more than two intersected nodes are found, splitting the to-be-stored space data into subspace data respectively corresponding to the more than two intersected nodes based on the intersection relation, and respectively storing the subspace data to the corresponding intersected nodes.
The splitting of the data of the storage space to be stored can be performed according to the intersection condition of the external frame corresponding to the intersection node, for example: assuming that the spatial data to be stored intersects two intersecting nodes, a portion intersecting with the external frame corresponding to the first intersecting node may be split into first subspace data, a portion intersecting with the external frame corresponding to the second intersecting node may be split into second subspace data, the first subspace data is stored in the first intersecting node, and the second subspace data is stored in the second intersecting node.
As shown in fig. 4, the space object P3 intersects both the space objects P1 and P2. At this time, the spatial data corresponding to the spatial object P3 may be split into two pieces of subspace data, and inserted into the leaf nodes corresponding to the two pieces of P3 and P4, respectively, for storage. As shown in FIG. 5a, the spatial data corresponding to P3 is split into P3-1 and P3-2, where P3-1 is stored in the leaf node corresponding to P2, and P3-2 is stored in the leaf node corresponding to P1. As a final result, as shown in fig. 5b, the leaf node 502 stores the spatial data corresponding to the spatial objects P1 and P3-2, the spatial object 503 stores the spatial data corresponding to the spatial objects P2 and P3-1, and the root node 501 stores the spatial data corresponding to all the spatial objects.
If the space object A and the space object B have an intersection relationship, the external frame corresponding to the space object A is intersected with the external frame corresponding to the space object B, so that the space data corresponding to the space objects A and B are stored in the same leaf node. Therefore, when searching the spatial data with intersection, only the leaf nodes storing two or more spatial data need to be searched, and all the spatial data with intersection can be found out.
In the foregoing embodiment, by establishing the n-ary tree, all spatial data that may have an intersection are stored in the same leaf node, so that the divide-and-conquer calculation of the intersection calculation is realized, the calculation amount is greatly reduced, and the retrieval efficiency is improved.
In practical situations, there are also situations where one intersecting node is found and where no intersecting node is found.
In an embodiment, when one of the intersecting nodes is found, the data of the space to be stored is stored in the intersecting node. The embodiment provides a storage method of the data in the space to be stored under the condition that one intersecting node is found, and the storage method is used for laying a cushion for subsequently generating the n-ary tree.
In an embodiment, under the condition that the intersecting node is not found, traversing father nodes of all leaf nodes, and selecting the father nodes which can completely contain the circumscribed frames corresponding to the to-be-stored space data; the spatial data stored by the father node is a union of the spatial data stored by all the child nodes; determining a target father node from the selected father nodes, wherein the area of an external frame corresponding to spatial data stored by the target father node is the smallest in the selected father nodes; generating child nodes of the target parent node; and storing the data of the space to be stored to the generated child node.
Traversal may refer to stepwise traversal, which may be from low to high, for example: traversing from the upper level node of the leaf node to the root node; it may also be from low to high, for example: and traversing from the root node to the nodes of the next level. The present description does not limit the order of traversal.
Complete containing may mean that the bounding box corresponding to the spatial data stored by the parent node contains the bounding box corresponding to the spatial data to be stored, as shown in fig. 3a, the bounding box A1 may completely contain B1 and B2.
The embodiment provides a storage method of the data in the space to be stored under the condition that the intersecting node is not found, and the method is used for laying a cushion for subsequently generating the n-ary tree.
Further, the generating a child node of the target parent node includes: under the condition that the number of the child nodes corresponding to the target parent node is smaller than a preset threshold value, generating the child nodes of the target parent node aiming at the to-be-stored space data; under the condition that the number of the child nodes corresponding to the target parent node reaches the preset threshold value, generating the child nodes of the target parent node, and splitting the target parent node into a first target parent node and a second target parent node; and respectively storing all the child nodes corresponding to the target parent node to the first target parent node or the second target parent node, so that the number of the child nodes corresponding to the first target parent node and the second target parent node does not exceed the preset threshold value.
The preset threshold is the maximum number of leaf nodes that can correspond to each parent node, and the preset threshold can be set by a user according to actual conditions.
Taking the spatial data shown in fig. 2b as an example, the spatial data corresponding to the five spatial objects, i.e., the park land 201, the housing land 202, and the industrial lands 203, 204, 205, are sequentially inserted into the n-ary tree for storage. There is only one root node in the n-ary tree at first, so the spatial data corresponding to the park land 201 is inserted into the root node for storage. Next, since the external frame B2 corresponding to the housing site 202 intersects with the external frame B1 corresponding to the park site 201, the spatial data corresponding to the park site 201 is also inserted into the root node, and as a result, as shown in fig. 3a, 301 is the root node, and the spatial data corresponding to the park site 201 and the housing site 202 are stored. The bounding box of node 301 may be adjusted to be A1.
It is assumed here that the preset threshold is 3, i.e. one parent node corresponds to 3 leaf nodes at most. When the industrial site 203 is inserted, a new node needs to be generated because the bounding box B3 corresponding to the industrial site 203 does not intersect with both of the nodes B1 and B2. As shown in fig. 3b, a leaf node 302 is generated for storing the spatial data corresponding to the industrial site 203, and a new root node 303 is generated, where the root node 303 is a parent node of the node 301 and the node 302. The node 301 stores spatial data corresponding to the park site 201 and the housing site 202, and the node 302 stores spatial data corresponding to the industrial site 203. The corresponding spatial data for industrial site 204 is interpolated and the result is shown in figure 3 c. Since the bounding box B4 corresponding to the industrial site 204 is disjoint from B1, B2, and B3, a new node 304 is generated for storing the spatial data corresponding to the industrial site 204, and the number of leaf nodes corresponding to the parent node 303 does not exceed 3, so that splitting is not required. The spatial data corresponding to the industrial site 205 is inserted, and the bounding box B5 and B4 corresponding to the industrial site 205 intersect with each other, so that the spatial data corresponding to the industrial site 205 is stored in the node 304. The circumscribed frame of node 304 is also adjusted by B4 to A3. At this time, the storage information of each leaf node is: 301 (201, 202),302 (203),304 (204, 205).
If the preset threshold is set to 2, as shown in fig. 3d, the node 303 needs to be split into a first target parent node 305 and a second target parent node 306, wherein the child node corresponding to the first target parent node 305 includes the node 301 and the node 302, and the child node corresponding to the second target parent node 306 includes the node 304. Node 305 and node 306 are both root nodes. It is noted that although industrial site 204 and industrial site 205 do not intersect, bounding box B4 corresponding to industrial site 204 intersects industrial site 205, and therefore the stored information of leaf node 304 also includes spatial data corresponding to industrial site 205.
The embodiment shows the method for storing the data in the space to be stored of the n-ary tree under the condition that the number of the child nodes reaches the preset threshold value and the number of the child nodes does not reach the preset threshold value, so that the number of the leaf nodes covered by the father node does not exceed the preset threshold value, and the n-ary tree is prevented from being failed to construct.
As shown in fig. 6, fig. 6 is a flowchart illustrating a method for determining an intersection relationship according to an exemplary embodiment, as shown in fig. 6, the method at least includes the following steps:
As previously mentioned, there are at least two cases of the acquired spatial data: the acquisition carries an circumscribing frame, and the acquisition does not have a circumscribing frame. Under the condition that no external frame exists during acquisition, a corresponding external frame can be generated according to the coordinates of the spatial data to be stored in the two-dimensional coordinate system, and the specific generation steps are shown in fig. 2a and fig. 2b, which are not described herein again.
As described above, in the process of generating the n-ary tree, it is necessary to search an intersection node for the data of the space to be stored, and store the data of the space to be stored in the intersection node under the condition that one intersection node is found; or under the condition that more than two intersected nodes are found, splitting the to-be-stored space data into subspace data corresponding to the intersected nodes, and respectively storing the subspace data to the corresponding intersected nodes. This allows spatial data that may have an intersection relationship to be stored in the same leaf node.
As described above, in the process of generating the n-ary tree, all the spatial data corresponding to the intersections of the bounding boxes are stored in the same leaf node. And under the condition that the two pieces of spatial data have an intersection relationship, the external frames corresponding to the two pieces of spatial data are necessarily intersected, so that when the intersection relationship is determined, intersection calculation is only carried out on the spatial data in the target leaf node in the n-branch tree, wherein the two or more pieces of spatial data are stored.
The embodiment provides a method for determining an intersection relationship, which stores spatial data possibly having the intersection relationship in the same leaf node, so that when the intersection relationship is determined, the spatial data having the intersection relationship can be determined only by aiming at the leaf node in an n-ary tree, thereby reducing the amount of calculation and improving the retrieval efficiency.
In one embodiment, the determining the intersection relationship for the spatial data in the leaf nodes contained in the n-ary tree includes: in the leaf nodes included in the n-branch tree, pairwise comparison is carried out on the spatial data in the target leaf node storing more than two pieces of spatial data; and determining the two pieces of spatial data with intersection as having an intersection relation. The embodiment provides a method for determining spatial data with an intersection relationship in an n-branch tree, and two sets of spatial data with an intersection can be determined to have the intersection relationship only by taking leaf nodes storing two or more sets of spatial data in the n-branch tree as target leaf nodes and comparing the two sets of spatial data stored in the target leaf nodes pairwise, so that the calculated amount is reduced, and the retrieval efficiency is improved.
There are many ways to calculate whether there is an intersection in the spatial data, for example, the spatial data corresponding to the spatial object may be calculated based on an intersection algorithm, which is not limited in this specification.
In an embodiment, the pairwise comparing the spatial data in the target leaf node storing two or more spatial data includes: any two pieces of spatial data in the spatial data stored by the target leaf node are extracted; and performing intersection operation on the arbitrary two parts of spatial data, wherein if the arbitrary two parts of spatial data are intersected, the arbitrary two parts of spatial data have intersection.
Taking the leaf node 301 in fig. 3c as an example, taking the leaf node 301 as a target leaf node, performing intersection operation on the spatial data corresponding to the park land 201 and the housing land 202 by using the spatial data stored by the leaf node 301 including the spatial data corresponding to the park land 201 and the housing land 202 to obtain that the spatial data corresponding to the park land 201 and the housing land 202 have an intersection, and thus, the spatial data corresponding to the park land 201 and the housing land 202 have an intersection relationship. Similarly, taking leaf nodes 302 and 304 as the target leaf nodes, respectively, it is not possible to have an intersection relationship because leaf node 302 stores only one copy of spatial data. While the spatial data corresponding to the industrial sites 204 and 205 in the leaf node 304 do not intersect.
In the method for comparing spatial data in this embodiment, whether two pieces of compared spatial data have an intersection is determined through intersection operation, so that it is determined that two pieces of spatial data having an intersection have an intersection relationship.
Corresponding to the embodiments of the method, the present specification also provides embodiments of an apparatus, an electronic device, and a storage medium.
The embodiment of the device for retrieving spatial data with an intersection relationship in the present specification can be applied to computer equipment, and the device embodiment can be implemented by software, or by hardware, or by a combination of hardware and software. Taking a software implementation as an example, as a search device of spatial data with an intersection relationship in a logical sense, the search device is formed by reading corresponding computer program instructions in a nonvolatile memory into a memory through a processor of the search device and running the computer program instructions. From a hardware aspect, as shown in fig. 7, a hardware structure diagram of a computer device in which a spatial data retrieval apparatus having an intersection relationship according to an embodiment of the present disclosure is located is shown in fig. 7, except for the processor 710, the memory 730, the network interface 720, and the nonvolatile memory 740 shown in fig. 7, other hardware may be included according to an actual function of the computer device, which is not described again.
FIG. 8 is a block diagram of an apparatus for generating an n-ary tree for storing spatial data, according to an exemplary embodiment shown in the present specification; the device comprises:
an obtaining unit 802, configured to obtain spatial data to be stored in a plurality of spatial data, where each piece of spatial data corresponds to an external frame;
a searching unit 804, configured to search for an intersecting node in all leaf nodes of the n-ary tree; an external frame corresponding to the spatial data stored in the intersected node and an external frame corresponding to the spatial data to be stored have an intersection relation;
a splitting unit 806, configured to, when more than two intersecting nodes are found, split the to-be-stored space data into subspace data corresponding to the more than two intersecting nodes, respectively, based on the intersection relationship, and store the subspace data to the corresponding intersecting nodes, respectively.
Optionally, the method further includes:
the first storage unit 808 is configured to store the to-be-stored space data into the intersecting node when one intersecting node is found.
Optionally, the method further includes:
a selecting unit 810, configured to traverse parent nodes of each leaf node under the condition that the intersecting node is not found, and select a parent node that can completely include an external frame corresponding to the to-be-stored space data; the spatial data stored by the father node is a union of the spatial data stored by all the child nodes;
a determining unit 812, configured to determine a target parent node from the selected parent nodes, where an outline area corresponding to the spatial data stored in the target parent node is the smallest in the selected parent node;
a generating unit 814, configured to generate child nodes of the target parent node;
a second storage unit 816, configured to store the data of the space to be stored to the generated child node.
Optionally, the generating unit 814 is specifically configured to:
under the condition that the number of the child nodes corresponding to the target parent node is smaller than a preset threshold value, generating the child nodes of the target parent node aiming at the to-be-stored space data;
under the condition that the number of the child nodes corresponding to the target parent node reaches the preset threshold value, generating child nodes of the target parent node, and splitting the target parent node into a first target parent node and a second target parent node; and respectively storing all the child nodes corresponding to the target parent node to the first target parent node or the second target parent node, so that the number of the child nodes corresponding to the first target parent node and the second target parent node does not exceed the preset threshold value.
FIG. 9, as shown in FIG. 9, is a block diagram of an apparatus for determining an intersection relationship shown in the present specification, according to an exemplary embodiment; the device comprises:
an obtaining unit 902, configured to obtain a plurality of spatial data of an intersection relationship to be determined, where each piece of the spatial data corresponds to an external frame;
a generating unit 904, configured to generate an n-ary tree according to the n-ary tree generating method described in any unit in the embodiment shown in fig. 8, based on the plurality of pieces of spatial data; the n-branch tree comprises a plurality of leaf nodes and father nodes of the leaf nodes; the leaf node stores at least one piece of spatial data, and under the condition that the leaf node stores two or more pieces of spatial data, the external frames corresponding to the two or more pieces of spatial data have an intersection relation;
a determining unit 906, configured to determine an intersection relationship for spatial data in leaf nodes included in the n-ary tree.
Optionally, the determining unit 906 is specifically configured to:
in the leaf nodes included in the n-branch tree, pairwise comparison is carried out on the spatial data in the target leaf node storing more than two pieces of spatial data;
and determining the two pieces of spatial data with intersection as having an intersection relation.
Optionally, the determining unit 906 is specifically configured to:
any two pieces of spatial data in the spatial data stored by the target leaf node are extracted;
and performing intersection operation on the arbitrary two pieces of spatial data, wherein if the arbitrary two pieces of spatial data are intersected, the intersection exists between the arbitrary two pieces of spatial data.
Correspondingly, the present specification also provides an apparatus comprising a processor; a memory for storing processor-executable instructions; wherein the processor is configured to implement the steps of the method for retrieving spatial data with an intersection relationship provided by all the above method embodiments.
Accordingly, the present specification also provides a computer readable storage medium having executable instructions stored thereon; wherein, when being executed by a processor, the instructions implement the steps of the method for retrieving spatial data with an intersection relationship provided by all the above method embodiments.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, wherein the modules described as separate parts may or may not be physically separate, and the parts displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution in the specification. One of ordinary skill in the art can understand and implement it without inventive effort.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
Other embodiments of the present description will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This specification is intended to cover any variations, uses, or adaptations of the specification following, in general, the principles of the specification and including such departures from the present disclosure as come within known or customary practice within the art to which the specification pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the specification being indicated by the following claims.
It will be understood that the present description is not limited to the precise arrangements that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.
The above description is only a preferred embodiment of the present disclosure, and should not be taken as limiting the present disclosure, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present disclosure should be included in the protection scope of the present disclosure.
Claims (9)
1. A method for determining an intersection, the method comprising:
acquiring a plurality of spatial data of an intersection relation to be determined, wherein each piece of spatial data corresponds to an external frame;
generating an n-ary tree based on the plurality of spatial data; the n-branch tree comprises a plurality of leaf nodes and father nodes of the leaf nodes; the leaf node stores at least one piece of spatial data, and under the condition that the leaf node stores more than two pieces of spatial data, the external frames corresponding to the more than two pieces of spatial data have an intersection relation;
the method for generating the n-ary tree comprises the steps of obtaining spatial data to be stored in the plurality of spatial data; searching for intersecting nodes in all leaf nodes of the n-ary tree; the external frame corresponding to the spatial data stored in the intersected node has an intersection relation with the external frame corresponding to the spatial data to be stored; under the condition that more than two intersected nodes are found, splitting the to-be-stored space data into subspace data respectively corresponding to the more than two intersected nodes based on the intersection relation, and respectively storing the subspace data to the corresponding intersected nodes;
determining an intersection relationship for spatial data within leaf nodes contained by the n-ary tree.
2. The method of claim 1, wherein the method for generating the n-ary tree further comprises:
and under the condition that one intersected node is found, storing the data of the space to be stored into the intersected node.
3. The method of claim 1 or 2, wherein the generating of the n-ary tree further comprises:
traversing father nodes of all leaf nodes under the condition that the intersected nodes are not found, and selecting father nodes which can completely contain external frames corresponding to the spatial data to be stored; the spatial data stored by the father node is a union of the spatial data stored by all the child nodes;
determining a target father node from the selected father nodes, wherein the area of an external frame corresponding to spatial data stored by the target father node is the smallest in the selected father nodes;
generating child nodes of the target parent node;
and storing the data of the space to be stored to the generated child nodes.
4. The method of claim 3, wherein the generating the child node of the target parent node comprises:
under the condition that the number of the child nodes corresponding to the target parent node is smaller than a preset threshold value, generating the child nodes of the target parent node aiming at the to-be-stored space data;
under the condition that the number of the child nodes corresponding to the target parent node reaches the preset threshold value, generating the child nodes of the target parent node, and splitting the target parent node into a first target parent node and a second target parent node;
and respectively storing all the child nodes corresponding to the target parent node to the first target parent node or the second target parent node, so that the number of the child nodes corresponding to the first target parent node and the second target parent node does not exceed the preset threshold value.
5. The method of claim 1, wherein determining an intersection relationship for spatial data within leaf nodes included in the n-ary tree comprises:
in the leaf nodes included in the n-branch tree, pairwise comparison is carried out on the spatial data in the target leaf node storing more than two pieces of spatial data;
and determining the two pieces of spatial data with intersection as having an intersection relation.
6. The method of claim 5, wherein pairwise comparing spatial data within the target leaf node that stores more than two spatial data comprises:
any two pieces of spatial data in the spatial data stored by the target leaf node are extracted;
and performing intersection operation on the arbitrary two pieces of spatial data, wherein if the arbitrary two pieces of spatial data are intersected, the intersection exists between the arbitrary two pieces of spatial data.
7. An apparatus for determining an intersection relationship, the apparatus comprising:
an acquisition unit: acquiring a plurality of spatial data of an intersection relation to be determined, wherein each piece of spatial data corresponds to an external frame;
a generation unit: generating an n-ary tree based on the plurality of spatial data; the n-branch tree comprises a plurality of leaf nodes and father nodes of the leaf nodes; the leaf node stores at least one piece of spatial data, and under the condition that the leaf node stores more than two pieces of spatial data, the external frames corresponding to the more than two pieces of spatial data have an intersection relation; the method for generating the n-ary tree comprises the steps of obtaining spatial data to be stored in the plurality of spatial data; searching for an intersecting node in all leaf nodes of the n-way tree; an external frame corresponding to the spatial data stored in the intersected node and an external frame corresponding to the spatial data to be stored have an intersection relation; under the condition that more than two intersected nodes are found, splitting the to-be-stored space data into subspace data respectively corresponding to the more than two intersected nodes based on the intersection relation, and respectively storing the subspace data to the corresponding intersected nodes;
a determination unit: determining an intersection relationship for spatial data within leaf nodes contained by the n-ary tree.
8. An electronic device includes a processor; memory for storing processor-executable instructions, wherein the processor is configured to implement the steps of the method of any one of claims 1-6.
9. A computer-readable storage medium having executable instructions stored thereon, wherein the instructions, when executed by a processor, perform the steps of the method of any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211589987.6A CN115630203B (en) | 2022-12-12 | 2022-12-12 | Method for generating n-ary tree and method and device for determining intersection relationship |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211589987.6A CN115630203B (en) | 2022-12-12 | 2022-12-12 | Method for generating n-ary tree and method and device for determining intersection relationship |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115630203A CN115630203A (en) | 2023-01-20 |
CN115630203B true CN115630203B (en) | 2023-03-28 |
Family
ID=84910124
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211589987.6A Active CN115630203B (en) | 2022-12-12 | 2022-12-12 | Method for generating n-ary tree and method and device for determining intersection relationship |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115630203B (en) |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2022142503A1 (en) * | 2020-12-31 | 2022-07-07 | 京东城市(北京)数字科技有限公司 | Spatial join query method and apparatus, electronic device, and storage medium |
Family Cites Families (14)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101515372B (en) * | 2009-02-04 | 2011-12-07 | 北京石油化工学院 | Visual analyzing and predicting method based on a virtual geological model |
CN102306166A (en) * | 2011-08-22 | 2012-01-04 | 河南理工大学 | Mobile geographic information spatial index method |
US8650220B2 (en) * | 2012-06-05 | 2014-02-11 | Google Inc. | System and method for storing and retrieving geospatial data |
US9798808B2 (en) * | 2014-03-17 | 2017-10-24 | SynerScope B.V. | Data visualization system |
US10885072B2 (en) * | 2016-10-25 | 2021-01-05 | International Business Machines Corporation | Spatial computing for location-based services |
CN108446357A (en) * | 2018-03-12 | 2018-08-24 | 浙江大学 | A kind of mass data spatial dimension querying method based on two-dimentional geographical location |
CN109947889A (en) * | 2019-03-21 | 2019-06-28 | 佳都新太科技股份有限公司 | Spatial data management method, apparatus, equipment and storage medium |
CN111159480B (en) * | 2019-12-12 | 2023-07-18 | 浙江华云信息科技有限公司 | Graph drawing method based on power grid GIS data |
CN112948518B (en) * | 2021-03-05 | 2024-05-14 | 苍穹数码技术股份有限公司 | Object processing method, device, electronic equipment and computer storage medium |
CN113139032A (en) * | 2021-05-19 | 2021-07-20 | 中国建设银行股份有限公司 | Geographic position searching method and device, electronic equipment and storage medium |
US11636153B2 (en) * | 2021-05-27 | 2023-04-25 | Western Digital Technologies, Inc. | Storage of tree data structures |
CN113536058A (en) * | 2021-08-03 | 2021-10-22 | 上海达梦数据库有限公司 | Spatial index modification method, device, equipment and storage medium |
CN114490899B (en) * | 2021-12-27 | 2022-09-23 | 北京吉威数源信息技术有限公司 | Multi-layer space big data superposition and combination method, device, equipment and storage medium |
CN114723900A (en) * | 2022-02-22 | 2022-07-08 | 高德软件有限公司 | Contour drawing method of ground element, electronic device and computer program product |
-
2022
- 2022-12-12 CN CN202211589987.6A patent/CN115630203B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2022142503A1 (en) * | 2020-12-31 | 2022-07-07 | 京东城市(北京)数字科技有限公司 | Spatial join query method and apparatus, electronic device, and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN115630203A (en) | 2023-01-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110276820B (en) | GIS model optimization method and system based on LOD organization and scheduling method | |
JP2005018591A (en) | Phase determination device, decomposable shape generation device, structural mesh generation device, phase determination method, decomposable shape generation method, computer-executable program for executing the phase determination method, computer-executable program for executing decomposable shape generation method, and structural mesh generation system | |
KR20090091617A (en) | 3d image processing method and apparatus for enabling efficient retrieval of neighbor point | |
CN111467806A (en) | Method, device, medium and electronic equipment for generating resources in game scene | |
Tasse et al. | Enhanced texture‐based terrain synthesis on graphics hardware | |
CN116883612B (en) | Three-dimensional scene model generation method and system | |
JP2019168976A (en) | Three-dimensional model generation device | |
CN110310220A (en) | A kind of half global real-time volume matching process | |
CN112085826A (en) | Efficient three-dimensional space grid rendering method and device | |
JPH10149432A (en) | Three-dimensional form retrieval device | |
CN109961129A (en) | A kind of Ocean stationary targets search scheme generation method based on improvement population | |
CN115630203B (en) | Method for generating n-ary tree and method and device for determining intersection relationship | |
CN109827585B (en) | Method for rapidly filling concave area in grid map | |
Alis et al. | Parallel processing of big point clouds using Z-Order-based partitioning | |
CN116091784A (en) | Target tracking method, device and storage medium | |
CN106652032B (en) | A kind of parallel contour lines creation method of DEM based on Linux cluster platform | |
CN114817775A (en) | Method and device for generating spatial index | |
Amir et al. | Efficient regular data structures and algorithms for dilation, location, and proximity problems | |
Thiemann et al. | A scalable approach for generalization of land cover data | |
Mashayekhi et al. | Analyzing and improving the use of the FastMap embedding in pathfinding tasks | |
CN112799669A (en) | Method and device for generating application program interface layout code and electronic equipment | |
CN113350800B (en) | Physical engine data processing system based on cloud computing | |
EP0436790A2 (en) | Multi-dimensional tree structure for the spatial sorting of geometric objects | |
CN113591739B (en) | Method, device, computer equipment and storage medium for identifying area in drawing | |
CN114675924B (en) | Page layout method and device based on FlexBox and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |