public void encode(OutputStream output) throws ServiceException, IOException { if (sourceCoverage == null) { throw new IllegalStateException("It seems prepare() has not been called or has not succeed"); } final GridCoverageWriter writer = new WorldImageWriter(output); // writing parameters for Image final Format writerParams = writer.getFormat(); final ParameterValueGroup writeParameters = writerParams.getWriteParameters(); final ParameterValue format = writeParameters.parameter("Format"); format.setValue(this.outputFormat.toLowerCase()); // writing writer.write(sourceCoverage, new GeneralParameterValue[] {format}); // freeing everything output.flush(); writer.dispose(); this.sourceCoverage.dispose(false); this.sourceCoverage = null; } }
public void encode(OutputStream output) throws ServiceException, IOException { // creating a zip outputstream final ZipOutputStream outZ = new ZipOutputStream(output); output = outZ; // creating a writer final GridCoverageWriter writer = new GTopo30Writer(outZ); // writing if (writer != null) { writer.write(sourceCoverage, null); } else { throw new ServiceException("Could not create a writer for the format Gtopo30!"); } // freeing everything writer.dispose(); this.sourceCoverage.dispose(false); this.sourceCoverage = null; } }
@Override public void encode(Object value, OutputStream os) throws IOException { Parameter<Boolean> forceSquareCells = new Parameter<Boolean>(ArcGridFormat.FORCE_CELLSIZE, Boolean.TRUE); new ArcGridFormat() .getWriter(os) .write((GridCoverage2D) value, new GeneralParameterValue[] {forceSquareCells}); }
@Override public void encode(Object value, OutputStream os) throws IOException { Parameter<Boolean> forceSquareCells = new Parameter<Boolean>(ArcGridFormat.FORCE_CELLSIZE, Boolean.TRUE); new ArcGridFormat().getWriter(os).write((GridCoverage2D) value, new GeneralParameterValue[] {forceSquareCells}); }
public void encode(OutputStream output) throws ServiceException, IOException { if (sourceCoverage == null) { throw new IllegalStateException("It seems prepare() has not been called" + " or has not succeed"); } final GeoTiffFormat format = new GeoTiffFormat(); final GeoTiffWriteParams wp = new GeoTiffWriteParams(); wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT); wp.setCompressionType("LZW"); wp.setCompressionQuality(0.75F); wp.setTilingMode(GeoToolsWriteParams.MODE_EXPLICIT); wp.setTiling(256, 256); final ParameterValueGroup writerParams = format.getWriteParameters(); writerParams.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString()) .setValue(wp); GridCoverageWriter writer = format.getWriter(output); writer.write(sourceCoverage, (GeneralParameterValue[]) writerParams.values().toArray(new GeneralParameterValue[1])); writer.dispose(); this.sourceCoverage.dispose(false); this.sourceCoverage = null; } }
private void saveCoverage(IState state, File file, Iterable<IScale.Locator> locators) throws KlabException { SpaceExtent space = (SpaceExtent) state.getSpace(); if (space.getGrid() != null) { GridCoverage2D coverage = GISOperations.stateToCoverage(state, locators); if (coverage != null) { if (!file.toString().endsWith(".tif") && !file.toString().endsWith(".tiff")) { file = new File(file + ".tif"); } GridCoverageWriter writer = new GeoTiffFormat().getWriter(file); try { writer.write(coverage, null); } catch (Exception e) { throw new KlabIOException(e); } } } }
writer.write(coverage, null); } catch (Exception e) { throw new KlabIOException(e);