Mercurial > dive4elements > river
changeset 2783:cbb513a8f548
FixA: km indexed datastructure for delta w/t results.
flys-artifacts/trunk@4522 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 25 May 2012 13:49:27 +0000 |
parents | 7c2b24fb0316 |
children | 156214e3ca55 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/DeltaWTsKM.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixResults.java |
diffstat | 4 files changed, 140 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri May 25 13:40:22 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri May 25 13:49:27 2012 +0000 @@ -5,6 +5,17 @@ 2012-05-25 Sascha L. Teichmann <sascha.teichmann@intevation.de> + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixResults.java: + New. Stores all results of a fixing analysis. + + * src/main/java/de/intevation/flys/artifacts/model/fixings/DeltaWTsKM.java: + New. Km indexed container for Delta W/t diagrams. + + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java: + Create FixResults and DeltaWTsKM now to store the results. + +2012-05-25 Sascha L. Teichmann <sascha.teichmann@intevation.de> + * src/main/java/de/intevation/flys/collections/AttributeParser.java: Replaced another silly "@attribute" XPATH with direct getAttribute() call.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/DeltaWTsKM.java Fri May 25 13:49:27 2012 +0000 @@ -0,0 +1,83 @@ +package de.intevation.flys.artifacts.model.fixings; + +import java.io.Serializable; + +import java.util.Date; +import java.util.List; +import java.util.ArrayList; +import java.util.Collections; + +public class DeltaWTsKM +implements Serializable +{ + public static final double EPSILON = 1e-5; + + public static class KM + implements Serializable, Comparable<KM> + { + protected double km; + + protected List<DeltaWT> deltaWTs; + + public KM() { + deltaWTs = new ArrayList<DeltaWT>(); + } + + public KM(double km) { + this(); + this.km = km; + } + + public double getKm() { + return km; + } + + public void setKm(double km) { + this.km = km; + } + + public List<DeltaWT> getDeltaWTs() { + return deltaWTs; + } + + public void setDeltaWTs(List<DeltaWT> deltaWTs) { + this.deltaWTs = deltaWTs; + } + + public void add(DeltaWT deltaWT) { + deltaWTs.add(deltaWT); + } + + @Override + public int compareTo(KM other) { + double d = km - other.km; + if (d < -EPSILON) return -1; + if (d > EPSILON) return +1; + return 0; + } + } // class KM + + protected List<KM> kms; + + public DeltaWTsKM() { + this(10); + } + + public DeltaWTsKM(int capacity) { + kms = new ArrayList<KM>(capacity); + } + + public void add(KM km) { + kms.add(km); + } + + public void sort() { + Collections.sort(kms); + } + + public KM findByKm(double km) { + int idx = Collections.binarySearch(kms, new KM(km)); + return idx >= 0 ? kms.get(idx) : null; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java Fri May 25 13:40:22 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixCalculation.java Fri May 25 13:49:27 2012 +0000 @@ -223,22 +223,20 @@ } // Calculate Delta W/t - List<DeltaWT> deltaWTs = calculateDeltaWTs( + DeltaWTsKM deltaWTsKM = calculateDeltaWTs( func, overview, results); - // TODO: Add km indexed structure for deltaWTs - - return new CalculationResult(deltaWTs, this); + return new CalculationResult(deltaWTsKM, this); } - public List<DeltaWT> calculateDeltaWTs( + public DeltaWTsKM calculateDeltaWTs( Function function, FixingsOverview overview, Parameters results ) { - List<DeltaWT> deltaWTs = new ArrayList<DeltaWT>(); + DeltaWTsKM deltaWTsKM = new DeltaWTsKM(results.size()); Column [][] analysisColumns = getAnalysisColumns(overview); @@ -254,6 +252,9 @@ double km = results.get(i, "km"); results.get(i, parameterIndices, parameterValues); + DeltaWTsKM.KM dwtkm = new DeltaWTsKM.KM(km); + deltaWTsKM.add(dwtkm); + // This is the paraterized function for a given km. de.intevation.flys.artifacts.math.Function instance = function.instantiate(parameterValues); @@ -291,12 +292,12 @@ pc.meta.getStartTime(), pc.meta.getDescription()); - deltaWTs.add(deltaWT); + dwtkm.add(deltaWT); } } } - return deltaWTs; + return deltaWTsKM; } /** Helper class to bundle the meta information of a column
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixResults.java Fri May 25 13:49:27 2012 +0000 @@ -0,0 +1,37 @@ +package de.intevation.flys.artifacts.model.fixings; + +import de.intevation.flys.artifacts.model.Parameters; + +import java.io.Serializable; + +public class FixResults +implements Serializable +{ + protected Parameters parameters; + protected DeltaWTsKM deltaWTsKM; + + public FixResults() { + } + + public FixResults(Parameters parameters, DeltaWTsKM deltaWTsKM) { + this.parameters = parameters; + this.deltaWTsKM = deltaWTsKM; + } + + public Parameters getParameters() { + return parameters; + } + + public void setParameters(Parameters parameters) { + this.parameters = parameters; + } + + public DeltaWTsKM getDeltaWTsKM() { + return deltaWTsKM; + } + + public void setDeltaWTsKM(DeltaWTsKM deltaWTsKM) { + this.deltaWTsKM = deltaWTsKM; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :