ucar.unidata.geoloc.projection
Class LatLonProjection

java.lang.Object
  extended by ucar.unidata.geoloc.ProjectionImpl
      extended by ucar.unidata.geoloc.projection.LatLonProjection
All Implemented Interfaces:
Serializable, Cloneable, Projection

public class LatLonProjection
extends ProjectionImpl

This is the "fake" identity projection where world coord = latlon coord. Topologically its the same as a cylinder tangent to the earth at the equator. The cylinder is cut at the "seam" = centerLon +- 180. Longitude values are always kept in the range [centerLon +-180]

Author:
John Caron
See Also:
ProjectionImpl, Serialized Form

Field Summary
 
Fields inherited from class ucar.unidata.geoloc.ProjectionImpl
ATTR_NAME, atts, defaultMapArea, EARTH_RADIUS, INDEX_LAT, INDEX_LON, INDEX_X, INDEX_Y, isLatLon, name, PI, PI_OVER_2, PI_OVER_4, TOLERANCE
 
Constructor Summary
LatLonProjection()
          Default constructor
LatLonProjection(String name)
          Create a new LatLonProjection
LatLonProjection(String name, ProjectionRect defaultMapArea)
          Create a new LatLonProjection
 
Method Summary
 Object clone()
          Clone this projection
 ProjectionImpl constructCopy()
          copy constructor - avoid clone !!
 boolean crossSeam(ProjectionPoint pt1, ProjectionPoint pt2)
          Does the line between these two points cross the projection "seam".
 boolean equals(Object p)
          See if this projection equals the object in question
 double getCenterLon()
          Get the center of the Longitude range.
 String getClassName()
          Get the class name
 String getProjectionTypeLabel()
          Get the label to be used in the gui for this type of projection
 double[][] latLonToProj(double[][] from, double[][] to, int latIndex, int lonIndex)
          Convert lat/lon coordinates to projection coordinates.
 float[][] latLonToProj(float[][] from, float[][] to, int latIndex, int lonIndex)
          Convert lat/lon coordinates to projection coordinates.
 ProjectionPoint latLonToProj(LatLonPoint latlon, ProjectionPointImpl result)
          Convert a LatLonPoint to projection coordinates
 ProjectionRect[] latLonToProjRect(double lat0, double lon0, double lat1, double lon1)
          Create a latlon rectangle and split it into the equivalent ProjectionRect using this LatLonProjection.
 ProjectionRect[] latLonToProjRect(LatLonRect latlonR)
          Split a latlon rectangle to the equivalent ProjectionRect using this LatLonProjection to split it at the seam if needed.
 String paramsToString()
          Get a String of the parameters
 double[][] projToLatLon(double[][] from, double[][] to)
          Convert projection coordinates to lat/lon coordinate.
 float[][] projToLatLon(float[][] from, float[][] to)
          Convert projection coordinates to lat/lon coordinate.
 LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result)
          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.
 double setCenterLon(double centerLon)
          Set the center of the Longitude range.
 void setDefaultMapArea(ProjectionRect bb)
          Set a reasonable bounding box for this projection.
 
Methods inherited from class ucar.unidata.geoloc.ProjectionImpl
addParameter, addParameter, addParameter, getDefaultMapArea, getDefaultMapAreaLL, getHeader, getLatLonBoundingBox, getName, getProjectionParameters, isLatLon, latLonToProj, latLonToProj, latLonToProj, latLonToProj, latLonToProj, latLonToProj, latLonToProj, latLonToProj, latLonToProjBB, projToLatLon, projToLatLon, projToLatLon, projToLatLon, setName, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LatLonProjection

public LatLonProjection()
Default constructor


LatLonProjection

public LatLonProjection(String name)
Create a new LatLonProjection

Parameters:
name - name of projection

LatLonProjection

public LatLonProjection(String name,
                        ProjectionRect defaultMapArea)
Create a new LatLonProjection

Parameters:
name - name of projection
defaultMapArea - bounding box
Method Detail

