River intersection judgment method and device

By determining the intersection relationship of river segments and using programming methods, the problem of inaccurate calculations caused by measurement deviations at river confluence points was solved, achieving efficient and accurate calculation and data processing of river confluence points.

CN121859532APending Publication Date: 2026-04-14POWERCHINA ZHONGNAN ENG
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-11
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

The discrepancy between the river confluences measured on-site by surveyors and the linearized river confluences displayed on the map leads to inaccurate calculation results from the digital model.

Method used

By judging the intersection relationship between the river segments, including parallelism, coincidence of endpoints, and equal slope, it is determined whether the river has an intersection point. The calculation is carried out using the first and last d segments of the segment set to reduce the amount of calculation. Combined with programming methods, the river confluence point is processed automatically.

Benefits of technology

It enables batch processing of river confluence relationships, reducing the time spent on manual judgment, improving the accuracy and efficiency of calculations, and avoiding data errors caused by human factors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121859532A_ABST
    Figure CN121859532A_ABST
Patent Text Reader

Abstract

The invention provides a river intersection judgment method and device. The river intersection judgment method comprises the following steps: judging whether a first river and a second river have an intersection point or not by judging an intersection relationship between a line segment of the first river and a line segment of the second river; the specific method for judging whether the two line segments intersect or not comprises the steps that A1, first judgment and second judgment are executed; if the first judgment result is yes, determining that there is no intersection relation; if the second judgment is yes, determining that an intersection relationship exists; if not, executing the step A2; a2, if any line segment is approximately parallel to the y axis, executing the step A3; if the two line segments have the slope, judging whether kAu-kBv is less than or equal to alpha2; if yes, determining that there is no intersection relation; if not, executing the step A3; a3, judging whether the intersection point between the two line segments meets the condition of being located on the two line segments at the same time or not; if yes, determining that there is an intersection point, otherwise, determining that there is no intersection point.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a server-side method and apparatus for determining river confluence, and relates to the determination of river confluence situations. Background Technology

[0002] In the implementation of water environment management projects, accurate calculation of river confluence points is crucial for simulating water flow dynamics, analyzing water balance and pollution loads, and formulating engineering strategies. To meet the needs of digital model calculations, when rendering GIS on a B / S platform, rivers are typically simplified into polylines and presented on the map in a linear form.

[0003] When surveyors conduct on-site measurements of river confluences, factors such as river width, complex morphology (e.g., bends / branches), and dynamic factors (e.g., water level changes) can lead to limited visibility and compromised measurement accuracy. This can result in discrepancies between the on-site measurements and the linearized representation on a map. If the on-site measurements are used, these discrepancies negatively impact the digital model calculations, severely affecting the accuracy of the results. Summary of the Invention

[0004] The problem this invention aims to solve is that there is a discrepancy between the river confluence situation and the location of the river confluence point measured by surveyors on the ground and the river confluence situation and the location of the confluence point displayed linearly on the map, which adversely affects the calculation process of digital models and seriously affects the accuracy of the calculation results. The invention provides a method for determining river confluence.

[0005] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is: a method for determining river confluence, wherein each of the first river and the second river is formed by connecting multiple line segments in sequence; The method for determining river confluence includes: determining whether the first river and the second river intersect by judging the intersection relationship between the line segments of the first river and the line segments of the second river; The specific methods for determining whether two line segments intersect include: Step A1: Perform the first and second judgments; if the result of the first judgment is yes, then it is determined that there is no intersection relationship between line segment A_u and line segment B_v; if the result of the second judgment is yes, then it is determined that there is an intersection relationship between line segment A_u and line segment B_v. If the results of the first and second judgments are both negative, then proceed to step A2; Wherein, the first judgment is the judgment of |SegA u[终点x] -SegA u[起点x] |≤α1、|SegBv[终点x] -SegB v[起点x] Whether |≤α1 is true at the same time, the second judgment is to determine whether the endpoint of line segment A_u coincides with the endpoint of line segment B_v, and α1 is the first set error value; Step A2: If |SegA u[终点x] -SegA u[起点x] |≤α1、|SegB v[终点x] -SegB v[起点x] If any term in |≤α1 is true, then proceed to step A3; if |SegA u[终点x] -SegA u[起点x] |>α1、and|SegB v[终点x] -SegB v[起点x] If |>α1, then execute the third judgment; the third judgment is to determine whether |kA_u-kB_v|≤α2 is true. If the result of the third judgment is yes, then it is determined that there is no intersection relationship between line segment A_u and line segment B_v; if the result of the third judgment is no, then step A3 is executed. Where kA_u is the slope of line segment A_u, kB_v is the slope of line segment B_v, and α2 is the second set error value; SegA u[起点x] SegA u[起点y] These are the x and y coordinates of one endpoint of line segment A_u, respectively; SegA u[终点x] SegA u[终点y] These are the x and y coordinates of the other endpoint of line segment A_u, respectively; SegB v[起点x] SegB v[起点y] Let SegB be the x-coordinate and y-coordinate of one endpoint of line segment B_v. v[终点x] SegB v[终点y] Let x and y be the coordinates of the other endpoint of line segment B_v, respectively. Step A3: Perform the fourth judgment, which is to determine whether the intersection point between the line containing line segment A_u and the line containing line segment B_v simultaneously satisfies the condition that it is located on line segment A_u and on line segment B_v. If the result of the fourth judgment is yes, then it is determined that there is an intersection between line segment A_u and line segment B_v; otherwise, it is determined that there is no intersection between line segment A_u and line segment B_v.

