[Dive4elements-commits] [PATCH 2 of 3] WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet
Wald Commits
scm-commit at wald.intevation.org
Tue Nov 13 14:44:24 CET 2012
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1352814537 -3600
# Node ID 5fc7df736634afb9e811382063c6c2da628eff2b
# Parent 6153c50f78cf7721ad993a2fad60296b459ed00d
WINFOArtifact: Compute extreme values for cross sections too. Add CS-Facet.
diff -r 6153c50f78cf -r 5fc7df736634 flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Tue Nov 13 14:46:44 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Tue Nov 13 14:48:57 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,6 +159,15 @@
//
// 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.
@@ -167,11 +178,15 @@
{
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);
diff -r 6153c50f78cf -r 5fc7df736634 flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/extreme/ExtremeCompute.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/extreme/ExtremeCompute.java Tue Nov 13 14:46:44 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/extreme/ExtremeCompute.java Tue Nov 13 14:48:57 2012 +0100
@@ -9,6 +9,7 @@
import de.intevation.flys.artifacts.access.ExtremeAccess;
import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.CrossSectionWaterLineFacet;
import de.intevation.flys.artifacts.model.DataFacet;
import de.intevation.flys.artifacts.model.FacetTypes;
import de.intevation.flys.artifacts.model.ReportFacet;
@@ -88,9 +89,11 @@
i, LONGITUDINAL_W, name, ComputeType.ADVANCE, id, hash);
Facet q = new WaterlevelFacet(
i, LONGITUDINAL_Q, qname, ComputeType.ADVANCE, id, hash);
+ Facet csFacet = new CrossSectionWaterLineFacet(i, name);
facets.add(w);
facets.add(q);
+ facets.add(csFacet);
}
More information about the Dive4elements-commits
mailing list