changeset 6948:d4108d6c4000

Cosmetics, docs.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 30 Aug 2013 09:47:15 +0200
parents 51f28e5417ee
children 13c2762270a6
files artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedDiffCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/QualityMeasurements.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentDensity.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java
diffstat 5 files changed, 45 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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 :
--- 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 :
--- 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 :
--- 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) {
--- 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);

http://dive4elements.wald.intevation.org