A method and apparatus for contour closing

CN122780452APending Publication Date: 2026-09-18POWERCHINA ZHONGNAN ENG
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611272090.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-21
Publication Date
2026-09-18

AI Technical Summary

Technical Problem

[0004]但该种方式,由于依赖人工逐一处理,接边效率低

Benefits of technology

本申请提供了一种等高线接边方法及装置,本公开实现了等高线接边的全流程自动化,无需人工逐对查找断裂端点、修剪、拼接及检查。通过自动确定接边区域、按高程分组、划分候选对、拓扑校验及合并,并输出新等高线及其走向,显著提高了接边效率,避免了新增交叉拓扑错误,确保成果一致性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122780452A_ABST
    Figure CN122780452A_ABST
Patent Text Reader

Abstract

The application discloses a contour edge connecting method and device, and relates to the technical field of digital terrain, which comprises the following steps: determining a connecting region according to the spatial distribution of contours to be connected in an AutoCAD model space; grouping the contours in the connecting region according to elevations to obtain at least one same-elevation group; performing the following edge connecting steps for each same-elevation group: removing closed contours in the group, matching the remaining non-closed contours two by two, dividing intersection point edge connecting candidate pairs and end point edge connecting candidate pairs, and determining the connection types of the candidate pairs; performing topological intersection checking on each end point edge connecting candidate pair in sequence, and removing the end point edge connecting candidate pairs that fail to pass the checking; merging the intersection point edge connecting candidate pairs and the end point edge connecting candidate pairs that pass the checking to obtain new contours, and determining the directions of the new contours in combination with the corresponding connection types; and outputting the new contours and the corresponding directions after detecting that all the same-elevation groups are processed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of digital terrain technology, and in particular to a method and apparatus for contour line joining. Background Technology

[0002] Hydropower engineering survey areas typically have large topographic relief and a wide range, and topographic data are often obtained by means of multiple aerial surveys, lidar, field and field surveys in different areas, and map compilation.

[0003] In the process of data processing and map making, it is necessary to manually find and connect pairs of contour lines at the same elevation between adjacent map sheets or zones to complete the contour line splicing operation.

[0004] However, this method is inefficient because it relies on manual processing one by one. Summary of the Invention

[0005] The purpose of this application is to provide a contour line splicing method and apparatus that can improve splicing efficiency.

[0006] To achieve the above objectives, this application provides the following solution: In a first aspect, this application provides a contour line joining method, the method comprising: The joining area is determined based on the spatial distribution of the contour lines of the edges to be joined in the AutoCAD model space. Contour lines within the boundary area are grouped by elevation to obtain at least one group with the same elevation. For each group with the same elevation, perform the following edge-joining steps: Remove closed contour lines within the group, match the remaining non-closed contour lines pairwise, divide them into candidate pairs of intersection points and candidate pairs of endpoints, and determine the connection type of each candidate pair. Perform topological intersection verification on each candidate endpoint edge pair in turn, and remove the candidate endpoint edge pairs that fail the verification; merge the candidate intersection edge pairs and the candidate endpoint edge pairs that pass the verification to obtain new contour lines, and determine the direction of the new contour lines in combination with the corresponding connection type. After all contour groups have been processed, new contour lines and their corresponding orientations are output in the AutoCAD model space.

[0007] Secondly, this application provides a contour line splicing device, the device comprising: The determination module is used to determine the joint area based on the spatial distribution of contour lines of the edges to be joined in the AutoCAD model space. The grouping module is used to group contour lines within the docking area according to elevation, resulting in at least one group with the same elevation. The processing module is used to perform the following edge-joining steps for each group with the same elevation: Remove closed contour lines within the group, match the remaining non-closed contour lines pairwise, divide them into candidate pairs of intersection points and candidate pairs of endpoints, and determine the connection type of each candidate pair. Perform topological intersection verification on each candidate endpoint edge pair in turn, and remove the candidate endpoint edge pairs that fail the verification; merge the candidate intersection edge pairs and the candidate endpoint edge pairs that pass the verification to obtain new contour lines, and determine the direction of the new contour lines in combination with the corresponding connection type. The output module is used to output new contour lines and their corresponding orientations in the AutoCAD model space after all groups of the same elevation have been processed.

[0008] According to the specific embodiments provided in this application, the following technical effects are disclosed: This application provides a contour line splicing method and apparatus. This disclosure automates the entire contour line splicing process, eliminating the need for manual searching of broken endpoints, trimming, splicing, and inspection. By automatically determining the splicing area, grouping by elevation, dividing candidate pairs, performing topology verification and merging, and outputting new contour lines and their orientations, it significantly improves splicing efficiency, avoids adding new cross-topology errors, and ensures consistency of results. Attached Figure Description

[0009] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0010] Figure 1 This is a flowchart illustrating a contour line joining method according to an exemplary embodiment; Figure 2 This is a schematic diagram of the joint area according to an exemplary embodiment; Figure 3 This is a schematic diagram of endpoint fitting according to an exemplary embodiment; Figure 4 This is a schematic diagram of an endpoint connection according to an exemplary embodiment; Figure 5 This is a functional module diagram of a contour line joining device provided in an embodiment of this application; Figure 6 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0011] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0012] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0013] Figure 1 This is a flowchart illustrating a contour line joining method according to an exemplary embodiment, such as... Figure 1 As shown, the method includes the following steps S101-S104: In step S101, the edge-joining area is determined based on the spatial distribution of the contour lines of the edges to be joined in the AutoCAD model space.

