ucar.visad
Class UTMCoordinateSystem

java.lang.Object
  extended by visad.CoordinateSystem
      extended by visad.georef.NavigatedCoordinateSystem
          extended by visad.georef.MapProjection
              extended by ucar.visad.UTMCoordinateSystem
All Implemented Interfaces:
Serializable, XmlPersistable

public class UTMCoordinateSystem
extends MapProjection
implements XmlPersistable

Transforms between UTM coordinates and lat/lon in degrees. Limitation: all elevations are treated as 0.0. The VisAD CoordinateSystem "Reference" is lat/lon (RealTupleType.LatitudeLongitudeTuple). Uses the SRI geotransform Java package for converters, ellipsoids, etc. Each UTM position requires a complete specification including an x,y position in meters, a zone number, a hemisphere boolean flag (true in northern), and a reference ellipsoid.

Version:
$Revision: 1.18 $ $Date: 2005/05/13 18:34:06 $
See Also:
http://www.ai.sri.com/geotransform/, Serialized Form

Field Summary
static geotransform.ellipsoids.Ellipsoid AA
          AA = Airy 1830 Ellipsoid
static geotransform.ellipsoids.Ellipsoid AM
          AM = Modified Airy Ellipsoid
static geotransform.ellipsoids.Ellipsoid AN
          AN = Australian National Ellipsoid
static geotransform.ellipsoids.Ellipsoid BN
          BN = Bessel 1841 (Namibia) Ellipsoid
static geotransform.ellipsoids.Ellipsoid BR
          BR = Bessel 1841 (Ethiopia Indonesia Japan Korea)
static geotransform.ellipsoids.Ellipsoid CC
          CC = Clarke 1866 Ellipsoid
static geotransform.ellipsoids.Ellipsoid CD
          CD = Clarke 1880 Ellipsoid
static geotransform.ellipsoids.Ellipsoid EA
          EA = Everest (India 1830) Ellipsoid
static geotransform.ellipsoids.Ellipsoid EB
          EB = Everest (Sabah & Sarawak) Ellipsoid
static geotransform.ellipsoids.Ellipsoid EC
          EC = Everest (India 1956) Ellipsoid
static geotransform.ellipsoids.Ellipsoid ED
          ED = Everest (West Malaysia 1969) Ellipsoid
static geotransform.ellipsoids.Ellipsoid EE
          EE = Everest (West Malaysia & Singapore 1948)
static geotransform.ellipsoids.Ellipsoid FA
          FA = Modified Fischer 1960 Ellipsoid
static geotransform.ellipsoids.Ellipsoid HE
          HE = Helmert 1906 Ellipsoid
static geotransform.ellipsoids.Ellipsoid HO
          HO = Hough 1960 Ellipsoid
static geotransform.ellipsoids.Ellipsoid IN
          IN = International 1924 Ellipsoid
static geotransform.ellipsoids.Ellipsoid KA
          KA = Krassovsky 1940 Ellipsoid
static geotransform.ellipsoids.Ellipsoid RF
          RF = Geodetic Reference System 1980 (GRS 80)
static geotransform.ellipsoids.Ellipsoid SA
          SA = South American 1969 Ellipsoid
static geotransform.ellipsoids.Ellipsoid WD
          WD = WGS 72 Ellipsoid
static geotransform.ellipsoids.Ellipsoid WE
          WE = WGS 84 Ellipsoid
 
Constructor Summary
UTMCoordinateSystem(geotransform.ellipsoids.Ellipsoid ellipsoid, int zone, boolean hemiflag)
          Constructs an instance of a UTM coordinate transform with the supplied Ellipsoid, zone and hemisphere.
UTMCoordinateSystem(geotransform.ellipsoids.Ellipsoid ellipsoid, int zone, boolean hemiflag, Rectangle2D bounds)
          Constructs an instance of a UTM coordinate transform with the supplied Ellipsoid, zone and hemisphere.
UTMCoordinateSystem(int zone, boolean hemiflag)
          Constructs an instance using the WSG 84 ellipsoid, and given zone and hemisphere.
 
