Class EarthTransform

java.lang.Object
noaa.coastwatch.util.MetadataContainer
noaa.coastwatch.util.trans.EarthTransform
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
EarthTransform2D

public abstract class EarthTransform extends MetadataContainer
The EarthTransform class translates between data coordinates and geographic coordinates in latitude and longitude degrees.
Since:
3.1.0
Author:
Peter Hollemans
  • Field Details

    • dims

      protected int[] dims
      Data location dimensions.
    • boundaryHandler

      protected BoundaryHandler boundaryHandler
      The boundary handler for this transform or null for none.
  • Constructor Details

    • EarthTransform

      public EarthTransform()
  • Method Details

    • get2DVersion

      public abstract EarthTransform2D get2DVersion()
      Gets a version of this transform that can be used with 2D data locations.
      Returns:
      the 2D version of this transform.
      Since:
      3.3.1
    • getDatum

      public Datum getDatum()
      Gets the transform datum. Unless overridden by the child class, this method returns WGS84.
      Returns:
      the geodetic datum.
    • isInvertible

      public boolean isInvertible()
      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.
      Returns:
      true if this transform is invertible or false if not.
      Since:
      3.5.0
    • closest

      public DataLocation closest(EarthLocation targetEarthLoc, DataLocation targetDataLoc)
      Gets the closest integer data location to a specified geographic location.
      Parameters:
      targetEarthLoc - the target earth location to locate the closest valid data location.
      targetDataLoc - the data location or null. If null, an object is created and returned. If non-null, the object is simply modified.
      Returns:
      the data location. The data location may be marked invalid if no closest data location can be found within the data location bounds of this transform.
      Since:
      3.8.1
    • getBoundaryHandler

      public BoundaryHandler getBoundaryHandler()
      Gets the boundary handler for this transform that handles boundary checking and splitting.
      Returns:
      the boundary handler or null if no special bounary handling is performed by this transform.
      Since:
      3.5.1
    • transform

      public EarthLocation transform(DataLocation dataLoc)
      Converts data coordinates to geographic coordinates.
      Parameters:
      dataLoc - the data location.
      Returns:
      the earth location. The earth location may contain Double.NaN if no conversion is possible.
      See Also:
    • transform

      public EarthLocation transform(DataLocation dataLoc, EarthLocation earthLoc)
      Converts data coordinates to geographic coordinates.
      Parameters:
      dataLoc - the data location.
      earthLoc - the earth location or null. If null, an object is created and returned. If non-null, the object is simply modified.
      Returns:
      the earth location. The earth location may contain Double.NaN if no conversion is possible.
      See Also:
    • transformImpl

      protected abstract void transformImpl(DataLocation dataLoc, EarthLocation earthLoc)
      Implements the data to geographic transform.
      See Also:
    • transform

      public DataLocation transform(EarthLocation earthLoc)
      Converts geographic coordinates to data coordinates.
      Parameters:
      earthLoc - the earth location.
      Returns:
      the data location. The data location may contain Double.NaN if no conversion is possible.
      See Also:
    • transform

      public DataLocation transform(EarthLocation earthLoc, DataLocation dataLoc)
      Converts geographic coordinates to data coordinates.
      Parameters:
      earthLoc - the earth location.
      dataLoc - the data location or null. If null, an object is created and returned. If non-null, the object is simply modified.
      Returns:
      the data location. The data location may contain Double.NaN if no conversion is possible.
      See Also:
    • transformImpl

      protected abstract void transformImpl(EarthLocation earthLoc, DataLocation dataLoc)
      Implements the geographic to data transform.
      See Also:
    • describe

      public abstract String describe()
      Gets a string describing the earth transform type.
    • distance

      public double distance(DataLocation loc1, DataLocation loc2)
      Calculates the distance between two data locations.
      Parameters:
      loc1 - the first data coordinate.
      loc2 - the second data coordinate.
      Returns:
      the distance between points in kilometers.
      See Also:
    • getSubset

      public EarthTransform getSubset(DataLocation newOrigin, int[] newDims)
      Creates and returns a new subset transform. The new transform is arranged with the specified new origin and dimensions. For example, if the transform maps the data location (100,100) to earth location (40N, 120W), and a translated transform is created with (100,100) as the new origin, then the new transform will map (0,0) to (40N, 120W). Note that not all transforms support subsets.
      Parameters:
      newOrigin - the new data location origin.
      newDims - the new data location dimensions.
      Throws:
      UnsupportedOperationException - if the underlying Earth transform class does not support the creation of subset transforms.
    • getResolution

      public double[] getResolution(DataLocation loc)
      Gets the projection resolution at the specified location. The calcuation uses a centered difference approach with increments of 0.5 on all sides of the data location to calculate the resolution in all dimensions in km/pixel.
      Parameters:
      loc - the data location at which to calculate the resolution.
      Returns:
      the resolution in each dimension in km/pixel.
    • getDimensions

      public int[] getDimensions()
      Gets the transform data location dimensions.
    • clone

      public Object clone()
      Creates and returns a copy of this object.
      Overrides:
      clone in class MetadataContainer
    • getSpheroid

      public static int getSpheroid(double semiMajor, double semiMinor)
      Gets the spheroid that most closely resembles the specified parameters.
      Parameters:
      semiMajor - the spheroid semi-major axis in meters.
      semiMinor - the spheroid semi-minor axis in meters.
      Returns:
      the matching spheroid code or -1 if none found.
    • getSpheroid

      public static int getSpheroid(String name)
      Gets the spheroid that matches the specified name.
      Parameters:
      name - the spheroid name.
      Returns:
      the matching spheroid code or -1 if none found.