Class MathTransformProvider
- Object
-
- Formattable
-
- AbstractIdentifiedObject
-
- DefaultOperationMethod
-
- MathTransformProvider
-
- All Implemented Interfaces:
Serializable
,IdentifiedObject
,OperationMethod
,PROJFormattable
- Direct Known Subclasses:
EarthGravitationalModel.Provider
,ExponentialTransform1D.Provider
,GeocentricTransform.Provider
,GeocentricTranslation.Provider
,LogarithmicTransform1D.Provider
,MapProjection.AbstractProvider
,MolodenskiTransform.Provider
,NADCONTransform.Provider
,NTv2Transform.Provider
,ProjectiveTransform.ProviderAffine
,ProjectiveTransform.ProviderLongitudeRotation
,SimilarityTransformProvider
,WarpTransform2DProvider
public abstract class MathTransformProvider extends DefaultOperationMethod
An operation method capable to creates a math transform from set of parameter values. Implementations of this class should be listed in the following file:META-INF/services/org.geotools.referencing.operation.MathTransformProvider
The math transform factory will parse this file in order to gets all available providers on a system. If this file is bundle in many JAR files, the math transform factory will read all of them.
- Since:
- 2.0
- Author:
- Martin Desruisseaux (IRD)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
MathTransformProvider.Delegate
The result of a call tocreateMathTransform
.
-
Field Summary
-
Fields inherited from class DefaultOperationMethod
sourceDimensions, targetDimensions
-
Fields inherited from class AbstractIdentifiedObject
EMPTY_ALIAS_ARRAY, EMPTY_IDENTIFIER_ARRAY, IDENTIFIER_COMPARATOR, NAME_COMPARATOR, REMARKS_COMPARATOR
-
Fields inherited from class Formattable
SINGLE_LINE
-
Fields inherited from interface IdentifiedObject
ALIAS_KEY, IDENTIFIERS_KEY, NAME_KEY, REMARKS_KEY
-
Fields inherited from interface OperationMethod
FORMULA_KEY
-
-
Constructor Summary
Constructors Constructor Description MathTransformProvider(int sourceDimensions, int targetDimensions, ParameterDescriptorGroup parameters)
Constructs a math transform provider from a set of parameters.MathTransformProvider(Map<String,?> properties, int sourceDimensions, int targetDimensions, ParameterDescriptorGroup parameters)
Constructs a math transform provider from a set of properties.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static ParameterDescriptor<Double>
createDescriptor(ReferenceIdentifier[] identifiers, double defaultValue, double minimum, double maximum, Unit<?> unit)
Constructs a parameter descriptor from a set of alias.protected static ParameterDescriptorGroup
createDescriptorGroup(ReferenceIdentifier[] identifiers, GeneralParameterDescriptor[] parameters)
Constructs a parameter group from a set of alias.protected abstract MathTransform
createMathTransform(ParameterValueGroup values)
Creates a math transform from the specified group of parameter values.protected static ParameterDescriptor<Double>
createOptionalDescriptor(ReferenceIdentifier[] identifiers, double minimum, double maximum, Unit<?> unit)
Constructs an optional parameter descriptor from a set of alias.protected static double
doubleValue(ParameterDescriptor<?> param, ParameterValueGroup group)
Returns the parameter value for the specified operation parameter.protected ParameterValueGroup
ensureValidValues(ParameterValueGroup values)
Ensures that the given set of parameters contains only valid values.protected String
formatWKT(Formatter formatter)
Format the inner part of a Well Known Text (WKT) element.Class<? extends Operation>
getOperationType()
Returns the operation type.protected static <T> ParameterValue<T>
getParameter(ParameterDescriptor<T> param, ParameterValueGroup group)
Returns the parameter value for the specified operation parameter.protected static int
intValue(ParameterDescriptor<?> param, ParameterValueGroup group)
Returns the parameter value for the specified operation parameter.protected static String
stringValue(ParameterDescriptor<?> param, ParameterValueGroup group)
Returns the parameter value for the specified operation parameter.protected static Map<String,Object>
toMap(ReferenceIdentifier... identifiers)
Put the identifiers into a properties map suitable forIdentifiedObject
constructor.protected static <T> T
value(ParameterDescriptor<T> param, ParameterValueGroup group)
Returns the parameter value for the specified operation parameter.-
Methods inherited from class DefaultOperationMethod
checkDimensions, equals, formatPROJ, getFormula, getParameters, getSourceDimensions, getTargetDimensions, hashCode
-
Methods inherited from class AbstractIdentifiedObject
asSet, ensureAngularUnit, ensureLinearUnit, ensureNonNull, ensureNonNull, ensureTimeUnit, equals, equals, equals, equals, getAlias, getIdentifier, getIdentifier, getIdentifiers, getName, getName, getName, getProperties, getProperties, getRemarks, nameMatches, nameMatches, nameMatches
-
Methods inherited from class Formattable
cleanupThreadLocals, toString, toWKT, toWKT, toWKT, toWKT
-
Methods inherited from interface IdentifiedObject
getAlias, getIdentifiers, getName, getRemarks, toWKT
-
-
-
-
Constructor Detail
-
MathTransformProvider
public MathTransformProvider(int sourceDimensions, int targetDimensions, ParameterDescriptorGroup parameters)
Constructs a math transform provider from a set of parameters. The provider identifiers will be the same than the parameter ones.- Parameters:
sourceDimensions
- Number of dimensions in the source CRS of this operation method.targetDimensions
- Number of dimensions in the target CRS of this operation method.parameters
- The set of parameters (nevernull
).
-
MathTransformProvider
public MathTransformProvider(Map<String,?> properties, int sourceDimensions, int targetDimensions, ParameterDescriptorGroup parameters)
Constructs a math transform provider from a set of properties. The properties map is given unchanged to the super-class constructor.- Parameters:
properties
- Set of properties. Should contains at least"name"
.sourceDimensions
- Number of dimensions in the source CRS of this operation method.targetDimensions
- Number of dimensions in the target CRS of this operation method.parameters
- The set of parameters (nevernull
).
-
-
Method Detail
-
getOperationType
public Class<? extends Operation> getOperationType()
Returns the operation type. It may beOperation.class
,Conversion.class
,Projection.class
, etc.The default implementation returns
Operation.class
. Subclass should overrides this methods and returns the appropriate OpenGIS interface type (not the implementation type).- Returns:
- The GeoAPI interface implemented by this operation.
-
createMathTransform
protected abstract MathTransform createMathTransform(ParameterValueGroup values) throws InvalidParameterNameException, ParameterNotFoundException, InvalidParameterValueException, FactoryException
Creates a math transform from the specified group of parameter values. Subclasses can implements this method as in the example below:double semiMajor = values.parameter("semi_major").doubleValue(SI.METRE); double semiMinor = values.parameter("semi_minor").doubleValue(SI.METRE); // etc... return new MyTransform(semiMajor, semiMinor, ...);
- Parameters:
values
- The group of parameter values.- Returns:
- The created math transform.
- Throws:
InvalidParameterNameException
- if the values contains an unknow parameter.ParameterNotFoundException
- if a required parameter was not found.InvalidParameterValueException
- if a parameter has an invalid value.FactoryException
- if the math transform can't be created for some other reason (for example a required file was not found).- See Also:
MathTransformProvider.Delegate
-
createDescriptor
protected static ParameterDescriptor<Double> createDescriptor(ReferenceIdentifier[] identifiers, double defaultValue, double minimum, double maximum, Unit<?> unit)
Constructs a parameter descriptor from a set of alias. The parameter is identified by codes provided by one or more authorities. Common authorities areOGC
andEPSG
for example.The first entry in the
identifiers
array is both the main name and the identifiers. All others are aliases.- Parameters:
identifiers
- The parameter identifiers. Most contains at least one entry.defaultValue
- The default value for the parameter, orDouble.NaN
if none.minimum
- The minimum parameter value, orDouble.NEGATIVE_INFINITY
if none.maximum
- The maximum parameter value, orDouble.POSITIVE_INFINITY
if none.unit
- The unit for default, minimum and maximum values.- Returns:
- The descriptor for the given identifiers.
-
createOptionalDescriptor
protected static ParameterDescriptor<Double> createOptionalDescriptor(ReferenceIdentifier[] identifiers, double minimum, double maximum, Unit<?> unit)
Constructs an optional parameter descriptor from a set of alias. The parameter is identified as withcreateDescriptor(org.geotools.api.referencing.ReferenceIdentifier[], double, double, double, javax.measure.Unit<?>)
.- Parameters:
identifiers
- The parameter identifiers. Most contains at least one entry.minimum
- The minimum parameter value, orDouble.NEGATIVE_INFINITY
if none.maximum
- The maximum parameter value, orDouble.POSITIVE_INFINITY
if none.unit
- The unit for default, minimum and maximum values.- Returns:
- The descriptor for the given identifiers.
-
createDescriptorGroup
protected static ParameterDescriptorGroup createDescriptorGroup(ReferenceIdentifier[] identifiers, GeneralParameterDescriptor[] parameters)
Constructs a parameter group from a set of alias. The parameter group is identified by codes provided by one or more authorities. Common authorities areOGC
andEPSG
for example.Special rules:
- The first entry in the
identifiers
array is the primary name. - If a an entry do not implements the
GenericName
interface, it is an identifiers. - All others are aliases.
- Parameters:
identifiers
- The operation identifiers. Most contains at least one entry.parameters
- The set of parameters, ornull
or an empty array if none.- Returns:
- The descriptor for the given identifiers.
- The first entry in the
-
toMap
protected static Map<String,Object> toMap(ReferenceIdentifier... identifiers)
Put the identifiers into a properties map suitable forIdentifiedObject
constructor.
-
ensureValidValues
protected ParameterValueGroup ensureValidValues(ParameterValueGroup values) throws InvalidParameterNameException, InvalidParameterValueException
Ensures that the given set of parameters contains only valid values. This method compares all parameter names against the names declared in the operation method parameter descriptor. If an unknow parameter name is found, then anInvalidParameterNameException
is thrown. This method also ensures that all values are assignable to the expected class, are between the minimum and maximum values and are one of the set of valid values. If the value fails any of those tests, then anInvalidParameterValueException
is thrown.- Parameters:
values
- The parameters values to check.- Returns:
- The parameter values to use for math transform
construction. May be different than the supplied
values
argument if some missing values needed to be filled with default values. - Throws:
InvalidParameterNameException
- if a parameter name is unknow.InvalidParameterValueException
- if a parameter has an invalid value.
-
getParameter
protected static <T> ParameterValue<T> getParameter(ParameterDescriptor<T> param, ParameterValueGroup group) throws ParameterNotFoundException
Returns the parameter value for the specified operation parameter. This convenience method is used by subclasses for initializing math transform from a set of parameters.- Parameters:
param
- The parameter to look for.group
- The parameter value group to search into.- Returns:
- The requested parameter value.
- Throws:
ParameterNotFoundException
- if the parameter is not found.
-
value
protected static <T> T value(ParameterDescriptor<T> param, ParameterValueGroup group) throws ParameterNotFoundException
Returns the parameter value for the specified operation parameter. This convenience method is used by subclasses for initializing math transform from a set of parameters.- Type Parameters:
T
- The type of parameter value.- Parameters:
param
- The parameter to look for.group
- The parameter value group to search into.- Returns:
- The requested parameter value, or
null
ifparam
is optional and the user didn't provided any value. - Throws:
ParameterNotFoundException
- if the parameter is not found.
-
stringValue
protected static String stringValue(ParameterDescriptor<?> param, ParameterValueGroup group) throws ParameterNotFoundException
Returns the parameter value for the specified operation parameter. This convenience method is used by subclasses for initializing math transform from a set of parameters.- Parameters:
param
- The parameter to look for.group
- The parameter value group to search into.- Returns:
- The requested parameter value, or
null
ifparam
is optional and the user didn't provided any value. - Throws:
ParameterNotFoundException
- if the parameter is not found.
-
intValue
protected static int intValue(ParameterDescriptor<?> param, ParameterValueGroup group) throws ParameterNotFoundException
Returns the parameter value for the specified operation parameter. This convenience method is used by subclasses for initializing math transform from a set of parameters.- Parameters:
param
- The parameter to look for.group
- The parameter value group to search into.- Returns:
- The requested parameter value, or
0
ifparam
is optional and the user didn't provided any value. - Throws:
ParameterNotFoundException
- if the parameter is not found.
-
doubleValue
protected static double doubleValue(ParameterDescriptor<?> param, ParameterValueGroup group) throws ParameterNotFoundException
Returns the parameter value for the specified operation parameter. Values are automatically converted into the standard units specified by the suppliedparam
argument. This convenience method is used by subclasses for initializing math transform from a set of parameters.- Parameters:
param
- The parameter to look for.group
- The parameter value group to search into.- Returns:
- The requested parameter value, or
NaN
ifparam
is optional and the user didn't provided any value. - Throws:
ParameterNotFoundException
- if the parameter is not found.
-
formatWKT
protected String formatWKT(Formatter formatter)
Format the inner part of a Well Known Text (WKT) element.- Overrides:
formatWKT
in classDefaultOperationMethod
- Parameters:
formatter
- The formatter to use.- Returns:
- The WKT element name.
- See Also:
Formattable.toWKT()
,Formattable.toString()
-
-