Method Summary
 double[][] ConvertUtmToLatLon(double[][] utmcoords, int[] zone, boolean[] hemisphere_north)
          Convert an array of UTM positions to lat/lon.
 double[][] ConvertUtmToLatLon(double[][] utmcoords, int zone, boolean hemisphere_north)
          Convert an array of UTM positions to lat/lon.
 Element createElement(XmlEncoder encoder)
          needed for XmlPersistable
 boolean equals(Object obj)
          Check for equality of input object to this UTMCoordinateSystem.
 double[][] fromReference(double[][] latlon)
          Convert from lat/lon (GDC) coordinates to UTM coords.
 float[][] fromReference(float[][] latlon)
          Convert from lat/lon (GDC) coordinates to UTM coords.
 Rectangle2D getDefaultMapArea()
          Get a bounding box in this coordinate system.
 boolean getHemisphereFlag()
          get boolean flag: if UTM positions in the northern hemisphere, true.
 boolean[] getHemisphereFlags()
          get array of booleans: if a UTM position is in the northern hemisphere, true.
 int getZone()
          get single UTM zone number (1...60) for the UTM positions.
 int[] getZoneNumbers()
          get UTM zone numbers (1...60) for the UTM positions.
 boolean initFromXml(XmlEncoder encoder, Element node)
          Do nothing, return true to tell the encoder that it is ok to process any methods or properties.
 double[][] toReference(double[][] utmcoords)
          Convert an array of UTM positions to lat/lon.
 float[][] toReference(float[][] utmcoords)
          Convert an array of UTM positions to lat/lon.
 String toString()
          Print elllipsoid mean radius and inverse flattening
 
Methods inherited from class visad.georef.MapProjection
getCenterLatLon, getLatLon, isLatLonOrder, isXYOrder
 
Methods inherited from class visad.georef.NavigatedCoordinateSystem
getLatitudeIndex, getLongitudeIndex
 
Methods inherited from class visad.CoordinateSystem
canConvert, fromReference, fromReference, getCoordinateSystemUnits, getDimension, getReference, getReferenceUnits, toReference, toReference, transformCoordinates, transformCoordinates, transformCoordinates, transformCoordinates, transformCoordinatesFreeUnits, transformCoordinatesFreeUnits
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AA

public static final geotransform.ellipsoids.Ellipsoid AA
AA = Airy 1830 Ellipsoid


AM

public static final geotransform.ellipsoids.Ellipsoid AM
AM = Modified Airy Ellipsoid


AN

public static final geotransform.ellipsoids.Ellipsoid AN
AN = Australian National Ellipsoid


BN

public static final geotransform.ellipsoids.Ellipsoid BN
BN = Bessel 1841 (Namibia) Ellipsoid


BR

public static final geotransform.ellipsoids.Ellipsoid BR
BR = Bessel 1841 (Ethiopia Indonesia Japan Korea)


CC

public static final geotransform.ellipsoids.Ellipsoid CC
CC = Clarke 1866 Ellipsoid


CD

public static final geotransform.ellipsoids.Ellipsoid CD
CD = Clarke 1880 Ellipsoid


EA

public static final geotransform.ellipsoids.Ellipsoid EA
EA = Everest (India 1830) Ellipsoid


EB

public static final geotransform.ellipsoids.Ellipsoid EB
EB = Everest (Sabah & Sarawak) Ellipsoid


EC

public static final geotransform.ellipsoids.Ellipsoid EC
EC = Everest (India 1956) Ellipsoid


ED

public static final geotransform.ellipsoids.Ellipsoid ED
ED = Everest (West Malaysia 1969) Ellipsoid


EE

public static final geotransform.ellipsoids.Ellipsoid EE
EE = Everest (West Malaysia & Singapore 1948)


FA

public static final geotransform.ellipsoids.Ellipsoid FA
FA = Modified Fischer 1960 Ellipsoid


HE

public static final geotransform.ellipsoids.Ellipsoid HE
HE = Helmert 1906 Ellipsoid


HO

public static final geotransform.ellipsoids.Ellipsoid HO
HO = Hough 1960 Ellipsoid


IN

public static final geotransform.ellipsoids.Ellipsoid IN
IN = International 1924 Ellipsoid


KA

public static final geotransform.ellipsoids.Ellipsoid KA
KA = Krassovsky 1940 Ellipsoid


RF

public static final geotransform.ellipsoids.Ellipsoid RF
RF = Geodetic Reference System 1980 (GRS 80)


SA

public static final geotransform.ellipsoids.Ellipsoid SA
SA = South American 1969 Ellipsoid


WD

public static final geotransform.ellipsoids.Ellipsoid WD
WD = WGS 72 Ellipsoid


WE

public static final geotransform.ellipsoids.Ellipsoid WE
WE = WGS 84 Ellipsoid

Constructor Detail

UTMCoordinateSystem

public UTMCoordinateSystem(geotransform.ellipsoids.Ellipsoid ellipsoid,
                           int zone,
                           boolean hemiflag)
                    throws VisADException
