ucar.unidata.geoloc
Class ProjectionImpl

java.lang.Object
  extended by ucar.unidata.geoloc.ProjectionImpl
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Projection
Direct Known Subclasses:
AlbersEqualArea, FlatEarth, LambertAzimuthalEqualArea, LambertConformal, LatLonProjection, Mercator, Orthographic, ProjectionAdapter, RotatedLatLon, RotatedPole, Stereographic, TransverseMercator, UtmProjection, VerticalPerspectiveView

public abstract class ProjectionImpl
extends java.lang.Object
implements Projection, java.lang.Cloneable, java.io.Serializable

Superclass for our implementations of geoloc.Projection.

All subclasses must:

If possible, set defaultmapArea to some reasonable world coord bounding box otherwise, provide a way for the user to specify it when a specific projection is created.

Note on "false_easting" and "fale_northing" projection parameters:

Author:
John Caron
See Also:
Projection, Serialized Form

Field Summary
static java.lang.String ATTR_NAME
          Projection Name
static double EARTH_RADIUS
          Earth radius in kilometers
static int INDEX_LAT
          Latitude index
static int INDEX_LON
          Longitude index
static int INDEX_X
          X index
static int INDEX_Y
          Y index
static double PI
          PI
static double PI_OVER_2
          PI/2
static double PI_OVER_4
          PI/4
 
Constructor Summary
ProjectionImpl()
           
 
Method Summary
 java.lang.Object clone()
          Clone this projection
abstract  ProjectionImpl constructCopy()
          copy constructor - avoid clone !!
abstract  boolean crossSeam(ProjectionPoint pt1, ProjectionPoint pt2)
          Does the line between these two points cross the projection "seam".
abstract  boolean equals(java.lang.Object proj)
          Returns true if this represents the same Projection as proj.
 java.lang.String getClassName()
          Get the name of the type of the projection.
 ProjectionRect getDefaultMapArea()
          Get a reasonable bounding box for this projection.
 LatLonRect getDefaultMapAreaLL()
          Get the bounding box in lat/lon.
static java.lang.String getHeader()
          Get a header for display.
 LatLonRect getLatLonBoundingBox(ProjectionRect bb)
          From GridCoordSys.
 java.lang.String getName()
          Get the name of this specific projection (also see getClassName)
 java.util.List<Parameter> getProjectionParameters()
          Get parameters as list of ucar.unidata.util.Parameter
 java.lang.String getProjectionTypeLabel()
          Get the label to be used in the gui for this type of projection.
 boolean isLatLon()
          Is this the lat/lon Projection ?
 double[][] latLonToProj(double[][] from)
          Convert lat/lon coordinates to projection coordinates.
 double[][] latLonToProj(double[][] from, double[][] to)
          Convert lat/lon coordinates to projection coordinates.
 double[][] latLonToProj(double[][] from, double[][] to, int latIndex, int lonIndex)
          Convert lat/lon coordinates to projection coordinates.
 double[][] latLonToProj(double[][] from, int latIndex, int lonIndex)
          Convert lat/lon coordinates to projection coordinates.
 ProjectionPointImpl latLonToProj(double lat, double lon)
          Convert a LatLonPoint to projection coordinates Note: a new object is now created on each call for the return value, as of 4.0.46
 float[][] latLonToProj(float[][] from)
          Convert lat/lon coordinates to projection coordinates.
 float[][] latLonToProj(float[][] from, float[][] to)
          Convert lat/lon coordinates to projection coordinates.
 float[][] latLonToProj(float[][] from, float[][] to, int latIndex, int lonIndex)
          Convert lat/lon coordinates to projection coordinates.
 float[][] latLonToProj(float[][] from, int latIndex, int lonIndex)
          Convert lat/lon coordinates to projection coordinates.
 ProjectionPoint latLonToProj(LatLonPoint latLon)
          Convert a LatLonPoint to projection coordinates Note: a new object is now created on each call for the return value, as of 4.0.46
abstract  ProjectionPoint latLonToProj(LatLonPoint latlon, ProjectionPointImpl destPoint)
          Convert a LatLonPoint to projection coordinates
 ProjectionRect latLonToProjBB(LatLonRect latlonRect)
          Convert a lat/lon bounding box to a world coordinate bounding box, by finding the minimum enclosing box.
