Class AbstractCoordinateOperationFactory
- Object
-
- AbstractFactory
-
- ReferencingFactory
-
- AbstractCoordinateOperationFactory
-
- All Implemented Interfaces:
Factory
,ObjectFactory
,CoordinateOperationFactory
,Factory
,RegistrableFactory
- Direct Known Subclasses:
BufferedCoordinateOperationFactory
,DefaultCoordinateOperationFactory
public abstract class AbstractCoordinateOperationFactory extends ReferencingFactory implements CoordinateOperationFactory
Base class for coordinate operation factories. This class provides helper methods for the construction of building blocks. It doesn't figure out any operation path by itself. This more "intelligent" job is left to subclasses.- Since:
- 2.1
- Author:
- Martin Desruisseaux (IRD)
-
-
Field Summary
Fields Modifier and Type Field Description protected static ReferenceIdentifier
AXIS_CHANGES
The identifier for conversion using an affine transform for axis swapping and/or unit conversions.protected static ReferenceIdentifier
DATUM_SHIFT
The identifier for a transformation which is a datum shift.protected static ReferenceIdentifier
ELLIPSOID_SHIFT
The identifier for a transformation which is a datum shift without Bursa Wolf parameters.protected static ReferenceIdentifier
GEOCENTRIC_CONVERSION
The identifier for a geocentric conversion.protected static ReferenceIdentifier
IDENTITY
The identifier for an identity operation.protected static ReferenceIdentifier
INVERSE_OPERATION
The identifier for an inverse operation.-
Fields inherited from class ReferencingFactory
LOGGER
-
Fields inherited from class AbstractFactory
hints, MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY, priority
-
-
Constructor Summary
Constructors Constructor Description AbstractCoordinateOperationFactory(Hints userHints)
Constructs a coordinate operation factory using the specified hints.AbstractCoordinateOperationFactory(Hints userHints, int priority)
Constructs a coordinate operation factory using the specified hints and priority.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Set<CoordinateOperation>
concatenate(Set<CoordinateOperation> candidatesStep1, Set<CoordinateOperation> candidatesStep2)
Concatenate two operation steps.protected Set<CoordinateOperation>
concatenate(Set<CoordinateOperation> candidatesStep1, Set<CoordinateOperation> candidatesStep2, Set<CoordinateOperation> candidatesStep3)
Concatenate two sets of operation steps.protected CoordinateOperation
concatenate(CoordinateOperation step1, CoordinateOperation step2)
Concatenate two operation steps.protected CoordinateOperation
concatenate(CoordinateOperation step1, CoordinateOperation step2, CoordinateOperation step3)
Concatenate three transformation steps.CoordinateOperation
createConcatenatedOperation(Map<String,?> properties, CoordinateOperation[] operations)
Creates a concatenated operation from a sequence of operations.Conversion
createDefiningConversion(Map<String,?> properties, OperationMethod method, ParameterValueGroup parameters)
Constructs a defining conversion from a set of properties.protected CoordinateOperation
createFromAffineTransform(ReferenceIdentifier name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, Matrix matrix)
Creates a coordinate operation from a matrix, which usually describes an affine tranform.protected CoordinateOperation
createFromMathTransform(Map<String,?> properties, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, MathTransform transform, OperationMethod method, Class<? extends CoordinateOperation> type)
Creates a coordinate operation from a math transform.protected CoordinateOperation
createFromMathTransform(ReferenceIdentifier name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, MathTransform transform)
Creates a coordinate operation from a math transform.protected CoordinateOperation
createFromParameters(ReferenceIdentifier name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, ParameterValueGroup parameters)
Creates a coordinate operation from a set of parameters.protected static void
ensureNonNull(String name, Object object)
Makes sure an argument is non-null.protected static String
getErrorMessage(IdentifiedObject source, IdentifiedObject target)
Returns an error message for "No path found from sourceCRS to targetCRS".Map<RenderingHints.Key,?>
getImplementationHints()
Returns the implementation hints for this factory.MathTransformFactory
getMathTransformFactory()
Returns the underlying math transform factory.protected CoordinateOperation
inverse(CoordinateOperation operation)
Returns the inverse of the specified operation.protected Matrix
swapAndScaleAxis(CoordinateSystem sourceCS, CoordinateSystem targetCS)
Returns an affine transform between two coordinate systems.-
Methods inherited from class ReferencingFactory
getVendor
-
Methods inherited from class AbstractFactory
addImplementationHints, equals, getPriority, hashCode, onDeregistration, onRegistration, toString
-
Methods inherited from interface CoordinateOperationFactory
createOperation, createOperation, findOperations
-
-
-
-
Field Detail
-
IDENTITY
protected static final ReferenceIdentifier IDENTITY
The identifier for an identity operation.
-
AXIS_CHANGES
protected static final ReferenceIdentifier AXIS_CHANGES
The identifier for conversion using an affine transform for axis swapping and/or unit conversions.
-
DATUM_SHIFT
protected static final ReferenceIdentifier DATUM_SHIFT
The identifier for a transformation which is a datum shift.
-
ELLIPSOID_SHIFT
protected static final ReferenceIdentifier ELLIPSOID_SHIFT
The identifier for a transformation which is a datum shift without Bursa Wolf parameters. Only the changes in ellipsoid axis-length are taken in account. Such ellipsoid shifts are approximative and may have 1 kilometer error. This transformation is allowed only if the factory was created withHints.LENIENT_DATUM_SHIFT
set toBoolean.TRUE
.
-
GEOCENTRIC_CONVERSION
protected static final ReferenceIdentifier GEOCENTRIC_CONVERSION
The identifier for a geocentric conversion.
-
INVERSE_OPERATION
protected static final ReferenceIdentifier INVERSE_OPERATION
The identifier for an inverse operation.
-
-
Constructor Detail
-
AbstractCoordinateOperationFactory
public AbstractCoordinateOperationFactory(Hints userHints)
Constructs a coordinate operation factory using the specified hints. This constructor recognizes theCRS
,CS
,DATUM
andMATH_TRANSFORM
FACTORY
hints.- Parameters:
userHints
- The hints, ornull
if none.
-
AbstractCoordinateOperationFactory
public AbstractCoordinateOperationFactory(Hints userHints, int priority)
Constructs a coordinate operation factory using the specified hints and priority. This constructor recognizes theCRS
,CS
,DATUM
andMATH_TRANSFORM
FACTORY
hints.- Parameters:
userHints
- The hints, ornull
if none.priority
- The priority for this factory, as a number betweenMINIMUM_PRIORITY
andMAXIMUM_PRIORITY
inclusive.- Since:
- 2.2
-
-
Method Detail
-
getImplementationHints
public Map<RenderingHints.Key,?> getImplementationHints()
Returns the implementation hints for this factory. The returned map contains values forCRS
,CS
,DATUM
andMATH_TRANSFORM
FACTORY
hints. Other values may be provided as well, at implementation choice.- Specified by:
getImplementationHints
in interfaceFactory
- Overrides:
getImplementationHints
in classAbstractFactory
- Returns:
- The map of hints, or an empty map if none.
-
getMathTransformFactory
public final MathTransformFactory getMathTransformFactory()
Returns the underlying math transform factory. This factory is used for constructingMathTransform
objects for all coordinate operations.- Returns:
- The underlying math transform factory.
-
swapAndScaleAxis
protected Matrix swapAndScaleAxis(CoordinateSystem sourceCS, CoordinateSystem targetCS) throws OperationNotFoundException
Returns an affine transform between two coordinate systems. Only units and axis order (e.g. transforming from (NORTH,WEST) to (EAST,NORTH)) are taken in account.Example: If coordinates in
sourceCS
are (x,y) pairs in metres and coordinates intargetCS
are (-y,x) pairs in centimetres, then the transformation can be performed as below:[-y(cm)] [ 0 -100 0 ] [x(m)] [ x(cm)] = [ 100 0 0 ] [y(m)] [ 1 ] [ 0 0 1 ] [1 ]
- Parameters:
sourceCS
- The source coordinate system.targetCS
- The target coordinate system.- Returns:
- The transformation from
sourceCS
totargetCS
as an affine transform. Only axis orientation and units are taken in account. - Throws:
OperationNotFoundException
- If the affine transform can't be constructed.- See Also:
AbstractCS.swapAndScaleAxis(org.geotools.api.referencing.cs.CoordinateSystem, org.geotools.api.referencing.cs.CoordinateSystem)
-
createFromAffineTransform
protected CoordinateOperation createFromAffineTransform(ReferenceIdentifier name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, Matrix matrix) throws FactoryException
Creates a coordinate operation from a matrix, which usually describes an affine tranform. A defaultOperationMethod
object is given to this transform. In the special case where thename
identifier isDATUM_SHIFT
orELLIPSOID_SHIFT
, the operation will be an instance ofTransformation
instead of the usualConversion
.- Parameters:
name
- The identifier for the operation to be created.sourceCRS
- The source coordinate reference system.targetCRS
- The target coordinate reference system.matrix
- The matrix which describe an affine transform operation.- Returns:
- The conversion or transformation.
- Throws:
FactoryException
- if the operation can't be created.
-
createFromParameters
protected CoordinateOperation createFromParameters(ReferenceIdentifier name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, ParameterValueGroup parameters) throws FactoryException
Creates a coordinate operation from a set of parameters. The operation method is inferred automatically, if possible.- Parameters:
name
- The identifier for the operation to be created.sourceCRS
- The source coordinate reference system.targetCRS
- The target coordinate reference system.parameters
- The parameters.- Returns:
- The conversion or transformation.
- Throws:
FactoryException
- if the operation can't be created.
-
createFromMathTransform
protected CoordinateOperation createFromMathTransform(ReferenceIdentifier name, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, MathTransform transform) throws FactoryException
Creates a coordinate operation from a math transform.- Parameters:
name
- The identifier for the operation to be created.sourceCRS
- The source coordinate reference system.targetCRS
- The destination coordinate reference system.transform
- The math transform.- Returns:
- A coordinate operation using the specified math transform.
- Throws:
FactoryException
- if the operation can't be constructed.
-
createFromMathTransform
protected CoordinateOperation createFromMathTransform(Map<String,?> properties, CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem targetCRS, MathTransform transform, OperationMethod method, Class<? extends CoordinateOperation> type) throws FactoryException
Creates a coordinate operation from a math transform. If the specified math transform is already a coordinate operation, and if source and target CRS match, thentransform
is returned with no change. Otherwise, a new coordinate operation is created.- Parameters:
properties
- The properties to give to the operation.sourceCRS
- The source coordinate reference system.targetCRS
- The destination coordinate reference system.transform
- The math transform.method
- The operation method, ornull
.type
- The required super-class (e.g.Transformation.class
).- Returns:
- A coordinate operation using the specified math transform.
- Throws:
FactoryException
- if the operation can't be constructed.
-
createDefiningConversion
public Conversion createDefiningConversion(Map<String,?> properties, OperationMethod method, ParameterValueGroup parameters) throws FactoryException
Constructs a defining conversion from a set of properties.- Specified by:
createDefiningConversion
in interfaceCoordinateOperationFactory
- Parameters:
properties
- Set of properties. Should contains at least"name"
.method
- The operation method.parameters
- The parameter values.- Returns:
- The defining conversion.
- Throws:
FactoryException
- if the object creation failed.- Since:
- 2.5
- See Also:
DefiningConversion
-
createConcatenatedOperation
public CoordinateOperation createConcatenatedOperation(Map<String,?> properties, CoordinateOperation[] operations) throws FactoryException
Creates a concatenated operation from a sequence of operations.- Specified by:
createConcatenatedOperation
in interfaceCoordinateOperationFactory
- Parameters:
properties
- Set of properties. Should contains at least"name"
.operations
- The sequence of operations.- Returns:
- The concatenated operation.
- Throws:
FactoryException
- if the object creation failed.
-
concatenate
protected CoordinateOperation concatenate(CoordinateOperation step1, CoordinateOperation step2) throws FactoryException
Concatenate two operation steps. If an operation is anAXIS_CHANGES
, it will be included as part of the second operation instead of creating anConcatenatedOperation
. If a concatenated operation is created, it will get an automatically generated name.- Parameters:
step1
- The first step, ornull
for the identity operation.step2
- The second step, ornull
for the identity operation.- Returns:
- A concatenated operation, or
null
if all arguments was nul. - Throws:
FactoryException
- if the operation can't be constructed.
-
concatenate
protected Set<CoordinateOperation> concatenate(Set<CoordinateOperation> candidatesStep1, Set<CoordinateOperation> candidatesStep2) throws FactoryException
Concatenate two operation steps. If an operation is anAXIS_CHANGES
, it will be included as part of the second operation instead of creating anConcatenatedOperation
. If a concatenated operation is created, it will get an automatically generated name.- Parameters:
candidatesStep1
- The first step, ornull
for the identity operation.candidatesStep2
- The second step, ornull
for the identity operation.- Returns:
- A concatenated operation, or
null
if all arguments was nul. - Throws:
FactoryException
- if the operation can't be constructed.
-
concatenate
protected Set<CoordinateOperation> concatenate(Set<CoordinateOperation> candidatesStep1, Set<CoordinateOperation> candidatesStep2, Set<CoordinateOperation> candidatesStep3) throws FactoryException
Concatenate two sets of operation steps. The result is the concatenation of all the steps on the firt set with all the steps on the second set (cartesian product), which will be then concatenated with all the steps on the third step.If an operation is an
AXIS_CHANGES
, it will be included as part of the second operation instead of creating anConcatenatedOperation
. If a concatenated operation is created, it will get an automatically generated name.- Parameters:
candidatesStep1
- The first set of candidate stepscandidatesStep2
- The second set of candidate stepscandidatesStep3
- The third step of candidate steps- Returns:
- A set of operations
- Throws:
FactoryException
- if any of the concatenated operations couldn't be constructed.- See Also:
concatenate(CoordinateOperation, CoordinateOperation, CoordinateOperation)
-
concatenate
protected CoordinateOperation concatenate(CoordinateOperation step1, CoordinateOperation step2, CoordinateOperation step3) throws FactoryException
Concatenate three transformation steps. If the first and/or the last operation is anAXIS_CHANGES
, it will be included as part of the second operation instead of creating anConcatenatedOperation
. If a concatenated operation is created, it will get an automatically generated name.- Parameters:
step1
- The first step, ornull
for the identity operation.step2
- The second step, ornull
for the identity operation.step3
- The third step, ornull
for the identity operation.- Returns:
- A concatenated operation, or
null
if all arguments were null. - Throws:
FactoryException
- if the operation can't be constructed.
-
inverse
protected CoordinateOperation inverse(CoordinateOperation operation) throws NoninvertibleTransformException, FactoryException
Returns the inverse of the specified operation.- Parameters:
operation
- The operation to invert.- Returns:
- The inverse of
operation
. - Throws:
NoninvertibleTransformException
- if the operation is not invertible.FactoryException
- if the operation creation failed for an other reason.- Since:
- 2.3
-
getErrorMessage
protected static String getErrorMessage(IdentifiedObject source, IdentifiedObject target)
Returns an error message for "No path found from sourceCRS to targetCRS". This is used for the construction ofOperationNotFoundException
.- Parameters:
source
- The source CRS.target
- The target CRS.- Returns:
- A default error message.
-
ensureNonNull
protected static void ensureNonNull(String name, Object object) throws IllegalArgumentException
Makes sure an argument is non-null.- Parameters:
name
- Argument name.object
- User argument.- Throws:
IllegalArgumentException
- ifobject
is null.
-
-