[PATCH 2 of 5] Merged

Wald Commits scm-commit at wald.intevation.org
Fri Jul 19 13:30:00 CEST 2013


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1374209790 -7200
# Node ID 03cc3bc749648dfd759b765f3549f6a10614ac47
# Parent  61dc90b2fbe2624e4418ff1a039b704c5ec3879a
# Parent  764371d4db6aa974169f985bacfb6a3ccd8e155c
Merged.

diff -r 61dc90b2fbe2 -r 03cc3bc74964 .hgtags
--- a/.hgtags	Thu Jul 18 15:44:31 2013 +0200
+++ b/.hgtags	Fri Jul 19 06:56:30 2013 +0200
@@ -59,3 +59,4 @@
 0000000000000000000000000000000000000000 3.0.10
 0000000000000000000000000000000000000000 3.0.10
 bfcb513c1fdace07ce39616bc9fda3899e8ee914 3.0.10
+63baa1873b1f86a78ab10d19ae4221ec01cc75a2 3.0.11
diff -r 61dc90b2fbe2 -r 03cc3bc74964 artifacts/doc/conf/datacage.sql
--- a/artifacts/doc/conf/datacage.sql	Thu Jul 18 15:44:31 2013 +0200
+++ b/artifacts/doc/conf/datacage.sql	Fri Jul 19 06:56:30 2013 +0200
@@ -41,7 +41,7 @@
     artifact_id INT             NOT NULL REFERENCES artifacts(id) ON DELETE CASCADE,
     kind        VARCHAR(256)    NOT NULL,
     k           VARCHAR(256)    NOT NULL,
-    v           VARCHAR(256),   -- Maybe too short
+    v           TEXT,
     UNIQUE (artifact_id, k)
 );
 
diff -r 61dc90b2fbe2 -r 03cc3bc74964 artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Thu Jul 18 15:44:31 2013 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/WaterlevelExporter.java	Fri Jul 19 06:56:30 2013 +0200
@@ -393,14 +393,14 @@
         if (first > last) {
             for (int i = wqkms.size() - 1; i >= 0; i--) {
                 dp = wqkms.get(i, dp);
-                if (dp[2] < first && dp[2] > last) {
+                if (dp[2] <= first + 1E-5 && dp[2] > last - 1E-5) {
                     filtered.add(dp[0], dp[1], dp[2]);
                 }
             }
         } else {
             for (int i = 0; i < wqkms.size(); i++) {
                 dp = wqkms.get(i, dp);
-                if (dp[2] < last && dp[2] > first) {
+                if (dp[2] < last + 1E-5 && dp[2] > first - 1E-5) {
                     filtered.add(dp[0], dp[1], dp[2]);
                 }
             }
@@ -591,13 +591,12 @@
         NumberFormat kmf = getKmFormatter();
         NumberFormat wf  = getWFormatter();
         NumberFormat qf  = getQFormatter();
-
-       writer.writeNext(new String[] {
-           kmf.format(wqkm[2]),
-           wf.format(wqkm[0]),
-           qf.format(wqkm[1]),
-           RiverUtils.getLocationDescription(flys, wqkm[2])
-       });
+        writer.writeNext(new String[] {
+            kmf.format(wqkm[2]),
+            wf.format(wqkm[0]),
+            qf.format(wqkm[1]),
+            RiverUtils.getLocationDescription(flys, wqkm[2])
+        });
     }
 
 
@@ -618,6 +617,38 @@
         });
     }
 
