Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhstate/TkhCalculation.java @ 9131:0a19a79663dd
TKH calculation now takes the stations of the bed heights for the waterlevel calculation instead of letting the user define a km-step
author | gernotbelger |
---|---|
date | Wed, 06 Jun 2018 14:17:18 +0200 |
parents | ae3565385e6a |
children | 3dae6b78e1da |
comparison
equal
deleted
inserted
replaced
9130:f61bc0c63188 | 9131:0a19a79663dd |
---|---|
61 final TkhAccess access = new TkhAccess(sinfo); | 61 final TkhAccess access = new TkhAccess(sinfo); |
62 final River river = access.getRiver(); | 62 final River river = access.getRiver(); |
63 final RiverInfo riverInfo = new RiverInfo(river); | 63 final RiverInfo riverInfo = new RiverInfo(river); |
64 final DoubleRange calcRange = access.getRange(); | 64 final DoubleRange calcRange = access.getRange(); |
65 | 65 |
66 final String calcModeLabel = Resources.getMsg(this.context.getMeta(), sinfo.getCalculationMode().name()); | |
67 final String user = CalculationUtils.findArtifactUser(this.context, sinfo); | |
68 | |
66 final Calculation problems = new Calculation(); | 69 final Calculation problems = new Calculation(); |
67 | 70 |
68 /* find relevant bed-heights */ | 71 /* find relevant bed-heights */ |
69 final List<BedHeight> defaultBedHeights = new DefaultBedHeights(river).getBedHeights(problems); | 72 final List<BedHeight> defaultBedHeights = new DefaultBedHeights(river).getBedHeights(problems); |
70 final Collection<BedHeightsFinder> bedHeights = BedHeightsFinder.createTkhBedHeights(problems, calcRange, defaultBedHeights); | 73 final Collection<BedHeightsFinder> bedHeights = BedHeightsFinder.createTkhBedHeights(problems, calcRange, defaultBedHeights); |
74 | |
75 if (defaultBedHeights.isEmpty()) { | |
76 final TkhCalculationResults results = new TkhCalculationResults(calcModeLabel, user, riverInfo, calcRange, ""); | |
77 return new CalculationResult(results, problems); | |
78 } | |
79 | |
71 final double[] stations = extractStations(bedHeights); | 80 final double[] stations = extractStations(bedHeights); |
72 | 81 |
73 /* misuse winfo-artifact to calculate waterlevels in the same way */ | 82 /* misuse winfo-artifact to calculate waterlevels in the same way */ |
74 final WINFOArtifact winfo = new WinfoArtifactWrapper(sinfo); | 83 final WINFOArtifact winfo = new WinfoArtifactWrapper(sinfo); |
75 | 84 |
76 /* calculate waterlevels */ | 85 /* calculate waterlevels */ |
77 final WQKms[] kms = calculateWaterlevels(winfo, stations, problems); | 86 final WQKms[] kms = calculateWaterlevels(winfo, stations, problems); |
78 | 87 |
79 final RiverInfoProvider infoProvider = RiverInfoProvider.forRange(this.context, river, calcRange); | 88 final RiverInfoProvider infoProvider = RiverInfoProvider.forRange(this.context, river, calcRange); |
80 | |
81 final String user = CalculationUtils.findArtifactUser(this.context, sinfo); | |
82 | |
83 final String calcModeLabel = Resources.getMsg(this.context.getMeta(), sinfo.getCalculationMode().name()); | |
84 | 89 |
85 final WaterlevelDescriptionBuilder descBuilder = new WaterlevelDescriptionBuilder(winfo, this.context); | 90 final WaterlevelDescriptionBuilder descBuilder = new WaterlevelDescriptionBuilder(winfo, this.context); |
86 final String descriptionHeader = descBuilder.getColumnHeader(); | 91 final String descriptionHeader = descBuilder.getColumnHeader(); |
87 | 92 |
88 /* for each waterlevel, do a tkh calculation */ | 93 /* for each waterlevel, do a tkh calculation */ |
124 return allStations; | 129 return allStations; |
125 } | 130 } |
126 | 131 |
127 private WQKms[] calculateWaterlevels(final WINFOArtifact winfo, final double[] stations, final Calculation problems) { | 132 private WQKms[] calculateWaterlevels(final WINFOArtifact winfo, final double[] stations, final Calculation problems) { |
128 | 133 |
129 // FIXME: we take kms from step, but instead we would like to take kms from bedheights | 134 final CalculationResult waterlevelData = winfo.computeWaterlevelData(stations); |
130 // FIXME: this will definitely break the serialization of the winfo artifact | |
131 | |
132 final CalculationResult waterlevelData = winfo.getWaterlevelData(this.context); | |
133 | 135 |
134 /* copy all problems */ | 136 /* copy all problems */ |
135 final Calculation winfoProblems = waterlevelData.getReport(); | 137 final Calculation winfoProblems = waterlevelData.getReport(); |
136 final List<Problem> problems2 = winfoProblems.getProblems(); | 138 final List<Problem> problems2 = winfoProblems.getProblems(); |
137 if (problems2 != null) { | 139 if (problems2 != null) { |