[PATCH 3 of 4] Cosmetics, docs
Wald Commits
scm-commit at wald.intevation.org
Fri Aug 30 09:37:53 CEST 2013
# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1377848835 -7200
# Node ID d4108d6c400088d643bbb041076fd19673205b20
# Parent 51f28e5417ee56702b90e68797de080267dccb9c
Cosmetics, docs.
diff -r 51f28e5417ee -r d4108d6c4000 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java Fri Aug 30 09:45:04 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java Fri Aug 30 09:47:15 2013 +0200
@@ -180,3 +180,4 @@
s2.getName());
}
}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 51f28e5417ee -r d4108d6c4000 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/QualityMeasurements.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/QualityMeasurements.java Fri Aug 30 09:45:04 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/QualityMeasurements.java Fri Aug 30 09:47:15 2013 +0200
@@ -56,3 +56,4 @@
this.measurements.add(qm);
}
}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 51f28e5417ee -r d4108d6c4000 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java Fri Aug 30 09:45:04 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java Fri Aug 30 09:47:15 2013 +0200
@@ -135,8 +135,12 @@
return (m * km) + b;
}
+
+ /** If multiple values for same year and station are found,
+ * build and store average, dismiss multiple values. */
public void cleanUp() {
Set<Integer> keys = densities.keySet();
+ // Walk over years
for (Integer key : keys) {
List<SedimentDensityValue> list = densities.get(key);
if (list.size() == 0) {
@@ -148,6 +152,7 @@
int counter = 0;
double sum = 0d;
for (SedimentDensityValue value : list) {
+ // Apparently we can assume that values are ordered by km.
if (value.getKm() == prevkm) {
sum += value.getDensity();
counter++;
@@ -166,3 +171,4 @@
}
}
}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
diff -r 51f28e5417ee -r d4108d6c4000 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java Fri Aug 30 09:45:04 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java Fri Aug 30 09:47:15 2013 +0200
@@ -125,6 +125,9 @@
return null;
}
+ /**
+ * @param[out] resLoad resulting SedimentLoad
+ */
private void calculateEpochKm(
List<SedimentLoad> epochLoads,
SedimentLoad resLoad,
@@ -243,7 +246,10 @@
return result;
}
- /** Calculate/Fetch values at off. epochs. */
+ /**
+ * Calculate/Fetch values at off. epochs.
+ * @param i index in epochs.
+ */
private SedimentLoadResult calculateOffEpoch(int i) {
SedimentLoad load = SedimentLoadFactory.getLoadWithData(
this.river,
@@ -521,7 +527,13 @@
/**
* Transform values in load.
+ * Background is to transform values measured in
+ * t/a to m^3/a or vice versa using the specific
+ * measured relationships.
+ *
* @param load The load of which values should be transformed.
+ * @param year The year at which to look at density (e.g. 2003).
+ *
* @return parameter load with transformed values.
*/
private SedimentLoad calculateUnit(SedimentLoad load, int year) {
diff -r 51f28e5417ee -r d4108d6c4000 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java Fri Aug 30 09:45:04 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java Fri Aug 30 09:47:15 2013 +0200
@@ -205,7 +205,7 @@
/**
* Get a sedimentLoad filled with data from db (or cache).
- * @param type "epoch","off_epoch" or "single"
+ * @param type "epoch", "off_epoch" or "single"
*/
public static SedimentLoad getLoadWithData(
String river,
@@ -359,22 +359,35 @@
Session session = SessionHolder.HOLDER.get();
SQLQuery sqlQuery = null;
- List<MeasurementStation> allStations = RiverFactory.getRiver(river).getMeasurementStations();
- TreeMap<Double,MeasurementStation> floatStations = new TreeMap<Double, MeasurementStation>();
- TreeMap<Double,MeasurementStation> suspStations = new TreeMap<Double, MeasurementStation>();
+ // Measurement stations: all, for float-stuff, for suspended stuff.
+ // Because they need fast sorted access, use TreeMaps.
+ // They map the starting validity range km to the station itself.
+ List<MeasurementStation> allStations =
+ RiverFactory.getRiver(river).getMeasurementStations();
+ TreeMap<Double,MeasurementStation> floatStations =
+ new TreeMap<Double, MeasurementStation>();
+ TreeMap<Double,MeasurementStation> suspStations =
+ new TreeMap<Double, MeasurementStation>();
+
+ // From all stations, sort into the two kinds, skip undefined ones.
for (MeasurementStation measurementStation: allStations) {
if (measurementStation.getMeasurementType() == null ||
measurementStation.getRange() == null) {
continue;
}
if (measurementStation.getMeasurementType().equals("Schwebstoff")) {
- suspStations.put(measurementStation.getRange().getA().doubleValue(), measurementStation);
+ suspStations.put(
+ measurementStation.getRange().getA().doubleValue(),
+ measurementStation);
}
else if (measurementStation.getMeasurementType().equals("Geschiebe")) {
- floatStations.put(measurementStation.getRange().getA().doubleValue(), measurementStation);
+ floatStations.put(
+ measurementStation.getRange().getA().doubleValue(),
+ measurementStation);
}
}
+ // Construct date constraint.
Calendar start = Calendar.getInstance();
start.set(syear - 1, 11, 31);
Calendar end = Calendar.getInstance();
@@ -401,11 +414,11 @@
else {
Object[] row = results.get(0);
load = new SedimentLoad(
- (String) row[0],
- (Date) row[1],
- null,
- false,
- (String) row[4]);
+ (String) row[0], //description
+ (Date) row[1], //start
+ null, //end
+ false, //isEpoch
+ (String) row[4]); //unit
}
load = getValues("coarse", sqlQuery, load, floatStations);
load = getValues("fine_middle", sqlQuery, load, floatStations);
More information about the Dive4elements-commits
mailing list