[0014] In one embodiment, step S101 includes the following sub-steps S1011-S1013: S1011: Receive the contour lines of multiple edges to be joined selected by the user in the AutoCAD model space.

[0015] Users select multiple contour lines that need to be joined using the AutoCAD interface (e.g., by using a mouse to select or click). These contour lines are typically LWPOLYLINE type and have an elevation attribute.

[0016] S1012. Obtain the joint outer rectangle of the contour lines of multiple edges to be joined.

[0017] The system iterates through all contour lines selected by the user in S1011, calculates the bounding rectangle of each contour line (i.e., the smallest axis-aligned rectangle that can completely contain the contour line), and then takes the union of all contour line bounding rectangles to obtain a joint bounding rectangle. : ; in, This represents the i-th contour line selected by the user. This represents the minimum bounding rectangle for calculating a single contour line.

[0018] Joint outsourcing rectangle The maximum span and range of all selected contour lines are represented as the rectangular boundary coordinates: (minX, minY, maxX, maxY).

[0019] For example, if the smallest X-coordinate among all contour lines is 100, the largest X-coordinate is 500, the smallest Y-coordinate is 200, and the largest Y-coordinate is 600, then the boundary of the joint outer rectangle is minX=100, maxX=500, minY=200, and maxY=600.

[0020] S1013. Based on the preset margin expansion coefficient, the joint outer rectangle is expanded outward to obtain the edge area.

[0021] In order to ensure that the joint area can fully cover the joint zone where contour lines may break or intersect, and to avoid missing the elevation lines at the edge, the joint outer rectangle obtained in S1012 needs to be extended outward by a certain margin.

[0022] Specifically, a margin expansion factor m is preset (e.g., the default value is 0.1, i.e., 10%), and the expansion widths in the X direction (marginX = (maxX - minX) × m) and Y direction (marginY = (maxY - minY) × m) are calculated respectively. Then, the four boundaries of the joint outer rectangle are translated outward by the above widths to obtain a new rectangular region E: E.minX = minX - marginX; E.maxX = maxX + marginX; E.minY = minY - marginY; E.maxY = maxY + marginY; Where E.minX, E.maxX, E.minY, and E.maxY represent the minimum X-coordinate, maximum X-coordinate, minimum Y-coordinate, and maximum Y-coordinate of the edge region obtained after outward expansion, respectively. Figure 2 As shown.

[0023] The rectangular area E is the jointing area used for subsequent jointing processing. This area includes the original range of all contour lines to be joined, and extends outwards with sufficient space to ensure that all line segments that may participate in the jointing are covered. Users can also customize the margin expansion factor according to the actual map overlap.

[0024] By extending the bounding rectangle outward to determine the joint area, the joint area can be automatically covered, avoiding subjective errors or omissions caused by manual delineation. At the same time, the introduction of the extension coefficient ensures that the joint area has sufficient inclusiveness to adapt to different map sheet overlap situations.

[0025] In step S102, the contour lines within the docking edge area are grouped according to elevation to obtain at least one group with the same elevation.

[0026] In one embodiment, step S102 involves grouping the contour lines within the boundary area according to their elevation to obtain at least one group with the same elevation, including performing the following steps A1-A2 on each contour line: A1. Calculate the absolute value of the difference between the current contour line elevation value and each preset standard elevation value.

[0027] Multiple standard elevation values ​​are set in advance. These standard elevation values ​​are usually integer values ​​or theoretical elevation values ​​set according to contour intervals, such as 20 meters, 21 meters, 22 meters, etc.

[0028] For each contour line Z currently being processed, obtain its elevation attribute value (e.g., 20.05 meters), and then calculate the absolute value of the difference between this elevation value and each preset standard elevation value. .

[0029] For example, if the preset standard elevation values ​​are 20 meters, 21 meters, and 22 meters, and the current contour line elevation is 20.05 meters, then the calculated absolute values ​​are: |20.05-20|=0.05 meters, |20.05-21|=0.95 meters, and |20.05-22|=1.95 meters.

[0030] A2. Contour lines whose calculated absolute values ​​are less than the preset elevation tolerance are assigned to the same elevation group corresponding to the preset standard elevation value.

[0031] Preset an elevation tolerance (For example, 0.1 meters). Calculate the absolute values ​​obtained in step A1. and Compare them.

[0032] If there exists a preset standard elevation value, such that the current contour line elevation is... Compared with the standard value The absolute value of the difference Less than If so, the contour line is assigned to the same elevation group corresponding to the standard elevation value.

[0033] If the absolute value of the difference between the current contour line elevation and all preset standard elevation values ​​is not less than (i.e., there is no matching standard elevation value), then the elevation value of that contour line is used. As the new standard elevation value, create a new group of equal elevations and assign the contour line to that new group.

[0034] Continuing with the previous example, 0.05 meters < 0.1 meters, therefore the contour line with an elevation of 20.05 meters is assigned to the same elevation group corresponding to the standard elevation value of 20 meters. Assuming another contour line has an elevation of 20.15 meters, the calculated differences are 0.15 meters (difference from 20 meters > 0.1), 0.85 meters (difference from 21 meters), and 1.85 meters (difference from 22 meters), all of which are not less than 0.1 meters. Therefore, there is no matching preset standard elevation value. In this case, 20.15 meters is used as the new standard elevation value, a new same elevation group is created, and the contour line is assigned to this new group.