[0006] According to the above technical solution, when determining the intersection relationship between the line segments of the first river and the line segments of the second river, it is first determined whether the two line segments are parallel (i.e., whether the slope is less than or greater than a set error value) and whether the endpoints of the two line segments coincide. If the two line segments are parallel, there is no intersection relationship. If the endpoints of the two line segments coincide, the intersection point is the endpoint. If the two line segments are not parallel and their endpoints do not coincide, it is further determined whether the intersection point of the lines containing the two line segments is located on the extension of the line or on the line segment. If it is located on the line segment, it is determined that there is an intersection relationship between the line segments. When determining whether the two line segments are parallel, considering that if the line segment is parallel to the y-axis, it is equivalent to the line segment having no slope, it is first determined whether the line segment is approximately parallel to the y-axis by judging whether the x-coordinates of the two endpoints of the line segment are approximately equal. If both line segments are approximately parallel to the y-axis, it means that the two line segments are approximately parallel and have no intersection point. Next, it is determined whether one of the line segments is approximately parallel to the y-axis. If so, the parallelism cannot be determined by comparing the slopes of the two line segments, so the process jumps to step A3. If not, the slopes of the two line segments are compared to see if they are approximately equal. If they are approximately equal, they are approximately parallel; if not, the process jumps back to step A3 for calculation. In this approach, special cases are considered first, such as whether the endpoints of the line segments coincide, whether the slopes of the line segments are equal, or whether the line segments are all approximately parallel to the y-axis, to simplify the calculation as much as possible. If no such special cases exist, the intersection point of the two line segments is determined to simultaneously satisfy the condition that it lies on line segment A_u and line segment B_v.

[0007] In the above technical solution, the specific method for determining whether the first river and the second river intersect by judging the intersection relationship between the line segments of the first river and the line segments of the second river is as follows: judge whether the line segments in the first line segment set and the line segments in the second line segment set have an intersection relationship; if the judgment result is yes, then it is determined that the first river and the second river have an intersection point; otherwise, it is determined that the first river and the second river have no intersection point. If U≤2×d, then the line segments in the first set of line segments are all U line segments of the first river; If U > 2 × d, then the line segments in the first set of line segments are the 1st line segment, the 2nd line segment, ..., the dth line segment and the Uth line segment, the (U-1)th line segment, ..., the (U-d+1)th line segment of the first river; If V≤2×d, then the line segments in the second line segment set are all V line segments of the second river; If V > 2 × d, then the line segments in the second set of line segments are the 1st line segment, the 2nd line segment, ..., the dth line segment and the Vth line segment, the (V-1)th line segment, ..., the (V-d+1)th line segment of the second river; in: d is the preset value; From the beginning to the end of the first river, the first line segment, the second line segment, ..., the Uth line segment of the first river are connected in sequence; From the beginning to the end of the second river, the first line segment, the second line segment, ..., the Vth line segment of the second river are connected in sequence.

[0008] In practical research, it has been found that rivers are generally formed by tributaries flowing into the main stream, or the main stream flowing out into tributaries. Therefore, the intersection of two rivers usually occurs near the ends of the rivers. According to the above technical solution, when the number of line segments in the first / second river is too large, only the first d and last d line segments of the river (i.e., the segments near the river ends) can be taken to determine whether there is an intersection relationship between the line segments of the two rivers. This technical solution can significantly reduce the amount of computation. This technical solution is particularly suitable for situations where the rivers do not intersect. If one of the first d and last d line segments of the first river intersects with one of the first d and last d line segments of the second river, it indicates that the two rivers intersect, and the intersection point can be calculated. This technical solution also applies to situations where the rivers intersect. Since it is impossible to determine which end of the river the intersection point is near, the line segments near both ends of the river (i.e., the first d line segments near one end of the river and the last d line segments near the other end) are included in the calculation.

[0009] In the above technical solution, the slope kA_u and slope kB_v are calculated using the following formulas; kA_u=(SegA u[终点y] -SegA u[起点y] ) / (SegA u[终点x] -SegA u[起点x] ); kB_v=(SegB v[终点y] -SegB v[起点y] ) / (SegB v[终点x] -SegB v[起点x] ); in: SegA u[起点x] SegA u[起点y] Let x and y be the coordinates of one endpoint of line segment A_u, respectively. SegA u[终点x] SegA u[终点y] Let x and y be the coordinates of the other endpoint of line segment A_u, respectively. SegB v[起点x] SegB v[起点y] These are the x and y coordinates of one endpoint of line segment B_v, respectively.

[0010] SegB v[终点x] SegB v[终点y]These are the x and y coordinates of the other endpoint of line segment B_v, respectively.

[0011] According to the above technical solution, the slope of the line segment can be calculated using the coordinates of the two endpoints of the line segment.

