PamUtils
Class LatLong

java.lang.Object
  extended by PamUtils.LatLong
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
GpsData

public class LatLong
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Class for handling and formatting latitude and longitude data. Only contains two variables, which are assumed to be in decimal degrees. Also contains a number of other static variables for formatting other lat long data.

Author:
Doug Gillespie
See Also:
Serialized Form

Field Summary
static int FORMAT_DECIMALMINUTES
           
static int FORMAT_MINUTESSECONDS
           
private static int formatStyle
           
protected  double latitude
          latitude in decimal degrees (North is positive; -90 <= latitude <= +90)
protected  double longitude
          longitude in decimal degrees (East is positive; -180 < longitude <= +180)
static double MetersPerMile
           
(package private) static long serialVersionUID
           
 
Constructor Summary
LatLong()
           
LatLong(double latitude, double longitude)
           
 
Method Summary
 LatLong addDistanceMeters(double addX, double addY)
           
 double bearingTo(LatLong destination)
           
 LatLong clone()
           
 double distanceToMetres(LatLong destination)
          Calculate the distance from this positions to some other position in metres.
 double distanceToMetresX(LatLong destination)
           
 double distanceToMetresY(LatLong destination)
           
 double distanceToMiles(LatLong destination)
          Calculate the distance from this positions to some other position in miles.
static java.lang.String doubleDegrees2StringDegs(double latlong)
           
static java.lang.String doubleDegrees2StringMins(double latlong)
           
 boolean equals(LatLong ll)
           
 java.lang.String formatLatitude()
          formats the latitude string
static java.lang.String formatLatitude(double latlong)
          convert a double decimal degrees into a formatted latlong string
private static java.lang.String formatLatLong(double latlong)
           
private static java.lang.String formatLatLong(double latLong, int style)
           
private static java.lang.String formatLatLongDDM(double latlong)
           
private static java.lang.String formatLatLongDMS(double latLong)
           
 java.lang.String formatLongitude()
          formats the longitude as a string
static java.lang.String formatLongitude(double latlong)
          convert a double decimal degrees into a formatted latlong string
 double getCrossTrackError(LatLong latLong1, LatLong latLong2)
          Clculate the perpendicular distance from this LatLong to a line joining latLong1 and latLong2
static double getDecimalMinutes(double latLong)
           
static int getFormatStyle()
           
static int getIntegerMinutes(double latLong)
           
 double getLatitude()
           
private  double getLongDistanceCorr(double latitude)
           
private  double getLongDistanceCorr(double latitude1, double latitude2)
           
 double getLongitude()
           
static double getSeconds(double latLong)
           
static int getSignedDegrees(double latLong)
           
(package private)  double metersToDegreeLatitude(double meters)
           
(package private)  double metersToDegreeLongitude(double meters, double latitudeDegrees)
           
static void setFormatStyle(int formatStyle)
           
 void setLatitude(double latitude)
           
 void setLongitude(double longitude)
           
 LatLong travelDistanceMeters(double trueHeading, double distance)
           
 LatLong TravelDistanceMiles(double trueHeading, double distance)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

MetersPerMile

public static final transient double MetersPerMile
See Also:
Constant Field Values

latitude

protected double latitude
latitude in decimal degrees (North is positive; -90 <= latitude <= +90)


longitude

protected double longitude
longitude in decimal degrees (East is positive; -180 < longitude <= +180)


FORMAT_DECIMALMINUTES

public static final int FORMAT_DECIMALMINUTES
See Also:
Constant Field Values

FORMAT_MINUTESSECONDS

public static final int FORMAT_MINUTESSECONDS
See Also:
Constant Field Values

formatStyle

private static int formatStyle
Constructor Detail

LatLong

public LatLong(double latitude,
               double longitude)

LatLong

public LatLong()
Method Detail

getFormatStyle

public static int getFormatStyle()
Returns:
Returns the formatStyle.

setFormatStyle

public static void setFormatStyle(int formatStyle)
Parameters:
formatStyle - The formatStyle to set.

clone

public LatLong clone()
Overrides:
clone in class java.lang.Object

getLatitude

public double getLatitude()
Returns:
Returns the latitude.

setLatitude

public void setLatitude(double latitude)
Parameters:
latitude - The latitude to set.

getLongitude

public double getLongitude()
Returns:
Returns the longitude.

setLongitude

public void setLongitude(double longitude)
Parameters:
longitude - The longitude to set.

formatLatitude

public java.lang.String formatLatitude()
formats the latitude string

Returns:
formated latitude string

formatLatitude

public static java.lang.String formatLatitude(double latlong)
convert a double decimal degrees into a formatted latlong string

Parameters:
latlong -
Returns:
a string representation of a Latitude

formatLongitude

public java.lang.String formatLongitude()
formats the longitude as a string

Returns:
formatted longitude string

formatLongitude

public static java.lang.String formatLongitude(double latlong)
convert a double decimal degrees into a formatted latlong string

Parameters:
latlong -
Returns:
a string representation of a Longitude

formatLatLong

private static java.lang.String formatLatLong(double latLong,
                                              int style)

formatLatLongDMS

private static java.lang.String formatLatLongDMS(double latLong)

formatLatLongDDM

private static java.lang.String formatLatLongDDM(double latlong)

formatLatLong

private static java.lang.String formatLatLong(double latlong)

doubleDegrees2StringDegs

public static java.lang.String doubleDegrees2StringDegs(double latlong)

doubleDegrees2StringMins

public static java.lang.String doubleDegrees2StringMins(double latlong)

getSignedDegrees

public static int getSignedDegrees(double latLong)

getDecimalMinutes

public static double getDecimalMinutes(double latLong)

getIntegerMinutes

public static int getIntegerMinutes(double latLong)

getSeconds

public static double getSeconds(double latLong)

travelDistanceMeters

public LatLong travelDistanceMeters(double trueHeading,
                                    double distance)
Parameters:
trueHeading - Heading relative to True North
distance - Distance to travel in meters.
Returns:
New Latlong in decimal degrees

TravelDistanceMiles

public LatLong TravelDistanceMiles(double trueHeading,
                                   double distance)
Parameters:
trueHeading - Heading relative to True North
distance - Distance to travel in nautical miles.
Returns:
New Latlong in decimal degrees

metersToDegreeLatitude

double metersToDegreeLatitude(double meters)

metersToDegreeLongitude

double metersToDegreeLongitude(double meters,
                               double latitudeDegrees)

addDistanceMeters

public LatLong addDistanceMeters(double addX,
                                 double addY)

distanceToMiles

public double distanceToMiles(LatLong destination)
Calculate the distance from this positions to some other position in miles.

Parameters:
destination - destiantion position
Returns:
distance in miles

distanceToMetres

public double distanceToMetres(LatLong destination)
Calculate the distance from this positions to some other position in metres.

Parameters:
destination - destiantion position
Returns:
distance in metres

distanceToMetresX

public double distanceToMetresX(LatLong destination)

distanceToMetresY

public double distanceToMetresY(LatLong destination)

equals

public boolean equals(LatLong ll)

bearingTo

public double bearingTo(LatLong destination)

getLongDistanceCorr

private double getLongDistanceCorr(double latitude)

getLongDistanceCorr

private double getLongDistanceCorr(double latitude1,
                                   double latitude2)

getCrossTrackError

public double getCrossTrackError(LatLong latLong1,
                                 LatLong latLong2)
Clculate the perpendicular distance from this LatLong to a line joining latLong1 and latLong2

Returns:
cross track error in metres