diff artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java @ 6948:d4108d6c4000

Cosmetics, docs.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 30 Aug 2013 09:47:15 +0200
parents 70b440dc5317
children 5a348e3df0f8
line wrap: on
line diff
--- 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