/** * Returns the parameters descriptors in this group. The amount of parameters depends on the * value of <code>"num_row"</code> and <code>"num_col"</code> parameters. */ public List<GeneralParameterDescriptor> descriptors() { return ((MatrixParameterDescriptors) descriptor) .descriptors(numRow.intValue(), numCol.intValue()); }
/** * Returns the value in this group for a matrix element at the specified index. Row and column * index are 0 based. * * @param row The row indice. * @param column The column indice * @return The parameter value for the specified matrix element (never {@code null}). * @throws IndexOutOfBoundsException if {@code row} or {@code column} is out of bounds. */ public final ParameterValue<Double> parameter(final int row, final int column) throws IndexOutOfBoundsException { return parameter(row, column, numRow.intValue(), numCol.intValue()); }
/** * Returns the parameter in this group for the specified name. The name can be a matrix element * if it uses the following syntax: <code>"elt_<var>row</var>_<var>col</var>"</code> where * <code>"elt_"</code> is the {@linkplain MatrixParameterDescriptors#prefix prefix} for all * matrix elements, and <var>row</var> and <var>col</var> are row and column indices * respectively. For example <code>"elt_2_1"</code> is the element name for the value at line 2 * and row 1. The row and column index are 0 based. * * @param name The case insensitive name of the parameter to search for. * @return The parameter for the given name. * @throws ParameterNotFoundException if there is no parameter for the given name. */ public GeneralParameterDescriptor descriptor(final String name) throws ParameterNotFoundException { return ((MatrixParameterDescriptors) descriptor) .descriptor(name, numRow.intValue(), numCol.intValue()); }
/** * Returns the parameter value for the specified operation parameter. This convenience method is * used by subclasses for initializing {@linkplain MathTransform math transform} from a set of * parameters. * * @param param The parameter to look for. * @param group The parameter value group to search into. * @return The requested parameter value, or {@code 0} if {@code param} is {@linkplain * #createOptionalDescriptor optional} and the user didn't provided any value. * @throws ParameterNotFoundException if the parameter is not found. * @todo Move to the {@link org.geotools.parameter.Parameters} class. */ protected static int intValue( final ParameterDescriptor<?> param, final ParameterValueGroup group) throws ParameterNotFoundException { final ParameterValue<?> value = getParameter(param, group); return (value != null) ? value.intValue() : 0; }
/** * Creates a matrix from this group of parameters. * * @return A matrix created from this group of parameters. */ public Matrix getMatrix() { final int numRow = this.numRow.intValue(); final int numCol = this.numCol.intValue(); final Matrix matrix = MatrixFactory.create(numRow, numCol); if (matrixValues != null) { for (int j = 0; j < numRow; j++) { final ParameterValue[] row = matrixValues[j]; if (row != null) { for (int i = 0; i < numCol; i++) { final ParameterValue element = row[i]; if (element != null) { matrix.setElement(j, i, element.doubleValue()); } } } } } return matrix; }
/** Compare this object with the specified one for equality. */ @Override public boolean equals(final Object object) { if (object == this) { return true; // Slight optimization. } if (super.equals(object)) { final MatrixParameters that = (MatrixParameters) object; final int numRow = this.numRow.intValue(); final int numCol = this.numCol.intValue(); for (int j = 0; j < numRow; j++) { for (int i = 0; i < numCol; i++) { if (!Utilities.equals( this.parameter(j, i, numRow, numCol), that.parameter(j, i, numRow, numCol))) { return false; } } } return true; } return false; }
/** * Returns the current tensor size for each dimensions. */ private int[] size() { final int[] indices = new int[dimensions.length]; for (int i=0; i<indices.length; i++) { indices[i] = dimensions[i].intValue(); } return indices; }
/** * Returns the current tensor size for each dimensions. */ private int[] size() { final int[] indices = new int[dimensions.length]; for (int i=0; i<indices.length; i++) { indices[i] = dimensions[i].intValue(); } return indices; }
"'yPeriod' should still backed by the ParameterList.", 2, rip.parameter("yPeriod").intValue());
/** * Returns the integer value of the parameter identified by the given descriptor. * See {@link #getValue(ParameterDescriptor)} for more information about how this * method uses the given {@code parameter} argument. * * @param parameter the name or alias of the parameter to look for. * @return the requested parameter value if it exists, or the <strong>non-null</strong> * {@linkplain DefaultParameterDescriptor#getDefaultValue() default value} otherwise. * @throws ParameterNotFoundException if the given {@code parameter} name or alias is not legal for this group. * @throws IllegalStateException if the value is not defined and there is no default value. * * @see DefaultParameterValue#intValue() * * @since 0.6 */ public int intValue(final ParameterDescriptor<? extends Number> parameter) throws ParameterNotFoundException { final ParameterValue<?> value = getParameter(parameter); return (value != null) ? value.intValue() : defaultValue(parameter).intValue(); }
assertSame("parameter(\"2\")", v2, group.parameter("2")); assertSame("parameter(\"3\")", v3, group.parameter("3")); assertEquals("parameter(\"1\")", 10, group.parameter("1").intValue()); assertEquals("parameter(\"2\")", 20, group.parameter("2").intValue()); assertEquals("parameter(\"3\")", 30, group.parameter("3").intValue()); assertFalse("add(v2b)", content.add(v2b)); // Already present assertFalse("add(v3b)", content.add(v3b)); // Already present assertEquals("parameter(\"1b\")", -10, group.parameter("1").intValue()); assertEquals("parameter(\"2b\")", -20, group.parameter("2").intValue()); assertEquals("parameter(\"3b\")", -30, group.parameter("3").intValue()); assertEquals("values.size()", 3, content.size()); assertFalse("add(v2b)", content.add(v2b)); // Already present assertFalse("add(v3b)", content.add(v3b)); // Already present assertEquals("parameter(\"1b\")", -10, group.parameter("1").intValue()); assertEquals("parameter(\"2b\")", -20, group.parameter("2").intValue()); assertEquals("parameter(\"3b\")", -30, group.parameter("3").intValue()); assertEquals("values.size()", 3, content.size());
/** * Returns the integer value of the parameter identified by the given descriptor. * See {@link #getValue(ParameterDescriptor)} for more information about how this * method uses the given {@code parameter} argument. * * @param parameter the name or alias of the parameter to look for. * @return the requested parameter value if it exists, or the <strong>non-null</strong> * {@linkplain DefaultParameterDescriptor#getDefaultValue() default value} otherwise. * @throws ParameterNotFoundException if the given {@code parameter} name or alias is not legal for this group. * @throws IllegalStateException if the value is not defined and there is no default value. * * @see DefaultParameterValue#intValue() * * @since 0.6 */ public int intValue(final ParameterDescriptor<? extends Number> parameter) throws ParameterNotFoundException { final ParameterValue<?> value = getParameter(parameter); return (value != null) ? value.intValue() : defaultValue(parameter).intValue(); }
@Override public CoordinateReferenceSystem getCRS(final GeoPos referencePos, ParameterValueGroup parameters, GeodeticDatum datum) throws FactoryException { int zoneIndex = parameters.parameter(ZONE_NAME).intValue(); String hemisphere1 = parameters.parameter(HEMISPHERE_NAME).stringValue(); boolean south = (SOUTH_HEMISPHERE.equals(hemisphere1)); ParameterValueGroup tmParameters = createTransverseMercatorParameters(zoneIndex, south, datum); return createCrs(getProjectionName(zoneIndex, south), new TransverseMercator.Provider(), tmParameters, datum); }
@Override public CoordinateReferenceSystem getCRS(final GeoPos referencePos, ParameterValueGroup parameters, GeodeticDatum datum) throws FactoryException { int zoneIndex = parameters.parameter(ZONE_NAME).intValue(); String hemisphere1 = parameters.parameter(HEMISPHERE_NAME).stringValue(); boolean south = (SOUTH_HEMISPHERE.equals(hemisphere1)); ParameterValueGroup tmParameters = createTransverseMercatorParameters(zoneIndex, south, datum); return createCrs(getProjectionName(zoneIndex, south), new TransverseMercator.Provider(), tmParameters, datum); }
assertEquals("minimum", 4.0, dDescriptor.getMinimumValue()); assertEquals("maximum", 20.0, dDescriptor.getMaximumValue()); assertEquals("value", 12, parameter.intValue()); assertEquals("unit", SI.METRE, parameter.getUnit()); for (int i = 4; i <= 20; i++) {
@Override protected UtmProjection createProjection(final ParameterValueGroup p) { if (p == null) return new UtmProjection(); return new UtmProjection(value(p, CF.SEMI_MAJOR_AXIS), value(p, CF.INVERSE_FLATTENING), p.parameter(UtmProjection.UTM_ZONE1).intValue(), p.parameter("north_hemisphere").booleanValue()); } }
/** * Tests {@code DefaultParameterValueGroup.values().clear()}. */ @Test @DependsOnMethod("testParameter") public void testValuesClear() { final DefaultParameterValueGroup group = createGroup(10); final List<GeneralParameterValue> values = group.values(); assertEquals("size", 4, values.size()); assertEquals("parameter(“Mandatory 2”)", 20, group.parameter("Mandatory 2").intValue()); values.clear(); assertEquals("size", 2, values.size()); assertEquals("parameter(“Mandatory 2”)", DefaultParameterDescriptorGroupTest.DEFAULT_VALUE, group.parameter("Mandatory 2").getValue()); }