Package noaa.coastwatch.util.trans
Class SwathProjection
java.lang.Object
noaa.coastwatch.util.MetadataContainer
noaa.coastwatch.util.trans.EarthTransform
noaa.coastwatch.util.trans.EarthTransform2D
noaa.coastwatch.util.trans.SwathProjection
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 Summary
Modifier and TypeFieldDescriptionstatic final String
Projection description string.static final int
Thetransform(EarthLocation)
maximum iterations.static final double
The default tolerance distance as a fraction of the resolution.Fields inherited from class noaa.coastwatch.util.trans.EarthTransform
boundaryHandler, dims
-
Constructor Summary
ConstructorDescriptionSwathProjection
(Object obj) Constructs a swath projection from the specified encoding.SwathProjection
(DataVariable lat, DataVariable lon, double maxSize, int[] maxDims) Constructs a swath projection from the specified latitude and longitude data and desired polynomial size. -
Method Summary
Modifier and TypeMethodDescriptiondescribe()
Gets a string describing the earth transform type.boolean
Compares the specified object with this swath projection for equality.Gets the data projection used to create the lat/lon estimators.Gets an encoded representation of this swath projection.boolean
Returns true if north is at the top of the data.double
Gets the tolerance distance for earth location transformations.void
getWorldAxes
(EarthLocation earthLoc, double[] northVector, double[] eastVector) Gets the world axes for this transform at the specified location.boolean
Determines if this transform is invertible.static void
Tests this class.void
Resets the tolerance based on the resolution at the center of the swath.static void
setNullMode
(boolean flag) Sets the null operation mode for newly constructed swath transforms.static void
setTestMode
(boolean flag) Sets the test operation mode for newly constructed swath transforms.void
setTolerance
(double tolerance) Sets the tolerance distance for earth location transformations.static BitSet
toBits
(byte[] byteArray) Converts an array of bytes to a bit set.static byte[]
Converts a bit set to a byte array.protected void
transformImpl
(DataLocation dataLoc, EarthLocation earthLoc) Implements the data to geographic transform.protected void
transformImpl
(EarthLocation earthLoc, DataLocation dataLoc) Implements the geographic to data transform.void
useEncoding
(Object obj) Constructs a swath projection from the specified encoding.Methods inherited from class noaa.coastwatch.util.trans.EarthTransform2D
get2DVersion, getBoundingBox, isOrientable, setPointTransform, transformToPoint
Methods inherited from class noaa.coastwatch.util.trans.EarthTransform
clone, closest, distance, getBoundaryHandler, getDatum, getDimensions, getResolution, getSpheroid, getSpheroid, getSubset, transform, transform, transform, transform
Methods inherited from class noaa.coastwatch.util.MetadataContainer
getMetadataMap
-
Field Details
-
TOLERANCE_FACTOR
public static final double TOLERANCE_FACTORThe default tolerance distance as a fraction of the resolution.- See Also:
-
MAX_ITERATIONS
public static final int MAX_ITERATIONSThetransform(EarthLocation)
maximum iterations.- See Also:
-
DESCRIPTION
Projection description string.- See Also:
-
-
Constructor Details
-
SwathProjection
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
Constructs a swath projection from the specified encoding. The encoding must be a valid encoding of a swath as created bygetEncoding
.- 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 classEarthTransform
- 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 thedescribe()
andgetNorthIsUp()
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
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 classEarthTransform2D
- 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
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
Description copied from class:EarthTransform
Gets a string describing the earth transform type.- Specified by:
describe
in classEarthTransform
-
transformImpl
Description copied from class:EarthTransform
Implements the data to geographic transform.- Specified by:
transformImpl
in classEarthTransform
- 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 totransform(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
Description copied from class:EarthTransform
Implements the geographic to data transform.- Specified by:
transformImpl
in classEarthTransform
- See Also:
-
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 interfaceEncodable
- 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
ofdouble[]
coordinates specifying swath partition boundaries as min and max (2 arrays per partition) - a
List
ofdouble[]
arrays specifying latitude estimator coefficients - a
List
ofdouble[]
arrays specifying longitude estimator coefficients - an
int[2]
array specifying swath dimensions
- a
- See Also:
-
useEncoding
Constructs a swath projection from the specified encoding. The encoding must be a valid encoding of a swath as created bygetEncoding
.- Specified by:
useEncoding
in interfaceEncodable
- Parameters:
obj
- the object encoding.- See Also:
-
toBytes
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
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
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). -
main
Tests this class.- Parameters:
argv
- the array of command line parameters.- Throws:
Exception
-