public File writeCoverageDataToFile( Request.Format format, LatLonRect bboxLatLonRect, VerticalRange verticalRange, DateRange timeRange)
throws WcsException
{
// Get the height range.
Range zRange = null;
try
{
zRange = verticalRange != null ? verticalRange.getRange( this.coordSys ) : null;
}
catch ( InvalidRangeException e )
{
log.error( "writeCoverageDataToFile(): Failed to subset coverage <" + this.coverage.getFullName() + "> along vertical range <" + verticalRange + ">: " + e.getMessage() );
throw new WcsException( WcsException.Code.CoverageNotDefined, "Vertical", "Failed to subset coverage [" + this.coverage.getFullName() + "] along vertical range." );
}
// Get the time range.
Range tRange = null;
if ( timeRange != null )
{
CoordinateAxis1DTime timeAxis = this.coordSys.getTimeAxis1D();
DateType requestStartTime = timeRange.getStart();
DateType requestEndTime = timeRange.getEnd();
int startIndex = timeAxis.findTimeIndexFromDate( requestStartTime.getDate() );
int endIndex = timeAxis.findTimeIndexFromDate( requestEndTime.getDate() );
if ( startIndex < 0 || startIndex > timeAxis.getSize() -1
|| endIndex < 0 || endIndex > timeAxis.getSize() - 1 )
{
String availStart = timeAxis.getDateRange().getStart().toDateTimeStringISO();
String availEnd = timeAxis.getDateRange().getEnd().toDateTimeStringISO();
String msg = "Requested temporal range [" + requestStartTime.toDateTimeStringISO()
+ " - " + requestEndTime.toDateTimeStringISO()
+ "] not in available range [" + availStart + " - " + availEnd + "].";
log.debug( "writeCoverageDataToFile(): " + msg );
throw new WcsException( WcsException.Code.CoverageNotDefined, "Time", msg );
}
try
{
tRange = new Range( startIndex, endIndex );
}
catch ( InvalidRangeException e )
{
log.error( "writeCoverageDataToFile(): Failed to subset coverage [" + this.coverage.getFullName() + "] along time axis [" + timeRange + "]: " + e.getMessage() );
throw new WcsException( WcsException.Code.CoverageNotDefined, "Time", "Failed to subset coverage [" + this.coverage.getFullName() + "] along time axis [" + timeRange + "]." );