[0035] By using preset standard elevation values ​​and elevation tolerances for grouping, a large number of contour lines can be quickly classified into theoretical elevation groups, effectively eliminating misgrouping caused by minor elevation deviations due to data acquisition or storage errors. It is particularly suitable for survey areas with known contour intervals and regular elevations.

[0036] In one embodiment, step S102 involves grouping the contour lines within the boundary area according to their elevation to obtain at least one group with the same elevation, including the following sub-steps B1-B2: B1. Traverse each contour line. If any vertex of the contour line is located within the adjacent region, add the contour line to the candidate set.

[0037] The border region E has been determined in step S101. All contour lines selected by the user in step S1011 are traversed, and for each contour line, the coordinates of all its vertices are checked. If the coordinates of any vertex of a contour line fall within the rectangular area of ​​the border region E, then that contour line is determined as a "candidate contour line" and added to the candidate set. If all vertices of a contour line are not within the border region, it means that the contour line is far from the border zone and will not participate in subsequent border processing; therefore, it is not added to the candidate set.

[0038] B2. After the traversal is completed, the contour lines in the candidate set are grouped according to their elevation to obtain at least one group with the same elevation.

[0039] Once all contour lines have been traversed and the candidate set has been constructed, the contour lines in the candidate set are clustered according to their elevation values. The grouping process is similar to steps A1-A2.

[0040] First, candidate contour lines are selected by whether the vertex is located within the boundary area. Then, the candidate set is grouped by elevation. This can significantly reduce the number of contour lines involved in the grouping calculation, reduce computational overhead, and is especially suitable for boundary scenarios of topographic maps with large areas and many contour lines, thereby improving the overall processing efficiency.

[0041] In step S103, the following edge-joining steps S1031-S1032 are performed for each group with the same elevation: S1031. Eliminate closed contour lines within the group, match the remaining non-closed contour lines pairwise, divide them into candidate pairs of intersection points and candidate pairs of endpoints, and determine the connection type of each candidate pair.

[0042] For the contour line set within each elevation group obtained in step S102 First, closed polylines (Closed=true) are filtered out. Closed contour lines do not have broken endpoints that require splicing, so they are not included in the splicing process. For the remaining non-closed contour lines in the group, pairwise pairing detection is performed according to the following two matching rules: (a) Intersection matching.

[0043] If two contour lines intersect at least once within the boundary area, and the elevation difference between the two contour lines is less than a preset elevation difference, then these two contour lines are classified as candidate pairs for intersection boundary.

[0044] For any two non-closed contour lines within the same elevation group and If they have at least one intersection point within the junction area E determined in step S101 And the elevation difference between the two contour lines satisfies: ; in, To preset the elevation difference (default 0.1 meters), here... It can be compared with the above embodiments. If the values ​​of are the same, then these two contour lines are divided into "intersection edge candidate pairs".

[0045] like Figure 2 The intersection point is shown. The situation within the boundary region E.

[0046] (ii) Endpoint matching.

[0047] If the minimum distance between the endpoints of two contour lines is less than a preset distance threshold, then these two contour lines are classified as candidate endpoint connection pairs.

[0048] For any two non-closed contour lines within the same elevation group and If they do not intersect within the boundary region E, then the minimum distance between the endpoints of the two contour lines is further calculated.

[0049] Set contour lines The set of endpoints within the border region is contour lines The set of endpoints within the border region is Then the minimum distance Defined as: ; in This represents the Euclidean distance between endpoints p and q. If this minimum distance is less than a preset distance threshold... That is, satisfying: ; These two contour lines are then classified as "endpoint edge candidate pairs".

[0050] Among them, the preset distance threshold between the endpoints of the polyline to be joined Users can input it manually.

[0051] like Figure 2 As shown, the endpoint distance between endpoints A1 and A2 is... ,at this time, .

[0052] For each candidate pair identified, its connection type can be determined based on geometric properties. There are four connection types: "end-to-end", "end-to-start", "start-to-start", and "start-to-end". These types are used to guide the order of vertex sequences in subsequent merging operations to avoid incorrect contour line orientation after edge merging.

[0053] By clearly distinguishing between intersection conditions and endpoint conditions, all possible edge-joining situations can be automatically identified: including both contour pairs that intersect within the edge zone and contour pairs that are broken at their endpoints but close to each other, thus ensuring comprehensive matching and avoiding omissions.

[0054] S1032. Perform topological intersection verification on each candidate pair of endpoints in sequence, and remove the candidate pairs of endpoints that fail the verification; merge the candidate pairs of intersections and the candidate pairs of endpoints that pass the verification to obtain new contour lines, and determine the direction of the new contour lines in combination with the corresponding connection type.

[0055] In one embodiment, the step of sequentially performing topological intersection verification on each candidate endpoint edge pair and eliminating candidate endpoint edge pairs that fail the verification includes the following sub-steps C1-C4: C1. Fit and connect the endpoints corresponding to the minimum distance between the two contour lines in the candidate endpoint connection pair to obtain the fitted connection line.

[0056] For each candidate pair of endpoints identified in step S1031, the minimum distance between the two contour lines in that candidate pair has been recorded. The system identifies the two corresponding endpoints. These endpoints lie on two separate contour lines, one being the start or end point of the first contour line and the other the start or end point of the second contour line. The system obtains the precise coordinates of these two endpoints and draws a temporary straight line segment between them. (i.e., "fitted connector") C2. Detect whether the fitted connecting line intersects with other elevation lines in the border area.

