result.setTimeOffset( (Double) coord); else if (coord instanceof double[]) result.setTimeOffsetIntv((double[]) coord); else throw new IllegalStateException("unknow time coord type "+coord.getClass().getName());
private void addAdjustedTimeCoords(SubsetParams result, CoverageCoordAxis1D axis, int coordIdx, CalendarDate runtime) { // this must be adjusted to be offset from the runtime. // adjust = end - start // axisCoordOffset + axis.reftime = offset + runtime // offset = axisCoordOffset + axis.reftime - runtime // offset = axisCoordOffset + adjust // offset = axisCoordOffset + end - start = axisCoordOffset + axis.reftime - runtime // therefore: end = reftime, start = runtime double adjust = axis.getOffsetInTimeUnits(runtime, axis.getRefDate()); if (axis.isInterval()) { double[] adjustVal = new double[] {axis.getCoordEdge1(coordIdx)+adjust, axis.getCoordEdge2(coordIdx)+adjust}; result.setTimeOffsetIntv(adjustVal); double mid = (adjustVal[0]+adjustVal[1]) / 2.0; result.set(SubsetParams.timeOffsetUnit, axis.makeDateInTimeUnits(runtime, mid)); // validation result.set(SubsetParams.timeOffsetUnit, axis.getCalendarDateUnit()); // validation } else { double adjustVal = axis.getCoordMidpoint(coordIdx) + adjust; result.setTimeOffset(adjustVal); result.set(SubsetParams.timeOffsetDate, axis.makeDateInTimeUnits(runtime, adjustVal)); // validation result.set(SubsetParams.timeOffsetUnit, axis.getCalendarDateUnit()); // validation } }
if (isTimeInterval) { dtCoords.set("timeDateIntv", tcoord1D.getCoordBoundsDate(t)); dtCoords.setTimeOffsetIntv(tcoord1D.getCoordBounds(t)); } else { dtCoords.setTime(tcoord1D.getCalendarDate(t)); timeBoundsDate[0] = helper.makeCalendarDateFromOffset(timeBounds[0]); timeBoundsDate[1] = helper.makeCalendarDateFromOffset(timeBounds[1]); dtCoords.setTimeOffsetIntv(timeBounds); dtCoords.set("timeDateIntv", timeBoundsDate); } else {