/** * Same as {@link #getAndStore(ParameterDescriptor)}, but returns the given default value if the parameter * is not specified. This method shall be used only for parameters having a default value more complex than * what we can represent in {@link ParameterDescriptor#getDefaultValue()}. */ final double getAndStore(final ParameterDescriptor<Double> descriptor, final double defaultValue) { final Double value = parameters.getValue(descriptor); // Apply a unit conversion if needed. if (value == null) { return defaultValue; } MapProjection.validate(descriptor, value); context.getOrCreate(descriptor).setValue(value); return value; }
/** * Same as {@link #getAndStore(ParameterDescriptor)}, but returns the given default value if the parameter * is not specified. This method shall be used only for parameters having a default value more complex than * what we can represent in {@link ParameterDescriptor#getDefaultValue()}. */ final double getAndStore(final ParameterDescriptor<Double> descriptor, final double defaultValue) { final Double value = parameters.getValue(descriptor); // Apply a unit conversion if needed. if (value == null) { return defaultValue; } MapProjection.validate(descriptor, value); context.getOrCreate(descriptor).setValue(value); return value; }
/** * Gets a parameter value identified by the given descriptor and stores it in the {@link #context}. * A "contextual parameter" is a parameter that apply to the normalize → {@code this} → denormalize * chain as a whole. It does not really apply to a {@code NormalizedProjection} instance taken alone. * * <p>This method performs the following actions:</p> * <ul> * <li>Convert the value to the units specified by the descriptor.</li> * <li>Ensure that the value is contained in the range specified by the descriptor.</li> * <li>Store the value only if different than the default value.</li> * </ul> */ final double getAndStore(final ParameterDescriptor<? extends Number> descriptor) { if (descriptor == null) { return 0; // Default value for all parameters except scale factor. } /* * Get the parameter value, or its default value if the parameter was not set. That default value * (which is specified by the descriptor of the user-supplied parameters) is not necessarily the * same than the default value of the map projection implementation (which is specified by the * descriptor given in argument to this method). */ final double value = parameters.doubleValue(descriptor); // Apply a unit conversion if needed. final Number defaultValue = descriptor.getDefaultValue(); if (defaultValue == null || !defaultValue.equals(value)) { MapProjection.validate(descriptor, value); context.getOrCreate(descriptor).setValue(value); } return value; }
/** * Gets a parameter value identified by the given descriptor and stores it in the {@link #context}. * A "contextual parameter" is a parameter that apply to the normalize → {@code this} → denormalize * chain as a whole. It does not really apply to a {@code NormalizedProjection} instance taken alone. * * <p>This method performs the following actions:</p> * <ul> * <li>Convert the value to the units specified by the descriptor.</li> * <li>Ensure that the value is contained in the range specified by the descriptor.</li> * <li>Store the value only if different than the default value.</li> * </ul> */ final double getAndStore(final ParameterDescriptor<? extends Number> descriptor) { if (descriptor == null) { return 0; // Default value for most parameters except scale factor. } /* * Get the parameter value, or its default value if the parameter was not set. That default value * (which is specified by the descriptor of the user-supplied parameters) is not necessarily the * same than the default value of the map projection implementation (which is specified by the * descriptor given in argument to this method). */ final double value = parameters.doubleValue(descriptor); // Apply a unit conversion if needed. final Number defaultValue = descriptor.getDefaultValue(); if (defaultValue == null || !defaultValue.equals(value)) { MapProjection.validate(descriptor, value); context.getOrCreate(descriptor).setValue(value); } return value; }
/** * Gets a parameter value identified by the given descriptor and stores it only if different than zero. * This method performs the same work than {@code Initializer.getAndStore(ParameterDescriptor)} in the * {@link org.apache.sis.referencing.operation.projection} package. * * @param source the parameters from which to read the value. * @param target where to store the parameter values. * @param descriptor the descriptor that specify the parameter names and desired units. * @return the parameter value in the units given by the descriptor. * @throws IllegalArgumentException if the given value is out of bounds. */ private static double getAndStore(final Parameters source, final ParameterValueGroup target, final ParameterDescriptor<Double> descriptor) throws IllegalArgumentException { final double value = source.doubleValue(descriptor); // Apply a unit conversion if needed. MapProjection.validate(descriptor, value); // Unconditional validation for all parameters. if (value != 0) { // All default values in this class are zero. target.parameter(descriptor.getName().getCode()).setValue(value); } return value; }
/** * Gets a parameter value identified by the given descriptor and stores it only if different than zero. * This method performs the same work than {@code Initializer.getAndStore(ParameterDescriptor)} in the * {@link org.apache.sis.referencing.operation.projection} package. * * @param source the parameters from which to read the value. * @param target where to store the parameter values. * @param descriptor the descriptor that specify the parameter names and desired units. * @return the parameter value in the units given by the descriptor. * @throws IllegalArgumentException if the given value is out of bounds. */ private static double getAndStore(final Parameters source, final ParameterValueGroup target, final ParameterDescriptor<Double> descriptor) throws IllegalArgumentException { final double value = source.doubleValue(descriptor); // Apply a unit conversion if needed. MapProjection.validate(descriptor, value); // Unconditional validation for all parameters. if (value != 0) { // All default values in this class are zero. target.parameter(descriptor.getName().getCode()).setValue(value); } return value; }
final double getAndStore(final Parameters parameters, final ParameterDescriptor<Double> descriptor) { final double value = parameters.doubleValue(descriptor); // Apply a unit conversion if needed. final Double defaultValue = descriptor.getDefaultValue(); if (defaultValue == null || !defaultValue.equals(value)) { org.apache.sis.internal.referencing.provider.MapProjection.validate(descriptor, value); String name = IdentifiedObjects.getName(descriptor, parameters.getDescriptor().getName().getAuthority()); if (name == null) { name = descriptor.getName().getCode(); } getContextualParameters().parameter(name).setValue(value); } return value; }