private ParameterValueGroup buildGeoToolsWriteParams(GeoTiffWriteParams writeParams) { final ParameterValueGroup wparams = TIFF_FORMAT.getWriteParameters(); wparams.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString()) .setValue(writeParams); return wparams; }
public static GeneralParameterValue[] getParameters(ParameterValueGroup params) { final List parameters = new ArrayList(); final String readGeometryKey = AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString();
public static Map getParametersKVP(ParameterValueGroup params) { final Map parameters = new HashMap(); final String readGeometryKey = AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString();
AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString())) { if ((params.get(key) != null) && params.get(key) instanceof String
public void write(OutputStream outStream) { try { long t0 = System.currentTimeMillis(); GeoTiffWriteParams wp = new GeoTiffWriteParams(); wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT); wp.setCompressionType("LZW"); ParameterValueGroup params = new GeoTiffFormat().getWriteParameters(); params.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString()).setValue(wp); new GeoTiffWriter(outStream).write(coverage, (GeneralParameterValue[]) params.values().toArray(new GeneralParameterValue[1])); //new GeoTiffWriter(outStream).write(coverage, null); //wasn't this line writing twice and trashing compressed version? long t1 = System.currentTimeMillis(); LOG.debug("wrote geotiff in {}msec", t1-t0); } catch (Exception e) { LOG.error("exception while preparing geotiff : {}", e.getMessage()); throw new WebApplicationException(e); } } };
/** Helper method that checks if the delegate reader support bands selection. */ private boolean checkIfDelegateReaderSupportsBands() { List<GeneralParameterDescriptor> parameters = delegate.getFormat().getReadParameters().getDescriptor().descriptors(); for (GeneralParameterDescriptor parameterDescriptor : parameters) { if (parameterDescriptor.getName().equals(AbstractGridFormat.BANDS.getName())) { return true; } } return false; }
public static GeneralParameterValue[] getParameters( ParameterValueGroup params, Map values, boolean readGeom) { final List<ParameterValue<?>> parameters = new ArrayList<ParameterValue<?>>(); final String readGeometryKey = AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString();
public void writeGeotiff(String fileName, ResultSet results) { LOG.info("writing geotiff."); float[][] imagePixelData = new float[rows][cols]; for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { int index = row * cols + col; float pixel = (float) (results.results[index]); if (unitySeconds > 0) pixel /= unitySeconds; imagePixelData[row][col] = pixel; } } GridCoverage2D coverage = new GridCoverageFactory().create("OTPAnalyst", imagePixelData, refEnvelope); try { GeoTiffWriteParams wp = new GeoTiffWriteParams(); wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT); wp.setCompressionType("LZW"); ParameterValueGroup params = new GeoTiffFormat().getWriteParameters(); params.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString()).setValue(wp); GeoTiffWriter writer = new GeoTiffWriter(new File(fileName)); writer.write(coverage, (GeneralParameterValue[]) params.values().toArray(new GeneralParameterValue[1])); } catch (Exception e) { LOG.error("exception while writing geotiff.", e); } LOG.info("done writing geotiff."); }
int[] getSelectedBandIndexes(GeneralParameterValue[] parameters) { // if the delegate cannot do band selection, don't bother if (delegate.getFormat() == null || !delegate.getFormat() .getReadParameters() .getDescriptor() .descriptors() .contains(AbstractGridFormat.BANDS)) { return null; } // lookup the bands if possible if (parameters != null) { for (int i = 0; i < parameters.length; i++) { final ParameterValue param = (ParameterValue) parameters[i]; if (AbstractGridFormat.BANDS.getName().equals(param.getDescriptor().getName())) { int[] bandIndicesParam = (int[]) param.getValue(); return bandIndicesParam; } } } return null; }
String useJaiImageRead = ImageMosaicFormat.USE_JAI_IMAGEREAD.getName().toString(); if (parameters.keySet().contains(useJaiImageRead)) { parameters.put(useJaiImageRead, false); AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString(), new GridGeometry2D(testRange, testEnvelope)); if (gc != null) { parameters.remove(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString()); sampleDimensions = gc.getSampleDimensions();
private GeneralParameterValue[] buildFootprintBandParams( FootprintBehavior footprintBehavior, int[] bands) { final List<ParameterValue<?>> parameters = new ArrayList<ParameterValue<?>>(); parameters.add( new DefaultParameterDescriptor<>( AbstractGridFormat.FOOTPRINT_BEHAVIOR.getName().toString(), AbstractGridFormat.FOOTPRINT_BEHAVIOR.getValueClass(), null, footprintBehavior.name()) .createValue()); parameters.add( new DefaultParameterDescriptor<>( AbstractGridFormat.BANDS.getName().toString(), AbstractGridFormat.BANDS.getValueClass(), null, bands) .createValue()); return (GeneralParameterValue[]) parameters.toArray(new GeneralParameterValue[parameters.size()]); }
.equals( AbstractGridFormat.READ_GRIDGEOMETRY2D .getName())) .findFirst(); for (int i = 0; i < parameters.length; i++) { final ParameterValue param = (ParameterValue) parameters[i]; if (AbstractGridFormat.BANDS.getName().equals(param.getDescriptor().getName())) { int[] bandIndicesParam = (int[]) param.getValue(); if (bandIndicesParam != null) { .equals( AbstractGridFormat.BANDS .getName())) .toArray(GeneralParameterValue[]::new);
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); } }
AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString(), new GridGeometry2D(reader.getOriginalGridRange(), subEnvelope)); GridCoverage2D gc =
/** * Check whether a specific parameter (identified by the {@link Identifier} name) is * supported by this manager (and therefore, by the reader). * * @param name * @return */ public boolean isParameterSupported(final Identifier name) { if (!domainsMap.isEmpty()) { for (DomainDescriptor domain : domainsMap.values()) { final ReferenceIdentifier nameLoc = domain.getDomainParameterDescriptor().getName(); if (nameLoc.equals(name)) { return true; } } } return false; }
private GeneralParameterValue[] mergeBandParam(GeneralParameterValue[] params, int[] bands) { // is it already there for some reason? if (params != null) { for (GeneralParameterValue param : params) { if (param.getDescriptor().getName().equals(AbstractGridFormat.BANDS.getName())) { ((ParameterValue) param).setValue(bands); return params; } } } // not found, need to add List<GeneralParameterValue> list = new ArrayList<>(params == null ? Collections.emptyList() : Arrays.asList(params)); ParameterValue<int[]> value = AbstractGridFormat.BANDS.createValue(); value.setValue(bands); list.add(value); return list.toArray(new GeneralParameterValue[list.size()]); }
AbstractGridFormat.USE_JAI_IMAGEREAD.getName().getCode(), Boolean.FALSE);
if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString())) { final GridGeometry2D gg = (GridGeometry2D) param.getValue(); requestedEnvelope = new GeneralEnvelope((Envelope) gg.getEnvelope2D()); continue; if (name.equals(AbstractGridFormat.OVERVIEW_POLICY.getName().toString())) { overviewPolicy = (OverviewPolicy) param.getValue(); continue;
final ParameterValue<?> param = (ParameterValue<?>) params[i]; final String name = param.getDescriptor().getName().getCode(); if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString())) { final GridGeometry2D gg = (GridGeometry2D) param.getValue(); requestedEnvelope = new GeneralEnvelope((Envelope) gg.getEnvelope2D());
&& !nameMatches(object, getName().getCode())) { return false;