if (aliases.contains(pd.getName().getCode())) { final ParameterValue pv = (ParameterValue) pd.createValue(); pv.setValue(value);
/** 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; }
/** Replace or add the provided parameter in the read parameters */ public static <T> GeneralParameterValue[] replaceParameter( GeneralParameterValue[] readParameters, Object value, ParameterDescriptor<T> pd) { // scan all the params looking for the one we want to add for (GeneralParameterValue gpv : readParameters) { // in case of match of any alias add a param value to the lot if (gpv.getDescriptor().getName().equals(pd.getName())) { ((ParameterValue) gpv).setValue(value); // leave return readParameters; } } // add it to the array // add to the list GeneralParameterValue[] readParametersClone = new GeneralParameterValue[readParameters.length + 1]; System.arraycopy(readParameters, 0, readParametersClone, 0, readParameters.length); final ParameterValue<T> pv = pd.createValue(); pv.setValue(value); readParametersClone[readParameters.length] = pv; return readParametersClone; } }
String pdCode = pv.getDescriptor().getName().getCode(); if ("FILTER".equals(pdCode) || "Filter".equals(pdCode)) { replacedOriginalFilter = true;
/** * Forward the call to the {@linkplain MatrixParameterDescriptors matrix parameter descriptors} * specified at construction time. */ public ReferenceIdentifier getName() { return descriptor.getName(); }
for (GeneralParameterValue p : params) { if (p.getDescriptor() .getName() .toString() .equalsIgnoreCase(CustomFormat.CUSTOM_DIMENSION_NAME)) {
/** * Convenience method returning the name of the specified descriptor. This method is used mostly * for output to be read by human, not for processing. Consequently, we may consider to returns * a localized name in a future version. */ static String getName(final GeneralParameterDescriptor descriptor) { return descriptor.getName().getCode(); }
/** * Returns the unlocalized operation name. This is different from {@link * AbstractParameter#getName}, which may returns a localized name. */ private String getName() { return descriptor.getName().getCode(); }
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()]); }
final String name = param.getDescriptor().getName().toString(); if (name.regionMatches(true, 0, prefix, 0, prefix.length())) { final int split = name.indexOf(separator, prefix.length());
@Override public GridCoverage2D read(GeneralParameterValue[] parameters) throws IllegalArgumentException, IOException { assertTrue( Arrays.stream(parameters) .anyMatch( p -> "Bands".equals(p.getDescriptor().getName().toString()) && Arrays.equals( expectedBands, (int[]) ((ParameterValue) p) .getValue()))); // Create a solid color single band coverage BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_BYTE_GRAY); Graphics2D graphics = bi.createGraphics(); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, bi.getWidth(), bi.getHeight()); graphics.dispose(); GridCoverage2D coverage = CoverageFactoryFinder.getGridCoverageFactory(null) .create("test", bi, getOriginalEnvelope()); return coverage; } }
/** * Remove the value at the specified index. * * @param type The descriptor of the value to remove. * @param index The index of the value to remove. */ private GeneralParameterValue remove(final GeneralParameterDescriptor type, final int index) { modCount++; int count = 0; final String name = type.getName().getCode(); for (final GeneralParameterValue value : values) { if (AbstractIdentifiedObject.nameMatches(value.getDescriptor(), name)) { count++; } } final int min = type.getMinimumOccurs(); if (count <= min) { final int max = type.getMaximumOccurs(); throw new InvalidParameterCardinalityException( Errors.format( ErrorKeys.ILLEGAL_OCCURS_FOR_PARAMETER_$4, name, count - 1, min, max), name); } final GeneralParameterValue value = values.remove(index); assert value != null && type.equals(value.getDescriptor()) : value; return value; } }
@Override public GridCoverage2D read(GeneralParameterValue[] parameters) throws IllegalArgumentException, IOException { for (GeneralParameterValue parameter : parameters) { if ("Bands".equals(parameter.getDescriptor().getName().toString())) { assertTrue( Arrays.equals( expectedBands, (int[]) ((ParameterValue) parameter).getValue())); } } BufferedImage bi = image; GridCoverage2D coverage = CoverageFactoryFinder.getGridCoverageFactory(null) .create("test", bi, getOriginalEnvelope()); return coverage; } }
/** * Copies all parameter values from {@code source} to {@code target}. A typical usage of this * method is for transfering values from an arbitrary implementation to some specific * implementation (e.g. a parameter group implementation backed by a {@link * java.awt.image.renderable.ParameterBlock} for image processing operations). * * @param source The parameters to copy. * @param target Where to copy the source parameters. * @since 2.2 */ public static void copy(final ParameterValueGroup source, final ParameterValueGroup target) { for (final GeneralParameterValue param : source.values()) { final String name = param.getDescriptor().getName().getCode(); if (param instanceof ParameterValueGroup) { copy((ParameterValueGroup) param, target.addGroup(name)); } else { target.parameter(name).setValue(((ParameterValue) param).getValue()); } } }
final ReferenceIdentifier name = param.getDescriptor().getName(); if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName())) { final GridGeometry2D gg = (GridGeometry2D) ((ParameterValue) param).getValue();
if (parameters != null) { for (GeneralParameterValue param : parameters) { final ReferenceIdentifier name = param.getDescriptor().getName(); if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName())) { final GridGeometry2D gg = (GridGeometry2D) ((ParameterValue) param).getValue();
final String name = values[j].getDescriptor().getName().getCode().trim(); for (int i = 0; i < values.length; i++) { if (i != j) {
throws InvalidParameterNameException, InvalidParameterValueException { for (final GeneralParameterValue value : values.values()) { final String name = value.getDescriptor().getName().getCode(); if (value instanceof ParameterValueGroup) {