/** * 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 String _key = descr.getName().toString();
final ParameterDescriptor descr = (ParameterDescriptor) val.getDescriptor(); final String _key = descr.getName().toString();
descr = (ParameterDescriptor) val.getDescriptor(); key = descr.getName().toString(); value = null;
final String _key = descr.getName().toString();
/** 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; } }
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; }
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()]); }
@Test public void testMaxTiles() { ParameterDescriptor<Integer> pdescriptor = ImageMosaicFormat.MAX_ALLOWED_TILES; ParameterValue<Integer> pvalue = pdescriptor.createValue(); String key = pdescriptor.getName().getCode(); Map values = Collections.singletonMap(key, "1"); Object value = CoverageUtils.getCvParamValue(key, pvalue, values); assertTrue(value instanceof Integer); assertEquals(Integer.valueOf(1), value); } }
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) {
String maxAllowedTiles = ImageMosaicFormat.MAX_ALLOWED_TILES.getName().toString(); if (parameters.keySet().contains(maxAllowedTiles)) { parameters.put(maxAllowedTiles, 1);
@Test public void testGetOutputTransparentColor() { ParameterDescriptor<Color> pdescriptor = ImageMosaicFormat.OUTPUT_TRANSPARENT_COLOR; ParameterValue<Color> pvalue = pdescriptor.createValue(); String key = pdescriptor.getName().getCode(); Map values = Collections.singletonMap(key, "0xFFFFFF"); Object value = CoverageUtils.getCvParamValue(key, pvalue, values); assertTrue(value instanceof Color); assertEquals(Color.WHITE, value); }
@Test public void testMosaicParameters() throws Exception { // build a mosaic with 1025 files (the standard ulimit is 1024) File mosaic = new File("./target/smallMosaic"); try { createTimeMosaic(mosaic, 4); // now configure a new store based on it Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); CoverageStoreInfo store = cb.buildCoverageStore("smallMosaic"); store.setURL(mosaic.getAbsolutePath()); store.setType("ImageMosaic"); cat.add(store); // and configure also the coverage cb.setStore(store); CoverageInfo ci = cb.buildCoverage(); cat.add(ci); // check the parameters have the default values assertEquals( String.valueOf(-1), ci.getParameters() .get(ImageMosaicFormat.MAX_ALLOWED_TILES.getName().toString())); assertEquals("", ci.getParameters().get(ImageMosaicFormat.FILTER.getName().toString())); cat.getResourcePool().dispose(); } finally { if (mosaic.exists() && mosaic.isDirectory()) { FileUtils.deleteDirectory(mosaic); } } }
public boolean isParameterSupported(ReferenceIdentifier name) throws IOException { getDynamicParameters(); if (dynamicParameters != null && !dynamicParameters.isEmpty()) { for (ParameterDescriptor<List> desc : dynamicParameters) { if (desc.getName().equals(name)) { return true; } } } return false; }
private void logRequestParams(GeneralParameterValue[] params) { LOGGER.info("----PARAMS START-------"); for (int i = 0; i < params.length; i++) { Parameter<Object> p = (Parameter<Object>) params[i]; LOGGER.info(p.getDescriptor().getName().toString() + ": " + p.getValue()); } LOGGER.info("----PARAMS END-------"); }
/** Ensures the the specified parameter is valid. */ private static void ensureValid(final ParameterDescriptor param, double value) { if (!(value > 0)) { throw new IllegalStateException( Errors.format(ErrorKeys.MISSING_PARAMETER_$1, param.getName().getCode())); } } }
/** * Crops the image to a specified clipping area * * @param source The source coverage. * @param envelope The cutting geometr * @throws CoverageProcessingException if the operation can't be applied. * @see org.geotools.coverage.processing.operation.Crop */ public Coverage crop(final Coverage Source, final Geometry roi) throws CoverageProcessingException { return doOperation("CoverageCrop", Source, Crop.CROP_ROI.getName().getCode(), roi); }
/** Extracts the {@link ParameterValue} for a certain {@link ParameterDescriptor} */ ParameterValue parameter(ParameterDescriptor param, ParameterValueGroup group) { return group.parameter(param.getName().getCode()); }
/** Extracts the {@link ParameterValue} for a certain {@link ParameterDescriptor} */ ParameterValue<?> parameter(ParameterDescriptor<?> param, ParameterValueGroup group) { return group.parameter(param.getName().getCode()); }
/** * Make a simple spherical Mercator (Google Mercator) CRS. We just use this as a simple example * of a MapProjection since that class is abstract. */ private static MapProjection createGoogleMercator() throws FactoryException { MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null); final ParameterValueGroup parameters = mtFactory.getDefaultParameters("Mercator_1SP"); parameters.parameter(SEMI_MAJOR.getName().getCode()).setValue(6378137.0); parameters.parameter(SEMI_MINOR.getName().getCode()).setValue(6378137.0); return (MapProjection) mtFactory.createParameterizedTransform(parameters); }