Class DimensionFilter
- Object
-
- DimensionFilter
-
public class DimensionFilter extends Object
An utility class for the separation of concatenation of pass through transforms. Given an arbitrary math transform, this utility class will returns a new math transform that operates only of a given set of source dimensions. For example if the suppliedtransform
has (x, y, z) inputs and (longitude, latitude, height) outputs, then the following code:addSourceDimensionRange(0, 2); MathTransform mt = separate(transform);
will returns a transform with (x, y) inputs and (probably) (longitude, latitude) outputs. The later can be verified with a call to
getTargetDimensions()
.- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD), Simone Giannecchini
-
-
Constructor Summary
Constructors Constructor Description DimensionFilter()
Constructs a dimension filter with the default math transform factory.DimensionFilter(MathTransformFactory factory)
Constructs a dimension filter with the specified factory.DimensionFilter(Hints hints)
Constructs a dimension filter with a math transform factory built using the provided hints.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSourceDimension(int dimension)
Add an input dimension to keep.void
addSourceDimensionRange(int lower, int upper)
Add a range of input dimensions to keep.void
addSourceDimensions(int[] dimensions)
Add input dimensions to keep.void
addTargetDimension(int dimension)
Add an output dimension to keep.void
addTargetDimensionRange(int lower, int upper)
Add a range of output dimensions to keep.void
addTargetDimensions(int[] dimensions)
Add output dimensions to keep.void
clear()
Clears any source and target dimension setting.static DimensionFilter
getInstance(Hints hints)
Creates or returns an existing instance from the given set of hints.int[]
getSourceDimensions()
Returns the input dimensions.int[]
getTargetDimensions()
Returns the output dimensions.MathTransform
separate(MathTransform transform)
Separates the specified math transform.
-
-
-
Field Detail
-
INSTANCE
public static final Hints.Key INSTANCE
Hint key for specifying a particular instance ofDimensionFilter
to use.- Since:
- 2.5
- See Also:
getInstance(org.geotools.util.factory.Hints)
-
-
Constructor Detail
-
DimensionFilter
public DimensionFilter()
Constructs a dimension filter with the default math transform factory.
-
DimensionFilter
public DimensionFilter(Hints hints)
Constructs a dimension filter with a math transform factory built using the provided hints.- Parameters:
hints
- Hints to control the creation of theMathTransformFactory
.
-
DimensionFilter
public DimensionFilter(MathTransformFactory factory)
Constructs a dimension filter with the specified factory.- Parameters:
factory
- The factory for the creation of new math transforms.
-
-
Method Detail
-
getInstance
public static DimensionFilter getInstance(Hints hints)
Creates or returns an existing instance from the given set of hints. If the hints contain a value for theINSTANCE
key, this value is returned. Otherwise a new instance is created with the given hints.- Parameters:
hints
- The hints, ornull
if none.- Returns:
- An existing or a new
DimensionFilter
instance (nevernull
). - Since:
- 2.5
- See Also:
INSTANCE
-
clear
public void clear()
Clears any source and target dimension setting.
-
addSourceDimension
public void addSourceDimension(int dimension) throws IllegalArgumentException
Add an input dimension to keep. Thedimension
applies to the source dimensions of the transform to be given toseparate(transform)
. The number must be in the range 0 inclusive totransform.getSourceDimensions()
exclusive.- Parameters:
dimension
- The dimension to add.- Throws:
IllegalArgumentException
- ifdimension
is negative.
-
addSourceDimensions
public void addSourceDimensions(int[] dimensions) throws IllegalArgumentException
Add input dimensions to keep. Thedimensions
apply to the source dimensions of the transform to be given toseparate(transform)
. All numbers must be in the range 0 inclusive totransform.getSourceDimensions()
exclusive. Thedimensions
values must be in strictly increasing order.- Parameters:
dimensions
- The new sequence of dimensions.- Throws:
IllegalArgumentException
- ifdimensions
contains negative values or is not a strictly increasing sequence.
-
addSourceDimensionRange
public void addSourceDimensionRange(int lower, int upper) throws IllegalArgumentException
Add a range of input dimensions to keep. Thelower
andupper
values apply to the source dimensions of the transform to be given toseparate(transform)
.- Parameters:
lower
- The lower dimension, inclusive. Must not be smaller than 0.upper
- The upper dimension, exclusive. Must not be greater thantransform.getSourceDimensions()
.- Throws:
IllegalArgumentException
-
getSourceDimensions
public int[] getSourceDimensions() throws IllegalStateException
Returns the input dimensions. This information is available only if at least one setter method has been explicitly invoked for source dimensions.- Returns:
- The input dimension as a sequence of strictly increasing values.
- Throws:
IllegalStateException
- if input dimensions have not been set.
-
addTargetDimension
public void addTargetDimension(int dimension) throws IllegalArgumentException
Add an output dimension to keep. Thedimension
applies to the target dimensions of the transform to be given toseparate(transform)
. The number must be in the range 0 inclusive totransform.getTargetDimensions()
exclusive.- Parameters:
dimension
- The dimension to add.- Throws:
IllegalArgumentException
- ifdimension
is negative.
-
addTargetDimensions
public void addTargetDimensions(int[] dimensions) throws IllegalArgumentException
Add output dimensions to keep. Thedimensions
apply to the target dimensions of the transform to be given toseparate(transform)
. All numbers must be in the range 0 inclusive totransform.getTargetDimensions()
exclusive. Thedimensions
values must be in strictly increasing order.- Parameters:
dimensions
- The new sequence of dimensions.- Throws:
IllegalArgumentException
- ifdimensions
contains negative values or is not a strictly increasing sequence.
-
addTargetDimensionRange
public void addTargetDimensionRange(int lower, int upper) throws IllegalArgumentException
Add a range of output dimensions to keep. Thelower
andupper
values apply to the target dimensions of the transform to be given toseparate(transform)
.- Parameters:
lower
- The lower dimension, inclusive. Must not be smaller than 0.upper
- The upper dimension, exclusive. Must not be greater thantransform.getTargetDimensions()
.- Throws:
IllegalArgumentException
-
getTargetDimensions
public int[] getTargetDimensions() throws IllegalStateException
Returns the output dimensions. This information is available only if one of the following conditions is meet:- Target dimensions has been explicitly set using setter methods.
- No target dimensions were set but
separate(transform)
has been invoked at least once, in which case the target dimensions are inferred automatically from the source dimensions and thetransform
.
- Returns:
- The output dimension as a sequence of strictly increasing values.
- Throws:
IllegalStateException
- if this information is not available.
-
separate
public MathTransform separate(MathTransform transform) throws FactoryException
Separates the specified math transform. This method returns a math transform that uses only the specified source dimensions and returns only the specified target dimensions. Special case:-
If source dimensions are unspecified, then the returned transform will expects all source dimensions as input but will produces only the specified target dimensions as output.
-
If target dimensions are unspecified, then the returned transform will expects only the specified source dimensions as input, and the target dimensions will be inferred automatically.
- Parameters:
transform
- The transform to separate.- Returns:
- The separated math transform.
- Throws:
FactoryException
- if the transform can't be separated.
-
-
-