Mercurial > gemma
annotate pkg/mesh/classbreaks.go @ 4931:e41d42be0e13 fairway-marks-import
One more callback to avoid code duplication more consequently
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Fri, 14 Feb 2020 19:34:08 +0100 |
parents | 4847ac70103a |
children | 34bc6041e61e |
rev | line source |
---|---|
3836
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 // This is Free Software under GNU Affero General Public License v >= 3.0 |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 // without warranty, see README.md and license for details. |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 // |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 // SPDX-License-Identifier: AGPL-3.0-or-later |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 // License-Filename: LICENSES/AGPL-3.0.txt |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 // |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 // Copyright (C) 2019 by via donau |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 // – Österreichische Wasserstraßen-Gesellschaft mbH |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 // Software engineering by Intevation GmbH |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 // |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 // Author(s): |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 |
4827
f4abfd0ee8ad
Renamed octree package to mesh as there is no octree any more.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4762
diff
changeset
|
14 package mesh |
3836
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import ( |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 "context" |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 "database/sql" |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 "errors" |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 "math" |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 "sort" |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 "strconv" |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 "strings" |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 ) |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 const ( |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 selectClassBreaksSQL = ` |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 SELECT config_val FROM sys_admin.system_config |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 WHERE config_key = $1` |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 ) |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 func SampleDiffHeights(min, max, step float64) []float64 { |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 var heights []float64 |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 switch { |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 case min >= 0: // All values positive. |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 for v := 0.0; v <= max; v += step { |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 if v >= min { |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 heights = append(heights, v) |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 case max <= 0: // All values negative. |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 for v := 0.0; v >= min; v -= step { |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 if v <= max { |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 heights = append(heights, v) |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 default: // Positive and negative. |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 for v := step; v <= max; v += step { |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 heights = append(heights, v) |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 for i, j := 0, len(heights)-1; i < j; i, j = i+1, j-1 { |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 heights[i], heights[j] = heights[j], heights[i] |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 for v := 0.0; v >= min; v -= step { |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 heights = append(heights, v) |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 return heights |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 |
4214
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
61 func ParseClassBreaks(config string) ([]float64, error) { |
3836
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 |
4214
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
63 parts := strings.Split(config, ",") |
3836
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 classes := make([]float64, 0, len(parts)) |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 for _, part := range parts { |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 if idx := strings.IndexRune(part, ':'); idx >= 0 { |
3882
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
67 part = part[:idx] |
3836
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 if part = strings.TrimSpace(part); part == "" { |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 continue |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 v, err := strconv.ParseFloat(part, 64) |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 if err != nil { |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 return nil, err |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 classes = append(classes, v) |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 sort.Float64s(classes) |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 return classes, nil |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 } |
631f5eaf29de
First preparation to use custom classbreaks in contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 |
4214
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
83 func LoadClassBreaks(ctx context.Context, tx *sql.Tx, key string) ([]float64, error) { |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
84 |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
85 var config sql.NullString |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
86 |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
87 err := tx.QueryRowContext(ctx, selectClassBreaksSQL, key).Scan(&config) |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
88 |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
89 switch { |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
90 case err == sql.ErrNoRows: |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
91 return nil, nil |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
92 case err != nil: |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
93 return nil, err |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
94 case !config.Valid: |
4847
4847ac70103a
Made staticcheck happy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4827
diff
changeset
|
95 return nil, errors.New("invalid config string") |
4214
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
96 } |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
97 |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
98 return ParseClassBreaks(config.String) |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
99 } |
49564382ffff
Added a import queue job to recalculate the contour lines of the sounding results if the heights have changed.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3882
diff
changeset
|
100 |
4746
5e0041fd3cba
Round height values of extrapolated classbreaks to four place behind the dot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4687
diff
changeset
|
101 func round(v float64) float64 { |
5e0041fd3cba
Round height values of extrapolated classbreaks to four place behind the dot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4687
diff
changeset
|
102 return math.Round(v*10000) / 10000 |
5e0041fd3cba
Round height values of extrapolated classbreaks to four place behind the dot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4687
diff
changeset
|
103 } |
5e0041fd3cba
Round height values of extrapolated classbreaks to four place behind the dot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4687
diff
changeset
|
104 |
3882
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
105 func ExtrapolateClassBreaks(cbs []float64, min, max float64) []float64 { |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
106 if min > max { |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
107 min, max = max, min |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
108 } |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
109 |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
110 n := make([]float64, len(cbs)) |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
111 copy(n, cbs) |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
112 sort.Float64s(n) |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
113 |
4685
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
114 for len(n) > 0 && n[0] < min { |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
115 n = n[1:] |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
116 } |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
117 |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
118 if len(n) == 0 { |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
119 return n |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
120 } |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
121 |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
122 for len(n) > 0 && n[len(n)-1] > max { |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
123 n = n[:len(n)-1] |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
124 } |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
125 |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
126 if len(n) == 0 { |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
127 return n |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
128 } |
7a9388943840
morphology: Clip class breaks again Z min and max of the the height model.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4214
diff
changeset
|
129 |
3882
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
130 for min < n[0] { |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
131 diff := n[1] - n[0] |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
132 if diff == 0 { |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
133 break |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
134 } |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
135 m := make([]float64, len(n)+1) |
4746
5e0041fd3cba
Round height values of extrapolated classbreaks to four place behind the dot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4687
diff
changeset
|
136 m[0] = round(n[0] - diff) |
3882
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
137 copy(m[1:], n) |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
138 n = m |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
139 } |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
140 |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
141 for max > n[len(n)-1] { |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
142 diff := n[len(n)-1] - n[len(n)-2] |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
143 if diff == 0 { |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
144 break |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
145 } |
4746
5e0041fd3cba
Round height values of extrapolated classbreaks to four place behind the dot.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
4687
diff
changeset
|
146 n = append(n, round(n[len(n)-1]+diff)) |
3882
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
147 } |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
148 |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
149 return n |
37d5c4441c70
Use custom morpho class breaks in sounding result contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
3836
diff
changeset
|
150 } |