Class SubOperationInfo

java.lang.Object
org.apache.sis.referencing.operation.SubOperationInfo

final class SubOperationInfo extends Object
Information about the operation from a source component to a target component in CompoundCRS instances. An instance of SubOperationInfo is created for each target CRS component. This class allows to collect information about all operation steps before to start the creation of pass-through operations. This separation is useful for applying reordering.
Since:
0.7
Version:
1.1
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final Class<?>[][]
    Types of target CRS, together with the type of CRS that may be used as the source for that target.
    private final double[]
    The constant values to store in target coordinates, or null if none.
    private final int
    The first dimension (inclusive) and the last dimension (exclusive) where the SingleCRS starts/ends in the full (usually compound) CRS.
    (package private) final org.opengis.referencing.operation.CoordinateOperation
    The coordinate operation between a source CRS component and a target CRS component.
    private final int
    The first dimension (inclusive) and the last dimension (exclusive) where the SingleCRS starts/ends in the full (usually compound) CRS.
    (package private) final int
    Index of this instance in the array of SubOperationInfo instances, before the reordering applied by getSourceCRS(SubOperationInfo[]).
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    SubOperationInfo(int targetComponentIndex, org.opengis.referencing.operation.CoordinateOperation operation, double[] constants, int startAtDimension, int endAtDimension)
    Creates a new instance wrapping the given coordinate operation or coordinate constants.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) static MatrixSIS
    createConstantOperation(SubOperationInfo[] selected, int n, int srcDim, int tgtDim)
    Returns the matrix of an operation setting some coordinates to a constant values.
    (package private) static SubOperationInfo[]
    createSteps(CoordinateOperationFinder caller, List<? extends org.opengis.referencing.crs.SingleCRS> sources, List<? extends org.opengis.referencing.crs.SingleCRS> targets)
    Searches in given list of source components for operations capable to transform coordinates to each target CRS.
    (package private) static org.opengis.referencing.crs.CoordinateReferenceSystem[]
    Returns the source CRS of given operations.
    (package private) static int
    Returns the index of the last non-identity operation.
    (package private) final boolean
    Returns true if the coordinate operation wrapped by this object is an identity transform.
    (package private) static MatrixSIS
    sourceToSelected(int sourceDimensions, SubOperationInfo[] selected)
    Returns a matrix for an affine transform moving coordinate values from their position in the source CRS to a position in the order operations are applied.
    private static Class<?>
    type(org.opengis.referencing.crs.SingleCRS crs)
    Returns the class of the given CRS after unwrapping derived and projected CRS.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • COMPATIBLE_TYPES

      private static final Class<?>[][] COMPATIBLE_TYPES
      Types of target CRS, together with the type of CRS that may be used as the source for that target. For each array COMPATIBLE_TYPES[i], the first element (i.e. COMPATIBLE_TYPES[i][0]) is the target CRS and the whole array (including the first element) gives the valid source CRS type, if preference order.
      Example: if a target CRS is of type VerticalCRS, then the source CRS may be another VerticalCRS or a GeodeticCRS. The geodetic CRS is possible because it may be three-dimensional.
      ProjectedCRS and DerivedCRS are not in this list because we rather use their base CRS as the criterion for determining their type.
    • operation

      final org.opengis.referencing.operation.CoordinateOperation operation
      The coordinate operation between a source CRS component and a target CRS component. Exactly one of operation or constants shall be non-null.
    • constants

      private final double[] constants
      The constant values to store in target coordinates, or null if none. This array is usually null. It may be non-null if no source CRS component has been found for a target CRS component. For example, if the source CRS has (x, y) axes and the target CRS has (x, y, t) axes, then this array may be set to a non-null value for specifying the t value. The array length is the number of dimensions in the full (usually compound) target CRS, but only the coordinate values for sourceless dimensions are used. Other coordinates are ignored and can be NaN. Exactly one of operation or constants shall be non-null.
      See Also:
    • startAtDimension

      private final int startAtDimension
      The first dimension (inclusive) and the last dimension (exclusive) where the SingleCRS starts/ends in the full (usually compound) CRS. It may be an index in source dimensions or in target dimensions, depending on the following rules:
      • If operation is non-null, then this is an index in the source dimensions. This is the normal case.
      • Otherwise the operation is sourceless with coordinate results described by the constants array. Since there is no source, the index become an index in target dimensions instead of source dimensions.
      See Also:
    • endAtDimension

      private final int endAtDimension
      The first dimension (inclusive) and the last dimension (exclusive) where the SingleCRS starts/ends in the full (usually compound) CRS. It may be an index in source dimensions or in target dimensions, depending on the following rules:
      • If operation is non-null, then this is an index in the source dimensions. This is the normal case.
      • Otherwise the operation is sourceless with coordinate results described by the constants array. Since there is no source, the index become an index in target dimensions instead of source dimensions.
      See Also:
    • targetComponentIndex

      final int targetComponentIndex
      Index of this instance in the array of SubOperationInfo instances, before the reordering applied by getSourceCRS(SubOperationInfo[]).
  • Constructor Details

    • SubOperationInfo

      private SubOperationInfo(int targetComponentIndex, org.opengis.referencing.operation.CoordinateOperation operation, double[] constants, int startAtDimension, int endAtDimension)
      Creates a new instance wrapping the given coordinate operation or coordinate constants. Exactly one of operation or constants shall be non-null.
  • Method Details

    • type

      private static Class<?> type(org.opengis.referencing.crs.SingleCRS crs)
      Returns the class of the given CRS after unwrapping derived and projected CRS. The returned type is for use with COMPATIBLE_TYPES.
    • createSteps

      static SubOperationInfo[] createSteps(CoordinateOperationFinder caller, List<? extends org.opengis.referencing.crs.SingleCRS> sources, List<? extends org.opengis.referencing.crs.SingleCRS> targets) throws org.opengis.util.FactoryException, org.opengis.referencing.operation.TransformException
      Searches in given list of source components for operations capable to transform coordinates to each target CRS. There is one SubOperationInfo per target CRS because we need to satisfy all target dimensions, while it is okay to ignore some source dimensions. If an operation cannot be found, then this method returns null.
      Parameters:
      caller - the object which is inferring a coordinate operation.
      sources - all components of the source CRS.
      targets - all components of the target CRS.
      Returns:
      information about each coordinate operation from a source CRS to a target CRS, or null.
      Throws:
      org.opengis.util.FactoryException - if an error occurred while grabbing a coordinate operation.
      org.opengis.referencing.operation.TransformException - if an error occurred while computing the sourceless coordinate constants.
    • getSourceCRS

      static org.opengis.referencing.crs.CoordinateReferenceSystem[] getSourceCRS(SubOperationInfo[] selected)
      Returns the source CRS of given operations. This method modifies the given array in-place by moving all sourceless operations last. Then an array is returned with the source CRS of only ordinary operations. Each CRS at index i in the returned array is the component from startAtDimension inclusive to endAtDimension exclusive in the complete (usually compound) source CRS analyzed by CoordinateOperationFinder.
      Parameters:
      selected - all operations from source to target CompoundCRS.
      Returns:
      source CRS of all ordinary operations (excluding operations producing constant values).
    • indexOfFinal

      static int indexOfFinal(SubOperationInfo[] selected)
      Returns the index of the last non-identity operation. This is used as a slight optimization for deciding when CoordinateOperationFinder can stop to create intermediate target CompoundCRS instances because all remaining operations leave target coordinates unchanged. It may help to skip a few operations for example when converting (x, y, t) coordinates where t value is unchanged.
      Parameters:
      selected - all operations from source to target CompoundCRS.
      Returns:
      index of the last non-identity operation, inclusive.
    • sourceToSelected

      static MatrixSIS sourceToSelected(int sourceDimensions, SubOperationInfo[] selected)
      Returns a matrix for an affine transform moving coordinate values from their position in the source CRS to a position in the order operations are applied. This matrix is needed because operation may select any source CRS in the list of SingleCRS given to the createSteps(…) method; the source CRS are not necessarily picked in the same order as they appear in the list.
      Example: if the source CRS has (x, y, t) coordinates and the target CRS has (t, x, y) coordinates with some operation applied on x and y, then the operations will be applied in that order:
      1. An operation for t, because it is the first coordinate to appear in target CRS.
      2. An operation for (x, y), because those coordinates are next in target CRS.
      Since DefaultPassThroughOperation cannot take coordinates before the "first affected coordinate" dimension and move them into the "trailing coordinates" dimension, we have to reorder coordinates before to create the pass-through operations. This is done by the following matrix:
      Furthermore, some dimensions may be dropped, e.g. from (x, y, t) to (x, y).
      Parameters:
      sourceDimensions - number of dimensions in the source CompoundCRS.
      selected - all operations from source to target CompoundCRS.
      Returns:
      mapping from source CompoundCRS to each CoordinateOperation.getSourceCRS().
    • isIdentity

      final boolean isIdentity()
      Returns true if the coordinate operation wrapped by this object is an identity transform.
    • createConstantOperation

      static MatrixSIS createConstantOperation(SubOperationInfo[] selected, int n, int srcDim, int tgtDim)
      Returns the matrix of an operation setting some coordinates to a constant values.
      Parameters:
      selected - all operations from source to target CompoundCRS.
      n - index of the first selected operation which describe a constant value.
      srcDim - number of dimensions in the target CRS of previous operation step.
      tgtDim - number of dimensions in the full (usually compound) target CRS.