[0012] In the above technical solution, the specific method for performing the fourth judgment in step A3 is as follows: Judge ifInBetween(SegA u[起点x] coord_x, SegA u[终点x] The value of ) ifInBetween(SegA u[起点y] coord_y, SegA u[终点y] The value of ) ifInBetween(SegB v[起点x] coord_x, SegB v[终点x] The value of ) ifInBetween(SegB v[起点y] coord_y, SegB v[终点y] Are all values ​​of 1? If the result of the judgment is yes, then the result of the fourth judgment is yes; if the result of the judgment is no, then the result of the fourth judgment is no. in: coord_x and coord_y are the x and y coordinates of the intersection point between the line containing line segment A_u and the line containing line segment B_v, respectively. The specific definition of the ifInBetween(ua, ub, uc) function is as follows: if any one of the following conditions is true: |ua-ub|<α3, |ub-uc|<α3, ua<ub<uc, uc<ub<ua, then ifInBetween(ua, ub, uc)=1; otherwise, ifInBetween(ua, ub, uc)=0; where ua, ub, and uc are the input values ​​of the ifInBetween(ua, ub, uc) function; and α3 is the third set error value.

[0013] Preferably, α3 = α2 = α1.

[0014] Based on the above technical solution, it can be determined whether the straight line containing line segment A_u and the straight line containing line segment B_v are located on the river line segment.

[0015] In the above technical solution, the calculation methods for coord_x and coord_y are as follows: If |SegA u[终点x] -SegA u[起点x] |≤α1, and |SegB v[终点x] -SegB v[起点x] |>α1, then: coord_x=SegAu[起点x] , or coord_x=SegA u[终点x] ; coord_y=kB_v×(coord_x-SegB v[起点x] )+SegB v[起点y] ; If |SegA u[终点x] -SegA u[起点x] |>α1, and |SegB v[终点x] -SegB v[起点x] |≤α1, then: coord_x=SegB v[起点x] , or coord_x=SegB v[终点x] ; coord_y=kA_u×(coord_x-SegA u[起点x] )+SegA u[起点y] ; If |SegA u[终点x] -SegA u[起点x] |>α1, and |SegB v[终点x] -SegB v[起点x] |>α1, then: coord_x=((SegB v[起点y] -SegA u[起点y] )-(kB_v×SegB v[起点x] -kA_u×SegA u[起点x] )) / (kA_u-kB_v); coord_y=kA_u×(coord_x-SegA u[起点x] )+SegA u[起点y] .

[0016] Based on the above technical solution, the coordinates of the line containing line segment A_u and the line containing line segment B_v can be calculated.

[0017] In the above technical solution, α1≤0.0001; preferably, α1=0.000001.

[0018] In the above technical solution, the value range of d is [10, 30], or d = max[U, V] × p1; The preset ratio p1 has a value range of [10%, 30%], and max[U, V] represents the larger value of U and V, which correspond to the number of segments in the first river and the number of segments in the second river, respectively.

[0019] According to the above technical solution, d can be set as a constant, or determined based on the larger value of U and V and the value of the preset ratio p1.

[0020] According to the same inventive concept, the present invention also provides a river confluence determination device, characterized in that it includes a processor configured to perform the steps of the above-described river confluence determination method.

[0021] The advantages and positive effects of this invention are as follows: This invention enables batch processing of river confluence relationships, significantly reducing the time spent by designers manually judging confluence relationships and calculating confluence point locations. This invention provides a simple and efficient method for judging water environment models, river confluence relationships, and the calculation of river confluence points. The calculation results of river confluence points can provide subsequent data support, greatly reducing the time spent by designers manually correcting river network data. Simultaneously, this invention leverages the high speed and accuracy of computer processing, entrusting data processing to powerful computer software and programs, minimizing data judgment errors and omissions that may occur due to human factors during repetitive work. Attached Figure Description

[0022] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying 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.

[0023] Figure 1 This is a schematic diagram of the method flow of Embodiment 1 of the present invention; Figure 2 This is a river network data map related to Embodiment 1 of the present invention; Figure 3 This is a schematic diagram of the confluence of two rivers involved in Embodiment 1 of the present invention. Detailed Implementation

[0024] The technical solutions in 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 in this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0025] Example 1 This invention provides a method for determining river confluence, wherein each of the first and second rivers is formed by sequentially connecting multiple line segments; The method for determining river confluence includes: determining whether the first river and the second river intersect by judging the intersection relationship between the line segments of the first river and the line segments of the second river.

[0026] The specific methods for determining whether two line segments intersect include: Step A1: Perform the first and second judgments; if the result of the first judgment is yes, then it is determined that there is no intersection relationship between line segment A_u and line segment B_v; if the result of the second judgment is yes, then it is determined that there is an intersection relationship between line segment A_u and line segment B_v. If the results of the first and second judgments are both negative, then proceed to step A2; Wherein, the first judgment is the judgment of |SegA u[终点x] -SegA u[起点x] |≤α1、|SegB v[终点x] -SegB v[起点x] Whether |≤α1 is true at the same time, the second judgment is to determine whether the endpoint of line segment A_u coincides with the endpoint of line segment B_v, and α1 is the first set error value; Step A2: If |SegA u[终点x] -SegA u[起点x] |≤α1、|SegB v[终点x] -SegB v[起点x] If any term in |≤α1 is true, then proceed to step A3; if |SegA u[终点x] -SegA u[起点x] |>α1、and|SegB v[终点x] -SegB v[起点x] If |>α1, then execute the third judgment; the third judgment is to determine whether |kA_u-kB_v|≤α2 is true. If the result of the third judgment is yes, then it is determined that there is no intersection relationship between line segment A_u and line segment B_v; if the result of the third judgment is no, then step A3 is executed. Where kA_u is the slope of line segment A_u, kB_v is the slope of line segment B_v, and α2 is the second set error value; SegA u[起点x] SegA u[起点y] These are the x and y coordinates of one endpoint of line segment A_u, respectively; SegA u[终点x] SegA u[终点y] These are the x and y coordinates of the other endpoint of line segment A_u, respectively; SegB v[起点x] SegB v[起点y] Let SegB be the x-coordinate and y-coordinate of one endpoint of line segment B_v. v[终点x] SegB v[终点y] Let x and y be the coordinates of the other endpoint of line segment B_v, respectively. In this context, the two endpoints of line segment A_u are the start and end points of line segment A_u, respectively, and the two endpoints of line segment B_v are the start and end points of line segment B_v, respectively.

