Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java @ 9130:f61bc0c63188
WQSelect can now handle distance-only data
author | gernotbelger |
---|---|
date | Wed, 06 Jun 2018 14:16:28 +0200 |
parents | e3519c3e7a0a |
children | 3f49835a00c3 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java Wed Jun 06 14:15:58 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/WINFOArtifact.java Wed Jun 06 14:16:28 2018 +0200 @@ -20,6 +20,7 @@ import org.dive4elements.river.artifacts.access.Calculation4Access; import org.dive4elements.river.artifacts.access.RangeAccess; +import org.dive4elements.river.artifacts.access.RiverAccess; import org.dive4elements.river.artifacts.access.ComputationRangeAccess; import org.dive4elements.river.artifacts.geom.Lines; @@ -42,8 +43,6 @@ import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; -import org.dive4elements.river.artifacts.states.LocationDistanceSelect; - import org.dive4elements.river.model.DischargeTable; import org.dive4elements.river.model.FastCrossSectionLine; import org.dive4elements.river.model.Gauge; @@ -174,7 +173,7 @@ return this.getWaterlevelData(null); } - protected CalculationResult getDischargeLongitudinalSectionData() { + private CalculationResult getDischargeLongitudinalSectionData() { // TODO: This caluclation should be cached as it is quite expensive. return new Calculation4(new Calculation4Access(this)).calculate(); } @@ -191,44 +190,51 @@ String calculationMode = getDataAsString("calculation_mode"); // If this WINFO-Artifact has a calculation trait. - if (calculationMode != null) { - if (calculationMode.equals("calc.discharge.longitudinal.section") - ) { + if (calculationMode != null) + { + if (calculationMode.equals("calc.discharge.longitudinal.section")) return getDischargeLongitudinalSectionData(); - } - else if (calculationMode.equals("calc.extreme.curve")) { - return (CalculationResult) - this.compute(context, ComputeType.ADVANCE, false); - } - else if (calculationMode.equals("calc.w.differences")) { - return (CalculationResult) - this.compute(context, ComputeType.ADVANCE, true); - } - else { - log.warn("Unhandled calculation_mode " + calculationMode); - } + + if (calculationMode.equals("calc.extreme.curve")) + return (CalculationResult)this.compute(context, ComputeType.ADVANCE, false); + + if (calculationMode.equals("calc.w.differences")) + return (CalculationResult)this.compute(context, ComputeType.ADVANCE, true); + + log.warn("Unhandled calculation_mode " + calculationMode); } - + // Otherwise get it from parameterization. - River river = RiverUtils.getRiver(this); - if (river == null) { + // TODO: wrong comment: now always a waterlevle computation is executed; actually there is a calc_mode for that, why dont check? + return computeWaterlevelData(); + } + + /** Execu5tes the calculation of 'waterlevel', fetches all input data from this artifact */ + private CalculationResult computeWaterlevelData() { + final double[] kms = new ComputationRangeAccess(this).getKms(); + if (kms == null) + return error(new WQKms[0], "no.kms.selected"); + + return computeWaterlevelData(kms); + } + + /** + * Execu5tes the calculation of 'waterlevel'. + * Allows to override the stations for which the calculation is done. All other inputs are fetched from this artifact. + */ + public final CalculationResult computeWaterlevelData(final double kms[]) { + + final River river = new RiverAccess(this).getRiver(); + if (river == null) return error(new WQKms[0], "no.river.selected"); - } - - double[] kms = getKms(); - if (kms == null) { - return error(new WQKms[0], "no.kms.selected"); - } double[] qs = getQs(); double[] ws = null; - boolean qSel = true; Calculation report = new Calculation(); if (qs == null) { log.debug("Determine Q values based on a set of W values."); - qSel = false; ws = getWs(); double [][] qws = getQsForWs(ws, report); if (qws == null || qws.length == 0) { @@ -273,10 +279,9 @@ "reference gauge: " + gauge.getName() + " (km " + refKm + ")"); } - return computeWaterlevelData(kms, qs, ws, wst, refKm, report); + return computeWaterlevelData(kms, qs, ws, wst, refKm, report); } - /** * Computes the data of a waterlevel computation based on the interpolation * in WstValueTable. @@ -287,7 +292,7 @@ * * @return an array of data triples that consist of W, Q and Kms. */ - public static CalculationResult computeWaterlevelData( + private static CalculationResult computeWaterlevelData( double [] kms, double [] qs, double [] ws, @@ -349,7 +354,7 @@ * * @return the computed data. */ - public static CalculationResult computeDurationCurveData( + private static CalculationResult computeDurationCurveData( Gauge gauge, WstValueTable wst, double location) @@ -409,7 +414,7 @@ * @return an object that contains tuples of W/Q values at the specified * location. */ - public static CalculationResult computeDischargeCurveData( + private static CalculationResult computeDischargeCurveData( WstValueTable wst, double location) { @@ -544,7 +549,7 @@ /** * Get corrected waterline against surface/profile. */ - public Lines.LineData waterLineC(int idx, FastCrossSectionLine csl) { + private Lines.LineData waterLineC(int idx, FastCrossSectionLine csl) { List<Point2D> points = csl.getPoints(); WQKms[] wqckms = (WQKms[]) @@ -665,7 +670,7 @@ * * @return an array of Q values. */ - public double [][] getQsForWs(double[] ws, Calculation report) { + private double [][] getQsForWs(double[] ws, Calculation report) { if (ws == null) { log.error("getQsForWs: ws == null"); @@ -803,19 +808,6 @@ /** - * Returns the selected Kms. - * - * @return the selected kms. - */ - public double[] getKms() { - return new ComputationRangeAccess(this).getKms(); - } - - public double [] getFromToStep() { - return new ComputationRangeAccess(this).getFromToStep(); - } - - /** * This method returns the Q values. * * @return the selected Q values or null, if no Q values are selected.