[0057] Obtain the fitted connection line Then, within the junction region E, the system detects whether the fitted connecting line intersects with other contour lines geometrically.

[0058] During the detection, the topology intersection check function is called. WouldCauseIntersection(...) Constructing a fitting connection line newPl ,use IntersectWith Check the intersection points within the joint area.

[0059] C3. If they exist, then remove the candidate pairs of endpoint edges that have intersection points.

[0060] like If a contour line intersects with another contour line within the boundary area, it is determined that an intersection will occur, and the candidate is discarded.

[0061] C4. If it does not exist, it is a qualified endpoint connection candidate pair.

[0062] like Figure 3 As shown, Figure 3 The image shows candidate endpoint connection pairs C1 and C2. By fitting the endpoints of C1 and C2, a fitted connection line is obtained. , Since the contour line Cother intersects with other contour lines at point Q within E, the candidate edge pairs C1 and C2 with intersection points are eliminated.

[0063] Before the formal merging, a topological intersection check is performed on the candidate pairs of endpoints. By fitting the connecting lines and detecting the intersections with the surrounding contour lines, candidate pairs that may lead to new intersections can be eliminated in advance, ensuring that the topological contours after the merging are conflict-free from the source and improving the quality of the results.

[0064] In one embodiment, merging candidate pairs of intersection points to obtain new contour lines includes the following sub-steps D1-D5: D1. Break the two contour lines in the candidate pair of intersection points at the intersection point and retain the longer valid segment of each contour line.

[0065] The system calls AutoCAD's GetSplitCurves function to break each contour line at the intersection point, resulting in two sub-segments. The system compares the lengths of the two sub-segments after each contour line is broken, keeping the longer segment as the valid segment and discarding the shorter one. In this way, each contour line retains only the part most likely to form the main line, thus obtaining two valid segments. These two valid segments are naturally connected at the intersection point (sharing the intersection point as a common endpoint).

[0066] D2. Within the junction area, determine the nearest endpoint pair of two valid segments and determine the connection type of the nearest endpoint pair.

[0067] After breaking and retaining the valid segments, the two valid segments share a common endpoint at their intersection (i.e., the intersection itself). To ensure the correct orientation of the merged contour lines, the system needs to redetermine the closest pair of endpoints between the two valid segments within the boundary region E. This involves extracting all endpoints on the two valid segments that lie within the boundary region (typically including the intersection and their respective ends furthest from the intersection), calculating the minimum distance between these endpoints, and finding the closest pair of endpoints.

[0068] Once the nearest endpoint pair is determined, the connection type is directly determined based on the inherent properties of these two endpoints on their respective valid segments (e.g., whether they are start or end points, or their position in the original contour vertex sequence), without the need for additional direction calculation. For example, if one endpoint in the nearest endpoint pair is the start point of the first valid segment and the other is the end point of the second valid segment, then the connection type is "start-end". This connection type will be used for the merging order of subsequent vertex sequences.

[0069] D3. Remove duplicate vertices that coincide in the nearest endpoint pair.

[0070] When the two endpoints of the most recent endpoint pair coincide (i.e., the intersection itself, which is the most common case), since the two valid segments share a single point at the intersection, this point will be recorded twice when merging the vertex sequences. Therefore, the system needs to remove one duplicate vertex and retain only one intersection coordinate.

[0071] D4. According to the connection type, merge the vertex sequences of the two valid segments to generate new contour lines.

[0072] The vertex sequences of the two valid segments (after removing overlapping common endpoints from step D3) are sequentially concatenated into a complete vertex sequence. Based on this vertex sequence, the system generates a new polyline in the AutoCAD model space, which serves as the new contour line. The new contour line inherits all the graphic attributes of the original two contour lines, including layer, linetype, linewidth, color, transparency, and elevation value.

[0073] D5. Delete the original two contour lines.

[0074] After the new contour lines are generated, the system deletes the original two contour lines involved in the edge joining from the model space to avoid duplicate or redundant graphic objects. At this point, the merging operation for a candidate pair of intersection edges is complete.

[0075] For intersection edge cases, by breaking, retaining longer valid segments, deduplicating, and merging vertex sequences according to connection type, the main body of the contour line can be automatically preserved, short fragments in the edge zone can be removed, and the direction of the new contour line can be correct, the vertices can be continuous, and there can be no duplicate points.

[0076] In one embodiment, merging the verified candidate endpoints to obtain a new contour line includes the following sub-steps E1-E4: E1. Connect the two contour lines in the qualified endpoint edge candidate pair at the endpoint to be connected to generate a new contour line.

[0077] For each candidate endpoint pair identified in step S1031 and verified through topological intersection in steps C1-C4, the system has recorded the two endpoints (i.e., "endpoints to be connected") corresponding to the minimum distance dmindmin between the two contour lines in that candidate pair. This step connects these two contour lines at the endpoints to be connected, forming a continuous contour line. The specific connection method is defined by further sub-steps E11-E13.

[0078] In one embodiment, the two contour lines in the qualified endpoint edge candidate pair verified in step E1 are connected at the endpoints to be connected to generate new contour lines, including the following sub-steps E11-E13: E11. Project the endpoints of one contour line to be connected onto another contour line to determine the projection point.

