Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java @ 9398:929d645691ae
Fixed: sinfo flood duration: no w/q problem report with unchecked wspl option
author | mschaefer |
---|---|
date | Mon, 13 Aug 2018 17:27:52 +0200 |
parents | f318359b81a2 |
children | 8562c60371b8 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java Mon Aug 13 17:26:33 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/flood_duration/FloodDurationCalculator.java Mon Aug 13 17:27:52 2018 +0200 @@ -67,15 +67,12 @@ * Calculate the infrastructures flood duration result rows */ public void execute(final Calculation problems, final String label, final DoubleRange calcRange, final RiversideChoiceKey riverside, - final WINFOArtifact winfo, final FloodDurationCalculationResults results) { + final boolean withWspl, final WINFOArtifact winfo, final FloodDurationCalculationResults results) { // Find all gauges of the calc range, and create the duration finders final Map<Gauge, GaugeDurationValuesFinder> durFinders = new HashMap<>(); - Gauge firstGauge = null; for (final Gauge gauge : this.riverInfoProvider.getRiver().determineGauges(calcRange.getMinimumDouble(), calcRange.getMaximumDouble())) { durFinders.put(gauge, GaugeDurationValuesFinder.loadValues(gauge, problems)); - if (firstGauge == null) - firstGauge = gauge; } // Find all infrastructures within the calc range @@ -92,13 +89,14 @@ final double[] stationsSorted = sortStations(allStations.keySet()); // Calculate W and Q for all stations and the selected discharge states/waterlevels - final WQKms[] wqkmsArray = calculateWsts(winfo, stationsSorted, problems); + final WQKms[] wqkmsArray = calculateWsts(winfo, withWspl, stationsSorted, problems); // Determine discharge state labels of the waterlevels updateWstLabels(wqkmsArray, winfo, problems); final Map<Gauge, List<Double>> gaugeWstDurations = new HashMap<>(); - calcGaugeWstDurations(winfo, new ArrayList<>(durFinders.keySet()), gaugeWstDurations, durFinders); + if (withWspl) + calcGaugeWstDurations(winfo, new ArrayList<>(durFinders.keySet()), gaugeWstDurations, durFinders); // Load base wst table (river).wst // (should be in cache since already used in calculateWaterlevels (winfo.computeWaterlevelData) @@ -107,7 +105,7 @@ // Create the result rows, and calculate and add the flood durations etc. for (int i = 0; i <= stationsSorted.length - 1; i++) { final Gauge gauge = this.riverInfoProvider.getGauge(stationsSorted[i], true); - final ResultRow row = createRow(stationsSorted[i], gauge, firstGauge, wqkmsArray, gaugeWstDurations.get(gauge), i); + final ResultRow row = createRow(stationsSorted[i], wqkmsArray, gaugeWstDurations.get(gauge), i); if (allStations.containsKey(stationsSorted[i]) && (allStations.get(stationsSorted[i]) != null)) calculateInfrastructure(row, gauge, allStations.get(stationsSorted[i]), wst, durFinders); this.rows.add(row); @@ -214,8 +212,7 @@ } /** - * Calculate the data for the W and Q lines in the duration curve chart for the infrastructure height and add to result - * collection + * Find and return the W or Q annotation(s) of a station and a riverside in a previously calculated result */ public List<StickyAxisAnnotation> calcInfrastructureAnnotations(final Calculation problems, final double station, final AttributeKey riverside, final boolean isW, final FloodDurationCalculationResult result) { @@ -338,7 +335,7 @@ /** * Calculates an array of w-q-longitudinal sections for all artifact W/Q options */ - private WQKms[] calculateWsts(final WINFOArtifact winfo, final double[] stations, final Calculation problems) { + private WQKms[] calculateWsts(final WINFOArtifact winfo, final boolean withWspl, final double[] stations, final Calculation problems) { // First run may take long, further runs are faster since WstValueTable is in cache then // (So funktioniert computeWaterlevelData wohl: // Es sucht die Spalte(n) zum Bezugspegel-Q in der W-Q-Tabelle ({river}.wst in Wst etc.), @@ -348,6 +345,9 @@ // interpoliert; // bei Vorgabe eines W auf freier Strecke wird wohl vorher noch die .wst-Interpolation eingesetzt, um das Q zu bekommen. + if (!withWspl) + return new WQKms[] {}; + final CalculationResult wstsData = winfo.computeWaterlevelData(stations); /* copy all problems */ @@ -410,17 +410,16 @@ } /** - * Create a result row for a station and its gauge, and add w-q-values as selected + * Create a result row for a station, and add w-q-values as selected */ - private ResultRow createRow(final Double station, final Gauge gauge, final Gauge firstGauge, final WQKms[] wqkmsArray, final List<Double> gaugeDurations, - final int kmIndex) { + private ResultRow createRow(final Double station, final WQKms[] wqkmsArray, final List<Double> gaugeDurations, final int kmIndex) { final ResultRow row = ResultRow.create(); row.putValue(GeneralResultType.station, station); row.putValue(SInfoResultType.infrastructuretype, null); // is replaced later for an infrastructure row.putValue(SInfoResultType.floodDuration, Double.NaN); // is replaced later for an infrastructure - final String gaugeLabel = this.riverInfoProvider.findGauge(station, (gauge == firstGauge)); + final String gaugeLabel = this.riverInfoProvider.findGauge(station); row.putValue(GeneralResultType.gaugeLabel, gaugeLabel); final String location = this.riverInfoProvider.getLocation(station);