Class DefaultMathTransformFactory.Context

Object
Context
All Implemented Interfaces:
Serializable
Enclosing class:
Default­Math­Transform­Factory

public static class DefaultMathTransformFactory.Context extends Object implements Serializable
Source and target coordinate systems for which a new parameterized transform is going to be used. Default­Math­Transform­Factory uses this information for:
  • Completing some parameters if they were not provided. In particular, the source ellipsoid can be used for providing values for the "semi_major" and "semi_minor" parameters in map projections.
  • Swapping and scaling axes if the source or the target coordinate systems are not normalized.
This class does not handle change of prime meridian or anything else related to datum. Datum changes have dedicated Operation­Method, for example "Longitude rotation" (EPSG:9601) for changing the prime meridian.

Scope

Instances of this class should be short-lived (they exist only the time needed for creating a Math­Transform) and should not be shared (because they provide no immutability guarantees). This class is not thread-safe.
Since:
0.7
See Also:
  • Constructor Details

    • Context

      public Context()
      Creates a new context with all properties initialized to null.
  • Method Details

    • setSource

      public void setSource(CoordinateSystem cs)
      Sets the source coordinate system to the given value. The source ellipsoid is unconditionally set to null.
      Parameters:
      cs - the coordinate system to set as the source (can be null).
    • setSource

      public void setSource(GeodeticCRS crs)
      Sets the source coordinate system and related ellipsoid to the components of given CRS. The Ellipsoid, fetched from the geodetic datum, is often used together with an Ellipsoidal­CS, but not necessarily. The geodetic CRS may also be associated with a spherical or Cartesian coordinate system, and the ellipsoid information may still be needed even with those non-ellipsoidal coordinate systems.

      This method is not for datum shifts. All datum information other than the ellipsoid are ignored.

      Parameters:
      crs - the coordinate system and ellipsoid to set as the source, or null.
      Since:
      1.3
    • setTarget

      public void setTarget(CoordinateSystem cs)
      Sets the target coordinate system to the given value. The target ellipsoid is unconditionally set to null.
      Parameters:
      cs - the coordinate system to set as the target (can be null).
    • setTarget

      public void setTarget(GeodeticCRS crs)
      Sets the target coordinate system and related ellipsoid to the components of given CRS. The Ellipsoid, fetched from the geodetic datum, is often used together with an Ellipsoidal­CS, but not necessarily. The geodetic CRS may also be associated with a spherical or Cartesian coordinate system, and the ellipsoid information may still be needed even with those non-ellipsoidal coordinate systems.

      This method is not for datum shifts. All datum information other than the ellipsoid are ignored.

      Parameters:
      crs - the coordinate system and ellipsoid to set as the target, or null.
      Since:
      1.3
    • getSourceCS

      public CoordinateSystem getSourceCS()
      Returns the source coordinate system, or null if unspecified.
      Returns:
      the source coordinate system, or null.
    • getSourceEllipsoid

      public Ellipsoid getSourceEllipsoid()
      Returns the ellipsoid of the source ellipsoidal coordinate system, or null if it does not apply. This information is valid only if get­Source­CS() returns an instance of Ellipsoidal­CS.
      Returns:
      the ellipsoid of the source ellipsoidal coordinate system, or null if it does not apply.
    • getTargetCS

      public CoordinateSystem getTargetCS()
      Returns the target coordinate system, or null if unspecified.
      Returns:
      the target coordinate system, or null.
    • getTargetEllipsoid

      public Ellipsoid getTargetEllipsoid()
      Returns the ellipsoid of the target ellipsoidal coordinate system, or null if it does not apply. This information is valid only if get­Target­CS() returns an instance of Ellipsoidal­CS.
      Returns:
      the ellipsoid of the target ellipsoidal coordinate system, or null if it does not apply.
    • getMatrix

      Returns the matrix that represent the affine transform to concatenate before or after the parameterized transform. The role argument specifies which matrix is desired: This method is invoked by Default­Math­Transform­Factory​.swap­And­Scale­Axes(Math­Transform, Context). Users an override this method if they need to customize the normalization process.
      Parameters:
      role - whether the normalization or denormalization matrix is desired.
      Returns:
      the requested matrix, or null if this Context has no information about the coordinate system.
      Throws:
      Factory­Exception - if an error occurred while computing the matrix.
      See Also:
    • getMethodUsed

      public OperationMethod getMethodUsed()
      Returns the operation method used for the math transform creation. This is the same information than Default­Math­Transform­Factory​.get­Last­Method­Used() but more stable (not affected by transforms created with other contexts).
      Returns:
      the operation method used by the factory.
      Throws:
      Illegal­State­Exception - if Default­Math­Transform­Factory​.create­Parameterized­Transform(Parameter­Value­Group, Context) has not yet been invoked.
      Since:
      1.3
      See Also:
    • getContextualParameters

      public Map<String,Boolean> getContextualParameters()
      Returns the names of parameters that have been inferred from the context. The set of keys can contain any of "dim", "semi_major", "semi_minor", "src_semi_major", "src_semi_minor", "tgt_semi_major", "tgt_semi_minor" and/or "inverse_flattening", depending on the operation method used. The parameters named in that set are included in the parameters returned by get­Completed­Parameters().

      Associated boolean values

      The associated boolean in the map tells whether the named parameter value is really contextual. The boolean is FALSE if the user explicitly specified a value in the parameters given to the Default­Math­Transform­Factory​.create­Parameterized­Transform(Parameter­Value­Group, Context) method, and that value is different than the value inferred from the context. Such inconsistencies are also logged at Level​.WARNING. In all other cases (no value specified by the user, or a value was specified but is consistent with the context), the associated boolean in the map is TRUE.

      Mutability

      The returned map is modifiable for making easier for callers to amend the contextual information. This map is not used by Context except for information purposes (e.g. in to­String()). In particular, modifications of this map have no incidence on the created Math­Transform.
      Returns:
      names of parameters inferred from context.
      Since:
      1.3
    • getCompletedParameters

      public ParameterValueGroup getCompletedParameters()
      Returns the parameter values used for the math transform creation, including the parameters completed by the factory. The parameters inferred from the context are listed by get­Contextual­Parameters().
      Returns:
      the parameter values used by the factory.
      Throws:
      Illegal­State­Exception - if Default­Math­Transform­Factory​.create­Parameterized­Transform(Parameter­Value­Group, Context) has not yet been invoked.
    • toString

      public String toString()
      Returns a string representation of this context for debugging purposes. Current implementation write the name of source/target coordinate systems and ellipsoids. If contextual parameters have already been inferred, then their names are appended with inconsistent parameters (if any) written on a separated line.
      Overrides:
      to­String in class Object
      Returns:
      a string representation of this context.