[0079] Let C1 and C2 be two contour lines in the candidate endpoint pair, and let P1 (located on C1) and P2 (located on C2) be the endpoints to be connected, respectively, with the distance between P1 and P2 being less than a preset threshold. The system selects the endpoint P1 of one contour line (e.g., C1) to be connected and projects it onto the other contour line C2 to obtain the projection point Q. The projection point is calculated using the point-to-line segment projection formula: Given a line segment on C2, with starting point A, ending point B, and projection point P, first calculate the projection parameter t: ; Then the coordinates of the projection point are obtained: ; If the projection point falls outside the endpoint of the line segment (i.e., t<0 or t>1), then the endpoint of the line segment closest to P is taken as the projection point. This projection point Q will be used as the location for subsequent breaks and connections.

[0080] E12. At the projection point, break another contour line to obtain two line segments, and keep the longer one.

[0081] At projection point Q, the system uses AutoCAD's GetSplitCurves method to break another contour line C2, resulting in two sub-segments. The system compares the lengths of the two sub-segments, retaining the longer one as the valid segment C2′ and discarding the shorter one. For the projected contour line C1, its endpoint P1 to be connected remains unchanged.

[0082] E13. Connect one contour line to the longer section that has been retained at the projection point to obtain a new contour line.

[0083] Connect the unbroken contour line C1 (including the endpoint P1 to be connected) to the valid segment C2′ retained after the break at the projection point Q. Since the distance between P1 and Q may not be zero (the projection point may not coincide with the original endpoint), the vertex order of one of the lines needs to be reversed depending on the connection type to ensure the formation of a continuous polyline. Specifically, the vertex sequences of the two lines (after removing duplicate endpoints at the connection point) are spliced ​​sequentially to generate a new polyline as the new contour line. The direction of this new contour line is determined by the connection type: if the connection type is "start-start" or "end-end", the vertex order of one of the lines needs to be reversed; if it is "start-end" or "end-start", the original order can be maintained.

[0084] like Figure 4 As shown, contour lines C1 and C2 are given. The endpoint P1 of C1 is projected onto contour line C2, with the projection point being Q. C2 is then broken at point Q, with the break point being Break.

[0085] exist Figure 4 In the diagram, the docking end of C1 is P1, and the docking end of C2 is the projection point Q. Since contour lines are directional lines, when two broken contour lines are docked, the two docking ends will form four kinds of start point / end point combinations. Different combinations must reverse the order of the corresponding line vertices in order to ensure that the trend of the target contour line after splicing is continuous and smooth.

[0086] ①End–Start (End-Start).

[0087] C1 is used to connect to its own end point (End); C2 is used to connect to its own start point (Start).

[0088] The path of C1 is: S1→…→P1(End); The direction of C2 is: Q(Start)→…→E2; The two curves naturally satisfy "end point connected to start point", the curve flow is coherent, and no reverse bending occurs after splicing.

[0089] Therefore, it is not necessary to reverse the vertex order of any line segment of C1 and C2, and direct splicing can be performed directly.

[0090] ② End–End.

[0091] The docking end of C1 is End, and the docking end of C2 is also End.

[0092] The terminal P1 of C1 is an end point, and the terminal Q of C2 is an end point, which is a "tail-to-tail" connection of the two curves. Direct splicing will result in inwardly folded polyline, and the morphology of terrain contour lines will be disordered.

[0093] Therefore, the vertex sequence of the entire contour line C2 can be reversed. After reversal, the direction of C2 becomes: original end point E2→…→Q(Start). At this time, the end point P1 of C1 docks with the start point Q of reversed C2, and the direction is coherent.

[0094] ③ Start–Start.

[0095] The docking end of C1 is Start, and the docking end of C2 is also Start.

[0096] The two curves form a "head-to-head" connection, direct splicing will diverge outward in two directions, generating wrong terrain lines.

[0097] Therefore, the vertex sequence of the entire contour line C1 can be reversed. After reversal, the direction of C1 becomes: original end point E1→…→P1(End). The end point of reversed C1 docks with the original start point Q of C2, and the line direction is continuous.

[0098] ④ Start–End.

[0099] The docking end of C1 is Start, and the docking end of C2 is End.

[0100] The head of C1 docks with the tail of C2, the flow directions of the two lines are completely opposite, and an S-shaped reverse turning line is formed after splicing.

[0101] Therefore, the vertex sequences of both contour lines C1 and C2 can be reversed simultaneously. Reversal of C1: E1→…→P1(End); reversal of C2: E2→…→Q(Start); finally, the end point of C1 docks with the start point of C2, and the curve is smooth and continuous.

[0102] In the process of endpoint edge connection, the operations of projection point determination, splitting and retaining longer segments are introduced, which can enable the connection point to be located at a suitable position of another contour line (instead of being forcibly connected to the original endpoint), and effectively avoid the wrong connection of short fragmented segments in the edge connection area to the main line by retaining longer segments, thus improving the geometric rationality of edge connection.

[0103] E2. Delete duplicate vertices at connection endpoints.

[0104] During connection, the endpoints to be connected of the two contour lines will coincide at the connection point. Since the merged new contour line should not contain duplicate vertex coordinates, the system needs to delete one of the coincident endpoints and keep only one. If the connection type is start-to-start or end-to-end, after reversing the vertex sequence of one of the contour lines, it is also necessary to check and delete duplicate vertices at the connection.

