@@ -135,6 +135,7 @@ |
protected String stateFips, countyFips; |
protected String stateAbbr, countyName; |
protected String lrr = ""; |
+ protected String legacyDB = ""; |
|
/** |
* |
@@ -142,6 +143,8 @@ |
*/ |
@Override |
protected void preProcess() throws Exception { |
+ |
+ legacyDB = config().getString("crp1.legacy.database.db", ""); |
bufferSize = parameter().getDouble(POINT_BUFER_SIZE, DEFAULT_POINT_BUFFER_SIZE); |
if (parameter().has(PARAM_SCENARIO_GEOMETRY)) { |
scenario_geometry = parameter().getParamJSON(PARAM_SCENARIO_GEOMETRY); |
@@ -464,7 +467,7 @@ |
tFact += tSoil.component.calculated_area() * tSoil.component.tfact(); |
totalErosionArea += tSoil.component.calculated_area(); |
|
- if (!legacyMapUnitData.containsKey(tSoil.mapUnit.mukey())) { |
+ if (!legacyMapUnitData.containsKey(tSoil.mapUnit.mukey()) && !legacyDB.isEmpty()) { |
LegacyMapunitData lData = new LegacyMapunitData(); |
lData.mapunit = tSoil.mapUnit; |
legacyMapUnitData.put(tSoil.mapUnit.mukey(), lData); |
@@ -473,7 +476,9 @@ |
} |
} |
// Get legacy values from Rich I'stmnt table data. |
- getLegacyValues(legacyMapUnitData); |
+ if (!legacyDB.isEmpty()) { |
+ getLegacyValues(legacyMapUnitData); |
+ } |
|
if (totalErosionArea > 0) { |
wAvgWaterErosion = totalwAvgWaterErosion / totalErosionArea; |
@@ -503,20 +508,22 @@ |
} |
} |
// Lookup legacy variable values using State and County FiPS |
- String lData = "SELECT " |
- + " RNFL_FCTR, " |
- + " CLMT_FCTR" |
- + " FROM ClimateFactorsLegacy " |
- + " WHERE ST_FIPS_CD=? AND CNTY_FIPS_CD=?; "; |
- try (Connection conn = resources().getJDBC(CRP_LEGACY_DATABASE); PreparedStatement stmnt = conn.prepareStatement(lData);) { |
- stmnt.setString(1, stateFips); |
- stmnt.setString(2, countyFips); |
- ResultSet result = stmnt.executeQuery(); |
- if (result.next()) { |
- legacyRFact = result.getDouble("RNFL_FCTR"); |
- legacyCFact = result.getDouble("CLMT_FCTR"); |
- } else { |
- throw new SQLException("No legacy data was found for that state and county FIPS combination, (" + stateFips + ", " + countyFips + ")."); |
+ if (!legacyDB.isEmpty()) { |
+ String lData = "SELECT " |
+ + " RNFL_FCTR, " |
+ + " CLMT_FCTR" |
+ + " FROM ClimateFactorsLegacy " |
+ + " WHERE ST_FIPS_CD=? AND CNTY_FIPS_CD=?; "; |
+ try (Connection conn = resources().getJDBC(CRP_LEGACY_DATABASE); PreparedStatement stmnt = conn.prepareStatement(lData);) { |
+ stmnt.setString(1, stateFips); |
+ stmnt.setString(2, countyFips); |
+ ResultSet result = stmnt.executeQuery(); |
+ if (result.next()) { |
+ legacyRFact = result.getDouble("RNFL_FCTR"); |
+ legacyCFact = result.getDouble("CLMT_FCTR"); |
+ } else { |
+ throw new SQLException("No legacy data was found for that state and county FIPS combination, (" + stateFips + ", " + countyFips + ")."); |
+ } |
} |
} |
} |
@@ -591,25 +598,27 @@ |
"The weighted average wind erosion index."); |
|
// Legacy Data by mapunit |
- JSONArray legacyData = new JSONArray(); |
- for (LegacyMapunitData lMapunit : legacyMapUnitData.values()) { |
- JSONArray lData = new JSONArray(); |
- lData.put(JSONUtils.data("mukey", lMapunit.mapunit.mukey())); |
- lData.put(JSONUtils.data("aoa_area_pct", lMapunit.mapunit.area_pct())); |
- lData.put(JSONUtils.dataDesc("wtr_erod_fctr", soils.utils.EvalResult.writeDouble(lMapunit.wtr_erod_fctr, "%.2f"), "wtr_erod_fctr")); |
- lData.put(JSONUtils.dataDesc("soil_loss_tolr_fctr", soils.utils.EvalResult.writeDouble(lMapunit.soil_loss_tolr_fctr, "%.2f"), "soil_loss_tolr_fctr")); |
- lData.put(JSONUtils.dataDesc("wind_erod_idx", soils.utils.EvalResult.writeDouble(lMapunit.wind_erod_idx, "%.2f"), "wind_erod_idx")); |
- lData.put(JSONUtils.dataDesc("soil_slp_lgth_fctr", soils.utils.EvalResult.writeDouble(lMapunit.soil_slp_lgth_fctr, "%.2f"), "soil_slp_lgth_fctr")); |
- lData.put(JSONUtils.dataDesc("long_leaf_suit_ind", soils.utils.EvalResult.writeString(lMapunit.long_leaf_suit_ind), "long_leaf_suit_ind")); |
- lData.put(JSONUtils.dataDesc("wesl_ind", soils.utils.EvalResult.writeString(lMapunit.wesl_ind), "wesl_ind")); |
- lData.put(JSONUtils.dataDesc("soil_lch_ind", soils.utils.EvalResult.writeInteger(lMapunit.soil_lch_ind), "soil_lch_ind")); |
- lData.put(JSONUtils.dataDesc("legacy_c_factor", soils.utils.EvalResult.writeDouble(legacyCFact), "Legacy C Factor based on State/County FIPS of this location")); |
- lData.put(JSONUtils.dataDesc("legacy_r_factor", soils.utils.EvalResult.writeDouble(legacyRFact), "Legacy R Factor based on State/County FIPS of this location")); |
- lData.put(JSONUtils.dataDesc("wind_erosion", soils.utils.EvalResult.writeDouble(lMapunit.windErosion), "Legacy Wind Erosion, (C * I) / T")); |
- lData.put(JSONUtils.dataDesc("water_erosion", soils.utils.EvalResult.writeDouble(lMapunit.waterErosion), "Legacy Water Erosion, (R * K * LS) / T")); |
- legacyData.put(lData); |
+ if (!legacyDB.isEmpty()) { |
+ JSONArray legacyData = new JSONArray(); |
+ for (LegacyMapunitData lMapunit : legacyMapUnitData.values()) { |
+ JSONArray lData = new JSONArray(); |
+ lData.put(JSONUtils.data("mukey", lMapunit.mapunit.mukey())); |
+ lData.put(JSONUtils.data("aoa_area_pct", lMapunit.mapunit.area_pct())); |
+ lData.put(JSONUtils.dataDesc("wtr_erod_fctr", soils.utils.EvalResult.writeDouble(lMapunit.wtr_erod_fctr, "%.2f"), "wtr_erod_fctr")); |
+ lData.put(JSONUtils.dataDesc("soil_loss_tolr_fctr", soils.utils.EvalResult.writeDouble(lMapunit.soil_loss_tolr_fctr, "%.2f"), "soil_loss_tolr_fctr")); |
+ lData.put(JSONUtils.dataDesc("wind_erod_idx", soils.utils.EvalResult.writeDouble(lMapunit.wind_erod_idx, "%.2f"), "wind_erod_idx")); |
+ lData.put(JSONUtils.dataDesc("soil_slp_lgth_fctr", soils.utils.EvalResult.writeDouble(lMapunit.soil_slp_lgth_fctr, "%.2f"), "soil_slp_lgth_fctr")); |
+ lData.put(JSONUtils.dataDesc("long_leaf_suit_ind", soils.utils.EvalResult.writeString(lMapunit.long_leaf_suit_ind), "long_leaf_suit_ind")); |
+ lData.put(JSONUtils.dataDesc("wesl_ind", soils.utils.EvalResult.writeString(lMapunit.wesl_ind), "wesl_ind")); |
+ lData.put(JSONUtils.dataDesc("soil_lch_ind", soils.utils.EvalResult.writeInteger(lMapunit.soil_lch_ind), "soil_lch_ind")); |
+ lData.put(JSONUtils.dataDesc("legacy_c_factor", soils.utils.EvalResult.writeDouble(legacyCFact), "Legacy C Factor based on State/County FIPS of this location")); |
+ lData.put(JSONUtils.dataDesc("legacy_r_factor", soils.utils.EvalResult.writeDouble(legacyRFact), "Legacy R Factor based on State/County FIPS of this location")); |
+ lData.put(JSONUtils.dataDesc("wind_erosion", soils.utils.EvalResult.writeDouble(lMapunit.windErosion), "Legacy Wind Erosion, (C * I) / T")); |
+ lData.put(JSONUtils.dataDesc("water_erosion", soils.utils.EvalResult.writeDouble(lMapunit.waterErosion), "Legacy Water Erosion, (R * K * LS) / T")); |
+ legacyData.put(lData); |
+ } |
+ results().put("legacy_data_by_mapunit", legacyData); |
} |
- results().put("legacy_data_by_mapunit", legacyData); |
|
if (detailedOutput) { |
JSONArray topThreeDetails = new JSONArray(); |