jwo.landserf.process.proj
Class UTM

java.lang.Object
  extended byjwo.landserf.process.proj.UTM
All Implemented Interfaces:
Transformable
Direct Known Subclasses:
OSGB

public class UTM
extends Object
implements Transformable

Class for representing Universal Transverse Mercator projections. Includes forward and inverse transforms from/to lat,long. Uses transformation equations from Snyder (1987) Atlas of Map Projections, and the Ordnance Survey (2002) National GPS Network Information. If explicit projection origins are not given, an appropriate UTM zone should be set before transforming in either directionn. This can be dertermined by passing a reasonably central lat/long coordinate pair to the constructor.

Version:
2.2, 3rd October, 2004.
Author:
Jo Wood.

Field Summary
static int FROM_LAT_LONG
          Indicates a transformation from lat/lng
static int TO_LAT_LONG
          Indicates a transformation to lat/lng
 
Constructor Summary
UTM(Ellipsoid ellipsoid, float lat, float lng)
          Initialises the UTM converter with the given ellipsoid.
UTM(Ellipsoid ellipsoid, int zoneNumber, char zoneLetter)
          Initialises the UTM converter with the given ellipsoid and zone.
 
Method Summary
 boolean doInterpolation()
          Indicates whether the transformation should use nearest neighbour (false) or some interpolator (true).
 String getDescription()
          Provides a general description of the transformation.
 Ellipsoid getEllipsoid()
          Reports the ellipsoid used in the transformation.
 String getZone()
          Reports the full UTM zone of the given (lat,lng) location.
 char getZoneLetter()
          Reports the UTM zone letter of the given (lat,lng) location.
 int getZoneNumber()
          Reports the UTM zone number of the given (lat,lng) location.
 Footprint invTransformCoords(Footprint fpIn)
          Performs an inverse UTM transform on the given location.
 Footprint latLongToUTM(float lng, float lat)
          Converts the given (lat,lng) coordinates into a UTM location.
 Footprint latLongToUTM(float lng, float lat, double lngOrigin, double latOrigin, double xOffset, double yOffset, double scaleFactor)
          Converts the given (lat,lng) coordinates into a UTM location using the given scale factor and origins.
 void setInterpolation(boolean doInterpolation)
          Sets whether the transformation should use nearest neighbour (false) or some interpolator (true).
 void setZone(float lat, float lng)
          Sets the UTM zone determined by the given (lat,lng) location.
 void setZone(int zoneNumber, char zoneLetter)
          Sets the zone number and letter for subsequent transformations.
 Footprint transformCoords(Footprint fpIn)
          Performs a forward transform on the given location.
 Footprint UTMToLatLong(float easting, float northing)
          Converts the given UTM coordinates into a (lat,lng) location.
 Footprint UTMToLatLong(float easting, float northing, double lngOrigin, double latOrigin, double xOffset, double yOffset, double scaleFactor)
          Converts the given UTM coordinates intto a (lat,lng) location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FROM_LAT_LONG

public static final int FROM_LAT_LONG
Indicates a transformation from lat/lng

See Also:
Constant Field Values

TO_LAT_LONG

public static final int TO_LAT_LONG
Indicates a transformation to lat/lng

See Also:
Constant Field Values
Constructor Detail

UTM

public UTM(Ellipsoid ellipsoid,
           int zoneNumber,
           char zoneLetter)
Initialises the UTM converter with the given ellipsoid and zone. It is assumed that if this constructor is called, the forward transformation will be from UTM to Lat/long.

Parameters:
ellipsoid - to use in projection.
zoneNumber - Zone number of UTM projection.
zoneLetter - Zone letter of UTM projection.

UTM

public UTM(Ellipsoid ellipsoid,
           float lat,
           float lng)
Initialises the UTM converter with the given ellipsoid. The initial lat/long location sets the default UTM zone. This can be changed by calling the setZone() method. It is assumed that if this constructor is called, the forward transformation will be from Lat/long to UTM.

Parameters:
ellipsoid - to use in projection.
lat - Initial latitude coordinate.
lng - Initial longitude coordinate.
Method Detail

transformCoords

public Footprint transformCoords(Footprint fpIn)
Performs a forward transform on the given location. The direction of the transformation (UTM to Lat/long or lat/long to UTM) will depend on the constructor that was called.

Specified by:
transformCoords in interface Transformable
Parameters:
fpIn - Incoming footprint to transform.
Returns:
Transformed footprint.

invTransformCoords

public Footprint invTransformCoords(Footprint fpIn)
Performs an inverse UTM transform on the given location. The direction of the transformation (UTM to Lat/long or lat/long to UTM) will depend on the constructor that was called.