[0105] E3. Inherit the attributes of the original two contour lines to the new contour line.

[0106] The newly generated contour line needs to maintain the cartographic attributes of the original contour lines to ensure that the result meets the delivery standards. The system assigns all attributes of the original two contour lines, including layer, linetype, lineweight, color, transparency and elevation, to the newly generated contour line. If the attributes of the two original contour lines are inconsistent, the processing can be performed according to preset rules (for example, taking the attributes of the first one, or taking the attributes common to both).

[0107] E4. Delete the two original contour lines.

[0108] After the new contour line is generated and assigned attributes, the system deletes the original two contour lines participating in the edge connection from the AutoCAD model space to avoid graphics redundancy and conflict.

[0109] Aiming at the endpoint edge connection scenario, rapid merging of broken contour lines is realized by directly connecting the endpoints to be connected, deleting duplicate vertices and inheriting original attributes. The operation is simple and efficient, and ensures that the cartographic attributes of the new contour line are consistent with the original Figure 1 and can be directly used for delivery.

[0110] In step S104, after detecting that all contour lines in the same elevation group have been processed, the new contour lines and their corresponding trends are output in the AutoCAD model space.

[0111] The system displays all the new contour lines (that is, the merged polylines) generated in step S103 in the AutoCAD model space.

[0112] This disclosure automates the entire process of contour line splicing, eliminating the need for manual searching, trimming, splicing, and inspection of each pair of broken endpoints. By automatically determining the splicing area, grouping by elevation, dividing candidate pairs, performing topology verification and merging, and outputting new contour lines and their orientations, it significantly improves splicing efficiency, avoids adding new cross-topology errors, and ensures consistency of results.

[0113] The following are specific embodiments of this disclosure.

[0114] Batch edge stitching of contour lines on large-scale topographic maps of hydropower projects (AutoCAD plugin command).

[0115] (1) Input data.

[0116] Model space contour lines: LWPOLYLINE, Elevation is the elevation of the contour lines; Data source: A collection of contour lines at the same elevation that are broken after multiple map sheets are spliced ​​together or divided into sections; User selection: Select multiple contour lines that are suspected of needing to be joined in the window near the joint strip.

[0117] (2) Table 1 is a typical parameter table (default recommendation).

[0118] Table 1

[0119] (3) Execution steps.

[0120] Run the command AutoContourEdgeMatching; enter ; Select / click on the polyline contour lines that need to be joined; The system automatically calculates the joint area and groups it according to elevation tolerance; Automatically match contour pairs within each group and perform edge splicing; Automatically delete the original contour lines, generate new merged contour lines, and preserve their attributes.

[0121] (4) Implementation effect.

[0122] Within the junction zone, contour lines of the same elevation fault can be automatically merged into continuous lines. In cases where there are intersections, automatic edge joining can be achieved by breaking the intersection and retaining a longer effective segment; The "fitting new line - intersection detection" constraint can significantly reduce new crossover errors after edge joining; Compared to purely manual edge joining, this method can significantly reduce the number of manual selections and trimmings for the same workload, greatly improving work efficiency and consistency.

[0123] Currently, the terrain in hydropower engineering survey areas is highly undulating, often requiring multiple aerial surveys / liDAR operations, regional field and office mapping, and segmented map creation. Due to factors such as data stitching, boundary clipping, localized revisions, and differences in layer styles, contour lines frequently exhibit the following edge-joining issues: 1) If contour lines at the same elevation break at the junction, they need to be manually found and connected one by one; 2) The endpoints are close but the connection directions are inconsistent, which can easily lead to incorrect connections (start-to-start / end-to-end need to be reversed). 3) Local intersections or overlaps exist, and new intersections are easily generated after the edges are joined, which disrupts the contour topology; 4) In large-area results, there are many contour lines at the same elevation and many endpoints, and manual edge joining is time-consuming and inconsistent.

[0124] Existing commercial mapping software or manual methods typically rely on an interactive process of "finding endpoints—manual trimming—splitting—checking," which is inefficient and unreliable for large-scale hydropower engineering projects, failing to meet the demands of rapid production. Therefore, an automated method and system are needed that can automatically perform batch edge splicing of selected contour lines in AutoCAD and automatically avoid adding new intersection errors.

[0125] This disclosure addresses at least the following issues: (1) In the edge area (the narrow strip of two adjacent drawings that overlap and are used to join them together), how to automatically group a large number of contour lines according to the elevation tolerance to avoid omission or misgrouping of the same elevation lines. (2) Within the same elevation group, how to automatically identify contour line pairs that can be connected (intersection connection / endpoint connection) and determine the connection type (endpoint connection, intersection connection). (3) How to automatically complete "pruning / breaking / taking valid segments / removing duplicate vertices / reconstructing vertex sequences / preserving attributes" when connecting edges; (4) How to avoid creating new intersections, backtracks or unreasonable topologies after the joint (especially within the joint zone). (5) How to batch process and output directly deliverable joint results in AutoCAD.

