@Override public ParameterValueGroup getReadParameters() { HashMap<String, String> info = new HashMap<String, String>(); info.put("name", getName()); info.put("description", getDescription()); info.put("vendor", getVendor()); info.put("docURL", getDocURL()); info.put("version", getVersion()); List<GeneralParameterDescriptor> delegateFormatParams = new ArrayList<GeneralParameterDescriptor>(); delegateFormatParams.addAll( delegateFormat.getReadParameters().getDescriptor().descriptors()); // add bands parameter descriptor only if the delegate reader doesn't have it // already if (!checkIfDelegateReaderSupportsBands()) { delegateFormatParams.add(AbstractGridFormat.BANDS); } return new ParameterGroup( new DefaultParameterDescriptorGroup( info, delegateFormatParams.toArray( new GeneralParameterDescriptor [delegateFormatParams.size()]))); }
/** 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; }
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; }
ParameterValueGroup readParameters = format.getReadParameters(); List<GeneralParameterDescriptor> descriptors = readParameters.getDescriptor().descriptors();
/** Returns the operation name for the specified parameters. */ static String getOperationName(final ParameterValueGroup parameters) { return parameters.getDescriptor().getName().getCode().trim(); }
/** Returns a name for the specified math transform. */ private static final String getName(final MathTransform transform) { if (transform instanceof AbstractMathTransform) { ParameterValueGroup params = ((AbstractMathTransform) transform).getParameterValues(); if (params != null) { String name = params.getDescriptor().getName().getCode(); if (name != null && (name = name.trim()).length() != 0) { return name; } } } return Classes.getShortClassName(transform); }
/** Sets the metadata information for this format */ private void setInfo() { HashMap<String, String> info = new HashMap<String, String>(); info.put("name", "ImagePyramid"); info.put("description", "Image pyramidal plugin"); info.put("vendor", "Geotools"); info.put("docURL", ""); info.put("version", "1.0"); mInfo = info; // reading parameters. Inheriting them from the ImageMosaic final ImageMosaicFormat formatForParameters = new ImageMosaicFormat(); final ParameterValueGroup readParams = formatForParameters.getReadParameters(); final DefaultParameterDescriptorGroup descriptor = (DefaultParameterDescriptorGroup) readParams.getDescriptor(); List<GeneralParameterDescriptor> descriptors = descriptor.descriptors(); GeneralParameterDescriptor[] descriptorArray = new GeneralParameterDescriptor[descriptors.size()]; descriptorArray = descriptors.toArray(descriptorArray); readParameters = new ParameterGroup(new DefaultParameterDescriptorGroup(mInfo, descriptorArray)); // writing parameters writeParameters = null; }
/** * Prints the elements of a parameter group to the output stream. * * @param values The parameter group to format. * @throws IOException if an error occured will writing to the stream. */ public void format(final ParameterValueGroup values) throws IOException { final ParameterDescriptorGroup descriptor = values.getDescriptor(); synchronized (lock) { format(descriptor.getName().getCode(), descriptor, values); } }
/** * Work around for RFE #4093999 in Sun's bug database ("Relax constraint on placement of * this()/super() call in constructors"). */ private static OperationMethod getOperationMethod(final ParameterValueGroup parameters) { ensureNonNull("parameters", parameters); final ParameterDescriptorGroup descriptor = parameters.getDescriptor(); return new DefaultOperationMethod(getProperties(descriptor, null), 2, 2, descriptor); }
throws InvalidParameterNameException, InvalidParameterValueException { final ParameterDescriptorGroup parameters = getParameters(); final GeneralParameterDescriptor descriptor = values.getDescriptor(); if (parameters.equals(descriptor)) {
/** * Format the inner part of a <A * HREF="http://geoapi.sourceforge.net/snapshot/javadoc/org/opengis/referencing/doc-files/WKT.html"><cite>Well * Known Text</cite> (WKT)</A> element. * * @param formatter The formatter to use. * @return The WKT element name. */ public String formatWKT(final Formatter formatter) { final ParameterValueGroup parameters = getParameterValues(); formatter.append(formatter.getName(parameters.getDescriptor())); formatter.append(parameters); return "PARAM_MT"; }
/** * Checks if band selection is present, and can be delegated down to the reader * * @param reader * @param symbolizer * @return */ public static boolean isBandsSelectionApplicable( GridCoverageReader reader, RasterSymbolizer symbolizer) { int[] bandIndices = ChannelSelectionUpdateStyleVisitor.getBandIndicesFromSelectionChannels(symbolizer); return reader.getFormat() != null && reader.getFormat() .getReadParameters() .getDescriptor() .descriptors() .contains(AbstractGridFormat.BANDS) && bandIndices != null; }
/** * Print parameters for the specified projection. Used to see the if parameters for a transform * are correct. */ private void printParameters(final String proj) throws NoSuchIdentifierException { final ParameterValueGroup values = mtFactory.getDefaultParameters(proj); ParameterWriter.print(values.getDescriptor()); }
/** * Format the inner part of a <A * HREF="http://geoapi.sourceforge.net/snapshot/javadoc/org/opengis/referencing/doc-files/WKT.html"><cite>Well * Known Text</cite> (WKT)</A> element. The default implementation formats all parameter values * returned by {@link #getParameterValues}. The parameter group name is used as the math * transform name. * * @param formatter The formatter to use. * @return The WKT element name, which is {@code "PARAM_MT"} in the default implementation. */ @Override protected String formatWKT(final Formatter formatter) { final ParameterValueGroup parameters = getParameterValues(); if (parameters != null) { formatter.append(formatter.getName(parameters.getDescriptor())); formatter.append(parameters); } return "PARAM_MT"; }
/** * Format the inner part of a <A * HREF="http://geoapi.sourceforge.net/snapshot/javadoc/org/opengis/referencing/doc-files/WKT.html"><cite>Well * Known Text</cite> (WKT)</A> element. If this inverse math transform has any parameter * values, then this method format the WKT as in the {@linkplain * AbstractMathTransform#formatWKT super-class method}. Otherwise this method format the * math transform as an <code>"INVERSE_MT"</code> entity. * * @param formatter The formatter to use. * @return The WKT element name, which is <code>"PARAM_MT"</code> or <code>"INVERSE_MT" * </code> in the default implementation. */ @Override protected String formatWKT(final Formatter formatter) { final ParameterValueGroup parameters = getParameterValues(); if (parameters != null) { formatter.append(formatter.getName(parameters.getDescriptor())); formatter.append(parameters); return "PARAM_MT"; } else { formatter.append((Formattable) AbstractMathTransform.this); return "INVERSE_MT"; } } }
OperationMethod method = null; try { final String classification = parameters.getDescriptor().getName().getCode(); final MathTransformProvider provider = getProvider(classification); method = provider;
String name = getName(param, group.getDescriptor().getName().getAuthority()); if (name == null) { name = param.getName().getCode(); search = group.getDescriptor().descriptor(name); if (search instanceof ParameterDescriptor) { for (final GeneralParameterValue candidate : group.values()) {
/** * Test method for {@link * org.geotools.referencing.operation.transform.NADCONTransform#getParameterValues()}. */ @Test public void testGetParameterValues() { ParameterValueGroup pvg = transform.getParameterValues(); // Descriptor is the same as provider's assertEquals(pvg.getDescriptor(), NADCONTransform.Provider.PARAMETERS); // One single value assertEquals(pvg.values().size(), 2); Object value = pvg.parameter("Latitude difference file").getValue(); assertTrue(value instanceof URI); assertEquals(value.toString(), STPAUL_LAS); value = pvg.parameter("Longitude difference file").getValue(); assertTrue(value instanceof URI); assertEquals(value.toString(), STPAUL_LOS); }
/** * Test method for {@link * org.geotools.referencing.operation.transform.NTv2Transform#getParameterValues()}. */ @Test public void testGetParameterValues() { ParameterValueGroup pvg = transform.getParameterValues(); // Descriptor is the same as provider's assertEquals(pvg.getDescriptor(), NTv2Transform.Provider.PARAMETERS); // One single value assertEquals(pvg.values().size(), 1); // Value accessible through its identifiers Object value = pvg.parameter("8656").getValue(); assertTrue(value instanceof URI); assertEquals(value.toString(), TEST_GRID); value = pvg.parameter("Latitude and longitude difference file").getValue(); assertTrue(value instanceof URI); assertEquals(value.toString(), TEST_GRID); }
assertSame(ripd, rip.getDescriptor()); final ParameterValue p = rip.parameter("xPeriod"); assertSame(SPATIAL_SUBSAMPLING_X, p.getDescriptor());