TableComponentCalculations.java [src/soils/db/tables] Revision: default Date:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package soils.db.tables;
import csip.api.server.ServiceException;
import soils.utils.EvalResult;
/**
*
* @author <a href="mailto:shaun.case@colostate.edu">Shaun Case</a>
*/
public class TableComponentCalculations extends Table {
// Calculated Column Names Constants
public static final String AREA_PCT_NAME = "area_pct";
public static final String COARSE_FRAG_NAME = "coarse_frag";
public static final String COARSE_FRAG_TOTAL_NAME = "frag_vol_total";
public static final String COMP_AREA_NAME = "area";
public static final String CRACKS_GR_24_NAME = "cracksgr24";
public static final String HWT_LT_24_NAME = "hwt_lt_24";
public static final String HZDEPTH_NAME = "hzdepth";
public static final String PROFILE_DEPTH = "profile_depth";
public static final String KFFACT_NAME = "kffact";
public static final String LENGTH_R_NAME = "length_r";
public static final String LSFACT_NAME = "lsfact";
public static final String NSLP_NAME = "nslp";
public static final String NSLP_NUMBER_NAME = "nslp_number";
public static final String OM_R_NAME = "om_r";
public static final String SANDTOTAL_R_NAME = "sandtotal_r";
public static final String SLOPE_GR_15_NAME = "slopegr15";
public static final String SRP_NAME = "srp";
public static final String SRP_NUMBER_NAME = "srp_number";
public static final String WTBL_NAME = "wtbl";
public static final String WTBL_TOP_MIN_NAME = "wtbl_top_min";
public static final String SILTTOTAL_R = "silttotal_r";
public static final String CLAYTOTAL_R = "claytotal_r";
public static final String TILLAGE_LAYER_CLAY_TOTAL = "tl_clay_total";
public static final String RESDEPTMIN_R = "resdeptmin_r";
public static final String PSLP_NUMBER = "comp_pslp_number";
public static final String PSLP = "comp_pslp";
public static final String PH = "ph1to1h2o_t";
public static final String PSSRP = "comp_pest_ssrp";
public static final String PSSRP_NUMBER = "comp_pest_ssrp_number";
public static final String PSARP = "comp_pest_sarp";
public static final String PSARP_NUMBER = "comp_pest_sarp_number";
public static final String LONG_NAME = "comp_long_name";
public static final String FLOD_FREQ_CL = "flod_freq_cl";
public static final String POND_FREQ_CL = "pond_freq_cl";
public static final String SALINITY = "salinity";
public static final String SODICITY = "sodicity";
public static final String ECEC = "ecec";
public static final String EC = "ec";
public static final String CEC7 = "cec7";
public static final String WATER_EP = "water_erodability_potential";
public static final String WIND_EP = "wind_erodability_potential";
// Calculated Column Definitions
private static final String[] AREA_PCT = {AREA_PCT_NAME, "The percentage of the component of the mapunit intersection with the AoI", "Percent", "%.2f"};
private static final String[] COARSE_FRAG = {COARSE_FRAG_NAME, "Weighted Average Coarse Rock Fragment Volume Percentage through the Profile of the Soil Component", "Percent", "%.2f"};
private static final String[] COARSE_FRAG_TOTAL = {COARSE_FRAG_TOTAL_NAME, "Total of all Weighted Average Coarse Rock Fragment Volume Percentage through the Profile of the Soil Component", "Percent", "%.2f"};
//component.area_pct * mapUnit.aoaArea,
private static final String[] COMP_AREA = {COMP_AREA_NAME, "Soil Component Area (Acres) in the Area of Analysis", "Acres", "%.3f"};
private static final String[] CRACKS_GR_24 = {CRACKS_GR_24_NAME, "Surface Connected Macropores (Cracks) at Least 24 centimeters Deep"};
private static final String[] HWT_LT_24 = {HWT_LT_24_NAME, "High Water is Less than 24 centimeters Under the Surface"};
private static final String[] HZDEPTH = {HZDEPTH_NAME, "Depth (centimeters) of the selected Horizon of the Soil Component", "Centimeters"};
private static final String[] PROFILE_DEPTH_DATA = {PROFILE_DEPTH, "Total depth of the soil profile calculated by the hzdepth of each horizon.", "Centimeters", "%.3f"};
private static final String[] KFFACT = {KFFACT_NAME, "A calculated K factor value taken from the selected Mineral Horizon of the Soil Component or adjusted based on Soils SME logic."};
private static final String[] LENGTH_R = {LENGTH_R_NAME, "Calculated slope length", "feet", "%.2f"};
private static final String[] LSFACT = {LSFACT_NAME, "The calculated distance, using slope_r and lambda, from the point of origin of overland flow to the point where either the slope gradient decreases enough that deposition begins, or the runoff water enters a well-defined channel that may be part of a drainage network or a constructed channel. (Predicting Rainfall Erosion Losses a Guide to Conservation Planning, Agr. Handbook #537, USDA, 1978).", "feet", "%.2f"};
private static final String[] NSLP = {NSLP_NAME, "Soil leaching potential of the soil component"};
private static final String[] NSLP_NUMBER = {NSLP_NUMBER_NAME, "Soil leaching potential of the soil component, numerical value"};
private static final String[] OM_R = {OM_R_NAME, "Organic Matter Percentage of the selected Horizon of the Soil Component", "Percent", "%.2f"};
private static final String[] SANDTOTAL_R = {SANDTOTAL_R_NAME, "Mineral particles 0.05mm to 2.0mm in equivalent diameter as a weight percentage of the less than 2 mm fraction.", "Percent", "%.2f"};
private static final String[] SLOPE_GR_15 = {SLOPE_GR_15_NAME, "Field Slope is Greater Than 15%"};
private static final String[] SRP = {SRP_NAME, "Soil runoff potential for the soil component"};
private static final String[] SRP_NUMBER = {SRP_NUMBER_NAME, "Soil runoff potential for the soil component, numerical value"};
private static final String[] WTBL = {WTBL_NAME, "Kind of Water Table of the Soil Component; values are None, Apparent, Perched"};
//(Double.isNaN(component.calculated_wtbl_top_min) ? "None" : component.calculated_wtbl_top_min),
private static final String[] WTBL_TOP_MIN = {WTBL_TOP_MIN_NAME, "Water table top minimum, the minimum value of soimoistdept_r", "Centimeters"};
private static final String[] SILTTOTAL_R_DATA = {SILTTOTAL_R, "Mineral particles 0.002 to 0.05mm in equivalent diameter as a weight percentage of the less than 2.0mm fraction", "Percent", "%.2f"};
private static final String[] CLAYTOTAL_R_DATA = {CLAYTOTAL_R, "Mineral particles less than 0.002mm in equivalent diameter as a weight percentage of the less than 2.0mm fraction", "Percent", "%.2f"};
private static final String[] RESDEPTMIN_R_DATA = {RESDEPTMIN_R, "The minimum calculated distance from the soil surface to the lower boundary of the restrictive layer", "Centimeters", "%03f"};
private static final String[] PSLP_NUMBER_DATA = {PSLP_NUMBER, "Computed pesticide soil loss potential number."};
private static final String[] PSLP_DATA = {PSLP, "Computed pesticide soil loss potential rating."};
private static final String[] PH_DATA = {PH, "Computed soil pH value from horizon ph1to1h2o values.", "pH", "%.3f"};
private static final String[] PSSRP_DATA = {PSSRP, "Calculated pesticide SSRP for soil component."};
private static final String[] PSSRP_NUMBER_DATA = {PSSRP_NUMBER, "Calculated pesticide SSRP number for soil component."};
private static final String[] PSARP_DATA = {PSARP, "Calculated pesticide SARP for soil component."};
private static final String[] PSARP_NUMBER_DATA = {PSARP_NUMBER, "Calculated pesticide SARP number for soil component."};
private static final String[] LONG_NAME_DATA = {LONG_NAME, "Concatenation of name, mukey, percent mapunit, and texture"};
private static final String[] TILLAGE_LAYER_CLAY_TOTAL_DATA = {TILLAGE_LAYER_CLAY_TOTAL, "Tillage layers clay content: Weighted average of top 6 inches claytotal_r values for this component.", "Percent", "%.2f"};
private static final String[] FLOD_FREQ_CL_DATA = {FLOD_FREQ_CL, "Maximum flodfreqcl value for the months' sequence found in the comonth table for this component key. A flodfreqcl is the annual probability of a flood event expressed as a class. (SSM)"};
private static final String[] POND_FREQ_CL_DATA = {POND_FREQ_CL, "Maximum pondfreqcl value for the months' sequence found in the comonth table for this component key. A pondfreqcl is the number of times ponding occurs over a period of time. (SSM)"};
private static final String[] SALINITY_DATA = {SALINITY, "A calculated salinity value based on a weighted average of the top 60cm of horizon data for this soil component.", null, "%.2f"};
private static final String[] SODICITY_DATA = {SODICITY, "A calculated sodicity value based on a weighted average of the top 60cm of horizon data for this soil component.", null, "%.2f"};
private static final String[] ECEC_DATA = {ECEC, "Calculated weighted average for horizons specified depth.", null, "%.3f"};
private static final String[] EC_DATA = {EC, "Calculated weighted average for horizons specified depth.", null, "%.3f"};
private static final String[] CEC7_DATA = {CEC7, "Calculated weighted average for horizons specified depth.", null, "%.3f"};
private static final String[] WATER_EP_DATA = {WATER_EP, "Calculated water erodabilty potential: (kffact * lsfact) / tfact", null, "%.3f"};
private static final String[] WIND_EP_DATA = {WIND_EP, "Calculated wind erodabilty potential: (cfactor * ifactor) / tfact", null, "%.3f"};
public TableComponentCalculations() throws ServiceException {
addDataColumn(AREA_PCT_NAME, new TableColumnDouble(AREA_PCT));
addDataColumn(COARSE_FRAG_NAME, new TableColumnDouble(COARSE_FRAG));
addDataColumn(COARSE_FRAG_TOTAL_NAME, new TableColumnDouble(COARSE_FRAG_TOTAL));
addDataColumn(COMP_AREA_NAME, new TableColumnDouble(COMP_AREA));
addDataColumn(CRACKS_GR_24_NAME, new TableColumnBoolean(CRACKS_GR_24));
addDataColumn(HWT_LT_24_NAME, new TableColumnBoolean(HWT_LT_24));
addDataColumn(HZDEPTH_NAME, new TableColumnDouble(HZDEPTH));
addDataColumn(PROFILE_DEPTH, new TableColumnDouble(PROFILE_DEPTH_DATA));
addDataColumn(KFFACT_NAME, new TableColumnDouble(KFFACT));
addDataColumn(LENGTH_R_NAME, new TableColumnDouble(LENGTH_R));
addDataColumn(LSFACT_NAME, new TableColumnDouble(LSFACT));
addDataColumn(NSLP_NAME, new TableColumnString(NSLP));
addDataColumn(NSLP_NUMBER_NAME, new TableColumnDouble(NSLP_NUMBER));
addDataColumn(OM_R_NAME, new TableColumnDouble(OM_R));
addDataColumn(SANDTOTAL_R_NAME, new TableColumnDouble(SANDTOTAL_R));
addDataColumn(SLOPE_GR_15_NAME, new TableColumnBoolean(SLOPE_GR_15));
addDataColumn(SRP_NAME, new TableColumnString(SRP));
addDataColumn(SRP_NUMBER_NAME, new TableColumnDouble(SRP_NUMBER));
addDataColumn(WTBL_NAME, new TableColumnString(WTBL));
addDataColumn(WTBL_TOP_MIN_NAME, new TableColumnString(WTBL_TOP_MIN));
addDataColumn(SILTTOTAL_R, new TableColumnDouble(SILTTOTAL_R_DATA));
addDataColumn(CLAYTOTAL_R, new TableColumnDouble(CLAYTOTAL_R_DATA));
addDataColumn(RESDEPTMIN_R, new TableColumnDouble(RESDEPTMIN_R_DATA));
addDataColumn(PSLP_NUMBER, new TableColumnInteger(PSLP_NUMBER_DATA));
addDataColumn(PSLP, new TableColumnString(PSLP_DATA));
addDataColumn(PH, new TableColumnDouble(PH_DATA));
addDataColumn(PSSRP, new TableColumnString(PSSRP_DATA));
addDataColumn(PSSRP_NUMBER, new TableColumnInteger(PSSRP_NUMBER_DATA));
addDataColumn(PSARP, new TableColumnString(PSARP_DATA));
addDataColumn(PSARP_NUMBER, new TableColumnInteger(PSARP_NUMBER_DATA));
addDataColumn(LONG_NAME, new TableColumnString(LONG_NAME_DATA));
addDataColumn(TILLAGE_LAYER_CLAY_TOTAL, new TableColumnDouble(TILLAGE_LAYER_CLAY_TOTAL_DATA));
addDataColumn(FLOD_FREQ_CL, new TableColumnString(FLOD_FREQ_CL_DATA));
addDataColumn(POND_FREQ_CL, new TableColumnString(POND_FREQ_CL_DATA));
addDataColumn(SALINITY, new TableColumnDouble(SALINITY_DATA));
addDataColumn(SODICITY, new TableColumnDouble(SODICITY_DATA));
addDataColumn(ECEC, new TableColumnDouble(ECEC_DATA));
addDataColumn(EC, new TableColumnDouble(EC_DATA));
addDataColumn(CEC7, new TableColumnDouble(CEC7_DATA));
addDataColumn(WATER_EP, new TableColumnDouble(WATER_EP_DATA));
addDataColumn(WIND_EP, new TableColumnDouble(WIND_EP_DATA));
calculated_wtbl("None");
calculated_wtbl_top_min(EvalResult.getDefaultDouble());
calculated_flod_freq_cl("None");
calculated_pond_freq_cl("None");
calculated_salinity(EvalResult.getDefaultDouble());
calculated_sodicity(EvalResult.getDefaultDouble());
calculated_water_ep(EvalResult.getDefaultDouble());
}
public double calculated_water_ep() {
return ((double) columns.get(WATER_EP).getValue());
}
public final void calculated_water_ep(double value) {
columns.get(WATER_EP).setValue(value);
}
public double calculated_wind_ep() {
return ((double) columns.get(WIND_EP).getValue());
}
public final void calculated_wind_ep(double value) {
columns.get(WIND_EP).setValue(value);
}
public double calculated_ecec() {
return ((double) columns.get(ECEC).getValue());
}
public void calculated_ecec(double value) {
columns.get(ECEC).setValue(value);
}
public double calculated_ec() {
return ((double) columns.get(EC).getValue());
}
public void calculated_ec(double value) {
columns.get(EC).setValue(value);
}
public double calculated_cec7() {
return ((double) columns.get(CEC7).getValue());
}
public void calculated_cec7(double value) {
columns.get(CEC7).setValue(value);
}
public String calculated_flod_freq_cl() {
return ((String) columns.get(FLOD_FREQ_CL).getValue());
}
public final void calculated_flod_freq_cl(String value) {
columns.get(FLOD_FREQ_CL).setValue(value);
}
public String calculated_pond_freq_cl() {
return ((String) columns.get(POND_FREQ_CL).getValue());
}
public final void calculated_pond_freq_cl(String value) {
columns.get(POND_FREQ_CL).setValue(value);
}
public double calculated_profile_depth() {
return ((double) columns.get(PROFILE_DEPTH).getValue());
}
public void calculated_profile_depth(double value) {
columns.get(PROFILE_DEPTH).setValue(value);
}
public double resdeptmin_r() {
return ((double) columns.get(RESDEPTMIN_R).getValue());
}
public void resdeptmin_r(double value) {
columns.get(RESDEPTMIN_R).setValue(value);
}
public double silttotal_r() {
return ((double) columns.get(SILTTOTAL_R).getValue());
}
public double claytotal_r() {
return ((double) columns.get(CLAYTOTAL_R).getValue());
}
public void silttotal_r(double value) {
columns.get(SILTTOTAL_R).setValue(value);
}
public void claytotal_r(double value) {
columns.get(CLAYTOTAL_R).setValue(value);
}
public double tl_claytotal() {
return ((double) columns.get(TILLAGE_LAYER_CLAY_TOTAL).getValue());
}
public void tl_claytotal(double value) {
columns.get(TILLAGE_LAYER_CLAY_TOTAL).setValue(value);
}
public double calculated_salinity() {
return ((double) columns.get(SALINITY).getValue());
}
public final void calculated_salinity(double value) {
columns.get(SALINITY).setValue(value);
}
public double calculated_sodicity() {
return ((double) columns.get(SODICITY).getValue());
}
public final void calculated_sodicity(double value) {
columns.get(SODICITY).setValue(value);
}
public void area(double area) {
columns.get(COMP_AREA_NAME).setValue(area);
}
public double area() {
return ((double) columns.get(COMP_AREA_NAME).getValue());
}
public double area_pct() {
return ((double) columns.get(AREA_PCT_NAME).getValue());
}
public void area_pct(double area_pct) {
columns.get(AREA_PCT_NAME).setValue(area_pct);
}
public double calculated_coarse_frag() {
return ((double) columns.get(COARSE_FRAG_NAME).getValue());
}
public void calculated_coarse_frag(double calculated_coarse_frag) {
columns.get(COARSE_FRAG_NAME).setValue(calculated_coarse_frag);
}
public double calculated_coarse_frag_vol_total() {
return ((double) columns.get(COARSE_FRAG_TOTAL_NAME).getValue());
}
public void calculated_coarse_frag_vol_total(double calculated_coarse_frag_vol_total) {
columns.get(COARSE_FRAG_TOTAL_NAME).setValue(calculated_coarse_frag_vol_total);
}
public boolean calculated_cracksgr24() {
return ((boolean) columns.get(CRACKS_GR_24_NAME).getValue());
}
public boolean calculated_hwt_lt_24() {
return ((boolean) columns.get(HWT_LT_24_NAME).getValue());
}
public void calculated_hwt_lt_24(boolean calculated_hwt_lt_24) {
columns.get(HWT_LT_24_NAME).setValue(calculated_hwt_lt_24);
}
// This may conflict with hzdepth at some point, make sure to check this in the future.
public void calculated_hzdepb_r(double calculated_hzdepb_r) {
columns.get(HZDEPTH_NAME).setValue(calculated_hzdepb_r);
}
public double calculated_hzdepb_r() {
return ((double) columns.get(HZDEPTH_NAME).getValue());
}
public double calculated_hzdepth() {
return ((double) columns.get(HZDEPTH_NAME).getValue());
}
public void calculated_hzdepth(double calculated_hzdepth) {
columns.get(HZDEPTH_NAME).setValue(calculated_hzdepth);
}
public double calculated_kffact() {
return ((double) columns.get(KFFACT_NAME).getValue());
}
public void calculated_kffact(double kffact) {
columns.get(KFFACT_NAME).setValue(kffact);
}
public double calculated_lsfact() {
return ((double) columns.get(LSFACT_NAME).getValue());
}
public void calculated_lsfact(double lsfact) {
columns.get(LSFACT_NAME).setValue(lsfact);
}
public String calculated_nslp() {
return ((String) columns.get(NSLP_NAME).getValue());
}
public void calculated_nslp(String calculated_nslp) {
columns.get(NSLP_NAME).setValue(calculated_nslp);
}
public double calculated_pH() {
return ((double) columns.get(PH).getValue());
}
public void calculated_pH(double pH) {
columns.get(PH).setValue(pH);
}
public double calculated_om_r() {
return ((double) columns.get(OM_R_NAME).getValue());
}
public void calculated_om_r(double calculated_om_r) {
columns.get(OM_R_NAME).setValue(calculated_om_r);
}
public void calculated_sandtotal_r(double calculated_sandtotal_r) {
columns.get(SANDTOTAL_R_NAME).setValue(calculated_sandtotal_r);
}
public double calculated_sandtotal_r() {
return ((double) columns.get(SANDTOTAL_R_NAME).getValue());
}
public boolean calculated_slopegr15() {
return ((boolean) columns.get(SLOPE_GR_15_NAME).getValue());
}
public void calculated_slopegr15(boolean slopegr15) {
columns.get(SLOPE_GR_15_NAME).setValue(slopegr15);
}
public String calculated_srp() {
return ((String) columns.get(SRP_NAME).getValue());
}
public void calculated_srp(String calculated_srp) {
columns.get(SRP_NAME).setValue(calculated_srp);
}
public double calculated_srp_number() {
return ((double) columns.get(SRP_NUMBER_NAME).getValue());
}
public void calculated_srp_number(double calculated_srp_number) {
columns.get(SRP_NUMBER_NAME).setValue(calculated_srp_number);
}
public String calculated_wtbl() {
return ((String) columns.get(WTBL_NAME).getValue());
}
public final void calculated_wtbl(String wtkind) {
columns.get(WTBL_NAME).setValue(wtkind);
}
public double calculated_wtbl_top_min() {
double ret_val = Double.NaN;
String value = (String) columns.get(WTBL_TOP_MIN_NAME).getValue();
if (!value.isEmpty() && !value.equalsIgnoreCase("None")) {
ret_val = Double.parseDouble(value);
}
return ret_val;
}
public final void calculated_wtbl_top_min(double wtbl_top_min) {
if (Double.isNaN(wtbl_top_min)) {
columns.get(WTBL_TOP_MIN_NAME).setValue("None");
} else {
columns.get(WTBL_TOP_MIN_NAME).setValue(String.valueOf(wtbl_top_min));
}
}
public double length_r() {
return ((double) columns.get(LENGTH_R_NAME).getValue());
}
public void length_r(double length_r) {
columns.get(LENGTH_R_NAME).setValue(length_r);
}
public String long_name() {
return ((String) columns.get(LONG_NAME).getValue());
}
public void long_name(String long_name) {
columns.get(LONG_NAME).setValue(long_name);
}
public double nslp_number() {
return ((double) columns.get(NSLP_NUMBER_NAME).getValue());
}
public void nslp_number(double nslp_number) {
columns.get(NSLP_NUMBER_NAME).setValue(nslp_number);
}
public int pslp_number() {
return ((int) columns.get(PSLP_NUMBER).getValue());
}
public void pslp_number(int pslp_number) {
columns.get(PSLP_NUMBER).setValue(pslp_number);
}
public String pslp() {
return ((String) columns.get(PSLP).getValue());
}
public void pslp(String pslp) {
columns.get(PSLP).setValue(pslp);
}
public int pssrp_number() {
return ((int) columns.get(PSSRP_NUMBER).getValue());
}
public void pssrp_number(int pssrp_number) {
columns.get(PSSRP_NUMBER).setValue(pssrp_number);
}
public String pssrp() {
return ((String) columns.get(PSSRP).getValue());
}
public void pssrp(String pssrp) {
columns.get(PSSRP).setValue(pssrp);
}
public int psarp_number() {
return ((int) columns.get(PSARP_NUMBER).getValue());
}
public void psarp_number(int pssrp_number) {
columns.get(PSARP_NUMBER).setValue(pssrp_number);
}
public String psarp() {
return ((String) columns.get(PSARP).getValue());
}
public void psarp(String pssrp) {
columns.get(PSARP).setValue(pssrp);
}
}