Mercurial > dive4elements > river
changeset 4835:8e72777c961c
Introduced a fake ConstantWQKms class to have type information to only generate w facets for curves which really carry w data.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 23 Jan 2013 05:53:44 +0100 |
parents | 601f9d69cc10 |
children | 01e82da3f919 |
files | flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ConstantWQKms.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java |
diffstat | 3 files changed, 62 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java Tue Jan 22 15:13:58 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation4.java Wed Jan 23 05:53:44 2013 +0100 @@ -15,8 +15,6 @@ import de.intevation.flys.utils.DoubleUtil; -import gnu.trove.TDoubleArrayList; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -276,14 +274,20 @@ } // Generate the "Umhuellende". - QKms [] qkms = generateInfolding(table, results, from, to, step); + ConstantWQKms [] infoldings = + generateInfolding(table, results, from, to, step); // TODO: Use qkms in a new result type. + WQKms [] newResults = new WQKms[results.length + infoldings.length]; + System.arraycopy( + results, 0, newResults, 0, results.length); + System.arraycopy( + infoldings, 0, newResults, results.length, infoldings.length); - return new CalculationResult(results, this); + return new CalculationResult(newResults, this); } - protected QKms [] generateInfolding( + protected ConstantWQKms [] generateInfolding( WstValueTable wst, WQKms [] results, double from, @@ -295,20 +299,22 @@ InfoldingColumns ic = new InfoldingColumns(columns); ic.markInfoldingColumns(results); - List<QKms> infoldings = new ArrayList<QKms>(); + List<ConstantWQKms> infoldings = new ArrayList<ConstantWQKms>(); boolean [] infoldingColumns = ic.getInfoldingColumns(); double [] kms = null; + double [] ws = null; for (int i = 0; i < infoldingColumns.length; ++i) { if (!infoldingColumns[i]) { continue; } - kms = kms == null - ? DoubleUtil.explode(from, to, step) - : (double [])kms.clone(); + if (kms == null) { + kms = DoubleUtil.explode(from, to, step); + ws = new double[kms.length]; + } QRangeTree.QuickQFinder qf = columns[i].getQRangeTree().new QuickQFinder(); @@ -319,19 +325,16 @@ // TODO: i18n String name = "Umh\u00fcllende " + columns[i].getName(); - QKmsImpl qkms = new QKmsImpl( - new TDoubleArrayList(kms), - new TDoubleArrayList(qs), - name); + ConstantWQKms infolding = new ConstantWQKms(kms, qs, ws, name); if (numProblems() > numProblemsBefore) { - qkms.removeNaNs(); + infolding.removeNaNs(); } - infoldings.add(qkms); + infoldings.add(infolding); } - return infoldings.toArray(new QKms[infoldings.size()]); + return infoldings.toArray(new ConstantWQKms[infoldings.size()]); } protected String createName(int index) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/ConstantWQKms.java Wed Jan 23 05:53:44 2013 +0100 @@ -0,0 +1,30 @@ +package de.intevation.flys.artifacts.model; + +public class ConstantWQKms +extends WQKms +{ + public ConstantWQKms() { + this(""); + } + + public ConstantWQKms(String name) { + super(name); + } + + public ConstantWQKms(int capacity) { + this(capacity, ""); + } + + public ConstantWQKms(int capacity, String name) { + super(capacity, name); + } + + public ConstantWQKms(double [] kms, double [] qs, double [] ws) { + this(kms, qs, ws, ""); + } + + public ConstantWQKms(double [] kms, double [] qs, double [] ws, String name) { + super(kms, qs, ws, name); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java Tue Jan 22 15:13:58 2013 +0100 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java Wed Jan 23 05:53:44 2013 +0100 @@ -11,6 +11,7 @@ import de.intevation.flys.artifacts.model.Calculation4; import de.intevation.flys.artifacts.model.CalculationResult; +import de.intevation.flys.artifacts.model.ConstantWQKms; import de.intevation.flys.artifacts.model.CrossSectionWaterLineFacet; import de.intevation.flys.artifacts.model.DataFacet; import de.intevation.flys.artifacts.model.EmptyFacet; @@ -70,16 +71,22 @@ nameQ = "Q(" + nameW + ")"; } - Facet w = new WaterlevelFacet( - i, DISCHARGE_LONGITUDINAL_W, nameW); + // Do not generate Waterlevel/Waterline facets + // for Q only curves. + if (!(wqkms[i] instanceof ConstantWQKms)) { + + Facet w = new WaterlevelFacet( + i, DISCHARGE_LONGITUDINAL_W, nameW); + + Facet s = new CrossSectionWaterLineFacet(i, nameW); + + facets.add(s); + facets.add(w); + } Facet q = new WaterlevelFacet( i, DISCHARGE_LONGITUDINAL_Q, nameQ); - Facet s = new CrossSectionWaterLineFacet(i, nameW); - - facets.add(s); - facets.add(w); facets.add(q); if (wqkms[i] instanceof WQCKms) {