Constructs an instance of a UTM coordinate transform with the supplied Ellipsoid, zone and hemisphere. The ellipsoid should be the one used as a basis for the UTM coordinates. The zone is the UTM zone which has positions to be converted; hemiflag is a boolean, true if points are northern hemisphere. You can convert points from more than one zone and hemisphere by using the method ConvertUtmToLatLon. The reference coordinate system is RealTupleType.LatitudeLongitudeTuple; the incoming units are assumed to be UTM coords based on the input ellipsoid. Most USGS topographic maps use the 1927 North American Datum (NAD 27); new maps are being slowly revised to NAD 83. To construct Ellipsoids for the first argument, import geotransform.jar, and do new CC_Ellipsoid() for NAD 27 (Clark 1866 ellipsoid), or new RF_Ellipsoid() for NAD 83 (GRS 80 ellipsoid), or new WE_Ellipsoid() for WSG 84. See http://www.ai.sri.com/geotransform/api.html for more details about 239 supported datums.

Parameters:
ellipsoid - the basis for some UTM coordinate system; many choices possible
zone - the UTM zone which has positions to be converted
hemiflag - a boolean, true if points are in the northern hemisphere
Throws:
NullPointerException - if the ellipsoid is null.
VisADException

UTMCoordinateSystem

public UTMCoordinateSystem(geotransform.ellipsoids.Ellipsoid ellipsoid,
                           int zone,
                           boolean hemiflag,
                           Rectangle2D bounds)
                    throws VisADException
Constructs an instance of a UTM coordinate transform with the supplied Ellipsoid, zone and hemisphere. The ellipsoid should be the one used as a basis for the UTM coordinates. The zone is the UTM zone which has positions to be converted; hemiflag is a boolean, true if points are northern hemisphere. You can convert points from more than one zone and hemisphere by using the method ConvertUtmToLatLon. The reference coordinate system is RealTupleType.LatitudeLongitudeTuple; the incoming units are assumed to be UTM coords based on the input ellipsoid. Most USGS topographic maps use the 1927 North American Datum (NAD 27); new maps are being slowly revised to NAD 83. To construct Ellipsoids for the first argument, import geotransform.jar, and do new CC_Ellipsoid() for NAD 27 (Clark 1866 ellipsoid), or new RF_Ellipsoid() for NAD 83 (GRS 80 ellipsoid), or new WE_Ellipsoid() for WSG 84. See http://www.ai.sri.com/geotransform/api.html for more details about 239 supported datums.

Parameters:
ellipsoid - the basis for some UTM coordinate system; many choices possible
zone - the UTM zone which has positions to be converted
bounds - Linear2DSet describing the bounds of this MapProjection
hemiflag - a boolean, true if points are in the northern hemisphere
Throws:
NullPointerException - if the ellipsoid is null.
VisADException

UTMCoordinateSystem

public UTMCoordinateSystem(int zone,
                           boolean hemiflag)
                    throws VisADException
Constructs an instance using the WSG 84 ellipsoid, and given zone and hemisphere. This ellipsoid should be the one used as a basis for the UTM coordinates. If you don't know the ellipsoid for your UTM values you will get approximately correct conversions using this cstr. "A mismatch between datums on your map and GPS receiver can cause errors of several hundred meters."

Parameters:
zone - the UTM zone which has positions to be converted
hemiflag - a boolean, true if points are in the northern hemisphere
Throws:
VisADException
Method Detail

toString

public String toString()
Print elllipsoid mean radius and inverse flattening

Overrides:
toString in class MapProjection
Returns:
string version of this

equals

public boolean equals(Object obj)
Check for equality of input object to this UTMCoordinateSystem.

Specified by:
equals in class CoordinateSystem
Parameters:
obj - other object in question
Returns:
true if the object in question is a UTMCoordinateSystem and it's ellipsoid, zone, & hemisphere are equal to this object's values.

ConvertUtmToLatLon

public double[][] ConvertUtmToLatLon(double[][] utmcoords,
                                     int[] zone,
                                     boolean[] hemisphere_north)
                              throws VisADException
Convert an array of UTM positions to lat/lon. All elevations zero. The UTM positions may be in more than one zone or one hemisphere. Each UTM position has an x,y pair, a zone number, and a hemisphere boolean flag. Lengths of all three arrays should be the same, the number of positions to convert., or both "zone" and "hemisphere_north" may both have one value for the case where all UTM positions are in the same zone.

Parameters:
utmcoords - array with UTM x,y values; x=utmcoords[0][i], y=utmcoords[1][i]
zone - array of the UTM zones for each of these positions
hemisphere_north - array of the UTM flags for each of these positions true if the UTM position is in the northern hemisphere
Returns:
a double[][] array of lat/lon; lat=result[0][i], lon=result[1][i]
Throws:
VisADException

ConvertUtmToLatLon

