/** * Utility methods for find param by key * * @param params DOCUMENT ME! * @param key DOCUMENT ME! * @return DOCUMENT ME! */ public static ParameterValue find(ParameterValueGroup params, String key) { List list = params.values(); Iterator it = list.iterator(); ParameterDescriptor descr; ParameterValue val; while (it.hasNext()) { val = (ParameterValue) it.next(); descr = (ParameterDescriptor) val.getDescriptor(); if (key.equalsIgnoreCase(descr.getName().toString())) { return val; } } return null; }
final ParameterDescriptor descr = (ParameterDescriptor) val.getDescriptor(); final String _key = descr.getName().toString();
final ParameterDescriptor descr = (ParameterDescriptor) val.getDescriptor();
descr = (ParameterDescriptor) val.getDescriptor();
final Class<? extends Object> target = param.getDescriptor().getValueClass(); if (key.equalsIgnoreCase("InputTransparentColor") || key.equalsIgnoreCase("OutputTransparentColor")) {
final ParameterDescriptor<?> descr = val.getDescriptor(); final String _key = descr.getName().toString();
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; }
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) {
/** * Create the coverageReadRequest on top of the specified read params * * @param params * @return * @throws IOException */ private CoverageReadRequest setupCoverageRequest( GeneralParameterValue[] params, final CoverageSource gridSource) throws IOException { CoverageReadRequest request = new CoverageReadRequest(); if (params != null) { for (GeneralParameterValue gParam : params) { if (gParam instanceof ParameterValue<?>) { final ParameterValue<?> param = (ParameterValue<?>) gParam; final ReferenceIdentifier name = param.getDescriptor().getName(); try { extractParameter(param, name, request, gridSource); } catch (Exception e) { throw new IOException(e); } } } } return request; }
/** * Returns the value in this group for the specified identifier code. Getter and setter methods * will use directly the JAI's {@linkplain #parameters parameter list} as the underlying backing * store, when applicable. * * @param name The case insensitive identifier code of the parameter to search for. * @return The parameter value for the given identifier code. * @throws ParameterNotFoundException if there is no parameter value for the given identifier * code. */ public synchronized ParameterValue parameter(String name) throws ParameterNotFoundException { ensureNonNull("name", name); name = name.trim(); final List<GeneralParameterValue> values = values(); final int size = values.size(); for (int i = 0; i < size; i++) { final ParameterValue value = (ParameterValue) values.get(i); if (AbstractIdentifiedObject.nameMatches(value.getDescriptor(), name)) { return value; } } throw new ParameterNotFoundException( Errors.format(ErrorKeys.MISSING_PARAMETER_$1, name), name); }
/** * Casts the given parameter value to the given type. An exception is thrown immediately if the * parameter does not have the expected value class. This is a helper method for type safety * when using Java 5 parameterized types. * * @param <T> The expected value class. * @param value The value to cast. * @param type The expected value class. * @return The value casted to the given type. * @throws ClassCastException if the given value doesn't have the expected value class. * @since 2.5 */ @SuppressWarnings("unchecked") public static <T> ParameterValue<T> cast(final ParameterValue<?> value, final Class<T> type) throws ClassCastException { if (value != null) { final ParameterDescriptor descriptor = value.getDescriptor(); final Class<?> actual = descriptor.getValueClass(); if (!type.equals(actual)) { // Same comment than cast(ParameterDescriptor)... throw new ClassCastException( Errors.format( ErrorKeys.BAD_PARAMETER_TYPE_$2, descriptor.getName().getCode(), actual)); } } return (ParameterValue) value; }
final ParameterValue param = (ParameterValue) parameters; final Object value = param.getValue(); final Object old = destination.put(param.getDescriptor().getName().getCode(), value); if (old != null && !old.equals(value)) {
final ParameterDescriptor<?> descriptor = parameter.getDescriptor(); final Object value = parameter.getValue(); if (value == null) {
/** * Build a new {@code CoverageRequest} given a set of input parameters. * * @param params The {@code GeneralParameterValue}s to initialize this request * @param baseGridCoverage2DReader */ public RasterLayerRequest(GeneralParameterValue[] params, BaseGridCoverage2DReader reader) { // // // // Parsing parameters // // // if (params != null) { for (GeneralParameterValue gParam : params) { final ParameterValue<?> param = (ParameterValue<?>) gParam; final ReferenceIdentifier name = param.getDescriptor().getName(); extractParameter(param, name); } } setDefaultParameters(); setBaseParameters(reader); }
continue; final String name = param.getDescriptor().getName().getCode(); if (name.equals(AbstractGridFormat.READ_GRIDGEOMETRY2D.getName().toString())) { final GridGeometry2D gg = (GridGeometry2D) param.getValue();
for (int i = 0; i < length; i++) { 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();
if (gParam instanceof ParameterValue<?>) { final ParameterValue<?> param = (ParameterValue<?>) gParam; final ReferenceIdentifier name = param.getDescriptor().getName(); extractParameter(param, name);
private static GeneralDirectPosition getProjectionCenterLonLat( CoordinateReferenceSystem crs, GeneralDirectPosition centerPt) { // set defaults centerPt.setOrdinate(0, 0); centerPt.setOrdinate(1, 0); MapProjection projection = getMapProjection(crs); if (projection == null) { return centerPt; } for (GeneralParameterValue gpv : projection.getParameterValues().values()) { // for safety if (!(gpv instanceof ParameterValue)) { continue; } ParameterValue pv = (ParameterValue) gpv; ReferenceIdentifier pvName = pv.getDescriptor().getName(); if (MapProjection.AbstractProvider.LATITUDE_OF_ORIGIN.getName().equals(pvName)) { centerPt.setOrdinate(1, pv.doubleValue()); } else if (MapProjection.AbstractProvider.LATITUDE_OF_CENTRE.getName().equals(pvName)) { centerPt.setOrdinate(1, pv.doubleValue()); } else if (MapProjection.AbstractProvider.LONGITUDE_OF_CENTRE .getName() .equals(pvName)) { centerPt.setOrdinate(0, pv.doubleValue()); } else if (MapProjection.AbstractProvider.CENTRAL_MERIDIAN.getName().equals(pvName)) { centerPt.setOrdinate(0, pv.doubleValue()); } } return centerPt; }
for (int i = 0; i < params.length; i++) { 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();
for (int i = 0; i < params.length; i++) { 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();