LIDControl.java [src/SwmmObjects] 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 SwmmObjects;

import org.apache.commons.lang3.StringUtils;

/**
 *
 * @author Lucas Yaege
 */
public class LIDControl {

  public String name;
  public String type; //BC bioretension //RG raingarden //GR green roof //IT infiltration trench //PP permeable pavement //RB rain barrel //RD rooftop disconnection //VS vegetative swale
  public LIDSurface surface;
  public LIDSoil soil;
  public LIDPavement pavement;
  public LIDStorage storage;
  public LIDDrain drain;
  public LIDDrainmat drainmat;
  public LIDRoofDrain roofDrain;

  @Override
  public String toString(){
    return toString( 17, 40 );
  }

  public String toString( int padDistance, int namePadDistance ){
    StringBuilder sb = new StringBuilder();

    //Data
    sb.append( StringUtils.rightPad( this.name, namePadDistance ) );
    sb.append( StringUtils.rightPad( type, padDistance ) );
    sb.append( "\n" );

    if( surface != null ){
      sb.append( StringUtils.rightPad( this.name, namePadDistance ) );
      sb.append( StringUtils.rightPad( "SURFACE", padDistance ) );
      sb.append( surface.toString() );
      sb.append( "\n" );
    }

    if( soil != null ){
      sb.append( StringUtils.rightPad( this.name, namePadDistance ) );
      sb.append( StringUtils.rightPad( "SOIL", padDistance ) );
      sb.append( soil.toString() );
      sb.append( "\n" );
    }

    if( pavement != null ){
      sb.append( StringUtils.rightPad( this.name, namePadDistance ) );
      sb.append( StringUtils.rightPad( "PAVEMENT", padDistance ) );
      sb.append( pavement.toString() );
      sb.append( "\n" );
    }

    if( storage != null ){
      sb.append( StringUtils.rightPad( this.name, namePadDistance ) );
      sb.append( StringUtils.rightPad( "STORAGE", padDistance ) );
      sb.append( storage.toString() );
      sb.append( "\n" );
    }
    if( drain != null ){
      sb.append( StringUtils.rightPad( this.name, namePadDistance ) );
      sb.append( StringUtils.rightPad( "DRAIN", padDistance ) );
      sb.append( drain.toString() );
      sb.append( "\n" );
    }
    if( drainmat != null ){
      sb.append( StringUtils.rightPad( this.name, namePadDistance ) );
      sb.append( StringUtils.rightPad( "DRAINMAT", padDistance ) );
      sb.append( drainmat.toString() );
      sb.append( "\n" );
    }
    if( roofDrain != null ){
      sb.append( StringUtils.rightPad( this.name, namePadDistance ) );
      sb.append( StringUtils.rightPad( "ROOF DRAIN", padDistance ) );
      sb.append( roofDrain.toString() );
      sb.append( "\n" );
    }

    sb.append( "\n\n" );
    return sb.toString();
  }

  public LIDControl(){

  }

  public LIDControl( String type, String name ){
    switch (type) {
      case "Rain_Garden":
        getDefaultRainGarden( name );
        break;
      case "Sand_Filter":
        getDefaultSandFilter( name );
        break;
      case "Permeable_Pavement":
        getDefaultPermeablePavement( name );
        break;
      case "Grass_Swales":
        getDefaultGrassSwales( name );
        break;
      case "Infiltration_Trench":
        getDefaultInfiltrationTrench( name );
        break;
      case "Stormwater_Harvesting":
        getDefaultStormwaterHarvesting( name );
        break;
      case "Storage_Vault":
        getDefaultStorageVault( name );
        break;
      case "Green_Roofs":
        getDefaultGreenRoof( name );
        break;
      case "Disconnection":
        getDefaultRoofDisconnection( name );
        break;
      case "Detention_Basin":
        getDefaultDetentionBasin( name );
        break;
      case "Wet_Pond":
        getDefaultWetPond( name );
        break;
      default:
        getDefaultRainGarden( name );
        throw new IllegalArgumentException( "String not recognized as LID Control Type: " + type );
    }
  }