abstract  java.lang.String paramsToString()
          Get a string representation of the projection parameters
 double[][] projToLatLon(double[][] from)
          Convert projection coordinates to lat/lon coordinates.
 double[][] projToLatLon(double[][] from, double[][] to)
          Convert projection coordinates to lat/lon coordinate.
 LatLonPointImpl projToLatLon(double x, double y)
          Convert a projection coordinate to a LatLonPoint Note: a new object is now created on each call for the return value, as of 4.0.46
 float[][] projToLatLon(float[][] from)
          Convert projection coordinates to lat/lon coordinates.
 float[][] projToLatLon(float[][] from, float[][] to)
          Convert projection coordinates to lat/lon coordinate.
 LatLonPoint projToLatLon(ProjectionPoint ppt)
          Convert projection coordinates to a LatLonPoint Note: a new object is now created on each call for the return value, as of 4.0.46
abstract  LatLonPoint projToLatLon(ProjectionPoint ppt, LatLonPointImpl destPoint)
          Convert projection coordinates to a LatLonPoint Note: a new object is not created on each call for the return value.
 LatLonRect projToLatLonBB(ProjectionRect world)
          Convert a world coordinate bounding box to a lat/lon bounding box, by finding the minimum enclosing box.
 void setDefaultMapArea(ProjectionRect bb)
          Set a reasonable bounding box for this specific projection.
 void setName(java.lang.String name)
          Set the name of this specific projection.
 java.lang.String toString()
          Get a String representation of this projection.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ATTR_NAME

public static final java.lang.String ATTR_NAME
Projection Name

See Also:
Constant Field Values

EARTH_RADIUS

public static final double EARTH_RADIUS
Earth radius in kilometers


INDEX_LAT

public static final int INDEX_LAT
Latitude index

See Also:
Constant Field Values

INDEX_LON

public static final int INDEX_LON
Longitude index

See Also:
Constant Field Values

INDEX_X

public static final int INDEX_X
X index

See Also:
Constant Field Values

INDEX_Y

public static final int INDEX_Y
Y index

See Also:
Constant Field Values

PI

public static final double PI
PI

See Also:
Constant Field Values

PI_OVER_2

public static final double PI_OVER_2
PI/2

See Also:
Constant Field Values

PI_OVER_4

public static final double PI_OVER_4
PI/4

See Also:
Constant Field Values
Constructor Detail

ProjectionImpl

public ProjectionImpl()
Method Detail

constructCopy

public abstract ProjectionImpl constructCopy()
copy constructor - avoid clone !!

Returns:
a copy of this Projection

getClassName

public java.lang.String getClassName()
Get the name of the type of the projection.

Specified by:
getClassName in interface Projection
Returns:
the class name

paramsToString

public abstract java.lang.String paramsToString()
Get a string representation of the projection parameters

Specified by:
paramsToString in interface Projection
Returns:
string representation of the projection parameters

getProjectionTypeLabel

public java.lang.String getProjectionTypeLabel()
Get the label to be used in the gui for this type of projection. This defaults to call getClassName

Returns:
Type label

latLonToProj

public abstract ProjectionPoint latLonToProj(LatLonPoint latlon,
                                             ProjectionPointImpl destPoint)
Convert a LatLonPoint to projection coordinates

Specified by:
latLonToProj in interface Projection
Parameters:
latlon - convert from these lat, lon coordinates
destPoint - the object to write to
Returns:
the given destPoint

projToLatLon

public abstract LatLonPoint projToLatLon(ProjectionPoint ppt,
                                         LatLonPointImpl destPoint)
Convert projection coordinates to a LatLonPoint Note: a new object is not created on each call for the return value.

Specified by:
projToLatLon in interface Projection
Parameters:
ppt - convert from these projection coordinates
destPoint - the object to write to
Returns:
LatLonPoint convert to these lat/lon coordinates

latLonToProj

public ProjectionPoint latLonToProj(LatLonPoint latLon)
Convert a LatLonPoint to projection coordinates Note: a new object is now created on each call for the return value, as of 4.0.46

Parameters:
latLon - convert from these lat, lon coordinates
Returns:
ProjectionPoint convert to these projection coordinates

projToLatLon

public LatLonPoint projToLatLon(ProjectionPoint ppt)
Convert projection coordinates to a LatLonPoint Note: a new object is now created on each call for the return value, as of 4.0.46

Parameters:
ppt - convert from these projection coordinates
Returns:
LatLonPoint convert to these lat/lon coordinates

crossSeam

public abstract boolean crossSeam(ProjectionPoint pt1,
                                  ProjectionPoint pt2)
Does the line between these two points cross the projection "seam".

Specified by:
crossSeam in interface Projection
Parameters:
pt1 - the line goes between these two points
pt2 - the line goes between these two points
Returns:
false if there is no seam

equals

public abstract boolean equals(java.lang.Object proj)
Returns true if this represents the same Projection as proj.

