changeset 6874:d9dfa52f69eb

FixA Delta W(t): Add 30 seconds to colliding dates to avoid them vanishing from the diagrams.
author Sascha L. Teichmann <teichmann@intevation.de>
date Tue, 20 Aug 2013 11:20:25 +0200
parents 6848c5c8fc23
children 437856cec419
files artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java	Mon Aug 19 22:19:09 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixDeltaWtGenerator.java	Tue Aug 20 11:20:25 2013 +0200
@@ -41,6 +41,8 @@
 import org.jfree.data.time.TimeSeriesCollection;
 import org.w3c.dom.Document;
 
+import gnu.trove.TLongHashSet;
+
 
 /**
  * Generator for Delta W(t) charts.
@@ -79,7 +81,10 @@
     }
 
 
-    private D4EArtifact artifact = null;
+    private D4EArtifact artifact;
+
+    // Used to make the dates collision free.
+    private TLongHashSet uniqueDates = new TLongHashSet();
 
 
     @Override
@@ -247,6 +252,12 @@
         }
     }
 
+    private long uniqueDate(long date) {
+        return uniqueDates.add(date)
+            ? date
+            : uniqueDate(date+30L*1000L); // add 30secs.
+    }
+
 
     protected void doSectorAverageOut(
             D4EArtifact artifact,
@@ -323,7 +334,8 @@
 
         int idxInterpol = 0;
         int idxRegular = 0;
-        RegularTimePeriod rtp = new FixedMillisecond(qwd.getDate());
+        long time = uniqueDate(qwd.getDate().getTime());
+        RegularTimePeriod rtp = new FixedMillisecond(time);
         double value =  qwd.getDeltaW();
         boolean interpolate = qwd.getInterpolated();
         if (interpolate) {

http://dive4elements.wald.intevation.org