[PATCH 1 of 2] Use GF_UNKNOWN constant instead of -1 to identify unknown grain fractions

Wald Commits scm-commit at wald.intevation.org
Wed Jul 16 16:04:08 CEST 2014


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1405518791 -7200
# Node ID 3a769d5fb733ed87f87dc2efd27bc886e79bb39a
# Parent  aa622bddfdacf50452ccdf80cb4ff9a8f015210f
Use GF_UNKNOWN constant instead of -1 to identify unknown grain fractions.

diff -r aa622bddfdac -r 3a769d5fb733 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Wed Jul 16 13:06:09 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Wed Jul 16 15:53:11 2014 +0200
@@ -19,15 +19,14 @@
 
 public class SedimentLoadData implements Serializable
 {
-    public static final double STATION_EPS = 0.0001;
-
-    public static final int GF_COARSE        = 0;
-    public static final int GF_FINE_MIDDLE   = 1;
-    public static final int GF_SAND          = 2;
-    public static final int GF_SUSP_SAND     = 3;
-    public static final int GF_SUSP_SAND_BED = 4;
-    public static final int GF_SUSP_SEDIMENT = 5;
-    public static final int GF_MAX           = 5;
+    public static final int GF_UNKNOWN       = -1;
+    public static final int GF_COARSE        =  0;
+    public static final int GF_FINE_MIDDLE   =  1;
+    public static final int GF_SAND          =  2;
+    public static final int GF_SUSP_SAND     =  3;
+    public static final int GF_SUSP_SAND_BED =  4;
+    public static final int GF_SUSP_SEDIMENT =  5;
+    public static final int GF_MAX           =  5;
 
     public static final int grainFractionIndex(String name) {
         if ("coarse".equals(name))             return GF_COARSE;
@@ -36,7 +35,7 @@
         if ("susp_sand".equals(name))          return GF_SUSP_SAND;
         if ("susp_sand_bed".equals(name))      return GF_SUSP_SAND_BED;
         if ("suspended_sediment".equals(name)) return GF_SUSP_SEDIMENT;
-        return -1;
+        return GF_UNKNOWN;
     }
 
     public interface Visitor {
diff -r aa622bddfdac -r 3a769d5fb733 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFactory.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFactory.java	Wed Jul 16 13:06:09 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataFactory.java	Wed Jul 16 15:53:11 2014 +0200
@@ -110,7 +110,7 @@
         sqlQuery.setString("river", river);
 
         SedimentLoadData.Load load = null;
-        int grainFractionIndex = -1;
+        int grainFractionIndex = SedimentLoadData.GF_UNKNOWN;
 
         HashMap<Integer, SedimentLoadData.Station> id2station
             = new HashMap<Integer, SedimentLoadData.Station>();
@@ -136,7 +136,7 @@
                 grainFractionIndex =
                     SedimentLoadData.grainFractionIndex(gf_name);
 
-                if (grainFractionIndex == -1) {
+                if (grainFractionIndex == SedimentLoadData.GF_UNKNOWN) {
                     log.error("Unknown grain fraction type: " + gf_name);
                     break;
                 }


More information about the Dive4Elements-commits mailing list