Specified by:
equals in interface Projection
Overrides:
equals in class java.lang.Object
Parameters:
proj - projection in question
Returns:
true if this represents the same Projection as proj.

getName

public java.lang.String getName()
Get the name of this specific projection (also see getClassName)

Specified by:
getName in interface Projection
Returns:
name of the projection

setName

public void setName(java.lang.String name)
Set the name of this specific projection.

Parameters:
name - name for this projection

getProjectionParameters

public java.util.List<Parameter> getProjectionParameters()
Get parameters as list of ucar.unidata.util.Parameter

Specified by:
getProjectionParameters in interface Projection
Returns:
List of parameters

isLatLon

public boolean isLatLon()
Is this the lat/lon Projection ?

Returns:
true if it is the lat/lon Projection

getHeader

public static java.lang.String getHeader()
Get a header for display.

Returns:
human readable header for display

toString

public java.lang.String toString()
Get a String representation of this projection.

Overrides:
toString in class java.lang.Object
Returns:
the name of the projection. This is what gets displayed when you add the projection object to a UI widget (e.g. label, combobox)

clone

public java.lang.Object clone()
Clone this projection

Overrides:
clone in class java.lang.Object
Returns:
a clone of this.

getDefaultMapArea

public ProjectionRect getDefaultMapArea()
Get a reasonable bounding box for this projection.

Specified by:
getDefaultMapArea in interface Projection
Returns:
reasonable bounding box

getDefaultMapAreaLL

public LatLonRect getDefaultMapAreaLL()
Get the bounding box in lat/lon.

Returns:
the LatLonRectangle for the bounding box

setDefaultMapArea

public void setDefaultMapArea(ProjectionRect bb)
Set a reasonable bounding box for this specific projection. Projections are typically specific to an area of the world; theres no bounding box that works for all projections.

Parameters:
bb - bounding box

latLonToProj

public ProjectionPointImpl latLonToProj(double lat,
                                        double lon)
Convert a LatLonPoint to projection coordinates Note: a new object is now created on each call for the return value, as of 4.0.46

Parameters:
lat - latitude of point to convert
lon - longitude of point to convert
Returns:
ProjectionPointImpl convert to these projection coordinates

projToLatLon

public LatLonPointImpl projToLatLon(double x,
                                    double y)
Convert a projection coordinate to a LatLonPoint Note: a new object is now created on each call for the return value, as of 4.0.46

Parameters:
x - x value to convert
y - y value to convert
Returns:
LatLonPointImpl convert to these lat/lon coordinates

projToLatLon

public double[][] projToLatLon(double[][] from)
Convert projection coordinates to lat/lon coordinates.

Parameters:
from - array of projection coordinates: from[2][n], where from[0][i], from[1][i] is the x, y coordinate of the ith point
Returns:
resulting array of lat/lon coordinates, where to[0][i], to[1][i] is the lat,lon coordinate of the ith point

projToLatLon

public double[][] projToLatLon(double[][] from,
                               double[][] to)
Convert projection coordinates to lat/lon coordinate.

Parameters:
from - array of projection coordinates: from[2][n], where (from[0][i], from[1][i]) is the (x, y) coordinate of the ith point
to - resulting array of lat/lon coordinates: to[2][n] where (to[0][i], to[1][i]) is the (lat, lon) coordinate of the ith point
Returns:
the "to" array

projToLatLon

public float[][] projToLatLon(float[][] from)
Convert projection coordinates to lat/lon coordinates.

Parameters:
from - array of projection coordinates: from[2][n], where from[0][i], from[1][i] is the x, y coordinate of the ith point
Returns:
resulting array of lat/lon coordinates, where to[0][i], to[1][i] is the lat,lon coordinate of the ith point

projToLatLon

public float[][] projToLatLon(float[][] from,
                              float[][] to)
Convert projection coordinates to lat/lon coordinate.

Parameters:
from - array of projection coordinates: from[2][n], where (from[0][i], from[1][i]) is the (x, y) coordinate of the ith point
to - resulting array of lat/lon coordinates: to[2][n] where (to[0][i], to[1][i]) is the (lat, lon) coordinate of the ith point
Returns:
the "to" array

latLonToProj

public double[][] latLonToProj(double[][] from)
Convert lat/lon coordinates to projection coordinates.

Parameters:
from - array of lat/lon coordinates: from[2][n], where from[0][i], from[1][i] is the (lat,lon) coordinate of the ith point
Returns:
resulting array of projection coordinates, where to[0][i], to[1][i] is the (x,y) coordinate of the ith point

latLonToProj

