Package noaa.coastwatch.util.trans
Class MapProjection
java.lang.Object
noaa.coastwatch.util.MetadataContainer
noaa.coastwatch.util.trans.EarthTransform
noaa.coastwatch.util.trans.EarthTransform2D
noaa.coastwatch.util.trans.MapProjection
- All Implemented Interfaces:
Cloneable
,ProjectionConstants
- Direct Known Subclasses:
GCTPProjection
,GCTPStyleProjection
The
MapProjection
class is the abstract parent of
all map projections that implement coordinate conversions for
the projection systems listed in ProjectionConstants
.- Since:
- 3.2.1
- Author:
- Peter Hollemans
-
Field Summary
Modifier and TypeFieldDescriptionprotected Datum
The map projection datum.static final String
Projection description string.protected AffineTransform
Map[x, y]
to data[row, column]
affine transform.protected AffineTransform
Data[row, column]
to map[x, y]
affine transform.protected int
The map projection spheroid code.protected int
The map projection system.protected int
The map projection system zone.Fields inherited from class noaa.coastwatch.util.trans.EarthTransform
boundaryHandler, dims
Fields inherited from interface noaa.coastwatch.util.trans.ProjectionConstants
ALASKA, ALBERS, AZMEQD, EQRECT, EQUIDC, GEO, GNOMON, GOOD, GVNSP, HAMMER, HOM, IMOLL, LAMAZ, LAMCC, MAX_PROJECTIONS, MERCAT, MILLER, MOLL, OBEQA, ORTHO, POLYC, PROJECTION_NAMES, PS, ROBIN, SNSOID, SOM, SPCS, STEREO, TM, USDEF, UTM, VGRINT, WAGIV, WAGVII
-
Constructor Summary
ModifierConstructorDescriptionprotected
MapProjection
(int system, int zone, int spheroid, int[] dimensions, AffineTransform affine) Constructs a map projection from the specified projection and affine transform. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Creates and returns a copy of this object.describe()
Gets a string describing the earth transform type.boolean
Compares the specified object with this map projection for equality.Gets the data[row, column]
to map[x, y]
affine transform.getDatum()
Gets the projection datum.getModified
(EarthLocation centerLoc, double[] pixelDims) Gets a modified version of this map projection.double[]
Gets a set of GCTP-style projection parameters if available.double[]
Gets the pixel dimensions.double
Gets the pixel size indicated by the affine transform.static int
getProjection
(String name) Gets the projection system that matches the specified name.int
Gets the projection spheroid code.Gets the projection spheroid name.getSubset
(int[] start, int[] stride, int[] length) Creates a subset version of this map projection.getSubset
(DataLocation newOrigin, int[] newDims) Creates and returns a new subset transform.int
Gets the projection system.Gets the projection system name.int
getZone()
Gets the projection zone.boolean
Gets the orientation hint.abstract void
mapTransformFor
(double[] lonLat, double[] xy) Performs a forward map transformation from (latitude, longitude) coordinates to map (x, y).abstract void
mapTransformInv
(double[] xy, double[] lonLat) Performs an inverse map transformation from map (x, y) coordinates to (latitude, longitude).protected void
setAffine
(EarthLocation centerLoc, double[] pixelDims) Sets the affines for this projection based on center and pixel dimensions.void
setPositiveLon
(boolean flag) Deprecated.As of 3.5.1, correct longitude interpretation in geographic projections are handled internally by the GeographicProjection class.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.Methods inherited from class noaa.coastwatch.util.trans.EarthTransform2D
get2DVersion, getBoundingBox, getWorldAxes, main, setPointTransform, transformToPoint
Methods inherited from class noaa.coastwatch.util.trans.EarthTransform
closest, distance, getBoundaryHandler, getDimensions, getResolution, getSpheroid, getSpheroid, isInvertible, transform, transform, transform, transform
Methods inherited from class noaa.coastwatch.util.MetadataContainer
getMetadataMap
-
Field Details
-
DESCRIPTION
Projection description string.- See Also:
-
system
protected int systemThe map projection system. -
zone
protected int zoneThe map projection system zone. -
spheroid
protected int spheroidThe map projection spheroid code. -
inverseAffine
Data[row, column]
to map[x, y]
affine transform. By inverse, we mean that the affine is used in the inverse mapping transformation. -
forwardAffine
Map[x, y]
to data[row, column]
affine transform. By forward, we mean that the affine is used in the forward mapping transformation. -
datum
The map projection datum.
-
-
Constructor Details
-
MapProjection
protected MapProjection(int system, int zone, int spheroid, int[] dimensions, AffineTransform affine) throws NoninvertibleTransformException Constructs a map projection from the specified projection and affine transform. TheSpheroidConstants
andProjectionConstants
class should be consulted for valid parameter constants.- Parameters:
system
- the map projection system.zone
- the map projection zone for State Plane and UTM projections.spheroid
- the spheroid code or -1 for user-defined. If the spheroid is user-defined, the datum should be set manually by the subclass.dimensions
- the dimensions of the data grid as[rows, columns]
.affine
- the affine transform for translating data[row, column]
to map[x, y]
.- Throws:
NoninvertibleTransformException
- if the map projection to data coordinate affine transform is not invertible.
-
-
Method Details
-
isOrientable
public boolean isOrientable()Description copied from class:EarthTransform2D
Gets the orientation hint. If a transform is orientable, then it may be better for the user to have it rotated for display so that northerly locations occur where data locations have smaller row values and southerly locations occur where data locations have larger row values. If a transform is not orientable, then it should be presented to the user exactly as-is.- Overrides:
isOrientable
in classEarthTransform2D
- Returns:
- true if the transform is orientable, or false if not. Unless overridden by the subclass, this method returns true.
-
getSystemName
Gets the projection system name. -
getSystem
public int getSystem()Gets the projection system. -
getZone
public int getZone()Gets the projection zone. -
getSpheroidName
Gets the projection spheroid name. -
getSpheroid
public int getSpheroid()Gets the projection spheroid code. -
getDatum
Gets the projection datum.- Overrides:
getDatum
in classEarthTransform
- Returns:
- the geodetic datum.
-
getAffine
Gets the data[row, column]
to map[x, y]
affine transform. -
describe
Description copied from class:EarthTransform
Gets a string describing the earth transform type.- Specified by:
describe
in classEarthTransform
-
getModified
public MapProjection getModified(EarthLocation centerLoc, double[] pixelDims) throws NoninvertibleTransformException Gets a modified version of this map projection.- Parameters:
centerLoc
- the new earth center location of the map center.pixelDims
- the new pixel dimensions in meters at the projection reference point as[height, width]
.- Returns:
- the modified version of this projection.
- Throws:
NoninvertibleTransformException
- if the map projection to data coordinate affine transform is not invertible.
-
setAffine
protected void setAffine(EarthLocation centerLoc, double[] pixelDims) throws NoninvertibleTransformException Sets the affines for this projection based on center and pixel dimensions.- Parameters:
centerLoc
- the earth location at the map center.pixelDims
- the pixel dimensions in meters at the projection reference point as[height, width]
.- Throws:
NoninvertibleTransformException
- if the map projection to data coordinate affine transform is not invertible.
-
getPixelSize
public double getPixelSize()Gets the pixel size indicated by the affine transform. The returned pixel size is only valid for square pixels.- Returns:
- the pixel size in meters.
-
getPixelDimensions
public double[] getPixelDimensions()Gets the pixel dimensions. The returned pixel dimensions are only valid for non-rotation data to map affine transforms.- Returns:
- the pixel dimensions in meters at the projection
reference point as
[height, width]
.
-
getSubset
Description copied from class:EarthTransform
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.- Overrides:
getSubset
in classEarthTransform
- Parameters:
newOrigin
- the new data location origin.newDims
- the new data location dimensions.
-
getSubset
Creates a subset version of this map projection.- Parameters:
start
- the 2D starting data coordinates.stride
- the 2D data stride.length
- the total number of values in each dimension.- Returns:
- the subset and/or subsampled transform.
-
clone
Description copied from class:EarthTransform
Creates and returns a copy of this object.- Overrides:
clone
in classEarthTransform
-
transformImpl
Description copied from class:EarthTransform
Implements the data to geographic transform.- Specified by:
transformImpl
in classEarthTransform
- See Also:
-
transformImpl
Description copied from class:EarthTransform
Implements the geographic to data transform.- Specified by:
transformImpl
in classEarthTransform
- See Also:
-
mapTransformFor
public abstract void mapTransformFor(double[] lonLat, double[] xy) Performs a forward map transformation from (latitude, longitude) coordinates to map (x, y).- Parameters:
lonLat
- the longitude and latitude in radians.xy
- the x and y in meters or Double.NaN if the transform could not be computed (modified).
-
mapTransformInv
public abstract void mapTransformInv(double[] xy, double[] lonLat) Performs an inverse map transformation from map (x, y) coordinates to (latitude, longitude).- Parameters:
xy
- the x and y in meters.lonLat
- the longitude and latitude in radians or Double.NaN if the transform could not be computed (modified).
-
setPositiveLon
Deprecated.As of 3.5.1, correct longitude interpretation in geographic projections are handled internally by the GeographicProjection class.Sets the positive longitude flag for geographic projections. When true, longitudes are converted to be positive only in calls totransform(EarthLocation)
. By default, the positive longitude flag is false and longitudes are not modified.- Parameters:
flag
- the positive longitude flag.
-
getParameters
public double[] getParameters()Gets a set of GCTP-style projection parameters if available.- Returns:
- the parameters array.
- Throws:
UnsupportedOperationException
- if the map projection properties cannot be represented using GCTP parameters.
-
getProjection
Gets the projection system that matches the specified name.- Parameters:
name
- the projection system name.- Returns:
- the matching projection code or -1 if none found.
-
equals
Compares the specified object with this map projection for equality. The GCTP-style projection parameters and affine transforms are compared value by value.
-