Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 4482:b5624ef2808f
Merged
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Tue, 13 Nov 2012 16:14:44 +0100 |
parents | 5fc7df736634 |
children | 6d3426aba65d |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Tue Nov 13 16:13:41 2012 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Tue Nov 13 16:14:44 2012 +0100 @@ -28,7 +28,9 @@ import de.intevation.flys.artifacts.model.WW; import de.intevation.flys.artifacts.model.WstValueTable; import de.intevation.flys.artifacts.model.WstValueTableFactory; +import de.intevation.flys.artifacts.model.extreme.ExtremeResult; +import de.intevation.flys.artifacts.states.DefaultState.ComputeType; import de.intevation.flys.artifacts.states.LocationDistanceSelect; import de.intevation.flys.model.DischargeTable; @@ -157,21 +159,34 @@ // // METHODS FOR RETRIEVING COMPUTED DATA FOR DIFFERENT CHART TYPES // + // + /** + * Returns the data that is computed by a waterlevel computation. + * + * @return an array of data triples that consist of W, Q and Kms. + */ + public CalculationResult getWaterlevelData() { + return this.getWaterlevelData(null); + } /** * Returns the data that is computed by a waterlevel computation. * * @return an array of data triples that consist of W, Q and Kms. */ - public CalculationResult getWaterlevelData() + public CalculationResult getWaterlevelData(CallContext context) { logger.debug("WINFOArtifact.getWaterlevelData"); - if (getDataAsString("calculation_mode") - .equals("calc.discharge.longitudinal.section") + String calculationMode = getDataAsString("calculation_mode"); + + if (calculationMode.equals("calc.discharge.longitudinal.section") ) { return getDischargeLongitudinalSectionData(); } + else if (calculationMode.equals("calc.extreme.curve")) { + return (CalculationResult) this.compute(context, ComputeType.ADVANCE, false); + } River river = FLYSUtils.getRiver(this); if (river == null) { @@ -625,13 +640,22 @@ */ @Override public Lines.LineData getWaterLines(int idx, FastCrossSectionLine csl, - double nextIgnored, double prevIgnored) { + double nextIgnored, double prevIgnored, CallContext context) { logger.debug("getWaterLines(" + idx + ")"); List<Point2D> points = csl.getPoints(); // Need W at km - WQKms [] wqkms = (WQKms[]) getWaterlevelData().getData(); + Object waterlevelResult = getWaterlevelData(context).getData(); + WQKms [] wqkms; + + if (waterlevelResult instanceof ExtremeResult) { + wqkms = ((ExtremeResult) waterlevelResult).getWQKms(); + } + else { + wqkms = (WQKms[]) waterlevelResult; + } + if (wqkms.length == 0) { logger.error("No WQKms found."); return Lines.createWaterLines(points, 0.0f); @@ -643,12 +667,12 @@ return waterLineC(idx, csl); } + // Find W at km, linear naive approach. + WQKms triple = wqkms[idx]; + // Find index of km. double wishKM = csl.getKm(); - // Find W at km, linear naive approach. - WQKms triple = wqkms[idx]; - if (triple.size() == 0) { logger.warn("Calculation of waterline is empty."); return Lines.createWaterLines(points, 0.0f);