Specified by:
invTransformCoords in interface Transformable
Parameters:
fpIn - Incoming footprint to transform.
Returns:
Transformed footprint.

getDescription

public String getDescription()
Provides a general description of the transformation.

Specified by:
getDescription in interface Transformable
Returns:
Description of the transformation.

doInterpolation

public boolean doInterpolation()
Indicates whether the transformation should use nearest neighbour (false) or some interpolator (true).

Specified by:
doInterpolation in interface Transformable
Returns:
True if transformation should perform some local interpolation.

setInterpolation

public void setInterpolation(boolean doInterpolation)
Sets whether the transformation should use nearest neighbour (false) or some interpolator (true).

Parameters:
doInterpolation - True if transformation should perform some local interpolation.

latLongToUTM

public Footprint latLongToUTM(float lng,
                              float lat)
Converts the given (lat,lng) coordinates into a UTM location. Lat/lng should be in decimal degrees with +ve North and +ve East. The UTM zone to use should already have been set though the constructor or a call to setzone().

Parameters:
lng - Longitude (+-180)
lat - Latitude (+-90)
Returns:
UTM location.

latLongToUTM

public Footprint latLongToUTM(float lng,
                              float lat,
                              double lngOrigin,
                              double latOrigin,
                              double xOffset,
                              double yOffset,
                              double scaleFactor)
Converts the given (lat,lng) coordinates into a UTM location using the given scale factor and origins. Lat/lng should be in decimal degrees with +ve North and +ve East. This version of the converion does not require a UTM zone to be set as the origin is set explicity.

Parameters:
lng - Longitude (+-180.0).
lat - Latitude (+-90.0).
lngOrigin - Origin longitude (+-180.0).
latOrigin - Origin latitude (+-90.0).
xOffset - UTM coordinate X origin.
yOffset - UTM coordinate Y origin.
scaleFactor - Scale factor on central meridian used in transformation.
Returns:
UTM location.

UTMToLatLong

public Footprint UTMToLatLong(float easting,
                              float northing)
Converts the given UTM coordinates into a (lat,lng) location. This requires a UTM zone to have been set (via constructor) in order to complete the conversion. Lat/lng will be in decimal degrees with +ve North and +ve East.

Parameters:
easting - UTM x coordinate.
northing - UTM y coordinate.
Returns:
location in geographical coordinates (lat/long).

UTMToLatLong

public Footprint UTMToLatLong(float easting,
                              float northing,
                              double lngOrigin,
                              double latOrigin,
                              double xOffset,
                              double yOffset,
                              double scaleFactor)
Converts the given UTM coordinates intto a (lat,lng) location. Lat/lng will be in decimal degrees with +ve North and +ve East. This transformation is independent of the UTM zone defined by the constructor since all parameters are given explicitly.

Parameters:
easting - UTM x coordinate.
northing - UTM y coordinate.
lngOrigin - Origin longitude (+-180)
latOrigin - Origin latitude (+-90)
xOffset - UTM coordinate X origin.
yOffset - UTM coordinate Y origin.
scaleFactor - Scale factor on central meridian used in transformation.
Returns:
location in geographical coordinates (long/lat).

setZone

public void setZone(float lat,
                    float lng)
Sets the UTM zone determined by the given (lat,lng) location. Numbers vary from 1 to 60, where 1 is around 175W, and 60 is 175E. Letters vary from N,M,O...X going north from equator and M,L,K...C going south from equator.

Parameters:
lat - Latitude (+-90)
lng - Longitude (+-180)

setZone

public void setZone(int zoneNumber,
                    char zoneLetter)
Sets the zone number and letter for subsequent transformations.

Parameters:
zoneNumber - Zone number to use.
zoneLetter - Zone letter to use.

getZoneNumber

public int getZoneNumber()
Reports the UTM zone number of the given (lat,lng) location. Numbers vary from 1 to 60, where 1 is around 175W, and 60 is 175E.

Returns:
UTM zone number (longitudinal zone).

getZoneLetter

public char getZoneLetter()
Reports the UTM zone letter of the given (lat,lng) location. Letters vary from N,M,O...X going north from equator and M,L,K...C going south from equator. Returns Z if outside 84N or 80S.

Returns:
UTM zone letter (latitudinal zone).

getZone

public String getZone()
Reports the full UTM zone of the given (lat,lng) location.

Returns:
UTM zone (e.g 19F for southern tip of South America).

getEllipsoid

public Ellipsoid getEllipsoid()
Reports the ellipsoid used in the transformation.

Returns:
Ellipsoid used in the UTM transformation.


Copyright Jo Wood, 1996-2005, last modified, 11th March, 2005