Class CoordinateOperationContext

java.lang.Object
org.apache.sis.referencing.operation.CoordinateOperationContext
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CanvasContext

public class CoordinateOperationContext extends Object implements Serializable
Optional information about the context in which a requested coordinate operation will be used. The context can provide information such as:
  • The geographic area where the transformation will be used.
  • The desired accuracy. A coarser accuracy may allow SIS to choose a faster transformation method.
While optional, those information can help DefaultCoordinateOperationFactory to choose the most suitable coordinate transformation between two CRS.
Example: if a transformation from NAD27 to WGS84 is requested without providing context, then Apache SIS will return the transformation applicable to the widest North American surface. But if the user provides a context saying that he wants to transform coordinates in Texas, then Apache SIS may return another coordinate transformation with different Bursa-Wolf parameters more suitable to Texas, but not suitable to the rest of North-America.
CoordinateOperationContext is part of the API used by SIS for implementing the late binding model. See package javadoc for a note on early binding versus late binding implementations.
Since:
0.7
Version:
1.1
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private org.opengis.metadata.extent.Extent
    The spatiotemporal area of interest, or null if none.
    private double
    The desired accuracy in metres, or 0 for the best accuracy available.
    private static final long
    For cross-version compatibility.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new context with no area of interest and the best accuracy available.
    CoordinateOperationContext(org.opengis.metadata.extent.Extent area, double accuracy)
    Creates a new context with the given area of interest and desired accuracy.
  • Method Summary

    Modifier and Type
    Method
    Description
    fromBoundingBox(org.opengis.metadata.extent.GeographicBoundingBox areaOfInterest)
    Creates an operation context for the given area of interest, which may be null or undefined.
    org.opengis.metadata.extent.Extent
    Returns the spatiotemporal area of interest, or null if none.
    (package private) static double[]
    Invoked when some coordinates in the target CRS cannot be computed from coordinates in the source CRS.
    double
    Returns the desired accuracy in metres.
    (package private) final Predicate<org.opengis.referencing.operation.CoordinateOperation>
    Returns a filter that can be used for applying additional restrictions on the coordinate operation.
    void
    setAreaOfInterest(org.opengis.metadata.extent.Extent area)
    Sets the spatiotemporal area of interest, or null if none.
    void
    setAreaOfInterest(org.opengis.metadata.extent.GeographicBoundingBox area)
    Sets the geographic component of the area of interest, or null if none.
    void
    setDesiredAccuracy(double accuracy)
    Sets the desired accuracy in metres.
    (package private) static org.opengis.metadata.extent.Extent
    setGeographicBoundingBox(org.opengis.metadata.extent.Extent areaOfInterest, org.opengis.metadata.extent.GeographicBoundingBox bbox)
    Sets the given geographic bounding box in the given extent.

    Methods inherited from class java.lang.Object

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

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • areaOfInterest

      private org.opengis.metadata.extent.Extent areaOfInterest
      The spatiotemporal area of interest, or null if none. This instance may be updated or replaced by other methods in this class, or (indirectly) by CoordinateOperationFinder.
    • desiredAccuracy

      private double desiredAccuracy
      The desired accuracy in metres, or 0 for the best accuracy available. See getDesiredAccuracy() for more details about what we mean by "best accuracy".
  • Constructor Details

    • CoordinateOperationContext

      public CoordinateOperationContext()
      Creates a new context with no area of interest and the best accuracy available.
    • CoordinateOperationContext

      public CoordinateOperationContext(org.opengis.metadata.extent.Extent area, double accuracy)
      Creates a new context with the given area of interest and desired accuracy.
      Parameters:
      area - the area of interest, or null if none.
      accuracy - the desired accuracy in metres, or 0 for the best accuracy available. See getDesiredAccuracy() for more details about what we mean by "best accuracy".
  • Method Details

    • fromBoundingBox

      public static CoordinateOperationContext fromBoundingBox(org.opengis.metadata.extent.GeographicBoundingBox areaOfInterest)
      Creates an operation context for the given area of interest, which may be null or undefined. This is a convenience method for a frequently-used operation.
      Parameters:
      areaOfInterest - the area of interest, or null if none.
      Returns:
      the operation context, or null if the given bounding box was null, undefined or covers the whole world (in which case Apache SIS does not need that we specify a context).
      Since:
      1.0
    • getAreaOfInterest

      public org.opengis.metadata.extent.Extent getAreaOfInterest()
      Returns the spatiotemporal area of interest, or null if none.
      Returns:
      the spatiotemporal area of interest, or null if none.
      See Also:
    • setAreaOfInterest

      public void setAreaOfInterest(org.opengis.metadata.extent.Extent area)
      Sets the spatiotemporal area of interest, or null if none.
      Parameters:
      area - the spatiotemporal area of interest, or null if none.
    • setAreaOfInterest

      public void setAreaOfInterest(org.opengis.metadata.extent.GeographicBoundingBox area)
      Sets the geographic component of the area of interest, or null if none. This convenience method set the bounding box into the spatiotemporal Extent.

      The reverse operation can be done with Extents.getGeographicBoundingBox(getAreaOfInterest()).

      Parameters:
      area - the geographic area of interest, or null if none.
    • setGeographicBoundingBox

      static org.opengis.metadata.extent.Extent setGeographicBoundingBox(org.opengis.metadata.extent.Extent areaOfInterest, org.opengis.metadata.extent.GeographicBoundingBox bbox)
      Sets the given geographic bounding box in the given extent. This method may modify the extent given in parameters.
      Parameters:
      areaOfInterest - the extent to update, or null.
      Returns:
      the updated extent. May be the given one or a new instance.
    • getDesiredAccuracy

      public double getDesiredAccuracy()
      Returns the desired accuracy in metres. A value of 0 means to search for the most accurate operation.

      When searching for the most accurate operation, SIS considers only the operations specified by the authority. For example, the Molodensky method is a better datum shift approximation than Abridged Molodensky. But if all coordinate operations defined by the authority use the Abridged Molodensky method, then SIS will ignore the Molodensky one.

      Returns:
      the desired accuracy in metres.
    • setDesiredAccuracy

      public void setDesiredAccuracy(double accuracy)
      Sets the desired accuracy in metres. A value of 0 means to search for the most accurate operation. See getDesiredAccuracy() for more details about what we mean by "most accurate".
      Parameters:
      accuracy - the desired accuracy in metres.
    • getOperationFilter

      final Predicate<org.opengis.referencing.operation.CoordinateOperation> getOperationFilter()
      Returns a filter that can be used for applying additional restrictions on the coordinate operation.
    • getConstantCoordinates

      static double[] getConstantCoordinates() throws org.opengis.referencing.operation.TransformException
      Invoked when some coordinates in the target CRS cannot be computed from coordinates in the source CRS. For example if the source CRS has (x, y) axes and the target CRS has (x, y, t) axes, then this method is invoked for determining which value to assign to the t coordinate. In some cases the user can tell that the coordinate should be set to a constant value.

      If this method returns null (which is the default), then the CoordinateOperationFinder caller will throw an OperationNotFoundException. Otherwise the returned array should have a length equals to the number of dimensions in the full (usually compound) target CRS. Only coordinate values in dimensions without source (the t dimension in above example) will be used. All other coordinate values will be ignored.

      Returns:
      coordinate values to take as constants for the specified target component, or null if none.
      Throws:
      org.opengis.referencing.operation.TransformException - if the coordinates cannot be computed. This exception may occur when the constant coordinate values are the results of performing a coordinate operation in advance.