[0126] Compared with the prior art, this disclosure has the following significant effects: Compared with manual edge joining / conventional semi-automatic tools, this disclosure has the following advantages: (1) Automatic batch matching and merging: Automatically group and match contour lines with the same elevation, significantly reducing manual pair-by-pair searching; (2) Compatible with intersection and endpoint joints: It can handle both the break where the endpoints are separate and the complex situation where there are intersections in the joint. (3) Topological constraint to prevent intersection: Before connecting edges, “fitting new lines - intersection detection” is performed to effectively avoid topological errors such as new intersections and backtracking lines; (4) Attribute inheritance and consistent results: The newly generated contour lines inherit the original layer, line type, line width, transparency and elevation attributes, and the results can be directly used for delivery; (5) Improved engineering efficiency: Applicable to the scenario of splicing and rapid editing of large-scale topographic maps of hydropower projects, improving the efficiency and consistency of internal production.

[0127] Based on the same inventive concept, this application also provides a contour line joining device for implementing the contour line joining method described above. The solution provided by this device is similar to the solution described in the above method. Therefore, the specific limitations of one or more contour line joining device embodiments provided below can be found in the limitations of the contour line joining method above, and will not be repeated here.

[0128] In one exemplary embodiment, such as Figure 5 As shown, a contour line splicing device is provided, the device comprising: The determination module is used to determine the joint area based on the spatial distribution of contour lines of the edges to be joined in the AutoCAD model space. The grouping module is used to group contour lines within the docking area according to elevation, resulting in at least one group with the same elevation. The processing module is used to perform the following edge-joining steps for each group with the same elevation: Remove closed contour lines within the group, match the remaining non-closed contour lines pairwise, divide them into candidate pairs of intersection points and candidate pairs of endpoints, and determine the connection type of each candidate pair. Perform topological intersection verification on each candidate endpoint edge pair in turn, and remove the candidate endpoint edge pairs that fail the verification; merge the candidate intersection edge pairs and the candidate endpoint edge pairs that pass the verification to obtain new contour lines, and determine the direction of the new contour lines in combination with the corresponding connection type. The output module is used to output new contour lines and their corresponding orientations in the AutoCAD model space after all groups of the same elevation have been processed.

[0129] In one embodiment, regarding the determination of the joint area based on the spatial distribution of contour lines of the edges to be joined in the AutoCAD model space, the determining module is specifically used for: Receives contour lines from multiple edges to be joined, selected by the user in the AutoCAD model space; Obtain the joint outer rectangle of contour lines from multiple edges to be joined; Based on the preset margin expansion coefficient, the joint outer rectangle is expanded outward to obtain the edge area.

[0130] In one embodiment, contour lines within the docking edge region are grouped by elevation to obtain at least one aspect in the same elevation group. The grouping module is specifically used to perform the following steps on each contour line: Calculate the absolute value of the difference between the current contour line elevation value and each preset standard elevation value; Contour lines whose calculated absolute values ​​are less than the preset elevation tolerance are assigned to the same elevation group corresponding to the preset standard elevation value.

[0131] In one embodiment, in the aspect of matching the remaining non-closed contour lines pairwise to divide them into candidate pairs of intersection edges and candidate pairs of endpoint edges, the processing module is specifically used for: If two contour lines intersect at least once in the boundary area, and the elevation difference between the two contour lines is less than the preset elevation difference, then the two contour lines are divided into candidate pairs of intersection points. If the minimum distance between the endpoints of two contour lines is less than a preset distance threshold, then these two contour lines are classified as candidate endpoint connection pairs.

[0132] In one embodiment, in the aspect of sequentially performing topological intersection verification on each candidate endpoint edge pair and eliminating candidate endpoint edge pairs that fail the verification, the processing module is specifically used for: The endpoints corresponding to the minimum distance between two contour lines in the candidate endpoint edge pair are fitted and connected to obtain the fitted connection line. Detect whether the fitted connection line intersects with other elevation lines in the border area; If they exist, then remove the candidate pairs of endpoint edges that have intersection points.

[0133] In one embodiment, regarding the merging of candidate intersection edge pairs to obtain a new contour line, the processing module is specifically configured to: Break the two contour lines in the candidate pair of intersection points at the intersection point and retain the longer valid segment of each contour line. Within the junction area, identify the nearest endpoint pair of two valid segments and determine the connection type of the nearest endpoint pair; Remove duplicate vertices that coincide in the nearest endpoint pair; According to the connection type, the vertex sequences of the two valid segments are merged to generate new contour lines; Delete the original two contour lines.

[0134] In one embodiment, in the aspect of merging the verified candidate endpoints to obtain new contour lines, the processing module is specifically used for: Connect the two contour lines from the qualified endpoint edge candidate pairs at the endpoints to be connected to generate new contour lines. Remove duplicate vertices at the endpoints of the connection; Inherit the properties of the original two contour lines to the new contour line; Delete the original two contour lines.

[0135] In one embodiment, in the aspect of connecting two contour lines from the verified candidate endpoint edge pairs at the endpoints to be connected to generate new contour lines, the processing module is specifically used for: Project the endpoints of one contour line to be connected onto another contour line to determine the projection point; At the projection point, break another contour line to obtain two line segments, and keep the longer one; Connect one contour line to the longer, retained section at the projection point to obtain a new contour line.

[0136] In one embodiment, the contour lines within the docking edge region are grouped by elevation to obtain at least one aspect in the same elevation group. The grouping module is specifically used for: Traverse each contour line. If any vertex of the contour line is located within the border region, add the contour line to the candidate set. After the traversal is complete, the contour lines in the candidate set are grouped according to their elevation to obtain at least one group with the same elevation.

[0137] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure diagram may be as follows. Figure 6 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and databases. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a contour mapping method.