[0027] Step A3: Perform the fourth judgment, which is to determine whether the intersection point between the line containing line segment A_u and the line containing line segment B_v simultaneously satisfies the condition that it is located on line segment A_u and on line segment B_v. If the result of the fourth judgment is yes, then it is determined that there is an intersection between line segment A_u and line segment B_v; otherwise, it is determined that there is no intersection between line segment A_u and line segment B_v.

[0028] For the following two conditions: (1) Simultaneously satisfying |SegA u[终点x] -SegA u[起点x] |≤α1、|SegB v[终点x] -SegB v[起点x] If |≤α1, it means that line segment A_u and line segment B_v are both parallel to or approximately parallel to the y-axis, which means that the two line segments are parallel. (2) |kA_u-kB_v|≤α1 indicates that the slopes of the two line segments are equal or approximately equal, which means that the two line segments are parallel.

[0029] For example, from the beginning to the end of the first river, the first line segment A_1, the second line segment A_2, ..., the Uth line segment A_U of the first river are connected in sequence; from the beginning to the end of the second river, the first line segment B_1, the second line segment B_2, ..., the Vth line segment B_V of the second river are connected in sequence.

[0030] In this embodiment 1, according to the methods of steps A1 and A2, it is determined whether line segment A_1 intersects with each line segment (B_1, ..., B_V) in the second river, whether line segment A_2 intersects with each line segment (B_1, ..., B_V) in the second river, ..., and whether line segment A_U intersects with each line segment (B_1, ..., B_V) in the second river.

[0031] In this embodiment 1, the specific method for determining whether the first river and the second river intersect by judging the intersection relationship between the line segments of the first river and the line segments of the second river is as follows: judge whether the line segments in the first line segment set and the line segments in the second line segment set intersect; if the judgment result is yes, then it is determined that the first river and the second river have an intersection point; otherwise, it is determined that the first river and the second river have no intersection point. If U≤2×d, then the line segments in the first set of line segments are all U line segments of the first river; If U > 2 × d, then the line segments in the first set of line segments are the first line segment A_1, the second line segment A_2, ..., the dth line segment A_d and the Uth line segment A_U, the (U-1)th line segment A_U-1, ..., the (U-d+1)th line segment A_U-d+1 of the first river; If V≤2×d, then the line segments in the second line segment set are all V line segments of the second river; If V > 2 × d, then the line segments in the second set of line segments are the first line segment B_1, the second line segment B_2, ..., the dth line segment B_d and the Vth line segment B_v, the (V-1)th line segment B_v-1, ..., the (V-d+1)th line segment B_v-d+1 of the second river; in: d is the default value.

[0032] Calculate the slope kA_u and slope kB_v using the following formulas; kA_u=(SegA u[终点y] -SegA u[起点y] ) / (SegA u[终点x] -SegA u[起点x] ); kB_v=(SegB v[终点y] -SegB v[起点y] ) / (SegB v[终点x] -SegB v[起点x] ); in: SegA u[起点x] SegA u[起点y] Let x and y be the coordinates of one endpoint of line segment A_u, respectively. SegA u[终点x] SegA u[终点y] Let x and y be the coordinates of the other endpoint of line segment A_u, respectively. SegB v[起点x] SegB v[起点y] These are the x and y coordinates of one endpoint of line segment B_v, respectively.

[0033] SegB v[终点x] SegB v[终点y] These are the x and y coordinates of the other endpoint of line segment B_v, respectively.

