public SubsetParams makeSubset(CoverageCollection gcd) {
    Calendar cal = gcd.getCalendar();
    boolean isFmrc = gcd.getCoverageType() == FeatureType.FMRC;

    SubsetParams subset = new SubsetParams();

    // vars
    subset.set(SubsetParams.variables, var);

    // other coords
    if (vertCoord != null)
      subset.set(SubsetParams.vertCoord, vertCoord);

    if (ensCoord != null)
      subset.set(SubsetParams.ensCoord, ensCoord);

    // horiz subset
    if (hasProjectionBB())
      subset.set(SubsetParams.projBB, getProjectionBB());
    else if (hasLatLonBB())
      subset.set(SubsetParams.latlonBB, getLatLonBoundingBox());
    if (horizStride != null && horizStride != 1)
      subset.set(SubsetParams.horizStride, horizStride);
    if (hasLatLonPoint())
      subset.set(SubsetParams.latlonPoint, new LatLonPointImpl(getLatitude(), getLongitude()));

    if (isFmrc) { // 2D Time subsetting

      // runtime
      CalendarDate rundate = getRuntimeDate(cal);
      if (rundate != null)
        subset.set(SubsetParams.runtime, rundate);
      else if (allRuntime)
        subset.set(SubsetParams.runtimeAll, true);
      else
        subset.set(SubsetParams.runtimeLatest, true); // default

      // timeOffset
      if (timeOffsetVal != null)
        subset.set(SubsetParams.timeOffset, timeOffsetVal);
      else if (firstTimeOffset)
        subset.set(SubsetParams.timeOffsetFirst, true);

      else { // if no timeOffset, will allow some time values
        CalendarDate date = getRequestedDate(cal);
        CalendarDateRange dateRange = getCalendarDateRange(cal);

        if (isPresentTime())
          subset.setTimePresent();

        else if (isAllTimes() && !allRuntime) {
          subset.set(SubsetParams.timeAll, true);
          if (timeStride != null && timeStride != 1)
            subset.set(SubsetParams.timeStride, timeStride);

        } else if (date != null) {              // for allRuntimes, only a date is allowed
          subset.set(SubsetParams.time, date);

        } else if (dateRange != null  && !allRuntime) {
          subset.set(SubsetParams.timeRange, dateRange);
          if (timeStride != null && timeStride != 1)
            subset.set(SubsetParams.timeStride, timeStride);
        }
      }

    } else { // not an FMRC

      // time
      CalendarDate date = getRequestedDate(cal);
      CalendarDateRange dateRange = getCalendarDateRange(cal);
      if (isPresentTime())
        subset.setTimePresent();
      else if (isAllTimes()) {
        subset.set(SubsetParams.timeAll, true);
        if (timeStride != null && timeStride != 1)
          subset.set(SubsetParams.timeStride, timeStride);

      } else if (date != null) {
        subset.set(SubsetParams.time, date);

      } else if (dateRange != null) {
        subset.set(SubsetParams.timeRange, dateRange);
        if (timeStride != null && timeStride != 1)
          subset.set(SubsetParams.timeStride, timeStride);

      } else {
        subset.set(SubsetParams.timePresent, true);
      }
    }

    return subset;
  }
public SubsetParams makeSubset ( CoverageCollection gcd ) { Calendar cal = gcd . getCalendar ( ) ; boolean isFmrc = gcd . getCoverageType ( ) == FeatureType . FMRC ; SubsetParams subset = new SubsetParams ( ) ; subset . set ( SubsetParams . variables , var ) ; if ( vertCoord != null ) subset . set ( SubsetParams . vertCoord , vertCoord ) ; if ( ensCoord != null ) subset . set ( SubsetParams . ensCoord , ensCoord ) ; if ( hasProjectionBB ( ) ) subset . set ( SubsetParams . projBB , getProjectionBB ( ) ) ; else if ( hasLatLonBB ( ) ) subset . set ( SubsetParams . latlonBB , getLatLonBoundingBox ( ) ) ; if ( horizStride != null && horizStride != 1 ) subset . set ( SubsetParams . horizStride , horizStride ) ; if ( hasLatLonPoint ( ) ) subset . set ( SubsetParams . latlonPoint , new LatLonPointImpl ( getLatitude ( ) , getLongitude ( ) ) ) ; if ( isFmrc ) { CalendarDate rundate = getRuntimeDate ( cal ) ; if ( rundate != null ) subset . set ( SubsetParams . runtime , rundate ) ; else if ( allRuntime ) subset . set ( SubsetParams . runtimeAll , true ) ; else subset . set ( SubsetParams . runtimeLatest , true ) ; if ( timeOffsetVal != null ) subset . set ( SubsetParams . timeOffset , timeOffsetVal ) ; else if ( firstTimeOffset ) subset . set ( SubsetParams . timeOffsetFirst , true ) ; else { CalendarDate date = getRequestedDate ( cal ) ; CalendarDateRange dateRange = getCalendarDateRange ( cal ) ; if ( isPresentTime ( ) ) subset . setTimePresent ( ) ; else if ( isAllTimes ( ) && ! allRuntime ) { subset . set ( SubsetParams . timeAll , true ) ; if ( timeStride != null && timeStride != 1 ) subset . set ( SubsetParams . timeStride , timeStride ) ; } else if ( date != null ) { subset . set ( SubsetParams . time , date ) ; } else if ( dateRange != null && ! allRuntime ) { subset . set ( SubsetParams . timeRange , dateRange ) ; if ( timeStride != null && timeStride != 1 ) subset . set ( SubsetParams . timeStride , timeStride ) ; } } } else { CalendarDate date = getRequestedDate ( cal ) ; CalendarDateRange dateRange = getCalendarDateRange ( cal ) ; if ( isPresentTime ( ) ) subset . setTimePresent ( ) ; else if ( isAllTimes ( ) ) { subset . set ( SubsetParams . timeAll , true ) ; if ( timeStride != null && timeStride != 1 ) subset . set ( SubsetParams . timeStride , timeStride ) ; } else if ( date != null ) { subset . set ( SubsetParams . time , date ) ; } else if ( dateRange != null ) { subset . set ( SubsetParams . timeRange , dateRange ) ; if ( timeStride != null && timeStride != 1 ) subset . set ( SubsetParams . timeStride , timeStride ) ; } else { subset . set ( SubsetParams . timePresent , true ) ; } } return subset ; }
/////////////////////////////