Package ucar.unidata.geoloc.projection
Class LatLonProjection
- java.lang.Object
-
- ucar.unidata.geoloc.ProjectionImpl
-
- ucar.unidata.geoloc.projection.LatLonProjection
-
- All Implemented Interfaces:
Serializable
,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]- See Also:
ProjectionImpl
, Serialized Form
-
-
Field Summary
-
Fields inherited from class ucar.unidata.geoloc.ProjectionImpl
atts, defaultMapArea, defaultUnits, EARTH_RADIUS, INDEX_LAT, INDEX_LON, INDEX_X, INDEX_Y, isLatLon, name, PI, PI_OVER_2, PI_OVER_4, TOLERANCE
-
-
Constructor Summary
Constructors Constructor Description LatLonProjection()
Default constructorLatLonProjection(String name)
Create a new LatLonProjectionLatLonProjection(String name, ProjectionRect defaultMapArea)
Create a new LatLonProjectionLatLonProjection(Earth earth)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 o)
See if this projection equals the object in questiondouble
getCenterLon()
Get the center of the Longitude range.String
getProjectionTypeLabel()
Get the label to be used in the gui for this type of projectionint
hashCode()
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 coordinatesProjectionRect[]
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 parametersdouble[][]
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)
Compute lat/lon bounding box from projection bounding 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, findProjectionParameter, getClassName, getDefaultMapArea, getDefaultMapAreaLL, getDefaultUnits, getHeader, getName, getProjectionParameters, isLatLon, latLonToProj, latLonToProj, latLonToProj, latLonToProj, latLonToProj, latLonToProj, latLonToProj, latLonToProjBB, projToLatLon, projToLatLon, projToLatLon, projToLatLonBBold, setName, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ucar.unidata.geoloc.Projection
latLonToProj, projToLatLon
-
-
-
-
Constructor Detail
-
LatLonProjection
public LatLonProjection()
Default constructor
-
LatLonProjection
public LatLonProjection(Earth earth)
-
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 projectiondefaultMapArea
- bounding box
-
-
Method Detail
-
constructCopy
public ProjectionImpl constructCopy()
Description copied from class:ProjectionImpl
copy constructor - avoid clone !!- Specified by:
constructCopy
in classProjectionImpl
- Returns:
- a copy of this Projection. TODO return Projection in ver6
-
getProjectionTypeLabel
public String getProjectionTypeLabel()
Get the label to be used in the gui for this type of projection- Overrides:
getProjectionTypeLabel
in classProjectionImpl
- Returns:
- Type label
-
paramsToString
public String paramsToString()
Get a String of the parameters- Specified by:
paramsToString
in interfaceProjection
- Specified by:
paramsToString
in classProjectionImpl
- Returns:
- a String of the parameters
-
equals
public boolean equals(Object o)
See if this projection equals the object in question- Specified by:
equals
in interfaceProjection
- Specified by:
equals
in classProjectionImpl
- Parameters:
o
- object in question- Returns:
- true if it is a LatLonProjection and covers the same area
-
latLonToProj
public ProjectionPoint latLonToProj(LatLonPoint latlon, ProjectionPointImpl result)
Description copied from class:ProjectionImpl
Convert a LatLonPoint to projection coordinates- Specified by:
latLonToProj
in interfaceProjection
- Specified by:
latLonToProj
in classProjectionImpl
- Parameters:
latlon
- convert from these lat, lon coordinatesresult
- the object to write to- Returns:
- the given destPoint
-
projToLatLon
public LatLonPoint projToLatLon(ProjectionPoint world, LatLonPointImpl result)
Description copied from class:ProjectionImpl
Convert projection coordinates to a LatLonPoint Note: a new object is not created on each call for the return value.- Specified by:
projToLatLon
in interfaceProjection
- Specified by:
projToLatLon
in classProjectionImpl
- Parameters:
world
- convert from these projection coordinatesresult
- 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 classProjectionImpl
- Parameters:
from
- array of projection coordinates: from[2][n], where (from[0][i], from[1][i]) is the (x, y) coordinate of the ith pointto
- 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 classProjectionImpl
- 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 pointto
- resulting array of projection coordinates: to[2][n] where (to[0][i], to[1][i]) is the (x,y) coordinate of the ith pointlatIndex
- index of lat coordinate; must be 0 or 1lonIndex
- 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 classProjectionImpl
- Parameters:
from
- array of projection coordinates: from[2][n], where (from[0][i], from[1][i]) is the (x, y) coordinate of the ith pointto
- 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 classProjectionImpl
- 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 pointto
- resulting array of projection coordinates: to[2][n] where (to[0][i], to[1][i]) is the (x,y) coordinate of the ith pointlatIndex
- index of lat coordinate; must be 0 or 1lonIndex
- index of lon coordinate; must be 0 or 1- Returns:
- the "to" array
-
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 interfaceProjection
- Specified by:
crossSeam
in classProjectionImpl
- Parameters:
pt1
- the line goes between these two pointspt2
- 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 classProjectionImpl
- 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 interface:Projection
Compute lat/lon bounding box from projection bounding box.- Specified by:
projToLatLonBB
in interfaceProjection
- Overrides:
projToLatLonBB
in classProjectionImpl
- Parameters:
world
- projection bounding box- Returns:
- lat, lon bounding box.
-
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 1lon0
- lon of point 1lat1
- lat of point 1lon1
- lon of point 1- Returns:
- 1 or 2 ProjectionRect. If it doesnt cross the seam, the second rectangle is null.
-
-