Mercurial > gemma
annotate pkg/octree/contours.go @ 3618:c03170a1c333
client: waterlevel: check if there is prediction data before drawing the predictionarea
author | Fadi Abbud <fadi.abbud@intevation.de> |
---|---|
date | Wed, 05 Jun 2019 15:47:30 +0200 |
parents | 647a58ee9ae9 |
children | 631f5eaf29de |
rev | line source |
---|---|
1017
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
977
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
977
diff
changeset
|
2 // without warranty, see README.md and license for details. |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
977
diff
changeset
|
3 // |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
977
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
977
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
977
diff
changeset
|
6 // |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
977
diff
changeset
|
7 // Copyright (C) 2018 by via donau |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
977
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
977
diff
changeset
|
9 // Software engineering by Intevation GmbH |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
977
diff
changeset
|
10 // |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
977
diff
changeset
|
11 // Author(s): |
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
977
diff
changeset
|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
1317
5443f5c9154c
Added missing authors names in Go files.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1186
diff
changeset
|
13 // * Tom Gottfried <tom.gottfried@intevation.de> |
1017
a244b18cb916
Added GNU Affero General Public License.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
977
diff
changeset
|
14 |
976
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 package octree |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import ( |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 "runtime" |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 "sync" |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 ) |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 |
2576
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
22 func SampleDiffHeights(min, max, step float64) []float64 { |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
23 var heights []float64 |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
24 switch { |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
25 case min >= 0: // All values positive. |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
26 for v := 0.0; v <= max; v += step { |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
27 if v >= min { |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
28 heights = append(heights, v) |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
29 } |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
30 } |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
31 case max <= 0: // All values negative. |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
32 for v := 0.0; v >= min; v -= step { |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
33 if v <= max { |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
34 heights = append(heights, v) |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
35 } |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
36 } |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
37 default: // Positive and negative. |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
38 for v := step; v <= max; v += step { |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
39 heights = append(heights, v) |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
40 } |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
41 for i, j := 0, len(heights)-1; i < j; i, j = i+1, j-1 { |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
42 heights[i], heights[j] = heights[j], heights[i] |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
43 } |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
44 for v := 0.0; v >= min; v -= step { |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
45 heights = append(heights, v) |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
46 } |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
47 } |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
48 return heights |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
49 } |
647a58ee9ae9
Morphological differences: Centralized generation of height values for differences in octree package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
2529
diff
changeset
|
50 |
1692
f4dcbe8941a1
Octree: Resolved the remaing golint issues with this package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1317
diff
changeset
|
51 // ContourResult stores an calculated iso line for a given height. |
f4dcbe8941a1
Octree: Resolved the remaing golint issues with this package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1317
diff
changeset
|
52 // Is used as a future variable in the concurrent iso line calculation. |
977
4a2ca0e20006
Fixed build error.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
976
diff
changeset
|
53 type ContourResult struct { |
4a2ca0e20006
Fixed build error.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
976
diff
changeset
|
54 Height float64 |
4a2ca0e20006
Fixed build error.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
976
diff
changeset
|
55 Lines MultiLineStringZ |
1134
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
56 |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
57 done bool |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
58 mu sync.Mutex |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
59 cond *sync.Cond |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
60 } |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
61 |
1692
f4dcbe8941a1
Octree: Resolved the remaing golint issues with this package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1317
diff
changeset
|
62 // NewContourResult prepares a future variable to later hold |
f4dcbe8941a1
Octree: Resolved the remaing golint issues with this package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1317
diff
changeset
|
63 // the result of the iso line calculation. |
1186
ba0d8c327b0b
Made code more idiomatic.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1184
diff
changeset
|
64 func NewContourResult(height float64) *ContourResult { |
1134
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
65 cr := ContourResult{Height: height} |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
66 cr.cond = sync.NewCond(&cr.mu) |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
67 return &cr |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
68 } |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
69 |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
70 func (cr *ContourResult) wait() { |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
71 cr.cond.L.Lock() |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
72 for !cr.done { |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
73 cr.cond.Wait() |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
74 } |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
75 cr.cond.L.Unlock() |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
76 } |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
77 |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
78 func (cr *ContourResult) get() float64 { |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
79 cr.cond.L.Lock() |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
80 defer cr.cond.L.Unlock() |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
81 return cr.Height |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
82 } |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
83 |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
84 func (cr *ContourResult) set(lines MultiLineStringZ) { |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
85 cr.cond.L.Lock() |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
86 defer cr.cond.L.Unlock() |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
87 cr.Lines = lines |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
88 cr.done = true |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
89 cr.cond.Signal() |
976
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 } |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 |
1692
f4dcbe8941a1
Octree: Resolved the remaing golint issues with this package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1317
diff
changeset
|
92 // DoContours calculates the iso line for the given heights. |
f4dcbe8941a1
Octree: Resolved the remaing golint issues with this package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1317
diff
changeset
|
93 // This is done concurrently. |
f4dcbe8941a1
Octree: Resolved the remaing golint issues with this package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1317
diff
changeset
|
94 // It is guaranteed that the results are given to the store |
f4dcbe8941a1
Octree: Resolved the remaing golint issues with this package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1317
diff
changeset
|
95 // function in order of the original heights values. |
1184
064d44ccc6f2
Adjust contour lines heights to multiples of step width
Tom Gottfried <tom@intevation.de>
parents:
1134
diff
changeset
|
96 func DoContours(tree *Tree, heights []float64, store func(*ContourResult)) { |
976
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 |
2479
c85b16db8a02
Calculate better triangulation and store it into database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1692
diff
changeset
|
98 if len(heights) == 0 { |
c85b16db8a02
Calculate better triangulation and store it into database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1692
diff
changeset
|
99 return |
c85b16db8a02
Calculate better triangulation and store it into database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1692
diff
changeset
|
100 } |
c85b16db8a02
Calculate better triangulation and store it into database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1692
diff
changeset
|
101 |
1186
ba0d8c327b0b
Made code more idiomatic.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1184
diff
changeset
|
102 contours := make([]*ContourResult, len(heights)) |
ba0d8c327b0b
Made code more idiomatic.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1184
diff
changeset
|
103 |
ba0d8c327b0b
Made code more idiomatic.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1184
diff
changeset
|
104 for i, h := range heights { |
ba0d8c327b0b
Made code more idiomatic.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1184
diff
changeset
|
105 contours[i] = NewContourResult(h) |
1134
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
106 } |
976
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 |
1134
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
108 jobs := make(chan *ContourResult) |
976
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 var wg sync.WaitGroup |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
111 for i, n := 0, runtime.NumCPU(); i < n; i++ { |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
112 wg.Add(1) |
1134
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
113 go processLevels(tree, jobs, &wg) |
976
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
114 } |
1134
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
115 |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
116 done := make(chan struct{}) |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
117 go func() { |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
118 defer close(done) |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
119 for _, cr := range contours { |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
120 cr.wait() |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
121 store(cr) |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
122 } |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
123 }() |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
124 |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
125 for _, cr := range contours { |
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
126 jobs <- cr |
976
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
127 } |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
128 close(jobs) |
1134
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
129 |
976
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
130 wg.Wait() |
1134
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
131 <-done |
976
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
132 } |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
133 |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
134 func processLevels( |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
135 tree *Tree, |
1134
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
136 jobs <-chan *ContourResult, |
976
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
137 wg *sync.WaitGroup, |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
138 ) { |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
139 defer wg.Done() |
1134
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
140 for cr := range jobs { |
976
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 var lines MultiLineStringZ |
1134
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
142 h := cr.get() |
976
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
143 tree.Horizontal(h, func(t *Triangle) { |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 line := t.IntersectHorizontal(h) |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 if len(line) > 1 { |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 lines = append(lines, line) |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
147 } |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
148 }) |
1134
0420761c1c3f
Store contour lines in deterministic order.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1017
diff
changeset
|
149 cr.set(lines.Merge()) |
976
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
150 } |
c397fdd8c327
Generate the contour lines of the sounding result during the import, too.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
151 } |