annotate pkg/controllers/bottlenecks.go @ 3076:e0daeb05bf50

Display Available Fairway Depths vs. LNWL: Completed backend (untested).
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 17 Apr 2019 15:04:28 +0200
parents a661e9b8f3b6
children c68cef0346b7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
1 // This is Free Software under GNU Affero General Public License v >= 3.0
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
2 // without warranty, see README.md and license for details.
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 //
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 // SPDX-License-Identifier: AGPL-3.0-or-later
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 // License-Filename: LICENSES/AGPL-3.0.txt
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6 //
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 // Copyright (C) 2019 by via donau
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 // – Österreichische Wasserstraßen-Gesellschaft mbH
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 // Software engineering by Intevation GmbH
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10 //
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11 // Author(s):
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de>
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
13
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 package controllers
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
15
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16 import (
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 "database/sql"
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 "fmt"
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 "log"
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 "net/http"
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21 "sort"
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
22 "strconv"
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23 "strings"
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 "time"
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 "gemma.intevation.de/gemma/pkg/common"
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27 "github.com/gorilla/mux"
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
28 )
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
29
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
30 const (
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 selectAvailableDepthSQL = `
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 WITH data AS (
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 SELECT
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 efa.measure_date,
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 efa.available_depth_value,
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 efa.water_level_value
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 FROM waterway.effective_fairway_availability efa
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 JOIN waterway.fairway_availability fa
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 ON efa.fairway_availability_id = fa.id
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 JOIN waterway.bottlenecks bn
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41 ON fa.bottleneck_id = bn.id
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
42 WHERE
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
43 bn.objnam = $1 AND
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 efa.level_of_service = $2 AND
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 efa.measure_type = 'Measured' AND
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46 efa.available_depth_value IS NOT NULL AND
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
47 efa.water_level_value IS NOT NULL
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
48 ),
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
49 before AS (
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 SELECT * FROM data WHERE measure_date < $3
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 ORDER BY measure_date DESC LIMIT 1
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
52 ),
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
53 inside AS (
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
54 SELECT * FROM data WHERE measure_date BETWEEN $3 AND $4
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
55 ),
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56 after AS (
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 SELECT * FROM data WHERE measure_date > $4
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 ORDER BY measure_date LIMIT 1
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 )
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 SELECT * FROM before
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 UNION ALL
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 SELECT * FROM inside
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 UNION ALL
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 SELECT * FROM after
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 ORDER BY measure_date
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 `
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 selectGaugeLevelsSQL = `
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 SELECT
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 grwl.depth_reference,
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 grwl.value
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 FROM waterway.gauges_reference_water_levels grwl JOIN
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73 waterway.bottlenecks bns
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
74 ON bns.fk_g_fid = grwl.gauge_id
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
75 WHERE bns.objnam = $1 AND (
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
76 grwl.depth_reference like 'HDC%' OR
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77 grwl.depth_reference like 'LDC%' OR
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
78 grwl.depth_reference like 'MW%'
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
79 )
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
80 `
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
81 )
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
82
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
83 type (
3076
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
84 referenceValue struct {
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
85 level int
3040
a661e9b8f3b6 Fairway availability: 'virtualized' the field to classify.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3038
diff changeset
86 value float64
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
87 }
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
88
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
89 availMeasurement struct {
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
90 when time.Time
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
91 depth int
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
92 value int
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
93 }
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
94 )
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
95
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
96 func classifyAvailMeasurements(
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
97 from, to time.Time,
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
98 measurements []availMeasurement,
3076
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
99 classes []referenceValue,
3040
a661e9b8f3b6 Fairway availability: 'virtualized' the field to classify.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3038
diff changeset
100 access func(*availMeasurement) float64,
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
101 ) []time.Duration {
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
102
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
103 type classValues struct {
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
104 when time.Time
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
105 kind common.ValueRangeKind
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
106 }
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
107
3038
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
108 //var invalid time.Duration
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
109 result := make([]time.Duration, len(classes)+1)
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
110
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
111 cvs := make([]classValues, len(classes))
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
112
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
113 classify := func(v func(float64) (time.Time, common.ValueRangeKind)) {
3038
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
114 for i := range classes {
3040
a661e9b8f3b6 Fairway availability: 'virtualized' the field to classify.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3038
diff changeset
115 cvs[i].when, cvs[i].kind = v(classes[i].value)
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
116 }
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
117 }
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
118
3036
7f12a87c56ff Fairway availability: Set boundaries of segments correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3027
diff changeset
119 vbt := func(p1, p2 *availMeasurement) func(time.Time) (float64, common.ValueRangeKind) {
3040
a661e9b8f3b6 Fairway availability: 'virtualized' the field to classify.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3038
diff changeset
120 return common.InterpolateValueByTime(p1.when, access(p1), p2.when, access(p2))
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
121 }
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
122
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
123 pairs:
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
124 for i := 0; i < len(measurements)-1; i++ {
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
125 p1 := &measurements[i]
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
126 p2 := &measurements[i+1]
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
127
3036
7f12a87c56ff Fairway availability: Set boundaries of segments correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3027
diff changeset
128 var start, end time.Time
7f12a87c56ff Fairway availability: Set boundaries of segments correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3027
diff changeset
129
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
130 switch {
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
131 case !p2.when.After(p2.when):
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
132 // Segment invalid
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
133 continue pairs
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
134
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
135 case p1.when.After(to) || p2.when.Before(from):
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
136 // Segment complete outside.
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
137 continue pairs
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
138
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
139 case p1.when.After(from) && p2.when.Before(to):
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
140 // (from-to) is complete inside segment.
3038
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
141 // invalid += p1.when.Sub(from)
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
142 // invalid += to.Sub(p2.when)
3036
7f12a87c56ff Fairway availability: Set boundaries of segments correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3027
diff changeset
143 v := vbt(p1, p2)
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
144 f, _ := v(from)
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
145 t, _ := v(to)
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
146 classify(common.InterpolateTimeByValue(from, f, to, t))
3036
7f12a87c56ff Fairway availability: Set boundaries of segments correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3027
diff changeset
147 start, end = from, to
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
148
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
149 case p1.when.After(from):
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
150 // from is inside segment
3038
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
151 // invalid += p1.when.Sub(from)
3036
7f12a87c56ff Fairway availability: Set boundaries of segments correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3027
diff changeset
152 f, _ := vbt(p1, p2)(from)
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
153 classify(common.InterpolateTimeByValue(
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
154 from, f,
3040
a661e9b8f3b6 Fairway availability: 'virtualized' the field to classify.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3038
diff changeset
155 p2.when, access(p2),
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
156 ))
3036
7f12a87c56ff Fairway availability: Set boundaries of segments correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3027
diff changeset
157 start, end = from, p2.when
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
158
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
159 case p2.when.Before(to):
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
160 // to is inside segment
3038
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
161 // invalid += to.Sub(p2.when)
3036
7f12a87c56ff Fairway availability: Set boundaries of segments correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3027
diff changeset
162 t, _ := vbt(p1, p2)(to)
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
163 classify(common.InterpolateTimeByValue(
3040
a661e9b8f3b6 Fairway availability: 'virtualized' the field to classify.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3038
diff changeset
164 p1.when, access(p1),
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
165 to, t,
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
166 ))
3036
7f12a87c56ff Fairway availability: Set boundaries of segments correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3027
diff changeset
167 start, end = p1.when, to
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
168
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
169 case !p1.when.Before(from) && !to.After(p2.when):
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
170 // Segment complete inside.
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
171 classify(common.InterpolateTimeByValue(
3040
a661e9b8f3b6 Fairway availability: 'virtualized' the field to classify.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3038
diff changeset
172 p1.when, access(p1),
a661e9b8f3b6 Fairway availability: 'virtualized' the field to classify.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3038
diff changeset
173 p2.when, access(p2),
3027
84e6577a474b Fairway availability: More robust time and value interpolations including corner cases. Still TODO: Distribute to classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2967
diff changeset
174 ))
3036
7f12a87c56ff Fairway availability: Set boundaries of segments correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3027
diff changeset
175 start, end = p1.when, p2.when
7f12a87c56ff Fairway availability: Set boundaries of segments correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3027
diff changeset
176 default:
7f12a87c56ff Fairway availability: Set boundaries of segments correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3027
diff changeset
177 log.Println("warn: unexpected case. That should not happen.")
7f12a87c56ff Fairway availability: Set boundaries of segments correctly.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3027
diff changeset
178 continue pairs
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
179 }
3038
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
180
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
181 for i := len(cvs) - 1; i >= 0; i-- {
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
182 switch cvs[i].kind {
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
183 case common.ValueAbove:
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
184 result[i+1] += end.Sub(start)
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
185 continue pairs
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
186
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
187 case common.ValueInside:
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
188 // -> split
3040
a661e9b8f3b6 Fairway availability: 'virtualized' the field to classify.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3038
diff changeset
189 if access(p1) < classes[i].value {
3038
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
190 // started below -> second part above
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
191 result[i+1] = end.Sub(cvs[i].when)
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
192 end = cvs[i].when
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
193 } else {
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
194 // started above -> first part above
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
195 result[i+1] = cvs[i].when.Sub(start)
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
196 start = cvs[i].when
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
197 }
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
198 }
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
199 }
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
200 result[0] += end.Sub(start)
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
201 }
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
202
3038
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
203 return result
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
204 }
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
205
3076
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
206 func durationsToPercentage(from, to time.Time, classes []time.Duration) []float64 {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
207 percents := make([]float64, len(classes))
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
208 total := 100 / to.Sub(from).Seconds()
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
209 for i, v := range classes {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
210 percents[i] = v.Seconds() * total
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
211 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
212 return percents
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
213 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
214
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
215 func bottleneckAvailabilty(
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
216 _ interface{},
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
217 req *http.Request,
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
218 conn *sql.Conn,
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
219 ) (jr JSONResult, err error) {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
220 bn := mux.Vars(req)["objnam"]
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
221
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
222 if bn == "" {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
223 err = JSONError{
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
224 Code: http.StatusBadRequest,
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
225 Message: "Missing objnam of bottleneck",
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
226 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
227 return
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
228 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
229
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
230 var from, to time.Time
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
231
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
232 if f := req.FormValue("from"); f != "" {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
233 if from, err = time.Parse(common.TimeFormat, f); err != nil {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
234 err = JSONError{
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
235 Code: http.StatusBadRequest,
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
236 Message: fmt.Sprintf("Invalid time format for 'from' field: %v", err),
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
237 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
238 return
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
239 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
240 from = from.UTC()
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
241 } else {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
242 from = time.Now().AddDate(-1, 0, 0).UTC()
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
243 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
244
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
245 if t := req.FormValue("to"); t != "" {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
246 if to, err = time.Parse(common.TimeFormat, t); err != nil {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
247 err = JSONError{
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
248 Code: http.StatusBadRequest,
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
249 Message: fmt.Sprintf("Invalid time format for 'from' field: %v", err),
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
250 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
251 return
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
252 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
253 to = to.UTC()
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
254 } else {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
255 to = from.AddDate(1, 0, 0).UTC()
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
256 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
257
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
258 if to.Before(from) {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
259 to, from = from, to
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
260 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
261
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
262 log.Printf("info: time interval: (%v - %v)\n", from, to)
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
263
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
264 var los int
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
265 if l := req.FormValue("los"); l != "" {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
266 if los, err = strconv.Atoi(l); err != nil {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
267 err = JSONError{
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
268 Code: http.StatusBadRequest,
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
269 Message: fmt.Sprintf("Invalid value for field 'los': %v", err),
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
270 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
271 return
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
272 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
273 } else {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
274 los = 1
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
275 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
276
3076
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
277 ctx := req.Context()
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
278
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
279 loadLNWLReferenceValues := func() ([]referenceValue, error) {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
280 rows, err := conn.QueryContext(ctx, selectGaugeLevelsSQL, bn)
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
281 if err != nil {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
282 return nil, err
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
283 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
284 defer rows.Close()
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
285
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
286 var levels []referenceValue
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
287
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
288 loop:
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
289 for rows.Next() {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
290 var what string
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
291 var value int
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
292 if err := rows.Scan(&what, &value); err != nil {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
293 return nil, err
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
294 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
295 var level int
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
296 switch {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
297 case strings.HasPrefix(what, "LDC"):
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
298 level = 0
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
299 case strings.HasPrefix(what, "MW"):
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
300 level = 1
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
301 case strings.HasPrefix(what, "HDC"):
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
302 level = 2
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
303 default:
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
304 return nil, fmt.Errorf("Unexpected reference level type '%s'", what)
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
305 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
306 for i := range levels {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
307 if levels[i].level == level {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
308 levels[i].value = float64(value)
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
309 continue loop
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
310 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
311 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
312 levels = append(levels, referenceValue{
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
313 level: level,
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
314 value: float64(value),
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
315 })
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
316 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
317
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
318 if err := rows.Err(); err != nil {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
319 return nil, err
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
320 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
321
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
322 sort.Slice(levels, func(i, j int) bool { return levels[i].level < levels[j].level })
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
323
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
324 return levels, nil
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
325 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
326
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
327 var lnwlRefs []referenceValue
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
328 if lnwlRefs, err = loadLNWLReferenceValues(); err != nil {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
329 return
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
330 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
331
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
332 if len(lnwlRefs) == 0 {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
333 err = JSONError{
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
334 Code: http.StatusNotFound,
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
335 Message: "No gauge reference values found for bottleneck",
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
336 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
337 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
338
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
339 loadDepthValues := func() ([]availMeasurement, error) {
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
340
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
341 rows, err := conn.QueryContext(
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
342 ctx, selectAvailableDepthSQL, bn, los, from, to)
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
343 if err != nil {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
344 return nil, err
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
345 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
346 defer rows.Close()
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
347
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
348 var ms []availMeasurement
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
349
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
350 for rows.Next() {
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
351 var m availMeasurement
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
352 if err := rows.Scan(&m.when, &m.depth, &m.value); err != nil {
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
353 return nil, err
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
354 }
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
355 m.when = m.when.UTC()
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
356 ms = append(ms, m)
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
357 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
358
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
359 if err := rows.Err(); err != nil {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
360 return nil, err
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
361 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
362
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
363 return ms, nil
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
364 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
365
2967
7c301ff449bc Fairway availibility: Started with class building.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2962
diff changeset
366 var ms []availMeasurement
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
367 if ms, err = loadDepthValues(); err != nil {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
368 return
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
369 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
370
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
371 if len(ms) == 0 {
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
372 err = JSONError{
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
373 Code: http.StatusNotFound,
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
374 Message: "No available fairway depth values found",
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
375 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
376 return
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
377 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
378
3076
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
379 lnwl := classifyAvailMeasurements(
3038
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
380 from, to,
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
381 ms,
3076
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
382 lnwlRefs,
3040
a661e9b8f3b6 Fairway availability: 'virtualized' the field to classify.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3038
diff changeset
383 func(m *availMeasurement) float64 { return float64(m.value) },
3038
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
384 )
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
385
3076
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
386 afdRefs := []referenceValue{
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
387 {0, 200},
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
388 {1, 230},
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
389 {2, 250},
3038
d47d289d6e68 Fairway availability: Fill classes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3036
diff changeset
390 }
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
391
3076
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
392 afd := classifyAvailMeasurements(
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
393 from, to,
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
394 ms,
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
395 afdRefs,
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
396 func(m *availMeasurement) float64 { return float64(m.depth) },
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
397 )
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
398
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
399 lnwlPercents := durationsToPercentage(from, to, lnwl)
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
400 afdPercents := durationsToPercentage(from, to, afd)
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
401
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
402 type lnwlOutput struct {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
403 Level string `json:"level"`
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
404 Value float64 `json:"value"`
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
405 Percent float64 `json:"percent"`
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
406 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
407
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
408 type afdOutput struct {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
409 Value float64 `json:"value"`
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
410 Percent float64 `json:"percent"`
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
411 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
412
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
413 type output struct {
3076
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
414 LNWL []lnwlOutput `json:"lnwl"`
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
415 AFD []afdOutput `json:"afd"`
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
416 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
417
3076
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
418 out := output{}
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
419
3076
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
420 for i := range lnwlRefs {
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
421 var level string
3076
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
422 switch lnwlRefs[i].level {
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
423 case 0:
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
424 level = "LDC"
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
425 case 1:
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
426 level = "MW"
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
427 case 2:
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
428 level = "HDC"
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
429 }
3076
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
430 out.LNWL = append(out.LNWL, lnwlOutput{
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
431 Level: level,
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
432 Value: lnwlRefs[i].value,
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
433 Percent: lnwlPercents[i],
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
434 })
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
435 }
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
436
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
437 for i := range afdRefs {
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
438 out.AFD = append(out.AFD, afdOutput{
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
439 Value: afdRefs[i].value,
e0daeb05bf50 Display Available Fairway Depths vs. LNWL: Completed backend (untested).
Sascha L. Teichmann <teichmann@intevation.de>
parents: 3040
diff changeset
440 Percent: afdPercents[i],
2962
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
441 })
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
442 }
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
443
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
444 jr = JSONResult{Result: &out}
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
445
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
446 return
8d825551bc72 Fairway availibity for bottlenecks: Started with fetchting the relevant data. TODO: Range calculations. WIP.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
447 }