constructCopy

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

Specified by:
constructCopy in class ProjectionImpl
Returns:
a copy of this Projection

getClassName

public String getClassName()
Get the class name

Specified by:
getClassName in interface Projection
Overrides:
getClassName in class ProjectionImpl
Returns:
class name

getProjectionTypeLabel

public String getProjectionTypeLabel()
Get the label to be used in the gui for this type of projection

Overrides:
getProjectionTypeLabel in class ProjectionImpl
Returns:
Type label

paramsToString

public String paramsToString()
Get a String of the parameters

Specified by:
paramsToString in interface Projection
Specified by:
paramsToString in class ProjectionImpl
Returns:
a String of the parameters

equals

public boolean equals(Object p)
See if this projection equals the object in question

Specified by:
equals in interface Projection
Specified by:
equals in class ProjectionImpl
Parameters:
p - object in question
Returns:
true if it is a LatLonProjection and covers the same area

latLonToProj

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

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

projToLatLon

public LatLonPoint projToLatLon(ProjectionPoint world,
                                LatLonPointImpl result)
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
Specified by:
projToLatLon in class ProjectionImpl
Parameters:
world - convert from these projection coordinates
result - the object to write to
Returns:
LatLonPoint convert to these lat/lon coordinates

projToLatLon

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

Overrides:
projToLatLon in class ProjectionImpl
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 float[][] latLonToProj(float[][] from,
                              float[][] to,
                              int latIndex,
                              int lonIndex)
Convert lat/lon coordinates to projection coordinates.

Overrides:
latLonToProj in class ProjectionImpl
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

projToLatLon

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

Overrides:
projToLatLon in class ProjectionImpl
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,
                               double[][] to,
                               int latIndex,
                               int lonIndex)
Convert lat/lon coordinates to projection coordinates.

Overrides:
latLonToProj in class ProjectionImpl
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

clone

public Object clone()
Clone this projection

Overrides:
clone in class ProjectionImpl
Returns:
a clone of this projection

setCenterLon

public double setCenterLon(double centerLon)
Set the center of the Longitude range. It is normalized to +/- 180. The cylinder is cut at the "seam" = centerLon +- 180. Use this to keep the Longitude values kept in the range [centerLon +-180], which makes seam handling easier.

Parameters:
centerLon - the center of the Longitude range.
Returns:
centerLon normalized to +/- 180.

getCenterLon

public double getCenterLon()
Get the center of the Longitude range. It is normalized to +/- 180.

Returns:
the center longitude

crossSeam

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

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

setDefaultMapArea

public void setDefaultMapArea(ProjectionRect bb)
Set a reasonable bounding box for this projection.

Overrides:
setDefaultMapArea in class ProjectionImpl
Parameters:
bb - a reasonable bounding box

latLonToProjRect

public ProjectionRect[] latLonToProjRect(LatLonRect latlonR)
Split a latlon rectangle to the equivalent ProjectionRect using this LatLonProjection to split it at the seam if needed.

Parameters:
latlonR - the latlon rectangle to transform
Returns:
1 or 2 ProjectionRect. If it doesnt cross the seam, the second rectangle is null.

projToLatLonBB

public LatLonRect projToLatLonBB(ProjectionRect world)
Description copied from class: ProjectionImpl
Convert a world coordinate bounding box to a lat/lon bounding box, by finding the minimum enclosing box.

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

latLonToProjRect

public ProjectionRect[] latLonToProjRect(double lat0,
                                         double lon0,
                                         double lat1,
                                         double lon1)
Create a latlon rectangle and split it into the equivalent ProjectionRect using this LatLonProjection. The latlon rect is constructed from 2 lat/lon points. The lon values are considered coords in the latlonProjection, and so do not have to be +/- 180.

Parameters:
lat0 - lat of point 1
lon0 - lon of point 1
lat1 - lat of point 1
lon1 - lon of point 1
Returns:
1 or 2 ProjectionRect. If it doesnt cross the seam, the second rectangle is null.


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.