[0034] In step A3, the specific method for performing the fourth judgment is as follows: Judge ifInBetween(SegA) u[起点x] coord_x, SegA u[终点x] The value of ) ifInBetween(SegA u[起点y] coord_y, SegA u[终点y] The value of ) ifInBetween(SegB v[起点x] coord_x, SegB v[终点x] The value of ) ifInBetween(SegB v[起点y] coord_y, SegB v[终点y]Are all values ​​of 1? If the result of the judgment is yes, then the result of the fourth judgment is yes; if the result of the judgment is no, then the result of the fourth judgment is no. in: coord_x and coord_y are the x and y coordinates of the intersection point between the line containing line segment A_u and the line containing line segment B_v, respectively. The specific definition of the ifInBetween(ua, ub, uc) function is as follows: if any one of the following conditions is true: |ua-ub|<α3, |ub-uc|<α3, ua<ub<uc, uc<ub<ua, then ifInBetween(ua, ub, uc)=1; otherwise, ifInBetween(ua, ub, uc)=0; where ua, ub, and uc are the input values ​​of the ifInBetween(ua, ub, uc) function; and α3 is the third set error value.

[0035] Where ua, ub, and uc are the input values ​​of the ifInBetween(ua, ub, uc) function; α2 is the second set error value; Preferably, α3 = α2 = α1.

[0036] The calculation methods for coord_x and coord_y are as follows: If |SegA u[终点x] -SegA u[起点x] |≤α1, and |SegB v[终点x] -SegB v[起点x] |>α1, then: coord_x=SegA u[起点x] , or coord_x=SegA u[终点x] ; coord_y=kB_v×(coord_x-SegB v[起点x] )+SegB v[起点y] ; If |SegA u[终点x] -SegA u[起点x] |>α1, and |SegB v[终点x] -SegB v[起点x] |≤α1, then: coord_x=SegB v[起点x] , or coord_x=SegB v[终点x] ; coord_y=kA_u×(coord_x-SegA u[起点x] )+SegA u[起点y] ; If |SegA u[终点x] -SegA u[起点x]|>α1, and |SegB v[终点x] -SegB v[起点x] |>α1, then: coord_x=((SegB v[起点y] -SegA u[起点y] )-(kB_v×SegB v[起点x] -kA_u×SegA u[起点x] )) / (kA_u-kB_v); coord_y=kA_u×(coord_x-SegA u[起点x] )+SegA u[起点y] ; Where coord_x and coord_y are the x and y coordinates of the intersection point between the line containing line segment A_u and the line containing line segment B_v, respectively.

[0037] α1≤0.0001; preferably, α1=0.000001.

[0038] The value of d is in the range of [10, 30], or d = max[U, V] × p1; where the preset ratio p1 is in the range of [10%, 30%], max[U, V] represents the larger value of U and V, and U and V correspond to the number of line segments in the first river and the number of line segments in the second river, respectively.

[0039] u = 1, 2, ..., U; v = 1, 2, ..., V; U is the number of line segments of the first river, and V is the number of line segments of the second river.

[0040] According to the same inventive concept, the present invention provides a river confluence determination device, including a processor configured to perform the steps of the above-described river confluence determination method.

[0041] The following is a further detailed description of Embodiment 1 of the present invention.

[0042] To address the complex river network relationships in water environment models and river network models, and the limitations of traditional methods that rely on manual judgment or simple geometric calculations to handle large volumes of complex river data, this invention proposes a server-side river confluence judgment method. This method automates the calculation and verification of river confluence points through programming. Designed for batch processing of project-related river network relationships, this method aims to improve work efficiency, accuracy, and repeatability. It can automatically process a large number of project-related river relationships for error detection and provides reference confluence point coordinates, saving significant manpower and time costs and improving efficiency. Specifically, this method relies on Geographic Information System (GIS) rendering technology under a browser / server (B / S) architecture. For river data presented in linear form, it uses an advanced line segment intersection detection algorithm to accurately determine the intersection relationships between rivers in the imported complex river network system, and further calculates and verifies the geographic coordinates of each river intersection point.

[0043] The river confluence determination method of this invention is universal, standardized, and supports parametric calculations. This invention provides accurate calculation and correction of the confluence relationships of linear rivers. Specifically, an effective method utilizes advanced programming techniques to batch process massive amounts of river network data and automatically calculate potential confluence points between river networks. Based on the nearest neighbor distance algorithm, it determines the possibility of river confluence, thereby identifying and correcting the coordinates of river network intersection points. By batch-processing linear river nearest neighbor distances through a programming system and correcting the river confluence data, the accuracy of calculations can be improved, errors in model calculations can be reduced, and efficiency can be increased. This method can quickly determine the intersection relationships between linear river networks and calculate the intersection points of extended lines, providing reminders and correction basis for frontline personnel and a reliable computational foundation for water environment management projects.

[0044] Meanwhile, this method can process the coordinates of multiple rivers and their river network interaction points related to a project in batches, which is very useful for large-scale engineering projects or situations that require the processing of multiple rivers. In addition, determining river confluence relationships and calculating confluence points through programming can improve the accuracy of calculations. The program can perform calculations based on predefined algorithms and rules, avoiding errors caused by human factors and ensuring the accuracy of the results.

[0045] Taking the river data from the Zhegao River project as an example, the specific implementation method of this invention is introduced. The calculation process of this invention is as follows: Figure 1 As shown. The specific calculation steps of the method of the present invention are as follows: Step 1: Obtain relevant river data for the project (in this example, the Zhegao River project), existing river network intersection data, and the set fault-tolerant river segment parameter d for the calculation. For example... Figure 2 This is a river network data map related to Embodiment 1 of the present invention.

[0046] Table 1 shows the river data for the Zhegao River project in this embodiment 1, and Table 2 shows the confluence relationships between the rivers in the Zhegao River project as measured by personnel on-site.

[0047]

[0048]

[0049] Step 2: First, circulate the river data within the basin (in this example, the Zhegao River basin) and obtain RiverA data for comparison. i (Get the data for one of the rivers used for comparison, i.e., perform intersection point judgment on all rivers in this area).

[0050] Step 3: Obtain river data (RiverB) for comparison within the second cycle of the watershed (Zhegao River Basin in this example). j (To obtain data from another river for comparison).

[0051] Step 4: Determine RiverA separately i With RiverB j Is the total number of river segments less than 2d? That is, for each river RiverA... i RiverB j Each step checks whether the number of line segments is greater than 2d. If a river has too many line segments, only the first d line segments and the last d line segments of the river are taken.

[0052] For the first river RiverA i : (1) If the length of the river segment is greater than or equal to 2d, then obtain the segment of the initial d segment (A_1, A_2, ..., A_d) and the final d segment (A_U-d+1, ..., A_U-1, A_U) of the river to be used in the calculation to form an array SegA={SegA1, SegA2, ..., SegA...} 2×d}

