@Override public GridCoverage2D read(GeneralParameterValue[] parameters) throws IllegalArgumentException, IOException { File baseDir = FileUtils.createTempDirectory(); try { File file = readToFile(baseDir, "WcsCoverageReader", parameters); // since the requested format may be one of several we need to look // up the format object // for reading the coverage from the file Format format = GridFormatFinder.findFormat(file); if (format instanceof AbstractGridFormat && UnknownFormat.class != format.getClass()) { AbstractGridFormat gridFormat = (AbstractGridFormat) format; // Now we need to find the parameters provided by the caller for // reading the coverage from the file // See the format API for details GeneralParameterValue[] readParams = new GeneralParameterValue[0]; try { ParameterValueGroup group = format.getReadParameters(); List<GeneralParameterValue> list = new ArrayList<GeneralParameterValue>(); for (GeneralParameterValue paramValue : group.values()) { list.addAll(find(paramValue, parameters)); } LOG.debug("Reading coverage from file using parameters: " + list); readParams = list.toArray(new GeneralParameterValue[list.size()]); } catch (Exception e) { // if can't configure the parameters then try to read with // what we have been able to configure LOG.warn("Exception occurred while getting request params for reading coverage", e); } AbstractGridCoverage2DReader reader = gridFormat.getReader(file); GridCoverage2D coverage = reader.read(readParams); return coverage; } throw new IllegalArgumentException( "Current configuration is unable to read coverage of " + file.getName() + " format. " + "Check that you have the correct geotools plugins"); } finally { FileUtils.delete(baseDir); } }