Class SwathProjection

All Implemented Interfaces:
Cloneable, Encodable

public class SwathProjection extends EarthTransform2D implements Encodable

The SwathProjection class implements earth transform calculations for satellite swath (also called sensor scan) 2D projections. Swaths may be created by supplying a field of latitude and longitude values -- one for each data value location. The swath projection uses polynomial estimator objects for estimating the latitude and longitude values in order to perform an accurate reverse lookup (ie: computing the data location for a given latitude and longitude).

This class is thread-safe as of version 3.5.0.

Since:
3.1.0
Author:
Peter Hollemans
  • Field Details

    • TOLERANCE_FACTOR

      public static final double TOLERANCE_FACTOR
      The default tolerance distance as a fraction of the resolution.
      See Also:
    • MAX_ITERATIONS

      public static final int MAX_ITERATIONS
      The transform(EarthLocation) maximum iterations.
      See Also:
    • DESCRIPTION

      public static final String DESCRIPTION
      Projection description string.
      See Also:
  • Constructor Details

    • SwathProjection

      public SwathProjection(DataVariable lat, DataVariable lon, double maxSize, int[] maxDims)
      Constructs a swath projection from the specified latitude and longitude data and desired polynomial size. A default tolerance is initially set for earth location to data location translation based on the resolution at the center of the projection.
      Parameters:
      lat - a data variable containing latitude data.
      lon - a data variable containing longitude data.
      maxSize - the maximum polynomial partition size in kilometres.
      maxDims - the maximum partition size in any dimension in terms of data locations.
      See Also:
    • SwathProjection

      public SwathProjection(Object obj)
      Constructs a swath projection from the specified encoding. The encoding must be a valid encoding of a swath as created by getEncoding.
      Parameters:
      obj - the object encoding.
      See Also:
  • Method Details

    • isInvertible

      public boolean isInvertible()
      Description copied from class: EarthTransform
      Determines if this transform is invertible. All transforms should translate from data location to geographic location. But to be invertible, the transform must also translate from geographic location back to data location. This method returns true unless overridden by the child class.
      Overrides:
      isInvertible in class EarthTransform
      Returns:
      true if this transform is invertible or false if not.
    • setNullMode

      public static void setNullMode(boolean flag)
      Sets the null operation mode for newly constructed swath transforms. In null mode, no operations may be performed with the swath, except the describe() and getNorthIsUp() methods. This mode is useful for informational routines that create swath transforms but want to avoid the time spent setting up the swath transform polynomials. But default, null mode is off.
      Parameters:
      flag - the null mode flag, true for null mode.
    • setTestMode

      public static void setTestMode(boolean flag)
      Sets the test operation mode for newly constructed swath transforms. In test mode, swath projections created from lat/lon data variables save the data projection for later testing. But default, test mode is off.
      Parameters:
      flag - the test mode flag, true for test mode.
    • getNorthIsUp

      public boolean getNorthIsUp()
      Returns true if north is at the top of the data. If true, then latitude values decrease as row index increases. If false, then latitude values increase as row index increases. This is a useful flag for rendering code that presents the data in a way that is familiar to the user.
    • resetTolerance

      public void resetTolerance()
      Resets the tolerance based on the resolution at the center of the swath. Also creates the seeds used to initialize the location search.
    • getWorldAxes

      public void getWorldAxes(EarthLocation earthLoc, double[] northVector, double[] eastVector)
      Description copied from class: EarthTransform2D
      Gets the world axes for this transform at the specified location. The world axes are the north-pointing unit vector and east-pointing unit vector in data coordinates.
      Overrides:
      getWorldAxes in class EarthTransform2D
      Parameters:
      earthLoc - the earth location to get the world axes. The location must transform to a valid data location, or the output vectors may contain NaN values.
      northVector - the north-pointing vector array of length 2 (modified).
      eastVector - the east-pointing vector array of length 2 (modified).
    • getDataTransform

      public EarthTransform getDataTransform()
      Gets the data projection used to create the lat/lon estimators. This is only available if the swath projection was created in test mode.
      Returns:
      the data peojection or null if not available.
    • describe

      public String describe()
      Description copied from class: EarthTransform
      Gets a string describing the earth transform type.
      Specified by:
      describe in class EarthTransform
    • transformImpl

      protected void transformImpl(DataLocation dataLoc, EarthLocation earthLoc)
      Description copied from class: EarthTransform
      Implements the data to geographic transform.
      Specified by:
      transformImpl in class EarthTransform
      See Also:
    • setTolerance

      public void setTolerance(double tolerance)
      Sets the tolerance distance for earth location transformations. The tolerance distance governs the accuracy of earth location to data location translations. Once set, a call to transform(EarthLocation) returns an approximate data location that is within the tolerance distance of the actual data location.
      Parameters:
      tolerance - the tolerance distance in kilometres.
    • getTolerance

      public double getTolerance()
      Gets the tolerance distance for earth location transformations.
      Returns:
      the tolerance distance in kilometres.
      See Also:
    • transformImpl

      protected void transformImpl(EarthLocation earthLoc, DataLocation dataLoc)
      Description copied from class: EarthTransform
      Implements the geographic to data transform.
      Specified by:
      transformImpl in class EarthTransform
      See Also:
    • getEncoding

      public Object getEncoding()
      Gets an encoded representation of this swath projection. The encoding may later be used to recreate the swath without using the original variable data.
      Specified by:
      getEncoding in interface Encodable
      Returns:
      the object encoding. The encoding object is an Object[5] array containing:
      • a BitSet object used for encoding swath partition structure information
      • a List of double[] coordinates specifying swath partition boundaries as min and max (2 arrays per partition)
      • a List of double[] arrays specifying latitude estimator coefficients
      • a List of double[] arrays specifying longitude estimator coefficients
      • an int[2] array specifying swath dimensions
      See Also:
    • useEncoding

      public void useEncoding(Object obj)
      Constructs a swath projection from the specified encoding. The encoding must be a valid encoding of a swath as created by getEncoding.
      Specified by:
      useEncoding in interface Encodable
      Parameters:
      obj - the object encoding.
      See Also:
    • toBytes

      public static byte[] toBytes(BitSet bits)
      Converts a bit set to a byte array. This method is useful for encoding the swath projection structure information into a byte stream.
      Parameters:
      bits - the bits to convert.
      Returns:
      a byte array large enough to hold all bits.
      See Also:
    • toBits

      public static BitSet toBits(byte[] byteArray)
      Converts an array of bytes to a bit set. This method is useful for decoding the swath projection structure information from a byte stream.
      Parameters:
      byteArray - the bytes to convert.
      Returns:
      a bit set large enough to hold all the byte information.
      See Also:
    • equals

      public boolean equals(Object obj)
      Compares the specified object with this swath projection for equality. The encodings of the two swath projections are compared value by value. If both swath projections were created in null mode, then they are considered equal (although this may not actually be the case).
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to be compared for equality.
      Returns:
      true if the swath projections are equivalent, or false if not.
    • main

      public static void main(String[] argv) throws Exception
      Tests this class.
      Parameters:
      argv - the array of command line parameters.
      Throws:
      Exception