A method for constructing building polygons from unordered vertex sets based on nearest neighbor growth
Through the method based on nearest neighbor point growth, the problem of self-intersection and poor generation effect when constructing building polygons from unordered point sets is solved, and regular polygons are generated, which conforms to the vertex distribution characteristics and is suitable for spatial big data processing and maps. mapping.
Patent Information
- Application Number
- CN202410462369.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-17
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-04-17
AI Technical Summary
When existing geographical information system software uses unordered point sets to construct building polygons, it is easy to generate self-intersecting non-simple polygons, and the existing sorting method is not effective in generating different types of point sets, resulting in cumbersome and easy manual interaction. Something went wrong.
A method based on nearest neighbor point growth is used to generate directed line segments by searching for the coordinate extreme points of the plane vertex set, recursively identifying unidentified points, and constructing a simple closed path as short as possible to ensure that the generated polygon conforms to the vertex distribution characteristics.
It avoids the self-intersection phenomenon of the generated polygons without edges. The polygon perimeter is as short as possible, which conforms to the geometric shape characteristics of the vertex distribution. It is suitable for spatial big data processing and map drawing.
Smart Images

Figure CN118262007B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of spatial big data processing, and in particular relates to a method for constructing building polygons based on an unordered vertex set growing from nearest neighbor points. Background Art
[0002] In the field of map making, cartographers often construct building polygons with a given unordered point set as vertices. In the actual building mapping process, cartographers need to understand the connection order of building vertices, and then connect the vertices in turn in the mapping software to generate building polygons. Since the current laser radar equipment and its data processing technology play an important role in building measurement and mapping, the point cloud data (point set) of the building is segmented from the point cloud collected by the laser radar equipment, and then the key building turning points (vertices) are extracted from it, and finally these vertices are connected to generate building polygons. This has become a common operation process for point cloud data extraction to generate buildings. However, the building vertices extracted from the point cloud are unordered unordered point sets. If these vertices are to be used to connect and generate building polygons, a lot of manual interaction is required, which is cumbersome and error-prone. Sometimes, for mapping needs, cartographers also need to add (insert) several vertices to the existing building polygons, which requires reordering the original polygon vertices and the newly added vertices to regenerate the building polygons. Therefore, using unordered point sets as vertices to construct building polygons plays an important role in the field of map making. In the field of spatial data management, a building polygon is defined as a simple polygon with non-intersecting edges, and the polygon can contain multiple "holes". Although existing geographic information system software such as ArcGIS and QGIS have tools to generate polygons from point sets, these tools can only connect and generate polygons in the order in which the points are stored. When the given coordinate points are not regularly ordered, the constructed polygons may be self-intersecting non-simple polygons. In order to realize the generation of simple polygons from unordered points, some methods have been published on the Internet, mainly including the scan line tangent sorting method and the center point scan line rotation angle method, but these two methods still have some problems. In summary, there are several problems with the current method of constructing building polygons using unordered vertices: (1) Existing GIS software can only generate polygons in the order in which the vertices are stored. When the vertices do not have sequence numbers, the generated polygons are quite different from the vertex distribution state, and sometimes there are self-intersections; (2) The scan line tangent sorting method can generate relatively satisfactory polygons for point sets with convex polygon distribution, but for point sets with concave polygon distribution, the generated results are quite different from the vertex distribution state; (3) The center point scan line rotation angle method generates better polygons when the center point of the point set is inside the polygon, otherwise the generation effect is poor. Summary of the invention
[0003] To solve the above technical problems, the present invention proposes a method for constructing building polygons from an unordered vertex set based on nearest neighbor growth, which can search for a simple closed path connecting all unordered vertices and as short as possible, and use the closed path to construct a building polygon that meets the vertex distribution characteristics.
[0004] To achieve the above object, the present invention provides a method for constructing building polygons from an unordered vertex set based on nearest neighbor growth, comprising the following steps:
[0005] S1, obtain the input plane vertex set, and end when the number of vertices in the plane vertex set is less than 3; if the number of vertices in the plane vertex set is equal to 3, connect the three vertices respectively, store the connecting lines in the line segment set, and proceed to S6; if the number of vertices in the plane vertex set is greater than 3, proceed to S2;
[0006] S2, searching for the x minimum, y maximum, x maximum and y minimum coordinate extreme value points corresponding to the plane vertex set, generating four directed line segments from the four coordinate extreme value points in sequence, storing them in the line segment set, and marking the four coordinate extreme value points;
[0007] S3, based on the plane vertex set, check whether there is an unidentified point, if not, proceed to S6, if there is an unidentified point, proceed to S4;
[0008] S4, searching for an unmarked point closest to the line segment set from the line segment set; and searching for a line segment closest to the closest point from the line segment set;
[0009] S5, calculating the foot of the perpendicular of the nearest point on the nearest line segment or the extension of the nearest line segment, performing a recursive search based on the positional relationship between the foot of the perpendicular and the nearest line segment or the extension of the nearest line segment, and marking all the nearest points searched, and returning to S3 after completion;
[0010] S6. Connect the line segment sets in sequence to construct a building polygon.
[0011] According to the method for constructing building polygons from an unordered vertex set based on nearest neighbor point growth provided by the present invention, the method for searching the x minimum, y maximum, and coordinate extreme value points corresponding to the x maximum and y minimum of the plane vertex set includes: when there are multiple points of x minimum, the point with the smallest y is taken as the coordinate extreme value point corresponding to the y minimum; when there are multiple points of y maximum, the point with the smallest x is taken as the coordinate extreme value point corresponding to the x minimum; when there are multiple points of x maximum, the point with the largest y is taken as the coordinate extreme value point corresponding to the y maximum; when there are multiple points of y minimum, the point with the largest x is taken as the coordinate extreme value point corresponding to the x maximum.
[0012] According to the method for constructing building polygons from an unordered vertex set based on nearest neighbor growth provided by the present invention, a recursive search is performed based on the positional relationship between the perpendicular foot and the nearest line segment or the extension of the nearest line segment, wherein the first case includes:
[0013] If the foot of the perpendicular is on the nearest line segment, the nearest line segment is deleted, and two directed line segments from the starting point of the nearest line segment to the nearest point and from the nearest point to the end point of the nearest line segment are added to the line segment set.
[0014] According to the method for constructing building polygons from an unordered vertex set based on nearest neighbor growth provided by the present invention, a recursive search is performed based on the positional relationship between the foot of the perpendicular and the nearest line segment or the extension of the nearest line segment, wherein the second case includes:
[0015] If the foot of the perpendicular is on the outward extension line of the starting point of the nearest line segment, generate a line segment from the nearest point to the starting point of the nearest line segment; if the generated line segment intersects with the line segments in the line segment set, operate according to the first case; otherwise, insert the nearest point between the starting point of the nearest line segment and the end point of the predecessor line of the nearest line segment, delete the predecessor line of the nearest line segment, and store the line segment from the nearest point to the starting point of the nearest line segment and the line segment from the nearest point to the end point of the predecessor line of the nearest line segment into the line segment set.
[0016] According to the method for constructing building polygons from an unordered vertex set based on nearest neighbor growth provided by the present invention, a recursive search is performed according to the positional relationship between the foot of the perpendicular and the nearest line segment or the extension of the nearest line segment, wherein the third case includes:
[0017] If the foot of the perpendicular is on the outward extension line of the endpoint of the nearest line segment, generate a line segment from the nearest point to the endpoint of the nearest line segment; if the line segment from the nearest point to the endpoint of the nearest line segment intersects with the line segments in the line segment set, operate according to the first case; otherwise, insert the nearest point between the endpoint of the nearest line segment and the starting point of the subsequent line of the nearest line segment, delete the subsequent line of the nearest line segment, and store the line segment from the nearest point to the endpoint of the nearest line segment and the line segment from the nearest point to the starting point of the subsequent line of the nearest line segment in the line segment set.
[0018] Technical effect of the invention: The invention discloses a method for constructing building polygons based on an unordered vertex set of nearest neighbor point growth, which can ensure that the generated polygons do not have self-intersection of edges, so that the perimeter of the generated polygons is as short as possible, that is, the polygons are as regular as possible, and the constructed building polygons conform to the geometric shape characteristics of vertex distribution, and are suitable for many scenarios of constructing building polygons such as spatial big data processing and map making. The method provided by the invention is more feasible and practical, and can better reflect the geometric characteristics of vertex distribution. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings constituting a part of the present application are used to provide a further understanding of the present application. The illustrative embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0020] Figure 1 A flow chart of a method for constructing building polygons based on an unordered vertex set of nearest neighbor growth according to an embodiment of the present invention;
[0021] Figure 2 A schematic diagram of the coordinate extreme value points and the directed line segments generated by the application example of the present invention;
[0022] Figure 3 This is a schematic diagram of inserting a point on a perpendicular line segment of an application example of the present invention;
[0023] Figure 4 It is a schematic diagram of inserting the perpendicular foot of the application example of the present invention on the outward extension line from the starting point of the line segment;
[0024] Figure 5 This is a schematic diagram of inserting the perpendicular foot of an application example of the present invention onto the outward extension line of the end point of the line segment. DETAILED DESCRIPTION
[0025] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0026] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0027] like Figure 1 As shown, this embodiment provides a method for constructing building polygons based on an unordered vertex set of nearest neighbor growth, including:
[0028] S1, get the input plane vertex set, and end when the number of vertices in the plane vertex set is less than 3; if the number of vertices in the plane vertex set is equal to 3, connect the three vertices respectively, store the connecting lines in the line segment set, and proceed to S6; if the number of vertices in the plane vertex set is greater than 3, proceed to S2;
[0029] S2, search for the x minimum, y maximum, x maximum and y minimum coordinate extreme value points corresponding to the plane vertex set, generate four directed line segments from the four coordinate extreme value points in sequence, store them in the line segment set, and mark the four coordinate extreme value points;
[0030] S3, based on the plane vertex set, check whether there is an unidentified point, if not, proceed to S6, if there is an unidentified point, proceed to S4;
[0031] S4, searching for an unmarked point from the line segment set that is closest to the line segment set; searching for a line segment from the line segment set that is closest to the closest point;
[0032] S5, calculate the foot of the perpendicular of the nearest point on the nearest line segment or the extension of the nearest line segment, perform a recursive search based on the positional relationship between the foot of the perpendicular and the nearest line segment or the extension of the nearest line segment, and mark all the nearest points searched, and return to S3 after completion;
[0033] S6. Connect the line segment sets in sequence to construct building polygons.
[0034] Furthermore, the method for searching for the x minimum, y maximum, and coordinate extreme value points corresponding to the x maximum and y minimum of a plane vertex set includes: when there are multiple points of x minimum, the point with the smallest y is taken as the coordinate extreme value point corresponding to the y minimum; when there are multiple points of y maximum, the point with the smallest x is taken as the coordinate extreme value point corresponding to the x minimum; when there are multiple points of x maximum, the point with the largest y is taken as the coordinate extreme value point corresponding to the y maximum; when there are multiple points of y minimum, the point with the largest x is taken as the coordinate extreme value point corresponding to the x maximum.
[0035] Furthermore, a recursive search is performed based on the positional relationship between the foot of the perpendicular and the nearest line segment or the extension of the nearest line segment, wherein the first case includes:
[0036] If the foot of the perpendicular is on the nearest line segment, the nearest point is inserted between the start and end point of the nearest line segment, the nearest line segment is deleted, and two directed line segments are added to the line segment set, from the start point of the nearest line segment to the nearest point and from the nearest point to the end point of the nearest line segment.
[0037] Furthermore, a recursive search is performed based on the positional relationship between the foot of the perpendicular and the nearest line segment or the extension of the nearest line segment, wherein the second case includes:
[0038] If the foot of the perpendicular is on the outward extension line of the starting point of the nearest segment, generate a line segment from the nearest point to the starting point of the nearest segment. If the line segment from the nearest point to the starting point of the nearest segment intersects with the line segments in the line segment set, the first case is followed; otherwise, insert the nearest point between the starting point of the nearest segment and the end point of the predecessor line of the nearest segment, delete the predecessor line of the nearest segment, and store the line segment from the nearest point to the starting point of the nearest segment and the line segment from the nearest point to the end point of the predecessor line of the nearest segment in the line segment set.
[0039] Furthermore, a recursive search is performed based on the positional relationship between the foot of the perpendicular and the nearest line segment or the extension of the nearest line segment, wherein the third case includes:
[0040] If the foot of the perpendicular is on the outward extension line of the endpoint of the nearest line segment, generate a line segment from the nearest point to the endpoint of the nearest line segment; if the line segment from the nearest point to the endpoint of the nearest line segment intersects with the line segments in the line segment set, operate according to the first case; otherwise, insert the nearest point between the endpoint of the nearest line segment and the starting point of the subsequent line of the nearest line segment, delete the subsequent line of the nearest line segment of the figure, and store the line segment from the nearest point to the endpoint of the nearest line segment and the line segment from the nearest point to the starting point of the subsequent line of the nearest line segment into the line segment set.
[0041] Specific application examples are:
[0042] (1) Calculate the number of points in the input plane vertex set P. If the number of vertices is less than 3, terminate the calculation. If the number of points is 3, connect the vertices in sequence to generate three line segments, and store the line segments in the line segment set, then jump to step 6. Otherwise, mark the serial numbers of all points as 0, that is, all points are unmarked.
[0043] (2) Search for the coordinate extreme points corresponding to the x minimum, y maximum, x maximum and y minimum, which are recorded as p respectively. xmin 、p ymax 、p xmax 、p ymin When there are multiple points with minimum x, choose the point with minimum y; when there are multiple points with maximum y, choose the point with minimum x; when there are multiple points with maximum x, choose the point with maximum y; when there are multiple points with minimum y, choose the point with maximum x. xmin 、p ymax 、p xmax 、p ymin The four points generate four directed line segments p in sequence xmin -p ymax 、p ymax -p xmax 、p xmax -p ymin and p ymin -p xmin , stored in the line segment set L; respectively xmin 、p ymax 、p xmax 、p ymin The four points are numbered 1 to 4. For example, the coordinate extreme points of the data are p7, p4, p6, and p3, and all points are marked as 1, that is, they have been marked. The four directed line segments generated are l1, l2, l3, and l4. Figure 2 shown.
[0044] (3) Check whether there is a point marked as "0". If not, go to step 6; otherwise, execute the recursive search calculation of steps 4 to 5.
[0045] (4) Combine all line segments in L into a graph q, search for a point p with a serial number of "0" and closest to q from the point set, mark p as 1, that is, it has been marked; find the line segment l closest to p from L. Line segment l is represented by p s -p e , where p s As the starting point, p e For the end point.
[0046] (5) Calculate the foot f of the perpendicular of p on line segment l or its extension, and then perform the following three operations. After completion, jump to step 3.
[0047] ①If f is on line segment l, insert p into p s and p e Delete line segment l and generate directed line segment p s -p and p-p e , stored in L. Figure 3 As shown, the foot of point p5 is on the p6-p3 line segment (the blue dotted line in the figure), so the p6-p3 line segment is removed and two line segments p6-p5 and p5-p3 are generated at the same time.
[0048] ② If f is on the outward extension line of the starting point of l, search for the previous line segment m of l and create the line segment p-p e m , where p e m is the end point of m. Check whether L exists with p-p e m Intersecting line segments: If they exist, insert point p as in operation ①; otherwise, insert p between the starting point of l and the end point of m, remove m, and add line segment p-p to L. s and p e m -p. Figure 4 As shown, p 16 Distance p 10 -p 22 The line segment is closest, and p 16 For line segment p 10 -p 22 The foot of the perpendicular falls on the outward extension line of the starting point, and L does not exist with the line segment p 16 -p 10 Intersecting line segments, remove the previous line segment p7-p 10 (blue dashed line 22 in the figure), generate and add line segment p7-p 16 and p 16 -p 10 .
[0049] ③If f is on the outward extension line of the end point of l, search for the subsequent line segment n of l and create the line segment p-p sn where p s n is the starting point of n. Check whether L exists with p-p s n Intersecting line segments: If they exist, insert point p as in operation ①; otherwise, insert p between the end point of l and the start point of n, remove n, and add line segment p to L e -p and p-p s n .like Figure 5 As shown, p 21 Distance p 16 -p 12 The line segment is closest, and p 21 P 16 -p 12 The foot of the perpendicular falls on the outward extension of the end point, and there is no perpendicular to the line segment p in L. 21 -p 12 Intersecting line segments, remove the subsequent line segment p 12 -p2 (blue dashed line 50 in the figure), add line segment p 12 -p 21 and p 21 -p2.
[0050] (6) Connect the line segments in L to generate building polygons.
[0051] The present invention discloses a method for constructing building polygons based on an unordered vertex set of nearest neighbor point growth, which can ensure that the generated polygons do not have self-intersection of edges, so that the perimeter of the generated polygons is as short as possible, that is, the polygons are as regular as possible, and the constructed building polygons conform to the geometric shape characteristics of vertex distribution, and are suitable for many scenarios of constructing building polygons such as spatial big data processing and map making. The method provided by the present invention is more feasible and practical, and can better reflect the geometric characteristics of vertex distribution.
[0052] The above are only preferred specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for constructing building polygons from an unordered vertex set based on nearest neighbor growth, characterized in that: The following steps are involved: S1, obtain the input plane vertex set, and end when the number of vertices in the plane vertex set is less than 3; if the number of vertices in the plane vertex set is equal to 3, connect the three vertices respectively, store the connecting lines in the line segment set, and proceed to S6; if the number of vertices in the plane vertex set is greater than 3, proceed to S2; S2, searching for the x minimum, y maximum, x maximum and y minimum coordinate extreme value points corresponding to the plane vertex set, generating four directed line segments from the four coordinate extreme value points in sequence, storing them in the line segment set, and marking the four coordinate extreme value points; S3, based on the plane vertex set, check whether there is an unidentified point, if not, proceed to S6, if there is an unidentified point, proceed to S4; S4, searching for an unmarked point closest to the line segment set from the line segment set; and searching for a line segment closest to the closest point from the line segment set; S5, calculating the foot of the perpendicular of the nearest point on the nearest line segment or the extension of the nearest line segment, performing a recursive search based on the positional relationship between the foot of the perpendicular and the nearest line segment or the extension of the nearest line segment, and marking all the nearest points searched, and returning to S3 after completion; S6, connecting the line segment sets in sequence to construct a building polygon; A recursive search is performed based on the positional relationship between the foot of the perpendicular and the nearest line segment or the extension of the nearest line segment, wherein the first case includes: If the foot of the perpendicular is on the nearest line segment, delete the nearest line segment, and add two directed line segments from the starting point of the nearest line segment to the nearest point and from the nearest point to the end point of the nearest line segment to the line segment set; A recursive search is performed based on the positional relationship between the foot of the perpendicular and the nearest line segment or the extension of the nearest line segment, wherein the second case includes: If the foot of the perpendicular is on the outward extension line from the starting point of the nearest line segment, generate a line segment from the nearest point to the starting point of the nearest line segment; if the generated line segment intersects with the line segments in the line segment set, operate according to the first case; otherwise, insert the nearest point between the starting point and the end point of the predecessor line of the nearest line segment, delete the predecessor line of the nearest line segment, and store the line segment from the starting point of the predecessor line to the nearest point and the line segment from the nearest point to the end point of the predecessor line segment in the line segment set; A recursive search is performed based on the positional relationship between the foot of the perpendicular and the nearest line segment or the extension of the nearest line segment, wherein the third case includes: If the foot of the perpendicular is on the outward extension line of the endpoint of the nearest line segment, generate a line segment from the nearest point to the endpoint of the nearest line segment; if the line segment from the nearest point to the endpoint of the nearest line segment intersects with the line segments in the line segment set, operate according to the first case; otherwise, insert the nearest point between the starting point and the end point of the subsequent line segment of the nearest line segment, delete the subsequent line of the nearest line segment, and store the line segment from the starting point of the subsequent line segment to the nearest point and the line segment from the nearest point to the end point of the subsequent line segment in the line segment set.
2. The method for constructing building polygons from an unordered vertex set based on nearest neighbor growth as claimed in claim 1, characterized in that: The method for searching for the x minimum, y maximum, and coordinate extreme value points corresponding to the x maximum and y minimum of the plane vertex set includes: when there are multiple points of x minimum, the point with the smallest y is taken as the coordinate extreme value point corresponding to the y minimum; when there are multiple points of y maximum, the point with the smallest x is taken as the coordinate extreme value point corresponding to the x minimum; when there are multiple points of x maximum, the point with the largest y is taken as the coordinate extreme value point corresponding to the y maximum; when there are multiple points of y minimum, the point with the largest x is taken as the coordinate extreme value point corresponding to the x maximum.