[0053] (2) If the length of the river segment is less than 2d, obtain all river segments (A_1, A_2, ..., A_U) to form an array SegA={SegA1, SegA2, ..., SegA...} U}

[0054] For the first river RiverBj : (1) If the length of the river segment is greater than or equal to 2d, then obtain the segment of the initial d segment (B_1, B_2, ..., B_d) and the final d segment (B_V-d+1, ..., B_V-1, B_V) of the river to be used in the calculation to form an array SegB={SegB1, SegB2, ..., SegB 2×d}; (2) If the length of a river segment is less than 2d, obtain all river segments (B_1, B_2, ..., B_V) to form an array SegB={SegB1, SegB2, ..., SegB V}

[0055] Step 5: Loop through the river segment array SegA of river A and obtain the segment data SegA. u ; That is, if U > 2 × d, then the line segments in the first set of line segments are the 1st line segment, the 2nd line segment, ..., the dth line segment and the Uth line segment, the (U-1)th line segment, ..., the (U-d+1)th line segment of the first river; If V≤2×d, then the line segments in the second line segment set are all V line segments of the second river; If V > 2 × d, then the line segments in the second set of line segments are the 1st line segment, the 2nd line segment, ..., the dth line segment and the Vth line segment, the (V-1)th line segment, ..., the (V-d+1)th line segment of the second river.

[0056] Step 6: Loop through the river segment array SegB of river B and obtain the segment data SegB. v .

[0057] Step 7: Determine SegA u With SegB v If the lines are parallel, there is no intersection between them, proceed to step 13; otherwise, proceed to step 8.

[0058] Step 8: Determine SegA u With SegB v If the coordinates of the start and end points of the line segment overlap, and if they do, the overlapping coordinates are stored in step 11; otherwise, proceed to step 9. This invention addresses the case where two rivers have at most one intersection point.

[0059] Step 9: Calculate the river intersection data coord based on the line segment coordinates. If there is no intersection, proceed to step 13. If there is an intersection, store the coordinate point coord in step 10.

[0060] kA_u=(SegA u[终点y] -SegA u[起点y] ) / (SegAu[终点x] -SegA u[起点x] ); kB_v=(SegB v[终点y] -SegB v[起点y] ) / (SegB v[终点x] -SegB v[起点x] ).

[0061] The specific method for calculating the coordinates of the intersection point between the lines containing two line segments is as follows: If |SegA u[终点x] -SegA u[起点x] |≤α1, and |SegB v[终点x] -SegB v[起点x] |>α1, then: coord_x=SegA u[起点x] , or coord_x=SegA u[终点x] ; coord_y=kB_v×(coord_x-SegB v[起点x] )+SegB v[起点y] ; If |SegA u[终点x] -SegA u[起点x] |>α1, and |SegB v[终点x] -SegB v[起点x] |≤α1, then: coord_x=SegB v[起点x] , or coord_x=SegB v[终点x] ; coord_y=kA_u×(coord_x-SegA u[起点x] )+SegA u[起点y] ; If |SegA u[终点x] -SegA u[起点x] |>α1, and |SegB v[终点x] -SegB v[起点x] |>α1, then: coord_x=((SegB v[起点y] -SegA u[起点y] )-(kB_v×SegB v[起点x] -kA_u×SegA u[起点x] )) / (kA_u-kB_v); coord_y=kA_u×(coord_x-SegA u[起点x] )+SegA u[起点y] ; The next step is to determine whether the calculated intersection point [coord_x, coord_y] lies on the line segment.

[0062] If the value of status is 1, the coordinates of the intersection of the two rivers are determined to be [coord_y, coord_x]. If the value of status is 0, an error value is returned, indicating that the line segments do not intersect. That is, the two line segments do not intersect, but rather the lines containing the two line segments intersect at coordinates [coord_y, coord_x], which are not located on the line segments.

[0063] Where, status=ifInBetween(SegA u[起点x] coord_x, SegA u[终点x] )&&ifInBetween(SegA u[起点y] coord_y, SegA u[终点y] )&&ifInBetween(SegB v[起点x] coord_x, SegB v[终点x] )&&ifInBetween(SegB v[起点y] coord_y, SegB v[终点y] That is, if InBetween(SegA) u[起点x] coord_x, SegA u[终点x] ), ifInBetween(SegA u[起点y] coord_y, SegA u[终点y] ), ifInBetween(SegB v[起点x] coord_x, SegB v[终点x] ), ifInBetween(SegB v[起点y] coord_y, SegB v[终点y] If all values ​​of ) are 1, then the value of status is 1; otherwise, the value of status is 0.

[0064] The `ifInBetween(ua, ub, uc)` function can also be defined as follows: If either `Math.abs(ua-ub) < 1e-6` or `Math.abs(ub-uc) < 1e-6` is satisfied, then `ifInBetween(ua, ub, uc)` returns 1. If `Math.abs(ua-ub) ≥ 1e-6` and `Math.abs(ub-uc) ≥ 1e-6`, then the function continues to evaluate whether the expressions `ua < ub < uc` and `uc < ub < ua` are true. If either expression is true, then `ifInBetween(ua, ub, uc)` returns 1. If neither expression is true, then `ifInBetween(ua, ub, uc)` returns 0. Here, `Math.abs(ua-ub)` represents `|ua-ub|`.

