Displaying differences for changeset
 
display as  

src/java/m/rhem/model/AoA.java

@@ -15,9 +15,9 @@
   protected int rhemSiteId;
   protected String scenarioName;
   protected String scenarioDescription;
-  protected int unit;
+//  protected int unit;
   protected String soilTexture;
-  protected double slopeLength;
+//  protected double slopeLength;
   protected String slopeShape;
   protected double slopeSteepness;
   protected double moisturecontent;
@@ -34,7 +34,7 @@
 
 
   public AoA(int aoaId, int rhemSiteId, String scenarioName,
-      String scenarioDescription, int unit, String soilTexture, double slopeLength,
+      String scenarioDescription, String soilTexture,
       String slopeShape, double slopeSteepness,
       double bunchGgrassCanopyCover, double forbsCanopyCover,
       double shrubsCanopyCover, double sodGrassCanopyCover, double basalCover,
@@ -44,9 +44,9 @@
     this.rhemSiteId = rhemSiteId;
     this.scenarioName = scenarioName;
     this.scenarioDescription = scenarioDescription;
-    this.unit = unit;
+//    this.unit = unit;
     this.soilTexture = soilTexture;
-    this.slopeLength = slopeLength;
+//    this.slopeLength = slopeLength;
     this.slopeShape = slopeShape;
     this.slopeSteepness = slopeSteepness / 100.0;
     this.bunchGgrassCanopyCover = bunchGgrassCanopyCover / 100.0;

src/java/m/rhem/model/Parameter.java

@@ -10,7 +10,7 @@
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
-import rhem.utils.DBResources;
+import m.rhem.DBResources;
 import static rhem.utils.RHEMUtils.fmt;
 import static rhem.utils.RHEMUtils.formatDouble;
 
@@ -24,7 +24,6 @@
   private static final double CLEN_MULTIPLIER = 2.5;
 
   String clen, diams, density;
-
   String len, chezy, rchezy;
   String sl, sx;
   String cv, sat, kss, komega, kcm, ke, adf, alf, bare;
@@ -77,18 +76,11 @@
 
 
   public void computeParameters(Connection connection, AoA aoa) throws SQLException, ServiceException {
-    // canopy cover for grass
-//        double grasscanopycover = aoa.bunchGgrassCanopyCover + aoa.forbsCanopyCover + aoa.sodGrassCanopyCover;
-    // TOTAL CANOPY COVER
-    double totalcanopycover = aoa.bunchGgrassCanopyCover + aoa.forbsCanopyCover + aoa.shrubsCanopyCover + aoa.sodGrassCanopyCover;
-    // TOTAL GROUND COVER
-    double totalgroundcover = aoa.rockCover + aoa.basalCover + aoa.litterCover + aoa.cryptogamsCover;
 
-    if (aoa.unit == 2) {
-      slopeLength = aoa.slopeLength * 0.3048;
-    } else {
-      slopeLength = aoa.slopeLength;
-    }
+    double totalcanopycover = aoa.bunchGgrassCanopyCover + aoa.forbsCanopyCover
+        + aoa.shrubsCanopyCover + aoa.sodGrassCanopyCover;
+    double totalgroundcover = aoa.rockCover + aoa.basalCover
+        + aoa.litterCover + aoa.cryptogamsCover;
 
     len = String.valueOf(slopeLength);
 
@@ -101,7 +93,7 @@
   }
 
 
-  public void computeChezyValue(AoA aoa) {
+  private void computeChezyValue(AoA aoa) {
     double ft = (-1 * 0.109) + (1.425 * aoa.litterCover)
         + (0.442 * aoa.rockCover) + (1.764 * (aoa.basalCover
         + aoa.cryptogamsCover)) + (2.068 * aoa.slopeSteepness);
@@ -114,23 +106,23 @@
   }
 
 
-  public void computeSlSxValues(AoA aoa) throws ServiceException {
+  private void computeSlSxValues(AoA aoa) throws ServiceException {
     switch (aoa.slopeShape.toLowerCase()) {
       case "uniform":
         sl = fmt(aoa.slopeSteepness) + ", " + fmt(aoa.slopeSteepness);
-        sx = 0.00 + ", " + 1.00;
+        sx = "0.00, 1.00";
         break;
       case "convex":
-        sl = 0.001 + ", " + fmt(aoa.slopeSteepness * 2);
-        sx = 0.00 + ", " + 1.00;
+        sl = "0.001, " + fmt(aoa.slopeSteepness * 2);
+        sx = "0.00, 1.00";
         break;
       case "concave":
         sl = fmt(aoa.slopeSteepness * 2) + ", " + 0.001;
-        sx = 0.00 + ", " + 1.00;
+        sx = "0.00, 1.00";
         break;
       case "s-shaped":
-        sl = 0.001 + ", " + fmt(aoa.slopeSteepness * 2) + ", " + 0.001;
-        sx = 0.00 + ", " + 0.50 + ", " + 1.00;
+        sl = "0.001, " + fmt(aoa.slopeSteepness * 2) + ", " + 0.001;
+        sx = "0.00, 0.50, 1.00";
         break;
       default:
         throw new ServiceException("Invalid slope shape, " + aoa.slopeShape + ", specified for this AoA; Cannot continue.");
@@ -139,12 +131,12 @@
 
   // format a double and avoid scientific notation for small values.
 
-  public void computeClenValue() {
+  private void computeClenValue() {
     clen = String.valueOf(slopeLength * CLEN_MULTIPLIER);
   }
 
 
-  public void getValuesFmDb(Connection con, AoA aoa) throws SQLException {
+  private void getValuesFmDb(Connection con, AoA aoa) throws SQLException {
     try (Statement st = con.createStatement()) {
       try (ResultSet rs = st.executeQuery(DBResources.RunRHEMQuery01(aoa.soilTexture))) {
         while (rs.next()) {
@@ -174,42 +166,43 @@
 
   private void computeKeValue(double totalcanopycover, AoA aoa) throws ServiceException {
     double Keb = 0;
+    double cover = aoa.basalCover + aoa.litterCover;
     switch (aoa.soilTexture) {
       case "Sand":
-        Keb = 24 * Math.exp(0.3483 * (aoa.basalCover + aoa.litterCover));
+        Keb = 24 * Math.exp(0.3483 * cover);
         break;
       case "Loamy Sand":
-        Keb = 10 * Math.exp(0.8755 * (aoa.basalCover + aoa.litterCover));
+        Keb = 10 * Math.exp(0.8755 * cover);
         break;
       case "Sandy Loam":
-        Keb = 5 * Math.exp(1.1632 * (aoa.basalCover + aoa.litterCover));
+        Keb = 5 * Math.exp(1.1632 * cover);
         break;
       case "Loam":
-        Keb = 2.5 * Math.exp(1.5686 * (aoa.basalCover + aoa.litterCover));
+        Keb = 2.5 * Math.exp(1.5686 * cover);
         break;
       case "Silt Loam":
-        Keb = 1.2 * Math.exp(2.0149 * (aoa.basalCover + aoa.litterCover));
+        Keb = 1.2 * Math.exp(2.0149 * cover);
         break;
       case "Silt":
-        Keb = 1.2 * Math.exp(2.0149 * (aoa.basalCover + aoa.litterCover));
+        Keb = 1.2 * Math.exp(2.0149 * cover);
         break;
       case "Sandy Clay Loam":
-        Keb = 0.80 * Math.exp(2.1691 * (aoa.basalCover + aoa.litterCover));
+        Keb = 0.80 * Math.exp(2.1691 * cover);
         break;
       case "Clay Loam":
-        Keb = 0.50 * Math.exp(2.3026 * (aoa.basalCover + aoa.litterCover));
+        Keb = 0.50 * Math.exp(2.3026 * cover);
         break;
       case "Silty Clay Loam":
-        Keb = 0.40 * Math.exp(2.1691 * (aoa.basalCover + aoa.litterCover));
+        Keb = 0.40 * Math.exp(2.1691 * cover);
         break;
       case "Sandy Clay":
-        Keb = 0.30 * Math.exp(2.1203 * (aoa.basalCover + aoa.litterCover));
+        Keb = 0.30 * Math.exp(2.1203 * cover);
         break;
       case "Silty Clay":
-        Keb = 0.25 * Math.exp(1.7918 * (aoa.basalCover + aoa.litterCover));
+        Keb = 0.25 * Math.exp(1.7918 * cover);
         break;
       case "Clay":
-        Keb = 0.2 * Math.exp(1.3218 * (aoa.basalCover + aoa.litterCover));
+        Keb = 0.2 * Math.exp(1.3218 * cover);
         break;
       default:
         throw new ServiceException("Invalid soilTexture: " + aoa.soilTexture);
@@ -219,10 +212,10 @@
 
     // calculate weighted Ke and Kss values for the vegetation types that have non-zero values
     if (totalcanopycover != 0.0) {
-      weightedKe = weightedKe + ((aoa.shrubsCanopyCover / totalcanopycover) * (Keb * 1.2));
-      weightedKe = weightedKe + ((aoa.sodGrassCanopyCover / totalcanopycover) * (Keb * 0.8));
-      weightedKe = weightedKe + ((aoa.bunchGgrassCanopyCover / totalcanopycover) * (Keb * 1.0));
-      weightedKe = weightedKe + ((aoa.forbsCanopyCover / totalcanopycover) * (Keb * 1.0));
+      weightedKe += ((aoa.shrubsCanopyCover / totalcanopycover) * (Keb * 1.2));
+      weightedKe += ((aoa.sodGrassCanopyCover / totalcanopycover) * (Keb * 0.8));
+      weightedKe += ((aoa.bunchGgrassCanopyCover / totalcanopycover) * Keb);
+      weightedKe += ((aoa.forbsCanopyCover / totalcanopycover) * Keb);
     } else {
       weightedKe = Keb;
     }
@@ -230,46 +223,47 @@
   }
 
 
-  public void computeKssValue(double totalcanopycover, double totalgroundcover, AoA aoa) {
+  private void computeKssValue(double totalcanopycover, double totalgroundcover, AoA aoa) {
     double kssSegBunch, kssSegSod, kssSegShrub, kssSegShrub0, kssSegForbs;
 
     // 1)
     //   a) CALCULATE KSS FOR EACH VEGETATION COMMUNITY USING TOTAL FOLIAR COVER
     //        A)   BUNCH GRASS
+    double steepness = 2.5535 * aoa.slopeSteepness;
+    double canopy = 0.7822 * totalcanopycover;
     if (totalgroundcover < 0.475) {
-      kssSegBunch = 4.154 + 2.5535 * aoa.slopeSteepness
-          - 2.547 * totalgroundcover - 0.7822 * totalcanopycover;
+      double ground = 2.547 * totalgroundcover;
+
+      kssSegBunch = 4.154 + steepness - ground - canopy;
       kssSegBunch = Math.pow(10, kssSegBunch);
 
-      kssSegSod = 4.2169 + 2.5535 * aoa.slopeSteepness
-          - 2.547 * totalgroundcover - 0.7822 * totalcanopycover;
+      kssSegSod = 4.2169 + steepness - ground - canopy;
       kssSegSod = Math.pow(10, kssSegSod);
 
-      kssSegShrub = 4.2587 + 2.5535 * aoa.slopeSteepness - 2.547 * totalgroundcover - 0.7822 * totalcanopycover;
+      kssSegShrub = 4.2587 + steepness - ground - canopy;
       kssSegShrub = Math.pow(10, kssSegShrub);
 
-      kssSegForbs = 4.1106 + 2.5535 * aoa.slopeSteepness - 2.547 * totalgroundcover - 0.7822 * totalcanopycover;
+      kssSegForbs = 4.1106 + steepness - ground - canopy;
       kssSegForbs = Math.pow(10, kssSegForbs);
 
-      kssSegShrub0 = 4.2587 + 2.5535 * aoa.slopeSteepness - 2.547 * totalgroundcover;
+      kssSegShrub0 = 4.2587 + steepness - ground;
       kssSegShrub0 = Math.pow(10, kssSegShrub0);
 
     } else {
-      kssSegBunch = 3.1726975 + 2.5535 * aoa.slopeSteepness
-          - 0.4811 * totalgroundcover - 0.7822 * totalcanopycover;
+      double ground = 0.4811 * totalgroundcover;
+      kssSegBunch = 3.1726975 + steepness - ground - canopy;
       kssSegBunch = Math.pow(10, kssSegBunch);
 
-      kssSegSod = 3.2355975 + 2.5535 * aoa.slopeSteepness
-          - 0.4811 * totalgroundcover - 0.7822 * totalcanopycover;
+      kssSegSod = 3.2355975 + steepness - ground - canopy;
       kssSegSod = Math.pow(10, kssSegSod);
 
-      kssSegShrub = 3.2773975 + 2.5535 * aoa.slopeSteepness - 0.4811 * totalgroundcover - 0.7822 * totalcanopycover;
+      kssSegShrub = 3.2773975 + steepness - ground - canopy;
       kssSegShrub = Math.pow(10, kssSegShrub);
 
-      kssSegForbs = 3.1292975 + 2.5535 * aoa.slopeSteepness - 0.4811 * totalgroundcover - 0.7822 * totalcanopycover;
+      kssSegForbs = 3.1292975 + steepness - ground - canopy;
       kssSegForbs = Math.pow(10, kssSegForbs);
 
-      kssSegShrub0 = 3.2773975 + 2.5535 * aoa.slopeSteepness - 0.4811 * totalgroundcover;
+      kssSegShrub0 = 3.2773975 + steepness - ground;
       kssSegShrub0 = Math.pow(10, kssSegShrub0);
     }
 

src/java/m/rhem/rhem01_runmodel/V1_0.java

@@ -30,11 +30,14 @@
 import m.rhem.model.RhemModel;
 import csip.annotations.Description;
 import csip.annotations.Name;
-import rhem.utils.DBResources;
+import m.rhem.ApplicationResources;
+import static m.rhem.ApplicationResources.DEFAULT_MINIMUM_SLOPE_STEEPNESS;
+import static m.rhem.ApplicationResources.DEFAULT_MOISTURE_CONTENT;
+import static m.rhem.ApplicationResources.DEFAULT_SLOPE_LENGTH_METER;
+import static m.rhem.ApplicationResources.RHEM4_EXE;
+import static m.rhem.ApplicationResources.RHEM4_INTL_EXE;
+import m.rhem.DBResources;
 import rhem.utils.RHEMUtils;
-import rhem.utils.RhemResources;
-import static rhem.utils.RhemResources.RHEM4_EXE;
-import static rhem.utils.RhemResources.RHEM4_INTL_EXE;
 
 /**
  * RHEM-01:Run RHEM Model
@@ -52,14 +55,9 @@
 @Path("m/rhem/runrhem/1.0")
 @Polling(first = 10000, next = 2000)
 @Resource(from = DBResources.class)
-@Resource(from = RhemResources.class)
+@Resource(from = ApplicationResources.class)
 public class V1_0 extends ModelDataService {
 
-  private static final int DEFAULT_MOISTURE_CONTENT = 25;
-  private static final double DEFAULT_SLOPE_LENGTH_1 = 50.0;
-  private static final double DEFAULT_SLOPE_LENGTH_2 = 164.04;
-  private static final double DEFAULT_MINIMUM_SLOPE_STEEPNESS = 0.01;
-
   private AoA aoa;
   private String parameterFileName;
   private String stormFileName;
@@ -70,7 +68,6 @@
 
   RhemModel rhemModel;
 
-  int unit;
   String climatestationId;
   String stateId;
 
@@ -83,7 +80,6 @@
     int rhemSiteId = parameters.getInt("rhem_site_id", 0);
     String scenarioName = parameters.getString("scenarioname");
     String scenarioDescription = parameters.getString("scenariodescription");
-    unit = parameters.getInt("units");
     stateId = parameters.getString("stateid");
     climatestationId = parameters.getString("climatestationid");
     String soilTexture = parameters.getString("soiltexture");
@@ -101,33 +97,20 @@
 
     ///////////////////////////////
     //  BEGIN  Validations of input 
-    //The values allowed for the field unit in the request are 1 and 2. 1 is for metric units and 2 is for English units
     if (sar < 0.0 || sar > 50.0) {
       throw new ServiceException("invalid sar (0.0 ... 50.0): " + sar);
     }
 
-    double slopeLength;
-    switch (unit) {
-      case 1:
-        slopeLength = DEFAULT_SLOPE_LENGTH_1;
-        break;
-
-      case 2:
-        slopeLength = DEFAULT_SLOPE_LENGTH_2;
-        break;
-
-      default:
-        throw new ServiceException("Unit should be 1-metric or 2-English. The value, " + unit + ", is not valid.");
-    }
-
     if (slopeSteepness <= 0.0) {
       throw new ServiceException("The slopesteepness input parameter must be greater than 0.");
     }
 
+    double slopeLength = RHEMUtils.getSlopelength(parameter());
+
     //  END Validations
     ///////////////////////////////
     aoa = new AoA(aoaId, rhemSiteId, scenarioName,
-        scenarioDescription, unit, soilTexture, slopeLength, slopeShape, slopeSteepness,
+        scenarioDescription, soilTexture, slopeShape, slopeSteepness,
         bunchGgrassCanopyCover, forbsCanopyCover, shrubsCanopyCover,
         sodGrassCanopyCover, basalCover, rockCover, litterCover,
         cryptogamsCover, DEFAULT_MOISTURE_CONTENT, sar);
@@ -159,7 +142,7 @@
         stormFileName, runFileName, summaryFileName);
 
     rhemModel.generateParamFile(parameter);
-    rhemModel.generateStormFile(RhemResources.cligen_db, Double.parseDouble(parameter.getKe()), stateId, climatestationId);
+    rhemModel.generateStormFile(ApplicationResources.cligen_db, Double.parseDouble(parameter.getKe()), stateId, climatestationId);
     rhemModel.generateRunFile();
 
     runModel();
@@ -195,7 +178,6 @@
     results().put("AoAID", aoa.getAoaId(), "Area of Analysis Identifier");
     results().put("rhem_site_id", aoa.getRhemSiteId(), "RHEM Evaluation Site Identifier");
     results().put("CLEN", parameter.getClen(), "characteristic length of hillsope");
-    results().put("UNITS", (unit == 1) ? "metric" : "English", "unit of measure, metric or English");
     results().put("DIAMS", parameter.getDiams(), "list of representative soil particle diameters for up to 5 particle classes");
     results().put("DENSITY", parameter.getDensity(), "list of densities corresponding to the DIAMS particle classes");
     results().put("CHEZY", parameter.getChezy(), "overland flow Chezy coefficient");

src/java/m/rhem/rhem01_runmodel/V2_0.java

@@ -28,11 +28,13 @@
 import csip.utils.Parallel;
 import csip.utils.TextParser;
 import java.io.File;
+import m.rhem.ApplicationResources;
+import static m.rhem.ApplicationResources.DEFAULT_MOISTURE_CONTENT;
+import static m.rhem.ApplicationResources.RHEM4_INTL_EXE;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
-import rhem.utils.DBResources;
-import rhem.utils.RhemResources;
-import static rhem.utils.RhemResources.RHEM4_INTL_EXE;
+import m.rhem.DBResources;
+import rhem.utils.RHEMUtils;
 
 /**
  * RHEM-01:Run RHEM Model
@@ -49,13 +51,9 @@
 @Path("m/rhem/runrhem/2.0")
 @Polling(first = 10000, next = 2000)
 @Resource(from = DBResources.class)
-@Resource(from = RhemResources.class)
+@Resource(from = ApplicationResources.class)
 public class V2_0 extends ModelDataService {
 
-  static final double DEFAULT_MOISTURE_CONTENT = 25.0;
-  static final double DEFAULT_SLOPE_LENGTH_1 = 50.0;
-  static final double DEFAULT_SLOPE_LENGTH_2 = 164.04;
-
   static final String CLIGEN_RECORD_PRISM_PAR = "cligenRecordPrism.par";
   static final String CLIGEN_RECORD_PAR = "cligenRecord.par";
   static final String CLIGEN_TXT = "cligen.txt";
@@ -69,7 +67,6 @@
   Parameter parameter;
 
   RhemModel rhemModel;
-  int unit;
 
   double[] latlon;
 
@@ -86,7 +83,6 @@
 
     String scenarioName = parameter().getString("scenarioname");
     String scenarioDescription = parameter().getString("scenariodescription");
-    unit = parameter().getInt("units");
 
     String soilTexture = parameter().getString("soiltexture");
     String slopeShape = parameter().getString("slopeshape");
@@ -112,21 +108,17 @@
       throw new ServiceException("Invalid sar (0.0 ... 50.0): " + sar);
     }
 
-    if (unit != 1 && unit != 2) {
-      throw new ServiceException("Unit: 1-metric or 2-English. The value, " + unit + ", is not valid.");
-    }
-
-    double slopeLength = (unit == 1) ? DEFAULT_SLOPE_LENGTH_1 : DEFAULT_SLOPE_LENGTH_2;
+    double slopeLength = RHEMUtils.getSlopelength(parameter());
 
     if (slopeSteepness <= 0.0) {
-      throw new ServiceException("The slopesteepness input parameter must be greater than 0.");
+      throw new ServiceException("'slopesteepness' parameter must be greater than 0.");
     }
 
     //  END Validations
     ///////////////////////////////
     aoa = new AoA(aoaId, rhemSiteId, scenarioName,
-        scenarioDescription, unit,
-        soilTexture, slopeLength, slopeShape, slopeSteepness,
+        scenarioDescription,
+        soilTexture, slopeShape, slopeSteepness,
         bunchGgrassCanopyCover, forbsCanopyCover, shrubsCanopyCover,
         sodGrassCanopyCover, basalCover, rockCover, litterCover,
         cryptogamsCover, DEFAULT_MOISTURE_CONTENT, sar);
@@ -189,7 +181,7 @@
             + "          }"
             + "        }]"
             + "}"))
-        .url(RhemResources.cligenUrl)
+        .url(ApplicationResources.cligenUrl)
         .withDefaultLogger()
         .call();
 
@@ -221,7 +213,6 @@
     results().put("AoAID", aoa.getAoaId(), "Area of Analysis Identifier");
     results().put("rhem_site_id", aoa.getRhemSiteId(), "RHEM Evaluation Site Identifier");
     results().put("CLEN", parameter.getClen(), "characteristic length of hillsope");
-    results().put("UNITS", (unit == 1) ? "metric" : "English", "unit of measure, metric or English");
     results().put("DIAMS", parameter.getDiams(), "list of representative soil particle diameters for up to 5 particle classes");
     results().put("DENSITY", parameter.getDensity(), "list of densities corresponding to the DIAMS particle classes");
     results().put("CHEZY", parameter.getChezy(), "overland flow Chezy coefficient");

src/java/m/rhem/rhem01_runmodel/V2_1.java

@@ -28,11 +28,13 @@
 import csip.utils.Parallel;
 import csip.utils.TextParser;
 import java.io.File;
+import m.rhem.ApplicationResources;
+import static m.rhem.ApplicationResources.DEFAULT_MOISTURE_CONTENT;
+import static m.rhem.ApplicationResources.RHEM4_INTL_EXE;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
-import rhem.utils.DBResources;
-import rhem.utils.RhemResources;
-import static rhem.utils.RhemResources.RHEM4_INTL_EXE;
+import m.rhem.DBResources;
+import rhem.utils.RHEMUtils;
 
 /**
  * RHEM-01:Run RHEM Model
@@ -48,13 +50,9 @@
 @Path("m/rhem/runrhem/2.1")
 @Polling(first = 10000, next = 2000)
 @Resource(from = DBResources.class)
-@Resource(from = RhemResources.class)
+@Resource(from = ApplicationResources.class)
 public class V2_1 extends ModelDataService {
 
-  static final double DEFAULT_MOISTURE_CONTENT = 25.0;
-  static final double DEFAULT_SLOPE_LENGTH_1 = 50.0;
-  static final double DEFAULT_SLOPE_LENGTH_2 = 164.04;
-
   static final String CLIGEN_RECORD_PRISM_PAR = "cligenRecordPrism.par";
   static final String CLIGEN_RECORD_PAR = "cligenRecord.par";
   static final String CLIGEN_TXT = "cligen.txt";
@@ -68,7 +66,6 @@
   Parameter parameter;
 
   RhemModel rhemModel;
-  int unit;
 
   double[] latlon;
 
@@ -83,7 +80,6 @@
 
     String scenarioName = parameter().getString("scenarioname");
     String scenarioDescription = parameter().getString("scenariodescription");
-    unit = parameter().getInt("units");
 
     String soilTexture = parameter().getString("soiltexture");
     String slopeShape = parameter().getString("slopeshape");
@@ -98,23 +94,18 @@
     double cryptogamsCover = parameter().getDouble("cryptogamscover", 0.0);
     double sar = parameter().getDouble("sar", 0.0);
 
+    double slopeLength = RHEMUtils.getSlopelength(parameter());
+
     ///////////////////////////////
     //  BEGIN  Validations of input 
     //The values allowed for the field unit in the request are 1 and 2. 1 is for metric units and 2 is for English units
     if (latlon.length != 2) {
       throw new ServiceException("Invalid site_loc, array expected [lat,lon]");
     }
-
     if (sar < 0.0 || sar > 50.0) {
       throw new ServiceException("Invalid sar (0.0 ... 50.0): " + sar);
     }
 
-    if (unit != 1 && unit != 2) {
-      throw new ServiceException("Unit: 1-metric or 2-English. The value, " + unit + ", is not valid.");
-    }
-
-    double slopeLength = (unit == 1) ? DEFAULT_SLOPE_LENGTH_1 : DEFAULT_SLOPE_LENGTH_2;
-
     if (slopeSteepness <= 0.0) {
       throw new ServiceException("The slopesteepness input parameter must be greater than 0.");
     }
@@ -122,8 +113,8 @@
     //  END Validations
     ///////////////////////////////
     aoa = new AoA(0, rhemSiteId, scenarioName,
-        scenarioDescription, unit,
-        soilTexture, slopeLength, slopeShape, slopeSteepness,
+        scenarioDescription,
+        soilTexture, slopeShape, slopeSteepness,
         bunchGgrassCanopyCover, forbsCanopyCover, shrubsCanopyCover,
         sodGrassCanopyCover, basalCover, rockCover, litterCover,
         cryptogamsCover, DEFAULT_MOISTURE_CONTENT, sar);
@@ -186,7 +177,7 @@
             + "          }"
             + "        }]"
             + "}"))
-        .url(RhemResources.cligenUrl)
+        .url(ApplicationResources.cligenUrl)
         .withDefaultLogger()
         .call();
 

src/java/m/rhem/rhem02_getclimatestations/V1_0.java

@@ -26,7 +26,7 @@
 import java.util.List;
 import org.codehaus.jettison.json.JSONArray;
 import rhem.utils.RHEMUtils;
-import rhem.utils.DBResources;
+import m.rhem.DBResources;
 import static rhem.utils.RHEMUtils.MONTH_NAMES_LIST;
 
 /**

src/java/m/rhem/rhem03_compEsd/V1_0.java

@@ -31,8 +31,8 @@
 import java.util.List;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONObject;
-import rhem.utils.DBResources;
-import static rhem.utils.DBResources.SDM_REST;
+import m.rhem.DBResources;
+import static m.rhem.DBResources.SDM_REST;
 
 /**
  * RHEM-03: Get Soil Component, Ecological Site, Soil Component Surface Texture

src/java/m/rhem/rhem03_compEsd/V2_0.java

@@ -11,7 +11,6 @@
  */
 package m.rhem.rhem03_compEsd;
 
-import csip.Config;
 import gisobjects.db.GISEngine;
 import gisobjects.GISObject;
 import gisobjects.GISObjectException;
@@ -23,7 +22,6 @@
 import csip.annotations.Resource;
 import csip.utils.JSONUtils;
 import static gisobjects.db.GISEngineFactory.createGISEngine;
-import java.io.IOException;
 import java.sql.Connection;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -33,13 +31,11 @@
 import csip.annotations.Description;
 import csip.annotations.Name;
 import java.util.List;
+import m.rhem.ApplicationResources;
 import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
-import rhem.utils.DBResources;
-import static rhem.utils.DBResources.CRDB;
-import rhem.utils.RHEMUtils;
-import rhem.utils.RhemResources;
+import m.rhem.DBResources;
+import static m.rhem.DBResources.CRDB;
 import soils.MapUnit;
 import soils.db.SOILS_DATA;
 import soils.db.SOILS_DB_Factory;
@@ -81,7 +77,7 @@
   @Override
   public void doProcess() throws Exception {
     try (SOILS_DATA soilsDb = SOILS_DB_Factory.createEngine(getClass(), LOG,
-        RhemResources.soils_db);
+        ApplicationResources.soils_db);
         Connection crdb = resources().getJDBC(CRDB)) {
       try (GISEngine gisEngine = createGISEngine(crdb)) {
         GISObject geometry = GISObjectFactory.createGISObject(rhemSiteGeometryPoint, gisEngine);

src/java/m/rhem/rhem04_surfacetextureclasses/V1_0.java

@@ -27,8 +27,8 @@
 import csip.annotations.Name;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
-import rhem.utils.DBResources;
-import static rhem.utils.DBResources.CRDB;
+import m.rhem.DBResources;
+import static m.rhem.DBResources.CRDB;
 
 /**
  * RHEM-04: Get RHEM Surface Texture Classes Choice List

src/java/m/rhem/rhem05_slopeShapes/V1_0.java

@@ -27,8 +27,8 @@
 import java.util.List;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
-import rhem.utils.DBResources;
-import static rhem.utils.DBResources.CRDB;
+import m.rhem.DBResources;
+import static m.rhem.DBResources.CRDB;
 
 /**
  * RHEM-05: Get RHEM Slope Shape Choice List

src/java/m/rhem/rhem06_riskassessment/V1_0.java

@@ -19,17 +19,16 @@
 import static csip.annotations.ResourceType.OUTPUT;
 import java.io.BufferedReader;
 import java.io.FileReader;
-import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.List;
 import javax.ws.rs.Path;
 import csip.annotations.Description;
 import csip.annotations.Name;
-import rhem.utils.DBResources;
+import m.rhem.ApplicationResources;
+import static m.rhem.ApplicationResources.RHEM_RA_EXE;
+import m.rhem.DBResources;
 import rhem.utils.RHEMUtils;
-import rhem.utils.RhemResources;
-import static rhem.utils.RhemResources.RHEM_RA_EXE;
 
 /**
  * RHEM-06: Risk Assessment
@@ -43,7 +42,7 @@
 @Polling(first = 10000, next = 2000)
 @Resource(file = "*.out *.run", type = OUTPUT)
 @Resource(from = DBResources.class)
-@Resource(from = RhemResources.class)
+@Resource(from = ApplicationResources.class)
 public class V1_0 extends ModelDataService {
 
   private String baseLineScenarioFileName;

src/java/m/rhem/rhem07_editparfile/V1_0.java

@@ -11,26 +11,23 @@
  */
 package m.rhem.rhem07_editparfile;
 
-import csip.Config;
 import csip.Executable;
 import csip.ModelDataService;
 import csip.ServiceException;
 import csip.annotations.Polling;
 import csip.annotations.Resource;
 import java.io.File;
-import java.io.IOException;
 import java.sql.Connection;
 import java.sql.ResultSet;
-import java.sql.SQLException;
 import java.sql.Statement;
 import javax.ws.rs.Path;
 import m.rhem.model.Parameter;
 import m.rhem.model.RhemModel;
 import csip.annotations.Description;
 import csip.annotations.Name;
-import rhem.utils.DBResources;
-import rhem.utils.RhemResources;
-import static rhem.utils.RhemResources.RHEM4_EXE;
+import m.rhem.ApplicationResources;
+import static m.rhem.ApplicationResources.RHEM4_EXE;
+import m.rhem.DBResources;
 
 /**
  * RHEM-07: Run model with edited parameter file
@@ -43,7 +40,7 @@
 @Path("m/rhem/editparfile/1.0")
 @Polling(first = 5000, next = 2000)
 @Resource(from = DBResources.class)
-@Resource(from = RhemResources.class)
+@Resource(from = ApplicationResources.class)
 public class V1_0 extends ModelDataService {
 
   private String parameterFileName;
@@ -113,7 +110,7 @@
         stormFileName, runFileName, summaryFileName);
 
     rhemModel.generateParamFile(parameter);
-    rhemModel.generateStormFile(RhemResources.cligen_db, Double.parseDouble(parameter.getKe()), stateId, climatestationId);
+    rhemModel.generateStormFile(ApplicationResources.cligen_db, Double.parseDouble(parameter.getKe()), stateId, climatestationId);
     rhemModel.generateRunFile();
 
     runModel();

src/java/rhem/utils/RHEMUtils.java

@@ -11,11 +11,14 @@
  */
 package rhem.utils;
 
+import csip.PayloadParameter;
+import csip.ServiceException;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
+import static m.rhem.ApplicationResources.DEFAULT_SLOPE_LENGTH_METER;
 
 /**
  *
@@ -182,4 +185,25 @@
     return interpolatedResultsArray;
   }
 
+
+  public static double getSlopelength(PayloadParameter p) throws ServiceException {
+    double slopeLength = DEFAULT_SLOPE_LENGTH_METER;
+    if (p.has("slopelength")) {
+      slopeLength = p.getDouble("slopelength");
+      switch (p.getUnit("slopelength")) {
+        case "m":
+          break;
+        case "ft":
+          slopeLength *= 0.3048;
+          break;
+        default:
+          throw new ServiceException("Illegal unit for slopelength: " + p.getUnit("slopelength"));
+      }
+    }
+    if (slopeLength <= 0.0) {
+      throw new ServiceException("'slopelength' parameter must be greater than 0.");
+    }
+    return slopeLength;
+  }
+
 }

web/WEB-INF/csip-defaults.json

@@ -1,5 +1,5 @@
 {  
-    "csip.context.version": "$version: 2.1.24 default 198 38e73616fd1b 2021-02-04 od, built at 2021-02-05 09:44 by od$",
+    "csip.context.version": "$version: 2.1.25 default 199 7a0a9e07b047 2021-02-05 od, built at 2021-03-15 18:51 by od$",
     "csip.archive.max.filesize": "1KB",
     "esd.db": "jdbc:sqlserver://129.82.20.129:1433;databaseName=esd;user=sa;password=csurams#1",
     "crdb.db": "jdbc:sqlserver://129.82.20.129:1433;databaseName=conservation_resources;user=sa;password=csurams#1",