public class ParameterBuilder extends Builder<ParameterBuilder>
ParameterDescriptor.createValue()
on the descriptor provided by the implementor.
createXXX(…)
method,
since those properties are specific to the each parameter. Other properties like codespace,
version and cardinality are left unchanged because they may be shared by many parameters.
addName(…)
methods. Parameters can optionally have an arbitrary amount of aliases, which are also specified
by the addName(…)
methods. Each call after the first one adds an alias.addIdentifier(…)
methods. Like names, more than one identifier can be
added by invoking the method many time.setRemarks(…)
method.ParameterDescriptorGroup
.
All parameters usually have the same namespace, which can be declared only once.
The following example creates parameters for "Mercator (variant A)"
projection method (EPSG:9804), previously known as "Mercator (1SP)",
centered by default on (0°,0°) with no scale factor and no false easting/northing.
The projection is valid from 80°S to 84°N and on all the longitude range (±180°).
In this example, the "Longitude of natural origin" parameter is giving different aliases
for illustrating the case of different softwares or standards using different conventions.
ParameterBuilder builder = new ParameterBuilder(); builder.setCodeSpace(Citations.EPSG, "EPSG") // The default namespace to be used below. .setRequired(true); // All parameters will be considered mandatory. // Constructs the list of parameters. ParameterDescriptor<?>[] parameters = { builder.addName("Latitude of natural origin") // Name in the default namespace ("EPSG" in this example). .createBounded( -80, +84, 0, NonSI.DEGREE_ANGLE), // Latitude of Mercator projection can not go to the poles. builder.addIdentifier("8802") // Primary key in default namespace ("EPSG" in this example). .addName("Longitude of natural origin") // Primary name in default namespace ("EPSG" in this example). .addName(Citations.OGC, "central_meridian") // First alias in "OGC" namespace. .addName(Citations.GEOTIFF, "NatOriginLong") // Second alias in "GeoTIFF" namespace. .createBounded(-180, +180, 0, NonSI.DEGREE_ANGLE), // Projection is valid on all the longitude range (±180°). builder.addName("Scale factor at natural origin") .createStrictlyPositive(1, Unit.ONE), builder.addName("False easting") .create(0, SI.METRE), builder.addName("False northing") .create(0, SI.METRE) }; // Put all above parameters in a group. ParameterDescriptorGroup group = builder .addIdentifier("9804") // Defined in implicit "EPSG" namespace. .addName ("Mercator (variant A)") // Defined in implicit "EPSG" namespace. .addName ("Mercator (1SP)") // Defined in implicit "EPSG" namespace. .addName (Citations.OGC, "Mercator_1SP") // "OGC" namespace explicitly shown by toString(). .addName (Citations.GEOTIFF, "CT_Mercator") // "GeoTIFF" namespace explicitly shown by toString(). .addIdentifier(Citations.GEOTIFF, "7") .setRemarks ("The “Mercator (1SP)” method name was used prior to October 2010.") .createGroupForMapProjection(parameters);
Defined in the sis-referencing
module
properties
Constructor and Description |
---|
ParameterBuilder()
Creates a new builder.
|
ParameterBuilder(GeneralParameterDescriptor descriptor)
Creates a new builder initialized to properties of the given object.
|
Modifier and Type | Method and Description |
---|---|
<T> ParameterDescriptor<T> |
create(Class<T> valueClass,
T defaultValue)
Creates a descriptor for values of the given type without domain restriction.
|
ParameterDescriptor<Double> |
create(double defaultValue,
Unit<?> unit)
Creates a descriptor for floating point values without domain restriction.
|
<T extends Comparable<? super T>> |
createBounded(Class<T> valueClass,
T minimumValue,
T maximumValue,
T defaultValue)
Creates a descriptor for values of the given type restricted to the given domain.
|
ParameterDescriptor<Double> |
createBounded(double minimumValue,
double maximumValue,
double defaultValue,
Unit<?> unit)
Creates a descriptor for floating point values restricted to the given domain.
|
ParameterDescriptor<Integer> |
createBounded(int minimumValue,
int maximumValue,
int defaultValue)
Creates a descriptor for integer values restricted to the given domain.
|
<T extends Comparable<? super T>> |
createBounded(Range<T> valueDomain,
T defaultValue)
Creates a descriptor for values in the domain represented by the given
Range object. |
<T> ParameterDescriptor<T> |
createEnumerated(Class<T> valueClass,
T[] validValues,
T defaultValue)
Creates a descriptor for a parameter restricted to a set of valid values.
|
ParameterDescriptorGroup |
createGroup(GeneralParameterDescriptor... parameters)
Creates a descriptor group for the given parameters.
|
ParameterDescriptorGroup |
createGroup(int minimumOccurs,
int maximumOccurs,
GeneralParameterDescriptor... parameters)
Creates a descriptor group for the given cardinality and parameters.
|
ParameterDescriptorGroup |
createGroupForMapProjection(ParameterDescriptor<?>... parameters)
Creates a descriptor group for a map projection.
|
ParameterDescriptor<Double> |
createStrictlyPositive(double defaultValue,
Unit<?> unit)
Creates a descriptor for floating point values greater than zero.
|
ParameterBuilder |
setRequired(boolean required)
Sets whether the parameter is mandatory or optional.
|
addIdentifier, addIdentifier, addIdentifier, addName, addName, addName, addName, addNamesAndIdentifiers, onCreate, rename, setCodeSpace, setDeprecated, setDescription, setRemarks, setVersion
public ParameterBuilder()
public ParameterBuilder(GeneralParameterDescriptor descriptor)
descriptor
- The descriptor from which to inherit properties, or null
.public ParameterBuilder setRequired(boolean required)
Default value:
If this method is never invoked, then the default value is false
.
Lifetime:
this property is kept unchanged until this setRequired(…)
method is invoked again.
required
- true
for a mandatory parameter, or false
for an optional one.this
, for method call chaining.public <T> ParameterDescriptor<T> create(Class<T> valueClass, T defaultValue)
T
- The compile-time type of the valueClass
argument.valueClass
- The class that describe the type of the parameter values.defaultValue
- The default value for the parameter, or null
if none.public ParameterDescriptor<Double> create(double defaultValue, Unit<?> unit)
double
values are considered valid.defaultValue
- The default value for the parameter, or Double.NaN
if none.unit
- The default unit, or null
if none.public ParameterDescriptor<Double> createStrictlyPositive(double defaultValue, Unit<?> unit)
defaultValue
- The default value for the parameter, or Double.NaN
if none.unit
- The default unit, or null
if none.public ParameterDescriptor<Double> createBounded(double minimumValue, double maximumValue, double defaultValue, Unit<?> unit)
minimumValue
- The minimum parameter value (inclusive), or Double.NEGATIVE_INFINITY
if none.maximumValue
- The maximum parameter value (inclusive), or Double.POSITIVE_INFINITY
if none.defaultValue
- The default value for the parameter, or Double.NaN
if none.unit
- The unit for default, minimum and maximum values, or null
if none.public ParameterDescriptor<Integer> createBounded(int minimumValue, int maximumValue, int defaultValue)
minimumValue
- The minimum parameter value (inclusive).maximumValue
- The maximum parameter value (inclusive).defaultValue
- The default value for the parameter.public <T extends Comparable<? super T>> ParameterDescriptor<T> createBounded(Class<T> valueClass, T minimumValue, T maximumValue, T defaultValue)
T
- The compile-time type of the valueClass
argument.valueClass
- The class that describe the type of the parameter values.minimumValue
- The minimum parameter value (inclusive), or null
if none.maximumValue
- The maximum parameter value (inclusive), or null
if none.defaultValue
- The default value for the parameter, or null
if none.public <T extends Comparable<? super T>> ParameterDescriptor<T> createBounded(Range<T> valueDomain, T defaultValue)
Range
object.
This method allows to specify whether the minimum and maximum values are inclusive or not.T
- The type of the parameter values.valueDomain
- The minimum value, maximum value and unit of measurement.defaultValue
- The default value for the parameter, or null
if none.public <T> ParameterDescriptor<T> createEnumerated(Class<T> valueClass, T[] validValues, T defaultValue)
The validValues
property is mostly for restricting values to
a code list or enumeration subset.
It is not necessary to provide this property when all values from the code list or enumeration are valid.
T
- The compile-time type of the valueClass
argument.valueClass
- The class that describe the type of the parameter values.validValues
- A finite set of valid values (usually from a code list or enumeration)
or null
if it doesn't apply.defaultValue
- The default value for the parameter, or null
if none.public ParameterDescriptorGroup createGroup(int minimumOccurs, int maximumOccurs, GeneralParameterDescriptor... parameters)
minimumOccurs
- The minimum
number of times that values for this parameter group are required.maximumOccurs
- The maximum
number of times that values for this parameter group are required.parameters
- The parameter descriptors
for the group to create.public ParameterDescriptorGroup createGroup(GeneralParameterDescriptor... parameters)
createGroup(int, int, GeneralParameterDescriptor[])
with a cardinality of [0 … 1]
or [1 … 1] depending on the value given to the last call to setRequired(boolean)
.parameters
- The parameter descriptors
for the group to create.public ParameterDescriptorGroup createGroupForMapProjection(ParameterDescriptor<?>... parameters)
DefaultMathTransformFactory
needs them.
In addition, this method adds hidden parameters for alternative ways to express some standard parameters. Those hidden parameters never appear in the list of parameters. However when one of those parameters is read or written, the work will be delegated to the standard parameters.
Name | Visibility | Comment |
---|---|---|
"semi_major" | Always | Standard parameter defined by WKT 1. |
"semi_minor" | Always | Standard parameter defined by WKT 1. |
"earth_radius" | Hidden | Mapped to "semi_major" and "semi_minor" parameters. |
"inverse_flattening" | Hidden | Computed from the "semi_major" and "semi_minor" parameters. |
"standard_parallel" | Hidden | Array of 1 or 2 elements mapped to "standard_parallel_1" and "standard_parallel_2" . |
"earth_radius"
parameter is read, its value is the
authalic radius
computed from the semi-major and semi-minor axis lengths.setRequired(boolean)
.parameters
- The parameter descriptors
for the group to create.DefaultMathTransformFactory.createBaseToDerived(CoordinateReferenceSystem, ParameterValueGroup, CoordinateSystem)
Copyright © 2010–2015 The Apache Software Foundation. All rights reserved.