  private void getDefaultRainGarden( String name ){
    this.type = "BC";
    this.name = name;
    this.surface = new LIDSurface( 12, 0.1, 0, 0 );
    this.soil = new LIDSoil( 24, 0.437, 0.062, 0.024, 4.74, 48, 1.93 );
    this.storage = new LIDStorage( 12, 0.67, 0.1, 0 );
    this.drain = new LIDDrain( 1.08, 0.5, 6, 0, 0, 0 );
  }

  private void getDefaultSandFilter( String name ){
    this.type = "BC";
    this.name = name;
    this.surface = new LIDSurface( 6, 0, 0, 0 );
    this.soil = new LIDSoil( 24, 0.437, 0.062, 0.024, 4.74, 48, 1.93 );
    this.storage = new LIDStorage( 12, 0.67, 0.05, 0 );
    this.drain = new LIDDrain( 0.82, 0.5, 6, 0, 0, 0 );
  }

  private void getDefaultPermeablePavement( String name ){
    this.type = "PP";
    this.name = name;
    this.surface = new LIDSurface( 0, 0, 0.024, 1.0 );
    this.pavement = new LIDPavement( 4, 0.12, 0, 10, 0, 0, 0 );
    this.soil = new LIDSoil( 0, 0.437, 0.062, 0.024, 4.74, 48, 1.93 );
    this.storage = new LIDStorage( 8, 0.67, 0, 0 );
    this.drain = new LIDDrain( 0.58, 0.5, 0 );
  }

  private void getDefaultGrassSwales( String name ){
    this.type = "VS";
    this.name = name;
    this.surface = new LIDSurface( 12, 0.1, 0.24, 1, 5 );
  }

  private void getDefaultInfiltrationTrench( String name ){
    this.type = "IT";
    this.name = name;
    this.surface = new LIDSurface( 0, 0, 0, 0 );
    this.storage = new LIDStorage( 24, 0.67, 0.5, 0 );
    this.drain = new LIDDrain( 0, 0.5, 0 );
  }

  private void getDefaultStormwaterHarvesting( String name ){
    this.type = "RB";
    this.name = name;
    this.storage = new LIDStorage( 36, 0.67, 0.0, 0 );
    this.drain = new LIDDrain( 0.21, 0, 2, 24, 0, 0 );
  }

  private void getDefaultStorageVault( String name ){
    this.type = "RB";
    this.name = name;
    this.storage = new LIDStorage( 120, 0.67, 0.0, 0 );
    this.drain = new LIDDrain( 2.2, 0, 0, 24, 0, 0 );
  }

  private void getDefaultGreenRoof( String name ){
    this.type = "GR";
    this.name = name;
    this.surface = new LIDSurface( 0, 0.1, 0, 0 );
    this.soil = new LIDSoil( 4, 0.453, 0.19, 0.085, 0.43, 60, 4.33 );
    this.drainmat = new LIDDrainmat( 1, 0.5, 0.25 );
  }

  private void getDefaultRoofDisconnection( String name ){
    this.type = "RD";
    this.name = name;
    //TODO: Double check with Mostafa on the last param, 0 is a default, not an actual value.
    this.surface = new LIDSurface( 12, 0.1, 1, 0 );
    this.drain = new LIDDrain( 0, 0.5, 6, 6, 0, 0 ); //So Many Defaults!  The first 0 is the only actual value.
  }

  private void getDefaultDetentionBasin( String name ){
    this.type = "IT";
    this.name = name;
    this.surface = new LIDSurface( 48, 0.0, 0, 0 );
    this.storage = new LIDStorage( 12, 0.1, 0, 0 );
    this.drain = new LIDDrain( 1, 0, 0 );
  }

  private void getDefaultWetPond( String name ){
    this.type = "IT";
    this.name = name;
    this.surface = new LIDSurface( 48, 0.0, 0, 0 );
    this.storage = new LIDStorage( 12, 0.1, 0, 0 );
    this.drain = new LIDDrain( 1, 0, 0 );
  }

}