annotate artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/BedHeightsFinder.java @ 9597:5395c6d4ca50

Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
author mschaefer
date Tue, 05 Feb 2019 15:47:58 +0100
parents b9c87bbff6a4
children
rev   line source
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
2 * Software engineering by
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
3 * Björnsen Beratende Ingenieure GmbH
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
5 *
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
6 * This file is Free Software under the GNU AGPL (>=v3)
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
8 * documentation coming with Dive4Elements River for details.
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
9 */
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
10 package org.dive4elements.river.artifacts.sinfo.tkhstate;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
11
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
12 import java.util.ArrayList;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
13 import java.util.Collection;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
14 import java.util.List;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
15 import java.util.Map.Entry;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
16 import java.util.NavigableMap;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
17 import java.util.TreeMap;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
18
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
19 import org.apache.commons.lang.math.DoubleRange;
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
20 import org.dive4elements.artifacts.CallContext;
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
21 import org.dive4elements.river.artifacts.BedHeightsArtifact;
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
22 import org.dive4elements.river.artifacts.math.Linear;
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
23 import org.dive4elements.river.artifacts.model.Calculation;
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
24 import org.dive4elements.river.artifacts.sinfo.util.BedHeightInfo;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
25 import org.dive4elements.river.model.BedHeight;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
26 import org.dive4elements.river.model.BedHeightValue;
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
27 import org.dive4elements.river.model.BedHeightValueType;
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
28 import org.dive4elements.river.utils.RiverUtils;
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
29
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
30 /**
9573
b9c87bbff6a4 mean bed height -> mean bed LEVEL
gernotbelger
parents: 9480
diff changeset
31 * Provides bed levels for various calculations.
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
32 *
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
33 * @author Gernot Belger
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
34 */
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
35 public final class BedHeightsFinder {
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
36
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
37 private static double MAX_DISTANCE_KM = 1;
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
38
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
39 private final BedHeightInfo info;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
40
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
41 private final NavigableMap<Double, BedHeightValue> values;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
42
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
43 private Calculation problems;
8955
798d9dcbccdd BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
mschaefer
parents: 8946
diff changeset
44
9480
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
45 private final boolean isNull;
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
46
9597
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
47 private final boolean doInterpolate;
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
48
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
49 /**
9573
b9c87bbff6a4 mean bed height -> mean bed LEVEL
gernotbelger
parents: 9480
diff changeset
50 * Create bed level finders from a collection of bed levels.
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
51 */
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
52 public static Collection<BedHeightsFinder> createTkhBedHeights(final Calculation problems, final DoubleRange range,
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
53 final Collection<BedHeight> bedHeights) {
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
54 final List<BedHeightsFinder> result = new ArrayList<>(bedHeights.size());
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
55
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
56 for (final BedHeight bedHeight : bedHeights) {
9597
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
57 final BedHeightsFinder finder = createBedHeights(problems, bedHeight, range, true);
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
58 result.add(finder);
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
59 }
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
60
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
61 return result;
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
62 }
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
63
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
64 /**
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
65 * Create not-interpolated bed level finders from a collection of bed levels.
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
66 */
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
67 public static Collection<BedHeightsFinder> createScenarioBedHeights(final Calculation problems, final DoubleRange range,
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
68 final Collection<BedHeight> bedHeights) {
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
69 final List<BedHeightsFinder> result = new ArrayList<>(bedHeights.size());
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
70
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
71 for (final BedHeight bedHeight : bedHeights) {
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
72 final BedHeightsFinder finder = createBedHeights(problems, bedHeight, range, false);
8942
11bf13cf0463 Minor changes to tkh calculation. Loading default bed heights form config file.
gernotbelger
parents: 8915
diff changeset
73 result.add(finder);
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
74 }
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
75
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
76 return result;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
77 }
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
78
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
79 public static BedHeightsFinder forId(final CallContext context, final String soundingId, final DoubleRange calcRange, final Calculation problems) {
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
80
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
81 // REMARK: absolutely unbelievable....
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
82 // The way how bed-heights (and other data too) is accessed is different for nearly every calculation-type
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
83 // throughout flys.
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
84 // The knowledge on how to parse the datacage-ids is spread through the complete code-base...
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
85
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
86 // We use here the way on how bed-heights are accessed by the BedDifferenceAccess/BedDifferenceCalculation, but
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
87 // this is plain random
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
88 final String[] parts = soundingId.split(";");
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
89
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
90 final BedHeightsArtifact artifact = (BedHeightsArtifact) RiverUtils.getArtifact(parts[0], context);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
91
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
92 final Integer bedheightId = artifact.getDataAsInteger("height_id");
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
93
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
94 // REMARK: this only works with type 'single'; unclear on how to distinguish from epoch data (or whatever the
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
95 // other type means)
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
96 // Luckily, the requirement is to only access 'single' data here.
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
97 // final String bedheightType = artifact.getDataAsString("type");
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
98
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
99 // REMARK: BedDifferences uses this, but we also need the metadata of the BedHeight
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
100 // REMARK: second absolutely awful thing: BedHeight is a hibernate binding class, accessing the database via
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
101 // hibernate stuff
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
102 // BedHeightFactory uses its own (direct) way of accessing the data, with its own implemented data classes.
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
103 // return BedHeightFactory.getHeight(bedheightType, bedheightId, from, to);
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
104
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
105 final BedHeightsFinder bedHeight = bedheightId == null ? null : BedHeightsFinder.forId(problems, bedheightId, calcRange);
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
106 if (bedHeight == null) {
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
107 problems.addProblem("sinfo.bedheightsfinder.notfound", soundingId);
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
108 return null;
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
109 }
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
110
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
111 if (bedHeight.isEmpty()) {
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
112 problems.addProblem("sinfo.bedheightsfinder.empty");
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
113 return null;
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
114 }
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
115
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
116 return bedHeight;
8946
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
117 }
5d5d482da3e9 Implementing SINFO - FlowDepthMinMax calculation
gernotbelger
parents: 8942
diff changeset
118
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
119 /**
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
120 * Creates a {@link BedHeightsFinder} for a dataset from the database, specified by its id.
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
121 *
9573
b9c87bbff6a4 mean bed height -> mean bed LEVEL
gernotbelger
parents: 9480
diff changeset
122 * @return <code>null</code> if no bed level with the given id exists.
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
123 */
9394
439699ff9b2d Added U-Info iota (prev. salix) calculation for historical scenario
mschaefer
parents: 8964
diff changeset
124 public static BedHeightsFinder forId(final Calculation problems, final int id, final DoubleRange range) {
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
125
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
126 final BedHeight bedHeight = BedHeight.getBedHeightById(id);
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
127 if (bedHeight == null)
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
128 return null;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
129
9597
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
130 return BedHeightsFinder.createBedHeights(problems, bedHeight, range, true);
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
131 }
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
132
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
133 /**
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
134 * Creates a interpolated or not-interpolated {@link BedHeightsFinder} for a dataset from the database, specified by its
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
135 * id.
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
136 *
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
137 * @return <code>null</code> if no bed level with the given id exists.
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
138 */
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
139 public static BedHeightsFinder forId(final Calculation problems, final int id, final DoubleRange range, final boolean doInterpolate) {
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
140
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
141 final BedHeight bedHeight = BedHeight.getBedHeightById(id);
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
142 if (bedHeight == null)
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
143 return null;
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
144
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
145 return BedHeightsFinder.createBedHeights(problems, bedHeight, range, doInterpolate);
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
146 }
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
147
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
148 /**
9480
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
149 * Creates a {@link BedHeightsFinder} that returns always NaN heights
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
150 */
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
151 public static BedHeightsFinder NullFinder() {
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
152 final NavigableMap<Double, BedHeightValue> values = new TreeMap<>();
9597
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
153 return new BedHeightsFinder(null, null, values, true, false);
9480
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
154 }
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
155
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
156 /**
9573
b9c87bbff6a4 mean bed height -> mean bed LEVEL
gernotbelger
parents: 9480
diff changeset
157 * Create a finder for a given bed level.
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
158 *
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
159 */
9597
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
160 private static BedHeightsFinder createBedHeights(final Calculation problems, final BedHeight bedHeight, final DoubleRange range,
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
161 final boolean doInterpolate) {
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
162
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
163 // FIXME: sort by station, but in what direction?
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
164 // FIXME: using river.getKmUp()?
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
165 final NavigableMap<Double, BedHeightValue> values = new TreeMap<>();
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
166
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
167 for (final BedHeightValue bedHeightValue : bedHeight.getValues()) {
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
168 final Double station = bedHeightValue.getStation();
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
169 if (station != null && range.containsDouble(station)) {
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
170
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
171 if (bedHeightValue.getHeight() != null)
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
172 values.put(station, bedHeightValue);
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
173 }
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
174 }
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
175
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
176 final BedHeightInfo info = BedHeightInfo.from(bedHeight);
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
177
9597
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
178 return new BedHeightsFinder(problems, info, values, false, doInterpolate);
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
179 }
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
180
9597
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
181 private BedHeightsFinder(final Calculation problems, final BedHeightInfo info, final NavigableMap<Double, BedHeightValue> values, final boolean isNull,
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
182 final boolean doInterpolate) {
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
183 this.info = info;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
184 this.values = values;
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
185 this.problems = problems;
9480
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
186 this.isNull = isNull;
9597
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
187 this.doInterpolate = doInterpolate;
9480
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
188 }
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
189
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
190 /**
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
191 * Whether this is a null (always NaN) finder.
9573
b9c87bbff6a4 mean bed height -> mean bed LEVEL
gernotbelger
parents: 9480
diff changeset
192 *
9480
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
193 * @return
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
194 */
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
195 public boolean isNull() {
7228bd10a8cc Fixed bundu bzws bedheightfinder todos, added types for excavation volume and costs total
mschaefer
parents: 9444
diff changeset
196 return this.isNull;
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
197 }
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
198
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
199 public boolean isEmpty() {
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
200 return this.values.isEmpty();
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
201 }
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
202
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
203 public BedHeightInfo getInfo() {
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
204 return this.info;
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
205 }
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
206
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
207 public Collection<Double> getStations() {
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
208 return this.values.keySet();
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
209 }
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
210
9394
439699ff9b2d Added U-Info iota (prev. salix) calculation for historical scenario
mschaefer
parents: 8964
diff changeset
211 public DoubleRange getKmRange() {
439699ff9b2d Added U-Info iota (prev. salix) calculation for historical scenario
mschaefer
parents: 8964
diff changeset
212 if (this.values.isEmpty())
439699ff9b2d Added U-Info iota (prev. salix) calculation for historical scenario
mschaefer
parents: 8964
diff changeset
213 return null;
439699ff9b2d Added U-Info iota (prev. salix) calculation for historical scenario
mschaefer
parents: 8964
diff changeset
214 return new DoubleRange(this.values.firstKey().doubleValue(), this.values.lastKey().doubleValue());
439699ff9b2d Added U-Info iota (prev. salix) calculation for historical scenario
mschaefer
parents: 8964
diff changeset
215 }
439699ff9b2d Added U-Info iota (prev. salix) calculation for historical scenario
mschaefer
parents: 8964
diff changeset
216
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
217 public double getMeanBedHeight(final double km) {
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
218 return interpolateBedHeights(km, BedHeightValueType.value);
8955
798d9dcbccdd BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
mschaefer
parents: 8946
diff changeset
219 }
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
220
8955
798d9dcbccdd BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
mschaefer
parents: 8946
diff changeset
221 public double getMinBedHeight(final double km) {
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
222 return interpolateBedHeights(km, BedHeightValueType.min);
8955
798d9dcbccdd BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
mschaefer
parents: 8946
diff changeset
223 }
798d9dcbccdd BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
mschaefer
parents: 8946
diff changeset
224
798d9dcbccdd BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
mschaefer
parents: 8946
diff changeset
225 public double getMaxBedHeight(final double km) {
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
226 return interpolateBedHeights(km, BedHeightValueType.max);
8955
798d9dcbccdd BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
mschaefer
parents: 8946
diff changeset
227 }
798d9dcbccdd BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
mschaefer
parents: 8946
diff changeset
228
9444
ecadc9ed0ba0 Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents: 9394
diff changeset
229 public double getFieldHeight(final double km, final int index) {
ecadc9ed0ba0 Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents: 9394
diff changeset
230 return interpolateBedHeights(km, BedHeightValueType.field(index));
ecadc9ed0ba0 Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents: 9394
diff changeset
231 }
ecadc9ed0ba0 Added heights and depths of cross section fields in the bundu bzws calculation and longitudinal section charts
mschaefer
parents: 9394
diff changeset
232
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
233 private double interpolateBedHeights(final double km, final BedHeightValueType type) {
9573
b9c87bbff6a4 mean bed height -> mean bed LEVEL
gernotbelger
parents: 9480
diff changeset
234 if (this.values.containsKey(km)) {
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
235 final Double value = type.getValue(this.values.get(km));
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
236 return value == null ? Double.NaN : value.doubleValue();
8955
798d9dcbccdd BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
mschaefer
parents: 8946
diff changeset
237 }
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
238
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
239 final Entry<Double, BedHeightValue> floorEntry = this.values.floorEntry(km);
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
240 final Entry<Double, BedHeightValue> ceilingEntry = this.values.ceilingEntry(km);
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
241
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
242 if (floorEntry == null || ceilingEntry == null)
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
243 return Double.NaN;
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
244
9597
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
245 // return NaN if value not found and no-interpolation mode, and report once
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
246 if (!this.doInterpolate && (floorEntry != ceilingEntry)) {
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
247 if (this.problems != null) {
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
248 this.problems.addProblem(km, "sinfo.bedheightsfinder.missing_bedheights");
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
249 this.problems = null;
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
250 }
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
251 return Double.NaN;
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
252 }
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
253
8955
798d9dcbccdd BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
mschaefer
parents: 8946
diff changeset
254 final double floorKm = floorEntry.getKey().doubleValue();
798d9dcbccdd BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
mschaefer
parents: 8946
diff changeset
255 final double ceilKm = ceilingEntry.getKey().doubleValue();
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
256 /* report once if the interpolation distance exceeds 1000m */
9597
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
257 if (Math.abs(floorKm - ceilKm) > MAX_DISTANCE_KM) {
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
258 if (this.problems != null) {
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
259 this.problems.addProblem(km, "linearInterpolator.maxdistance", MAX_DISTANCE_KM * 1000);
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
260 this.problems = null;
5395c6d4ca50 Softwaretests...20181219 7.3: no interpolation of missing bed heights for Uinfo/Salix historical scenario and B&U/Bzws
mschaefer
parents: 9573
diff changeset
261 }
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
262 return Double.NaN;
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
263 }
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
264
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
265 final Double floorHeight = type.getValue(floorEntry.getValue());
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
266 final Double ceilingHeight = type.getValue(ceilingEntry.getValue());
8955
798d9dcbccdd BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
mschaefer
parents: 8946
diff changeset
267
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
268 if (floorHeight == null || ceilingHeight == null)
8955
798d9dcbccdd BedHeightValue (bed_height_values) extended by two columns for minimum and maximum bed height
mschaefer
parents: 8946
diff changeset
269 return Double.NaN;
8964
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
270
45f1ad66560e Code cleanup concerning calculations: improved error handling; improved interpolation; bed heights are now always used for spatial discretisation
gernotbelger
parents: 8955
diff changeset
271 return Linear.linear(km, floorKm, ceilKm, floorHeight, ceilingHeight);
8915
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
272 }
d9dbf0b74bc2 Refaktoring of flow depth calculation, extracting tkh part. First implementation of tkh calculation.
gernotbelger
parents:
diff changeset
273 }

http://dive4elements.wald.intevation.org