Ejemplo n.º 1
0
  private boolean validateRapidResponse() {

    // System.out.println("Validating Rapid Response");

    // Get LKP values
    double rapidResponseLKPLat = rapidResponseDatumPointInputPanel.getRapidResponseDatumLKPLat();

    if (rapidResponseLKPLat == -9999) {
      return false;
    }

    double rapidResponseLKPLon = rapidResponseDatumPointInputPanel.getRapidResponseDatumLKPLon();

    Position rapidResponsePosition;

    if (rapidResponseLKPLat != -9999 && rapidResponseLKPLon != -9999) {
      rapidResponsePosition = Position.create(rapidResponseLKPLat, rapidResponseLKPLon);
    } else {
      // msgbox
      // System.out.println("Failed lat");
      return false;
    }

    // System.out.println("All validated correctly, we got positions");

    // System.out.println("LKP Date is "
    // + rapidResponseDatumPointInputPanel.getLKPDate());
    // System.out.println("CSS Date is "
    // + rapidResponseDatumPointInputPanel.getCSSDate());

    // Time and date will be automatically sorted

    List<SurfaceDriftPanel> weatherList =
        rapidResponseDatumPointInputPanel.getSurfaceDriftPanelList();

    List<SARWeatherData> sarWeatherDataPoints = new ArrayList<SARWeatherData>();

    for (int i = 0; i < weatherList.size(); i++) {
      // Get weather
      SurfaceDriftPanel weatherPanel = weatherList.get(i);

      double TWCKnots = weatherPanel.getTWCKnots();

      if (TWCKnots == -9999) {
        // Error message is handled within function
        return false;
      }

      double leewayKnots = weatherPanel.getLeeway();

      if (leewayKnots == -9999) {
        // Error message is handled within function
        return false;
      }

      double twcHeading = weatherPanel.getTWCHeading();

      if (twcHeading == -9999) {
        // Error message is handled within function
        return false;
      }

      double leewayHeading = weatherPanel.getLeewayHeading();

      if (leewayHeading == -9999) {
        // Error message is handled within function
        return false;
      }

      DateTime dateTime = new DateTime(weatherPanel.getDateTime().getTime());

      SARWeatherData sarWeatherData =
          new SARWeatherData(twcHeading, TWCKnots, leewayKnots, leewayHeading, dateTime);

      sarWeatherDataPoints.add(sarWeatherData);
    }

    double xError = rapidResponseDatumPointInputPanel.getInitialPositionError();

    if (xError == -9999) {
      // Error message is handled within function
      return false;
    }

    double yError = rapidResponseDatumPointInputPanel.getNavError();

    if (yError == -9999) {
      // Error message is handled within function
      return false;
    }

    double safetyFactor = rapidResponseDatumPointInputPanel.getSafetyFactor();

    if (safetyFactor == -9999) {
      // Error message is handled within function
      return false;
    }

    int searchObject = rapidResponseDatumPointInputPanel.getSearchItemID();

    // Only valid search objects is value 0 to 19
    if (searchObject < 0 || searchObject > 20) {
      // Error message is handled within function
      // System.out.println("failed search object with id " +
      // searchObject);
      return false;
    }

    // rapidResponsePosition
    // commenceStartPosition
    // TWCKnots
    // twcHeading
    // leewayKnots
    // leewayHeading
    // xError
    // yError
    // safetyFactor
    // searchObject

    if (!rapidResponseDatumPointInputPanel.checkTime()) {
      return false;
    }

    if (!rapidResponseDatumPointInputPanel.checkMetocTime()) {
      return false;
    }

    voctManager.inputRapidResponseDatumData(
        rapidResponseDatumPointInputPanel.getSARID(),
        rapidResponseDatumPointInputPanel.getLKPDate(),
        rapidResponseDatumPointInputPanel.getCSSDate(),
        rapidResponsePosition,
        xError,
        yError,
        safetyFactor,
        searchObject,
        sarWeatherDataPoints);

    return true;
  }