SoilResult.java [src/java/crp/utils] Revision: default  Date:
/*
 * $Id$
 *
 * This file is part of the Cloud Services Integration Platform (CSIP),
 * a Model-as-a-Service framework, API, and application suite.
 *
 * 2012-2019, OMSLab, Colorado State University.
 *
 * OMSLab licenses this file to you under the MIT license.
 * See the LICENSE file in the project root for more information.
 */
package crp.utils;

import data.interpretors.SlopeSteepness;
import java.util.ArrayList;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;

/**
 *
 * @author <a href="mailto:shaun.case@colostate.edu">Shaun Case</a>
 */
public class SoilResult {

  public volatile String mukey;
  public volatile String musym;
  public volatile String muname;
  public volatile String areaSymbol;
  public volatile double area;
  public volatile String cokey;
  public volatile double length;
  public volatile double slope_r;
  public volatile double tfact;
  public volatile double slopeDEM;
  public volatile double windErosion = Double.NaN;
  public volatile double waterErosion = Double.NaN;
  public volatile double area_pct;
  public volatile String soilName;
  public volatile String soilLongName;
  public volatile boolean usedDEM = false;
  public volatile String ifcFile = null;
  public volatile String solFile = null;
  public volatile ArrayList<JSONObject> polygonList;
  public volatile SlopeSteepness slopes = null;

  public SoilResult() {
    polygonList = new ArrayList<>();
    area = Double.NaN;
    length = Double.NaN;
    slope_r = Double.NaN;
    slopeDEM = Double.NaN;
    windErosion = Double.NaN;
    waterErosion = Double.NaN;
    area_pct = Double.NaN;
  }

  public SoilResult(SoilResult _soilResult) throws JSONException {
    mukey = _soilResult.mukey;
    area = _soilResult.area;
    cokey = _soilResult.cokey;
    length = _soilResult.length;
    slope_r = _soilResult.slope_r;
    slopeDEM = _soilResult.slopeDEM;
    windErosion = _soilResult.windErosion;
    waterErosion = _soilResult.waterErosion;
    area_pct = _soilResult.area_pct;
    soilName = _soilResult.soilName;
    soilLongName = _soilResult.soilLongName;
    ifcFile = _soilResult.ifcFile;
    solFile = _soilResult.solFile;
    usedDEM = _soilResult.usedDEM;
    tfact = _soilResult.tfact;
    areaSymbol = _soilResult.areaSymbol;
    slopes = _soilResult.slopes;
    musym = _soilResult.musym;
    muname = _soilResult.muname;

    polygonList = new ArrayList<>();
    for (JSONObject tObject : _soilResult.polygonList) {
      polygonList.add(new JSONObject(tObject.toString()));
    }

  }

  public void setPolygons(ArrayList<JSONObject> _polygonList) {
    if (_polygonList.size() > 0) {
      polygonList.clear();
      polygonList.addAll(_polygonList);
    }
  }
}