[0065] Step 10: Obtain the coordinates (coord) of the current original river intersection point; Step 11: Obtain the original river intersection information data relationShipData[RiverA] i RiverB j ]; Step 12: Compare the calculation results of Step 11 with the existing river network intersection data obtained in Step 10. If any of the following situations exist, store the difference data (differData) and proceed to Step 16: (1) The current coordinate of the intersection of river A and river B is inconsistent with the original data of the intersection coordinates stored in the river network data. (2) River A and River B intersect, but the original data river network does not have an intersection relationship.

[0066] Step 13: Determine if v is less than 2d. If yes, repeat steps 6 to 12 to obtain RiverA. i SegA u With RiverB j All relevant river segments intersect; otherwise, proceed to step 14. Step 14: Determine if u is less than 2d. If yes, repeat steps 5 through 13 to obtain RiverA. i The relevant river segments and RiverB j All relevant river segments intersect; otherwise, proceed to step 15. Step 15, if the loop is complete (loop reaches u=2d), the current river RiverA i With RiverB j If there is still no intersection, then the current river RiverA i With RiverB jIf there is no intersection, store the current result; Step 16, repeat steps 3 through 15 to obtain RiverA. i Intersection with other rivers; Step 17: Repeat steps 2 to 16 to obtain the intersection relationships of all calculated river networks, as shown in Table 3.

[0067]

[0068] Step 18: Obtain the calculated confluence relationships of all rivers, the coordinates of the confluence points, and the differences from the original confluence relationships. Store the results as shown in Tables 4 and 5.

[0069]

[0070]

[0071] If any one of the first d line segments and the last d line segments of the first river intersects with any one of the first d line segments and the last d line segments of the second river, then determine the intersection relationship between all U line segments of the first river and all V line segments of the second river, and calculate the coordinates of the corresponding intersection points.

[0072] like Figure 3 As shown, A_S and A_T are the starting and ending points of the first river, respectively; B_S and B_T are the starting and ending points of the second river, respectively. From A_S to A_T, line segments A_1, A_2, ..., A_U-1, and A_U are connected sequentially to form the first river. From B_S to B_T, line segments B_1, B_2, ..., B_V-1, and B_V are connected sequentially to form the second river. Only the line segments closest to the starting and ending points are shown for each river; the intermediate segments are not shown and are represented by ellipses in the diagram.

[0073] To simplify the calculation, we can set d=4, that is, select line segments A_1, A_2, A_3, A_4, A_U-3, A_U-2, A_U-1, and A_U as the first set of line segments, and select line segments B_1, B_2, B_3, B_4, B_V-3, B_V-2, B_V-1, and B_V as the second set of line segments. By determining the intersection relationships between the line segments in the first and second sets, we can determine whether the first and second rivers intersect. For example... Figure 3 As shown, since line segment A_2 intersects with line segment B_3, it can be determined that the first river and the second river intersect.

[0074] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0075] The embodiments of the present invention have been described in detail above, but the content described is only a preferred embodiment of the present invention and should not be considered as limiting the scope of the present invention. All equivalent changes and modifications made within the scope of the present invention should still fall within the scope of the present invention. After reading this invention, those skilled in the art will understand that various equivalent modifications to the present invention fall within the scope defined by the appended claims. Unless otherwise specified, the embodiments and features in the embodiments of the present invention can be combined with each other.

Claims

1. A method for determining river confluence, wherein each of the first and second rivers is formed by sequentially connecting multiple line segments, characterized in that: The method for determining river confluence includes: determining whether the first river and the second river intersect by judging the intersection relationship between the line segments of the first river and the line segments of the second river; The specific methods for determining whether two line segments intersect include: Step A1: Perform the first and second judgments; if the result of the first judgment is yes, then it is determined that there is no intersection relationship between line segment A_u and line segment B_v; if the result of the second judgment is yes, then it is determined that there is an intersection relationship between line segment A_u and line segment B_v. If the results of the first and second judgments are both negative, then proceed to step A2; Wherein, the first judgment is the judgment of |SegA u[终点x] -SegA u[起点x] |≤α1、|SegB v[终点x] -SegB v[起点x] Whether |≤α1 is true at the same time, the second judgment is to determine whether the endpoint of line segment A_u coincides with the endpoint of line segment B_v, and α1 is the first set error value; Step A2: If |SegA u[终点x] -SegA u[起点x] |≤α1、|SegB v[终点x] -SegB v[起点x] If any term in |≤α1 is true, then proceed to step A3; if |SegA u[终点x] -SegA u[起点x] |>α1、and|SegB v[终点x] -SegB v[起点x] If |>α1, then execute the third judgment; the third judgment is to determine whether |kA_u-kB_v|≤α2 is true. If the result of the third judgment is yes, then it is determined that there is no intersection relationship between line segment A_u and line segment B_v; if the result of the third judgment is no, then step A3 is executed. Where kA_u is the slope of line segment A_u, kB_v is the slope of line segment B_v, and α2 is the second set error value; SegA u[起点x] SegA u[起点y] These are the x and y coordinates of one endpoint of line segment A_u, respectively; SegA u[终点x] SegA u[终点y] These are the x and y coordinates of the other endpoint of line segment A_u, respectively; SegB v[起点x] SegB v[起点y] Let SegB be the x-coordinate and y-coordinate of one endpoint of line segment B_v. v[终点x] SegB v[终点y] Let x and y be the coordinates of the other endpoint of line segment B_v, respectively. Step A3: Perform the fourth judgment; the fourth judgment is to determine whether the intersection point between the line containing line segment A_u and the line containing line segment B_v simultaneously satisfies the condition that it is located on line segment A_u and on line segment B_v. If the result of the fourth judgment is yes, then it is determined that there is an intersection between line segment A_u and line segment B_v; otherwise, it is determined that there is no intersection between line segment A_u and line segment B_v.