+    private String getDesc(WQKms wqkms, boolean isQ)
+    {
+        D4EArtifact flys = (D4EArtifact) master;
+        String colDesc = "";
+
+        if (flys instanceof WINFOArtifact && isQ) {
+            colDesc = getCSVRowTitle((WINFOArtifact)flys, wqkms);
+        }
+        else if (!isQ) {
+            Double value = RiverUtils.getValueFromWQ(wqkms);
+            colDesc = (value != null) ?
+                Formatter.getWaterlevelW(context).format(value) : null;
+        }
+
+        if (flys instanceof WINFOArtifact) {
+            if (wqkms != null && wqkms.getRawValue() != null) {
+                WINFOArtifact winfo = (WINFOArtifact) flys;
+                colDesc = RiverUtils.getNamedMainValue(winfo, wqkms.getRawValue());
+                // For 'W am Pegel' s
+                if (colDesc == null) {
+                    colDesc = ((D4EArtifact)master).getDataAsString("wq_single");
+                }
+            }
+        }
+        if (colDesc != null) {
+            /* Quick hack. Can be removed when database strings are
+             * adapted or left in here as it should never be harmful. */
+            colDesc = colDesc.replace("Amtl.Festlegung_", "Amtl. ");
+        }
+
+        return colDesc == null ? "" : colDesc;
+    }
 
     /**
      * Write "rows" of csv data from wqkms with writer.
@@ -650,35 +681,16 @@
         String       notinrange = msg(
             CSV_NOT_IN_GAUGE_RANGE,
             DEFAULT_CSV_NOT_IN_GAUGE_RANGE);
+        List<Segment> segments = null;
+        boolean isFixRealize = false;
 
         double a = gauge.getRange().getA().doubleValue();
         double b = gauge.getRange().getB().doubleValue();
-
-        if (flys instanceof WINFOArtifact && isQ) {
-            desc = getCSVRowTitle((WINFOArtifact)flys, wqkms);
-        }
-        else if (!isQ) {
-            Double value = RiverUtils.getValueFromWQ(wqkms);
-            desc         = value != null
-                ? Formatter.getWaterlevelW(context).format(value) : null;
-        }
-
         long startTime = System.currentTimeMillis();
 
-        String colDesc = desc;
-        List<Segment> segments = null;
-        boolean isFixRealize = false;
-        if (flys instanceof WINFOArtifact) {
-            if (wqkms != null && wqkms.getRawValue() != null) {
-                WINFOArtifact winfo = (WINFOArtifact) flys;
-                colDesc = RiverUtils.getNamedMainValue(winfo, wqkms.getRawValue());
-                // For 'W am Pegel' s
-                if (colDesc == null) {
-                    colDesc = ((D4EArtifact)master).getDataAsString("wq_single");
-                }
-            }
-        }
-        else if (flys instanceof FixationArtifact) {
+        desc = getDesc(wqkms, isQ);
+
+        if (flys instanceof FixationArtifact) {
             // Get W/Q input per gauge for this case.
             FixRealizingAccess fixAccess = new FixRealizingAccess(flys);
             segments = fixAccess.getSegments();
@@ -708,7 +720,7 @@
                         : findSegment(km, segments);
 
                     if (found != null) {
-                        colDesc = nf.format(found.getValues()[0]);
+                        desc = nf.format(found.getValues()[0]);
                     }
                     lastSegment = found;
                 }
@@ -729,7 +741,7 @@
                         ? gaugeName
                         : notinrange;
                 }
-                writeRow6(writer, result, colDesc, flys, gaugeN);
+                writeRow6(writer, result, desc, flys, gaugeN);
             }
         }
         else { // Not at gauge.
@@ -855,12 +867,38 @@
         boolean atGauge = mode == WQ_MODE.QGAUGE || mode == WQ_MODE.WGAUGE;
         boolean isQ     = mode == WQ_MODE.QGAUGE || mode == WQ_MODE.QFREE;
 
+        Double first = Double.NaN;
+        Double last = Double.NaN;
+
         addMetaData(source);
         for (WQKms[] tmp: data) {
             for (WQKms wqkms: tmp) {
                 addWKmsData(wqkms, atGauge, isQ, source);
+                double[] firstLast = wqkms.getFirstLastKM();
+                if (first.isNaN()) {
+                    /* Initialize */
+                    first = firstLast[0];
+                    last = firstLast[1];
+                }
+                if (firstLast[0] > firstLast[1]) {
+                    /* Calculating upstream we assert that it is
+                     * impossible that the direction changes during this
+                     * loop */
+                    first = Math.max(first, firstLast[0]);
+                    last = Math.min(last, firstLast[1]);
+                } else if (firstLast[0] < firstLast[1]) {
+                    first = Math.min(first, firstLast[0]);
+                    last = Math.max(last, firstLast[1]);
+                } else {
+                    first = last = firstLast[0];
+                }
             }
         }
