Package noaa.coastwatch.util.trans
Class EarthTransform
java.lang.Object
noaa.coastwatch.util.MetadataContainer
noaa.coastwatch.util.trans.EarthTransform
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
EarthTransform2D
The
EarthTransform
class translates between data coordinates and
geographic coordinates in latitude and longitude degrees.- Since:
- 3.1.0
- Author:
- Peter Hollemans
-
Field Summary
Modifier and TypeFieldDescriptionprotected BoundaryHandler
The boundary handler for this transform or null for none.protected int[]
Data location dimensions. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates and returns a copy of this object.closest
(EarthLocation targetEarthLoc, DataLocation targetDataLoc) Gets the closest integer data location to a specified geographic location.abstract String
describe()
Gets a string describing the earth transform type.double
distance
(DataLocation loc1, DataLocation loc2) Calculates the distance between two data locations.abstract EarthTransform2D
Gets a version of this transform that can be used with 2D data locations.Gets the boundary handler for this transform that handles boundary checking and splitting.getDatum()
Gets the transform datum.int[]
Gets the transform data location dimensions.double[]
Gets the projection resolution at the specified location.static int
getSpheroid
(double semiMajor, double semiMinor) Gets the spheroid that most closely resembles the specified parameters.static int
getSpheroid
(String name) Gets the spheroid that matches the specified name.getSubset
(DataLocation newOrigin, int[] newDims) Creates and returns a new subset transform.boolean
Determines if this transform is invertible.transform
(DataLocation dataLoc) Converts data coordinates to geographic coordinates.transform
(DataLocation dataLoc, EarthLocation earthLoc) Converts data coordinates to geographic coordinates.transform
(EarthLocation earthLoc) Converts geographic coordinates to data coordinates.transform
(EarthLocation earthLoc, DataLocation dataLoc) Converts geographic coordinates to data coordinates.protected abstract void
transformImpl
(DataLocation dataLoc, EarthLocation earthLoc) Implements the data to geographic transform.protected abstract void
transformImpl
(EarthLocation earthLoc, DataLocation dataLoc) Implements the geographic to data transform.Methods inherited from class noaa.coastwatch.util.MetadataContainer
getMetadataMap
-
Field Details
-
dims
protected int[] dimsData location dimensions. -
boundaryHandler
The boundary handler for this transform or null for none.
-
-
Constructor Details
-
EarthTransform
public EarthTransform()
-
-
Method Details
-
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
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
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
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
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
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
Implements the data to geographic transform.- See Also:
-
transform
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
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
Implements the geographic to data transform.- See Also:
-
describe
Gets a string describing the earth transform type. -
distance
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
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
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
Creates and returns a copy of this object.- Overrides:
clone
in classMetadataContainer
-
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
Gets the spheroid that matches the specified name.- Parameters:
name
- the spheroid name.- Returns:
- the matching spheroid code or -1 if none found.
-