public double[][] ConvertUtmToLatLon(double[][] utmcoords,
                                     int zone,
                                     boolean hemisphere_north)
                              throws VisADException
Convert an array of UTM positions to lat/lon. The UTM positions are all assumed to be in the given zone and hemisphere args. Each UTM position has an x,y pair, a zone number, and a hemisphere boolean flag. Treats all positions as at zero elevation.

Parameters:
utmcoords - array with UTM x,y values; x=utmcoords[0][i], y=utmcoords[1][i]
zone - the single UTM zone for all of these positions
hemisphere_north - the hemisphere flag for all of these positions (true=N)
Returns:
a double [][] array of lat/lon; lat=result[0][i], lon=result[1][i]
Throws:
VisADException

toReference

public double[][] toReference(double[][] utmcoords)
                       throws VisADException
Convert an array of UTM positions to lat/lon. The UTM positions are all assumed have the zone and hemisphere used in the cstr. Each UTM position has an x,y pair, a zone number, and a hemisphere boolean flag. Treats all positions as at zero elevation.

Specified by:
toReference in class CoordinateSystem
Parameters:
utmcoords - array with UTM x,y values; x=utmcoords[0][i], y=utmcoords[1][i]
Returns:
a double [][] array of lat/lon; lat=result[0][i], lon=result[1][i]
Throws:
VisADException

toReference

public float[][] toReference(float[][] utmcoords)
                      throws VisADException
Convert an array of UTM positions to lat/lon. The UTM positions are all assumed have the zone and hemisphere used in the cstr. Each UTM position has an x,y pair, a zone number, and a hemisphere boolean flag. Treats all positions as at zero elevation.

Overrides:
toReference in class CoordinateSystem
Parameters:
utmcoords - array with UTM x,y values; x=utmcoords[0][i], y=utmcoords[1][i]
Returns:
a double [][] array of lat/lon; lat=result[0][i], lon=result[1][i]
Throws:
VisADException

fromReference

public double[][] fromReference(double[][] latlon)
                         throws VisADException
Convert from lat/lon (GDC) coordinates to UTM coords. Note this finds UTM x/y and corresponding UTM zones (1...60) - use method getZoneNumbers(), and hemisphere flags == true if north - use method getHemisphereFlags(). All positions' elevations are set to zero.

Specified by:
fromReference in class CoordinateSystem
Parameters:
latlon - lat/lon values (lat = latlon[0][i], lon=latlon[1][i])
Returns:
UTM coordinates (x = result[0][i], y=result[1][i])
Throws:
VisADException - unable to make transformation

fromReference

public float[][] fromReference(float[][] latlon)
                        throws VisADException
Convert from lat/lon (GDC) coordinates to UTM coords. Note this finds UTM x/y and corresponding UTM zones (1...60) - use method getZoneNumbers(), and hemisphere flags == true if north - use method getHemisphereFlags(). All positions' elevations are set to zero.

Overrides:
fromReference in class CoordinateSystem
Parameters:
latlon - lat/lon values (lat = latlon[0][i], lon=latlon[1][i])
Returns:
UTM coordinates (x = result[0][i], y=result[1][i])
Throws:
VisADException - unable to make transformation

getZoneNumbers

public int[] getZoneNumbers()
get UTM zone numbers (1...60) for the UTM positions.

Returns:
array of zone numbers for values

getHemisphereFlags

public boolean[] getHemisphereFlags()
get array of booleans: if a UTM position is in the northern hemisphere, true.

Returns:
array of hemisphere flags for values

getZone

public int getZone()
get single UTM zone number (1...60) for the UTM positions. Use this only to check constructor argument.

Returns:
get the UTM zone for the positions

getHemisphereFlag

public boolean getHemisphereFlag()
get boolean flag: if UTM positions in the northern hemisphere, true. Use this only to check constructor argument.

Returns:
UTM hemisphere flag for this CS

getDefaultMapArea

public Rectangle2D getDefaultMapArea()
Get a bounding box in this coordinate system. Return an x-y rectangle that covers most of a UTM zone, in meters.

Specified by:
getDefaultMapArea in class MapProjection
Returns:
a default MapArea of a UTM zone in UTM x-y meters.

createElement

public Element createElement(XmlEncoder encoder)
needed for XmlPersistable

Specified by:
createElement in interface XmlPersistable
Parameters:
encoder - encoder for encoding
Returns:
this as an encoded Element

initFromXml

public boolean initFromXml(XmlEncoder encoder,
                           Element node)
Do nothing, return true to tell the encoder that it is ok to process any methods or properties. This is needed for XmlPersistable

Specified by:
initFromXml in interface XmlPersistable
Parameters:
encoder - encoder for encoding
node - node to initialize from
Returns:
true