+
+        /* Append the official fixing at the bottom */
+        for (WQKms wqkms: officalFixings) {
+            addWKmsData(filterWQKms(wqkms, first, last), atGauge, isQ, source);
+        }
         return source;
     }
 
@@ -919,15 +957,7 @@
         double a = gauge.getRange().getA().doubleValue();
         double b = gauge.getRange().getB().doubleValue();
 
-        if (flys instanceof WINFOArtifact && isQ) {
-            desc = getCSVRowTitle((WINFOArtifact)flys, wqkms);
-        }
-        else if (!isQ) {
-            Double value = RiverUtils.getValueFromWQ(wqkms);
-            desc         = value != null
-                ? Formatter.getWaterlevelW(context).format(value) : null;
-        }
-
+        desc = getDesc(wqkms, isQ);
         long startTime = System.currentTimeMillis();
 
         for (int i = 0; i < size; i ++) {
diff -r 61dc90b2fbe2 -r 03cc3bc74964 artifacts/src/main/resources/messages_de.properties
--- a/artifacts/src/main/resources/messages_de.properties	Thu Jul 18 15:44:31 2013 +0200
+++ b/artifacts/src/main/resources/messages_de.properties	Fri Jul 19 06:56:30 2013 +0200
@@ -330,7 +330,7 @@
 export.waterlevel.csv.meta.gauge = # Bezugspegel: {0}
 export.waterlevel.csv.meta.q = # Q (m\u00b3/s): {0}
 export.waterlevel.csv.meta.w = # W (NN + m): {0} - {1}
-export.waterlevel.csv.not.in.gauge.range = au\u00dferhalb gew\u00e4hlter Bezugspegels
+export.waterlevel.csv.not.in.gauge.range = au\u00dferh. d. Bez.pegels
 export.computed.discharge.curve.csv.header.w = W [{0}]
 export.computed.discharge.curve.csv.header.q = Q [m\u00b3/s]
 export.duration.curve.csv.header.duration = D [Tagen]
diff -r 61dc90b2fbe2 -r 03cc3bc74964 artifacts/src/main/resources/messages_de_DE.properties
--- a/artifacts/src/main/resources/messages_de_DE.properties	Thu Jul 18 15:44:31 2013 +0200
+++ b/artifacts/src/main/resources/messages_de_DE.properties	Fri Jul 19 06:56:30 2013 +0200
@@ -328,7 +328,7 @@
 export.waterlevel.csv.meta.gauge = # Bezugspegel: {0}
 export.waterlevel.csv.meta.q = # Q (m\u00b3/s): {0}
 export.waterlevel.csv.meta.w = # W (NN + m): {0} - {1}
-export.waterlevel.csv.not.in.gauge.range = au\u00dferhalb gew\u00e4hlter Bezugspegels
+export.waterlevel.csv.not.in.gauge.range = au\u00dferh. d. Bez.pegels
 export.computed.discharge.curve.csv.header.w = W [{0}]
 export.computed.discharge.curve.csv.header.q = Q [m\u00b3/s]
 export.duration.curve.csv.header.duration = D [Tagen]
diff -r 61dc90b2fbe2 -r 03cc3bc74964 contrib/make_flys_release/make_release.sh
--- a/contrib/make_flys_release/make_release.sh	Thu Jul 18 15:44:31 2013 +0200
+++ b/contrib/make_flys_release/make_release.sh	Fri Jul 19 06:56:30 2013 +0200
@@ -367,6 +367,11 @@
 mv $WORK_DIR/datacagedb $WORK_DIR/server/
 
 echo "INFO: create tarball"
+if [ -d "$WORK_DIR/flys-$VERSION" ]; then
+    echo "INFO: removing old directory"
+    rm -rf "$WORK_DIR/flys-$VERSION"
+fi
+
 mkdir $WORK_DIR/flys-$VERSION
 mv $WORK_DIR/server $WORK_DIR/client $WORK_DIR/flys-$VERSION
 cd $WORK_DIR


More information about the Dive4elements-commits mailing list