public double[][] latLonToProj(double[][] from,
                               double[][] to)
Convert lat/lon coordinates to projection coordinates.

Parameters:
from - array of lat/lon coordinates: from[2][n], where (from[0][i], from[1][i]) is the (lat,lon) coordinate of the ith point
to - resulting array of projection coordinates: to[2][n] where (to[0][i], to[1][i]) is the (x,y) coordinate of the ith point
Returns:
the "to" array

latLonToProj

public double[][] latLonToProj(double[][] from,
                               int latIndex,
                               int lonIndex)
Convert lat/lon coordinates to projection coordinates.

Parameters:
from - array of lat/lon coordinates: from[2][n], where (from[latIndex][i], from[lonIndex][i]) is the (lat,lon) coordinate of the ith point
latIndex - index of lat coordinate; must be 0 or 1
lonIndex - index of lon coordinate; must be 0 or 1
Returns:
resulting array of projection coordinates: to[2][n] where (to[0][i], to[1][i]) is the (x,y) coordinate of the ith point

latLonToProj

public double[][] latLonToProj(double[][] from,
                               double[][] to,
                               int latIndex,
                               int lonIndex)
Convert lat/lon coordinates to projection coordinates.

Parameters:
from - array of lat/lon coordinates: from[2][n], where (from[latIndex][i], from[lonIndex][i]) is the (lat,lon) coordinate of the ith point
to - resulting array of projection coordinates: to[2][n] where (to[0][i], to[1][i]) is the (x,y) coordinate of the ith point
latIndex - index of lat coordinate; must be 0 or 1
lonIndex - index of lon coordinate; must be 0 or 1
Returns:
the "to" array

latLonToProj

public float[][] latLonToProj(float[][] from)
Convert lat/lon coordinates to projection coordinates.

Parameters:
from - array of lat/lon coordinates: from[2][n], where from[0][i], from[1][i] is the (lat,lon) coordinate of the ith point
Returns:
resulting array of projection coordinates, where to[0][i], to[1][i] is the (x,y) coordinate of the ith point

latLonToProj

public float[][] latLonToProj(float[][] from,
                              float[][] to)
Convert lat/lon coordinates to projection coordinates.

Parameters:
from - array of lat/lon coordinates: from[2][n], where (from[0][i], from[1][i]) is the (lat,lon) coordinate of the ith point
to - resulting array of projection coordinates: to[2][n] where (to[0][i], to[1][i]) is the (x,y) coordinate of the ith point
Returns:
the "to" array

latLonToProj

public float[][] latLonToProj(float[][] from,
                              int latIndex,
                              int lonIndex)
Convert lat/lon coordinates to projection coordinates.

Parameters:
from - array of lat/lon coordinates: from[2][n], where (from[latIndex][i], from[lonIndex][i]) is the (lat,lon) coordinate of the ith point
latIndex - index of lat coordinate; must be 0 or 1
lonIndex - index of lon coordinate; must be 0 or 1
Returns:
resulting array of projection coordinates: to[2][n] where (to[0][i], to[1][i]) is the (x,y) coordinate of the ith point

latLonToProj

public float[][] latLonToProj(float[][] from,
                              float[][] to,
                              int latIndex,
                              int lonIndex)
Convert lat/lon coordinates to projection coordinates.

Parameters:
from - array of lat/lon coordinates: from[2][n], where (from[latIndex][i], from[lonIndex][i]) is the (lat,lon) coordinate of the ith point
to - resulting array of projection coordinates: to[2][n] where (to[0][i], to[1][i]) is the (x,y) coordinate of the ith point
latIndex - index of lat coordinate; must be 0 or 1
lonIndex - index of lon coordinate; must be 0 or 1
Returns:
the "to" array

latLonToProjBB

public ProjectionRect latLonToProjBB(LatLonRect latlonRect)
Convert a lat/lon bounding box to a world coordinate bounding box, by finding the minimum enclosing box. Handles lat/lon points that do not intersect the projection panel.

Parameters:
latlonRect - input lat,lon bounding box
Returns:
minimum enclosing box in world coordinates, or null if no part of the LatLonRect intersects the projection plane

projToLatLonBB

public LatLonRect projToLatLonBB(ProjectionRect world)
Convert a world coordinate bounding box to a lat/lon bounding box, by finding the minimum enclosing box.

Parameters:
world - input world coordinate bounding box
Returns:
minimum enclosing box in lat,lon coordinates.

getLatLonBoundingBox

public LatLonRect getLatLonBoundingBox(ProjectionRect bb)
From GridCoordSys. use this instead of projToLatLonBB() ?

Returns:
lat, lon bounding box.