triptracker.core
Class Coordinate

java.lang.Object
  extended by triptracker.core.Coordinate

public class Coordinate
extends Object

Represents a coordinate in a latitude/longitude coordinate system on a given time and date. Data in a Coordinate object is immutable.

Latitude is numbered from 0 degrees to 90 degrees north and south. 0 degrees is the equator, 90 degrees north is the North Pole and 90 degrees south is the South Pole. The Coordinate class numbers latitudes from -90 degrees to 90 degrees where -90 degrees is the South Pole and 90 degrees is the North Pole.

Longitude is numbered from 0 degrees to 180 degrees east and west. 0 degrees is at Greenwich, England and they continue 180 degrees east and 180 degrees west where they meet at the International Date Line in the Pacific Ocean. The Coordinate class numbers longitude from -180 degrees to 180 degrees where negative degrees are west and positive degrees are east of Greenwich, England at 0 degrees.

To precisely locate points on the earth's surface, degrees longitude and latitude have been divided into minutes (') and seconds ("). There are 60 minutes in each degree and each minute is divided into 60 seconds. Seconds can be further divided into tenths, hundredths, or even thousandths.


Field Summary
static double EARTH_RADIUS
          Earth radius.
static double WGS84_A
          See http://www.movable-type.co.uk/scripts/LatLongVincenty.html
static double WGS84_B
           
static double WGS84_F
           
 
Constructor Summary
Coordinate()
          Default constructor.
Coordinate(double latitude, double longitude)
          Creates a coordinate with the given latitude and longitude.
Coordinate(double latitude, double longitude, Date date)
          Creates a coordinate with the given latitude, longitude and date.
Coordinate(int coordId, double latitude, double longitude)
           
Coordinate(int coordId, double latitude, double longitude, Date date)
           
 
Method Summary
static double cosineDist(Coordinate coord1, Coordinate coord2)
          Returns the distance between two points according to the law of cosines.
static int decideZoneNum(double result, double latitude)
          Decides a UTM Zone Number for a given latitude and result.
static double decOldToNmea(double degrees)
          Deprecated. Replaced by decToNmea(double) to correct a calculation error.
static double decToNmea(double degrees)
          Converts degrees in decimal format to NMEA sexagesimal format.
 int getCoordId()
          Returns id of coordinate
 Date getDate()
          Returns date of coordinate
 String getDateString()
          Returns the time and date associated with the coordinate.
 String getStringLat()
          Returns a string representation of the latitude
 String getStringLon()
          Returns a string representation of the longitude
 double getX()
          Returns the longitude position of the coordinate.
 double getY()
          Returns the latitude position of the coordinate.
 double haversineDist(Coordinate coord)
          Returns the Haversine distance from this to another coordinate.
static double haversineDist(Coordinate coord1, Coordinate coord2)
          Returns the Haversine distance between two points.
static double haversineDist(double lat1, double lon1, double lat2, double lon2)
          Returns the Haversine distance between two points.
static double haversineDist(List<Coordinate> coords)
          Returns the sequential Haverside distance between the coordinates.
static UTMPoint llToUTM(int ellipsoidId, double lat, double lon)
          Converts from lat/lon to a UTMpoint containting northing and easting plus zone with zone letter
static double nmeaOldToDec(double degrees)
          Deprecated. Replaced by nmeaToDec(double) to correct a calculation error.
static double nmeaToDec(double degrees)
          Converts degrees in NMEA sexagesimal format to decimal format.
static double sexToDec(int degrees, int minutes, double seconds)
          Converts degrees in sexagesimal format to decimal format.
static double sexToDec(Sexagesimal sex)
          Converts degrees in sexagesimal format to decimal format.
 String toString()
          Returns the string representation of a latitude/longitude coordinate.
static Coordinate utmToLl(int ellipsoidId, double northing, double easting, int zoneNum, char zoneLetter)
           
static Coordinate utmToLl(int i, UTMPoint utmpoint)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EARTH_RADIUS

public static final double EARTH_RADIUS
Earth radius. See http://www.movable-type.co.uk/scripts/GIS-FAQ-5.1.html section 5.1a or http://www.movable-type.co.uk/scripts/LatLong.html.

See Also:
Constant Field Values

WGS84_A

public static final double WGS84_A
See http://www.movable-type.co.uk/scripts/LatLongVincenty.html

See Also:
Constant Field Values

WGS84_B

public static final double WGS84_B
See Also:
Constant Field Values

WGS84_F

public static final double WGS84_F
See Also:
Constant Field Values
Constructor Detail

Coordinate

public Coordinate()
Default constructor. Creates a coordinate with x=0 and y=0.


Coordinate

public Coordinate(double latitude,
                  double longitude)
Creates a coordinate with the given latitude and longitude. The values of latitude and longitude can be retrieved by calling getY() and getX() respectively.

Parameters:
latitude - latitude from 90 degrees (north) to -90 degrees (south)
longitude - longitude from 180 degrees (east) to -180 degrees (west)
Throws:
IllegalArgumentException - if latitude or longitude is out of range.

Coordinate

public Coordinate(double latitude,
                  double longitude,
                  Date date)
Creates a coordinate with the given latitude, longitude and date. The values of latitude and longitude can be retrieved by calling getY() and getX() respectively.

Parameters:
latitude - latitude from 90 degrees (north) to -90 degrees (south)
longitude - longitude from 180 degrees (east) to -180 degrees (west)
date - time associated with coordinate
Throws:
IllegalArgumentException - if latitude or longitude is out of range.

Coordinate

public Coordinate(int coordId,
                  double latitude,
                  double longitude)

Coordinate

public Coordinate(int coordId,
                  double latitude,
                  double longitude,
                  Date date)
Method Detail

getY

public double getY()
Returns the latitude position of the coordinate.

Returns:
latitude position of the coordinate

getX

public double getX()
Returns the longitude position of the coordinate.

Returns:
longitude position of the coordinate

getDateString

public String getDateString()
Returns the time and date associated with the coordinate.

Returns:
time and date associated with coordinate

toString

public String toString()
Returns the string representation of a latitude/longitude coordinate. Example: 38?53'23.83"N 77?00'27.76"W

Overrides:
toString in class Object
Returns:
string representation of a latitude/longitude coordinate
See Also:
Object.toString()

getStringLat

public String getStringLat()
Returns a string representation of the latitude

Returns:
string representation of latitude

getStringLon

public String getStringLon()
Returns a string representation of the longitude

Returns:
string representation of longitude

sexToDec

public static double sexToDec(Sexagesimal sex)
Converts degrees in sexagesimal format to decimal format.

Parameters:
sex - sexagesimal formatted angle
Returns:
degrees in decimal format

sexToDec

public static double sexToDec(int degrees,
                              int minutes,
                              double seconds)
Converts degrees in sexagesimal format to decimal format.

Parameters:
degrees - whole degrees
minutes - whole minutes
seconds - whole or fractional seconds
Returns:
degrees in decimal format

decToNmea

public static double decToNmea(double degrees)
Converts degrees in decimal format to NMEA sexagesimal format.

Parameters:
degrees - decimal degrees
Returns:
degrees in NMEAs sexagesimal format with degrees and minutes in front of the decimal separator and seconds (in 0-99) after in full decimal format after.

decOldToNmea

@Deprecated
public static double decOldToNmea(double degrees)
Deprecated. Replaced by decToNmea(double) to correct a calculation error.

Converts degrees in decimal format to NMEA sexagesimal format. This is the old bugged conversion.

Parameters:
degrees - decimal degrees
Returns:
degrees in NMEAs sexagesimal format with degrees and minutes in front of the decimal separator and seconds (in 0-99) after in full decimal format after.

nmeaToDec

public static double nmeaToDec(double degrees)
Converts degrees in NMEA sexagesimal format to decimal format.

Parameters:
degrees - in NMEA sexagesimal format with degrees and minutes in front of the decimal separator and seconds after
Returns:
degrees in decimal format

nmeaOldToDec

@Deprecated
public static double nmeaOldToDec(double degrees)
Deprecated. Replaced by nmeaToDec(double) to correct a calculation error.

Converts degrees in NMEA sexagesimal format to decimal format.

Parameters:
degrees - in NMEA sexagesimal format with degrees and minutes in front of the decimal separator and seconds after
Returns:
degrees in decimal format

haversineDist

public double haversineDist(Coordinate coord)
Returns the Haversine distance from this to another coordinate.

Parameters:
coord - destination coordinate
Returns:
Haversine distance
See Also:
haversineDist(double, double, double, double)

haversineDist

public static double haversineDist(Coordinate coord1,
                                   Coordinate coord2)
Returns the Haversine distance between two points.

Parameters:
coord1 - first coordinate
coord2 - secound coordinate
Returns:
Haversine distance between two points
See Also:
haversineDist(double, double, double, double)

haversineDist

public static double haversineDist(double lat1,
                                   double lon1,
                                   double lat2,
                                   double lon2)
Returns the Haversine distance between two points. See Wikipedia or GIS-FAQ for more in-depth information on the formula.

Parameters:
lat1 - latitude of first coordinate
lon1 - longitude of first coordinate
lat2 - latitude of second coordinate
lon2 - longitude of second coordinate
Returns:
Haversine distance between the two coordinates

haversineDist

public static double haversineDist(List<Coordinate> coords)
Returns the sequential Haverside distance between the coordinates. The method takes the distance between each consecutive coordinate and adds it together. Because of the sequencing of calculations, the order of the coordinates in the list determines the total distance.

Parameters:
coords - list of coordinates used for distance calculation
Returns:
total distance between all coordinates
See Also:
haversineDist(double, double, double, double)

cosineDist

public static double cosineDist(Coordinate coord1,
                                Coordinate coord2)
Returns the distance between two points according to the law of cosines. Use of this method of distance calculation is HIGHLY DISCOURAGED as it is unreliable for small distances because the inverse cosine is ill-conditioned.

Parameters:
coord1 - first coordinate
coord2 - secound coordinate
Returns:
cosine distance between two points

llToUTM

public static UTMPoint llToUTM(int ellipsoidId,
                               double lat,
                               double lon)
Converts from lat/lon to a UTMpoint containting northing and easting plus zone with zone letter

Parameters:
ellipsoidId - ellipsoid to use (i.e. WGS84 = 22)
lat - points latitude
lon - points longitude
Returns:
UTMPoint with northing/easting + zone and zone letter

utmToLl

public static Coordinate utmToLl(int i,
                                 UTMPoint utmpoint)

utmToLl

public static Coordinate utmToLl(int ellipsoidId,
                                 double northing,
                                 double easting,
                                 int zoneNum,
                                 char zoneLetter)

decideZoneNum

public static int decideZoneNum(double result,
                                double latitude)
Decides a UTM Zone Number for a given latitude and result.

Parameters:
result - result
latitude - latitude
Returns:
the zonenumber

getCoordId

public int getCoordId()
Returns id of coordinate


getDate

public Date getDate()
Returns date of coordinate



Copyright © 2006 Team Trip Tracker. All Rights Reserved.