public GeoTiffWriterHelper(GridCoverage2D coverage) throws IOException { this.coverage = coverage; // did we get lucky and all we need to do is to copy the original file file over? if (isUnprocessed(coverage)) { this.sourceFile = getSourceFile(coverage); } // setup default writing params, respect by default the original tiling structure // for optimal extraction performance this.imageIoWriteParams = buildWriteParams(coverage); this.geotoolsWriteParams = buildGeoToolsWriteParams(imageIoWriteParams); }
/** * Allows the delegate to specify the output format given the object to encode and the * * @param value * @param coverageId * @param format * @return */ default String getFileName(GridCoverage2D value, String coverageId, String format) { return coverageId + "." + getFileExtension(format); } }
/** * Provides a fallback, a value that looks like a GMLCOV conformance class. Delegates that can * be actually associated to an official conformance class should override this method */ public String getConformanceClass(String format) { return "http://www.opengis.net/spec/WCS_coverage-encoding-x" + getMimeType(format); } }
public void encode( GridCoverage2D sourceCoverage, String outputFormat, Map<String, String> econdingParameters, OutputStream output) throws IOException { Utilities.ensureNonNull("sourceCoverage", sourceCoverage); Utilities.ensureNonNull("econdingParameters", econdingParameters); GeoTiffWriterHelper writerHelper = new GeoTiffWriterHelper(sourceCoverage); // compression handleCompression(econdingParameters, writerHelper); // tiling handleTiling(econdingParameters, sourceCoverage, writerHelper); // interleaving handleInterleaving(econdingParameters, sourceCoverage, writerHelper); if (geoserver.getService(WCSInfo.class).isLatLon()) { final ParameterValueGroup gp = writerHelper.getGeotoolsWriteParams(); gp.parameter(GeoTiffFormat.RETAIN_AXES_ORDER.getName().toString()).setValue(true); } try { writerHelper.write(output); } finally { sourceCoverage.dispose(false); } }
GeoTiffWriteParams wp = helper.getImageIoWriteParams(); helper.disableSourceCopyOptimization(); ows20Code(WcsExceptionCode.PredictorNotSupported), predictorS); } else if (!predictorS.equals("None")) { ows20Code(WcsExceptionCode.PredictorInvalid), predictorS); ows20Code(WcsExceptionCode.JpegQualityInvalid), quality_); ows20Code(WcsExceptionCode.JpegQualityInvalid), quality_); ows20Code(WcsExceptionCode.CompressionInvalid), compressionS);
public void encode(OutputStream output) throws ServiceException, IOException { this.delegate.encode(coverage, outputFormat, encodingParameters, output); } }
/** * Initialize the dimensions by creating NetCDF Dimensions of the proper type. */ private void initializeDimensions() { initializeHigherRankDimensions(); // Initialize the lat,lon/y,x 2D dimensions and coordinates dimensionsManager.addDimensions(crsWriter.initialize2DCoordinatesDimensions()); }
/** Initialize the dimensions by creating NetCDF Dimensions of the proper type. */ protected void initializeDimensions() { initializeHigherRankDimensions(); // Initialize the lat,lon/y,x 2D dimensions and coordinates dimensionsManager.addDimensions(crsWriter.initialize2DCoordinatesDimensions()); }
/** * Basic NetCDF Initialization */ private void initializeNetCDF() { // Initialize the coordinates writer crsWriter = new NetCDFCRSWriter(writer, sampleGranule); // Initialize the Dimensions and coordinates variable initializeDimensions(); // Initialize the variable by setting proper coordinates and attributes initializeVariable(); initializeGlobalAttributes(); }
/** Locates an encoder for a specific GetCoverage results output format */ public CoverageResponseDelegate encoderFor(String outputFormat) { // lookup the encoders dynamically (the list returned might be subject to dynamic extension // filters, so we don't cache it) List<CoverageResponseDelegate> delegates = GeoServerExtensions.extensions(CoverageResponseDelegate.class, applicationContext); for (CoverageResponseDelegate delegate : delegates) { if (delegate.isAvailable() && delegate.canProduce(outputFormat)) { return delegate; } } return null; }
@SuppressWarnings("serial") public DebugCoverageResponseDelegate(GeoServer geoserver) { super( geoserver, Arrays.asList("DEBUG", "text/debug"), // output formats new HashMap<String, String>() { // file extensions { put("DEBUG", "txt"); put("text/debug", "txt"); put("text/plain", "txt"); } }, new HashMap<String, String>() { // mime types { put("DEBUG", "text/plain"); put("text/debug", "text/plain"); } }); }
@SuppressWarnings("serial") public IMGCoverageResponseDelegate(GeoServer geoserver) { super( geoserver, Arrays.asList("png", "jpeg", "JPEG", "PNG"), // output formats new HashMap<String, String>() { // file extensions { put("png", "png"); put("jpeg", "jpeg"); put("JPEG", "jpeg"); put("PNG", "png"); put("image/png", "png"); put("image/jpeg", "jpeg"); } }, new HashMap<String, String>() { // mime types { put("png", "image/png"); put("jpeg", "image/jpeg"); put("PNG", "image/png"); put("JPEG", "image/jpeg"); } }); }
@SuppressWarnings("serial") public AscCoverageResponseDelegate(GeoServer geoserver) { super( geoserver, Arrays.asList( ARCGRID_COVERAGE_FORMAT, ARCGRID_COMPRESSED_COVERAGE_FORMAT, "ArcGrid", "ArcGrid-GZIP"), // output formats new HashMap<String, String>() { // file extensions { put("ArcGrid", ARCGRID_FILE_EXTENSION); put("ArcGrid-GZIP", ARCGRID_COMPRESSED_FILE_EXTENSION); put(ARCGRID_MIME_TYPE, ARCGRID_FILE_EXTENSION); put(ARCGRID_COMPRESSED_MIME_TYPE, ARCGRID_COMPRESSED_FILE_EXTENSION); put(ARCGRID_COVERAGE_FORMAT, ARCGRID_FILE_EXTENSION); put(ARCGRID_COMPRESSED_COVERAGE_FORMAT, ARCGRID_COMPRESSED_FILE_EXTENSION); } }, new HashMap<String, String>() { // mime types { put("ArcGrid", ARCGRID_MIME_TYPE); put("ArcGrid-GZIP", ARCGRID_COMPRESSED_MIME_TYPE); put(ARCGRID_COVERAGE_FORMAT, ARCGRID_MIME_TYPE); put(ARCGRID_COMPRESSED_COVERAGE_FORMAT, ARCGRID_COMPRESSED_MIME_TYPE); } }); }
new HashMap<String, String>() { // file extensions put("tiff", "tif"); put("tiff", "tif"); put("geotiff", "tif"); put("TIFF", "tif"); put("GEOTIFF", "tif"); put("GeoTIFF", "tif"); put("image/geotiff", "tif"); put("image/tiff", "tif"); put("tiff", "image/tiff"); put("tif", "image/tiff"); put("geotiff", "image/tiff"); put("TIFF", "image/tiff"); put("GEOTIFF", "image/tiff"); put("GeoTIFF", "image/tiff"); put("image/geotiff", "image/tiff");
/** Returns the list of all the supported output formats */ public List<String> getOutputFormats() { Set<String> formats = new HashSet<String>(); List<CoverageResponseDelegate> delegates = GeoServerExtensions.extensions(CoverageResponseDelegate.class, applicationContext); for (CoverageResponseDelegate delegate : delegates) { if (delegate.isAvailable()) { formats.addAll(delegate.getOutputFormats()); } } List<String> result = new ArrayList<String>(formats); Collections.sort(result); return result; }
public void writeTo(Object value, String mimeType, OutputStream os) throws IOException { CoverageEncoder encoder = (CoverageEncoder) value; encoder.encode(os); os.flush(); } }
if (isOutputCompressed(outputFormat)) { gzipOut = new GZIPOutputStream(output); output = gzipOut;
final ParameterValueGroup writeParameters = writerParams.getWriteParameters(); final ParameterValue<?> format = writeParameters.parameter("Format"); format.setValue(getFileExtension(outputFormat));
ows20Code(WcsExceptionCode.TilingInvalid), Integer.toString(tileW)); ows20Code(WcsExceptionCode.TilingInvalid), tileW_); ows20Code(WcsExceptionCode.TilingInvalid), Integer.toString(tileH)); ows20Code(WcsExceptionCode.TilingInvalid), tileH_); GeoTiffWriteParams wp = helper.getImageIoWriteParams(); helper.disableSourceCopyOptimization(); wp.setTilingMode(GeoToolsWriteParams.MODE_EXPLICIT); wp.setTiling(tileDimensions.width, tileDimensions.height);