[0138] Those skilled in the art will understand that Figure 6The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0139] In one exemplary embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.

[0140] In one exemplary embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.

[0141] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.

[0142] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.

[0143] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).

[0144] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0145] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0146] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for joining contour lines, characterized in that, The method includes: The joining area is determined based on the spatial distribution of the contour lines of the edges to be joined in the AutoCAD model space. Contour lines within the boundary area are grouped by elevation to obtain at least one group with the same elevation. For each group with the same elevation, perform the following edge-joining steps: Remove closed contour lines within the group, match the remaining non-closed contour lines pairwise, divide them into candidate pairs of intersection points and candidate pairs of endpoints, and determine the connection type of each candidate pair. Perform topological intersection verification on each candidate endpoint edge pair in turn, and remove the candidate endpoint edge pairs that fail the verification; merge the candidate intersection edge pairs and the candidate endpoint edge pairs that pass the verification to obtain new contour lines, and determine the direction of the new contour lines in combination with the corresponding connection type. After all contour groups have been processed, new contour lines and their corresponding orientations are output in the AutoCAD model space.

2. The method according to claim 1, characterized in that, The step of determining the joining area based on the spatial distribution of contour lines of the edges to be joined in the AutoCAD model space includes: Receives contour lines from multiple edges to be joined, selected by the user in the AutoCAD model space; Obtain the joint outer rectangle of contour lines from multiple edges to be joined; Based on the preset margin expansion coefficient, the joint outer rectangle is expanded outward to obtain the edge area.

3. The method according to claim 1, characterized in that, The contour lines within the docking edge area are grouped according to elevation to obtain at least one group with the same elevation, including: Perform the following steps for each contour line: Calculate the absolute value of the difference between the current contour line elevation value and each preset standard elevation value; Contour lines whose calculated absolute values ​​are less than the preset elevation tolerance are assigned to the same elevation group corresponding to the preset standard elevation value.

4. The method according to claim 1, characterized in that, The process of pairwise matching of the remaining non-closed contour lines to identify candidate pairs of intersection edges and candidate pairs of endpoint edges includes: If two contour lines intersect at least once in the boundary area, and the elevation difference between the two contour lines is less than the preset elevation difference, then the two contour lines are divided into candidate pairs of intersection points. If the minimum distance between the endpoints of two contour lines is less than a preset distance threshold, then these two contour lines are classified as candidate endpoint connection pairs.

5. The method according to claim 1, characterized in that, The step of performing topological intersection verification on each candidate endpoint edge pair in sequence and eliminating candidate endpoint edge pairs that fail the verification includes: The endpoints corresponding to the minimum distance between two contour lines in the candidate endpoint edge pair are fitted and connected to obtain the fitted connection line. Detect whether the fitted connection line intersects with other elevation lines in the border area; If they exist, then remove the candidate pairs of endpoint edges that have intersection points.

6. The method according to claim 1, characterized in that, The process of merging candidate pairs of intersection points to obtain new contour lines includes: Break the two contour lines in the candidate pair of intersection points at the intersection point and retain the longer valid segment of each contour line. Within the junction area, identify the nearest endpoint pair of two valid segments and determine the connection type of the nearest endpoint pair; Remove duplicate vertices that coincide in the nearest endpoint pair; According to the connection type, the vertex sequences of the two valid segments are merged to generate new contour lines; Delete the original two contour lines.

7. The method according to claim 1, characterized in that, The process of merging the qualified endpoint edge candidate pairs to obtain new contour lines includes: Connect the two contour lines from the qualified endpoint edge candidate pairs at the endpoints to be connected to generate new contour lines. Remove duplicate vertices at the endpoints of the connection; Inherit the properties of the original two contour lines to the new contour line; Delete the original two contour lines.

8. The method according to claim 7, characterized in that, The step of connecting two contour lines from the verified candidate endpoint edge pairs at the endpoints to be connected to generate new contour lines includes: Project the endpoints of one contour line to be connected onto another contour line to determine the projection point; At the projection point, break another contour line to obtain two line segments, and keep the longer one; Connect one contour line to the longer, retained section at the projection point to obtain a new contour line.

9. The method according to claim 1, characterized in that, The contour lines within the docking edge area are grouped according to elevation to obtain at least one group with the same elevation, including: Traverse each contour line. If any vertex of the contour line is located within the border region, add the contour line to the candidate set. After the traversal is complete, the contour lines in the candidate set are grouped according to their elevation to obtain at least one group with the same elevation.

10. A contour line splicing device, characterized in that, The device includes: The determination module is used to determine the joint area based on the spatial distribution of contour lines of the edges to be joined in the AutoCAD model space. The grouping module is used to group contour lines within the docking area according to elevation, resulting in at least one group with the same elevation. The processing module is used to perform the following edge-joining steps for each group with the same elevation: Remove closed contour lines within the group, match the remaining non-closed contour lines pairwise, divide them into candidate pairs of intersection points and candidate pairs of endpoints, and determine the connection type of each candidate pair. Perform topological intersection verification on each candidate endpoint edge pair in turn, and remove the candidate endpoint edge pairs that fail the verification; merge the candidate intersection edge pairs and the candidate endpoint edge pairs that pass the verification to obtain new contour lines, and determine the direction of the new contour lines in combination with the corresponding connection type. The output module is used to output new contour lines and their corresponding orientations in the AutoCAD model space after all groups of the same elevation have been processed.