2. The method for determining river confluence according to claim 1, characterized in that: The specific method for determining whether the first and second rivers intersect by judging the intersection relationship between the line segments of the first river and the line segments of the second river is as follows: judge whether the line segments in the first line segment set and the line segments in the second line segment set intersect; if the judgment result is yes, then the first river and the second river intersect; otherwise, the first river and the second river do not intersect. If U≤2×d, then the line segments in the first set of line segments are all U line segments of the first river; If U > 2 × d, then the line segments in the first set of line segments are the 1st line segment, the 2nd line segment, ..., the dth line segment and the Uth line segment, the (U-1)th line segment, ..., the (U-d+1)th line segment of the first river; If V≤2×d, then the line segments in the second line segment set are all V line segments of the second river; If V > 2 × d, then the line segments in the second set of line segments are the 1st line segment, the 2nd line segment, ..., the dth line segment and the Vth line segment, the (V-1)th line segment, ..., the (V-d+1)th line segment of the second river; in: d is the preset value; From the beginning to the end of the first river, the first line segment, the second line segment, ..., the Uth line segment of the first river are connected in sequence; From the beginning to the end of the second river, the first line segment, the second line segment, ..., the Vth line segment of the second river are connected in sequence.

3. The method for determining river confluence according to claim 2, characterized in that: The range of values ​​for d is [10, 30], or d = max[U, V] × p1; The preset ratio p1 has a value range of [10%, 30%], and max[U, V] represents the larger value of U and V, which correspond to the number of segments in the first river and the number of segments in the second river, respectively.

4. The method for determining river confluence according to claim 1, characterized in that: Calculate the slope kA_u and slope kB_v using the following formulas; kA_u=(SegA u[终点y] -SegA u[起点y] ) / (SegA u[终点x] -SegA u[起点x] ); kB_v=(SegB v[终点y] -SegB v[起点y] ) / (SegB v[终点x] -SegB v[起点x] )。 5. The method for determining river confluence according to claim 4, characterized in that: In step A3, the specific method for performing the fourth judgment is as follows: Judge ifInBetween(SegA u[起点x] coord_x, SegA u[终点x] The value of ) ifInBetween(SegA u[起点y] coord_y, SegA u[终点y] The value of ) ifInBetween(SegB v[起点x] coord_x, SegB v[终点x] The value of ) ifInBetween(SegB v[起点y] coord_y, SegB v[终点y] Are all values ​​of 1? If the result of the judgment is yes, then the result of the fourth judgment is yes; if the result of the judgment is no, then the result of the fourth judgment is no. in: coord_x and coord_y are the x and y coordinates of the intersection point between the line containing line segment A_u and the line containing line segment B_v, respectively. The specific definition of the ifInBetween(ua, ub, uc) function is as follows: if any one of the following conditions is true: |ua-ub|<α3, |ub-uc|<α3, ua<ub<uc, uc<ub<ua, then ifInBetween(ua, ub, uc)=1; otherwise, ifInBetween(ua, ub, uc)=0; where ua, ub, and uc are the input values ​​of the ifInBetween(ua, ub, uc) function; and α3 is the third set error value.

6. The method for determining river confluence according to claim 5, characterized in that: α3=α2=α1。 7. The method for determining river confluence according to claim 5, characterized in that: The calculation methods for coord_x and coord_y are as follows: If |SegA u[终点x] -SegA u[起点x] |≤α1, and |SegB v[终点x] -SegB v[起点x] |>α1, then: coord_x=SegA u[起点x] , or coord_x=SegA u[终点x] ; coord_y=kB_v×(coord_x-SegB v[起点x] )+SegB v[起点y] ; If |SegA u[终点x] -SegA u[起点x] |>α1, and |SegB v[终点x] -SegB v[起点x] |≤α1, then: coord_x=SegB v[起点x] , or coord_x=SegB v[终点x] ; coord_y=kA_u×(coord_x-SegA u[起点x] )+SegA u[起点y] ; If |SegA u[终点x] -SegA u[起点x] |>α1, and |SegB v[终点x] -SegB v[起点x] |>α1, then: coordinate_x=((FromB v[起点y] -SegA u[起点y] )-(kB_v×SegB v[起点x] -kA_u×SegA u[起点x] )) / (kA_u-kB_v): coord_y=kA_u×(coord_x-SegA u[起点x] )+SegA u[起点y] 。 8. The method for determining river confluence according to any one of claims 1-7, characterized in that: α1≤0.0001。 9. The method for determining river confluence according to claim 8, characterized in that: α1=0.000001。 10. A device for determining river confluence, characterized in that, Includes a processor configured to perform the steps of the river confluence determination method according to any one of claims 1-9.