|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.me.jstott.jcoord.LatLng
public class LatLng
This class is part of the Jcoord package. Visit the Jcoord website for more information.
Class to represent a latitude/longitude pair based on a particular datum.
(c) 2006 Jonathan Stott
Created on 11-02-2006
Field Summary | |
---|---|
static int |
EAST
Longitude is east of the prime meridian. |
static int |
NORTH
Latitude is north of the equator. |
static int |
SOUTH
Latitude is south of the equator. |
static int |
WEST
Longitude is west of the prime meridian. |
Constructor Summary | |
---|---|
LatLng(double latitude,
double longitude)
Create a new LatLng object to represent a latitude/longitude pair using the WGS84 datum. |
|
LatLng(double latitude,
double longitude,
double height)
Create a new LatLng object to represent a latitude/longitude pair using the WGS84 datum. |
|
LatLng(double latitude,
double longitude,
double height,
Datum datum)
Create a new LatLng object to represent a latitude/longitude pair using the specified datum. |
|
LatLng(int latitudeDegrees,
int latitudeMinutes,
double latitudeSeconds,
int northSouth,
int longitudeDegrees,
int longitudeMinutes,
double longitudeSeconds,
int eastWest)
Create a new LatLng object to represent a latitude/longitude pair using the WGS84 datum. |
|
LatLng(int latitudeDegrees,
int latitudeMinutes,
double latitudeSeconds,
int northSouth,
int longitudeDegrees,
int longitudeMinutes,
double longitudeSeconds,
int eastWest,
double height)
Create a new LatLng object to represent a latitude/longitude pair using the WGS84 datum. |
|
LatLng(int latitudeDegrees,
int latitudeMinutes,
double latitudeSeconds,
int northSouth,
int longitudeDegrees,
int longitudeMinutes,
double longitudeSeconds,
int eastWest,
double height,
Datum datum)
Create a new LatLng object to represent a latitude/longitude pair using the specified datum. |
Method Summary | |
---|---|
double |
distance(LatLng ll)
Calculate the surface distance in kilometres from this LatLng to the given LatLng. |
double |
distanceMiles(LatLng ll)
Calculate the surface distance in miles from this LatLng to the given LatLng. |
Datum |
getDatum()
Get the datum. |
double |
getHeight()
Get the height. |
double |
getLat()
Deprecated. Use getLatitude() instead. |
double |
getLatitude()
Return the latitude in degrees. |
int |
getLatitudeDegrees()
|
int |
getLatitudeMinutes()
|
double |
getLatitudeSeconds()
|
double |
getLng()
Deprecated. Use getLongitude() instead. |
double |
getLongitude()
Return the longitude in degrees. |
int |
getLongitudeDegrees()
|
int |
getLongitudeMinutes()
|
double |
getLongitudeSeconds()
|
void |
toDatum(Datum d)
|
java.lang.String |
toDMSString()
Return a String representation of this LatLng object in degrees-minutes-seconds format. |
MGRSRef |
toMGRSRef()
Convert this latitude and longitude to an MGRS reference. |
void |
toOSGB36()
Convert this LatLng from the WGS84 datum to the OSGB36 datum using an approximate Helmert transformation. |
OSRef |
toOSRef()
Convert this latitude and longitude into an OSGB (Ordnance Survey of Great Britain) grid reference. |
java.lang.String |
toString()
Get a String representation of this LatLng object. |
UTMRef |
toUTMRef()
Convert this latitude and longitude to a UTM reference. |
void |
toWGS84()
Convert this LatLng from the OSGB36 datum to the WGS84 datum using an approximate Helmert transformation. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int NORTH
public static final int SOUTH
public static final int EAST
public static final int WEST
Constructor Detail |
---|
public LatLng(double latitude, double longitude)
latitude
- the latitude in degrees. Must be between -90.0 and 90.0 inclusive.
-90.0 and 90.0 are effectively equivalent.longitude
- the longitude in degrees. Must be between -180.0 and 180.0
inclusive. -180.0 and 180.0 are effectively equivalent.
java.lang.IllegalArgumentException
- if either the given latitude or the given longitude are invalid.public LatLng(double latitude, double longitude, double height)
latitude
- the latitude in degrees. Must be between -90.0 and 90.0 inclusive.
-90.0 and 90.0 are effectively equivalent.longitude
- the longitude in degrees. Must be between -180.0 and 180.0
inclusive. -180.0 and 180.0 are effectively equivalent.height
- the perpendicular height above the reference ellipsoid.
java.lang.IllegalArgumentException
- if either the given latitude or the given longitude are invalid.public LatLng(int latitudeDegrees, int latitudeMinutes, double latitudeSeconds, int northSouth, int longitudeDegrees, int longitudeMinutes, double longitudeSeconds, int eastWest) throws java.lang.IllegalArgumentException
latitudeDegrees
- the degrees part of the latitude. Must be 0 <= latitudeDegrees <=
90.0.latitudeMinutes
- the minutes part of the latitude. Must be 0 <= latitudeMinutes <
60.0.latitudeSeconds
- the seconds part of the latitude. Must be 0 <= latitudeSeconds <
60.0.northSouth
- whether the latitude is north or south of the equator. One of
LatLng.NORTH or LatLng.SOUTH.longitudeDegrees
- the degrees part of the longitude. Must be 0 <= longitudeDegrees <=
90.0.longitudeMinutes
- the minutes part of the longitude. Must be 0 <= longitudeMinutes <
60.0.longitudeSeconds
- the seconds part of the longitude. Must be 0 <= longitudeSeconds <
60.0.eastWest
- whether the longitude is east or west of the prime meridian. One
of LatLng.EAST or LatLng.WEST.
java.lang.IllegalArgumentException
- if any of the parameters are invalid.public LatLng(int latitudeDegrees, int latitudeMinutes, double latitudeSeconds, int northSouth, int longitudeDegrees, int longitudeMinutes, double longitudeSeconds, int eastWest, double height) throws java.lang.IllegalArgumentException
latitudeDegrees
- the degrees part of the latitude. Must be 0 <= latitudeDegrees <=
90.0.latitudeMinutes
- the minutes part of the latitude. Must be 0 <= latitudeMinutes <
60.0.latitudeSeconds
- the seconds part of the latitude. Must be 0 <= latitudeSeconds <
60.0.northSouth
- whether the latitude is north or south of the equator. One of
LatLng.NORTH or LatLng.SOUTH.longitudeDegrees
- the degrees part of the longitude. Must be 0 <= longitudeDegrees <=
90.0.longitudeMinutes
- the minutes part of the longitude. Must be 0 <= longitudeMinutes <
60.0.longitudeSeconds
- the seconds part of the longitude. Must be 0 <= longitudeSeconds <
60.0.eastWest
- whether the longitude is east or west of the prime meridian. One
of LatLng.EAST or LatLng.WEST.height
- the perpendicular height above the reference ellipsoid.
java.lang.IllegalArgumentException
- if any of the parameters are invalid.public LatLng(int latitudeDegrees, int latitudeMinutes, double latitudeSeconds, int northSouth, int longitudeDegrees, int longitudeMinutes, double longitudeSeconds, int eastWest, double height, Datum datum) throws java.lang.IllegalArgumentException
latitudeDegrees
- the degrees part of the latitude. Must be 0 <= latitudeDegrees <=
90.0.latitudeMinutes
- the minutes part of the latitude. Must be 0 <= latitudeMinutes <
60.0.latitudeSeconds
- the seconds part of the latitude. Must be 0 <= latitudeSeconds <
60.0.northSouth
- whether the latitude is north or south of the equator. One of
LatLng.NORTH or LatLng.SOUTH.longitudeDegrees
- the degrees part of the longitude. Must be 0 <= longitudeDegrees <=
90.0.longitudeMinutes
- the minutes part of the longitude. Must be 0 <= longitudeMinutes <
60.0.longitudeSeconds
- the seconds part of the longitude. Must be 0 <= longitudeSeconds <
60.0.eastWest
- whether the longitude is east or west of the prime meridian. One
of LatLng.EAST or LatLng.WEST.height
- the perpendicular height above the reference ellipsoid.datum
- the datum that this reference is based on.
java.lang.IllegalArgumentException
- if any of the parameters are invalid.public LatLng(double latitude, double longitude, double height, Datum datum) throws java.lang.IllegalArgumentException
latitude
- the latitude in degrees. Must be between -90.0 and 90.0 inclusive.
-90.0 and 90.0 are effectively equivalent.longitude
- the longitude in degrees. Must be between -180.0 and 180.0
inclusive. -180.0 and 180.0 are effectively equivalent.height
- the perpendicular height above the reference ellipsoid.datum
- the datum that this reference is based on.
java.lang.IllegalArgumentException
- if either the given latitude or the given longitude are invalid.Method Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toDMSString()
public OSRef toOSRef()
public UTMRef toUTMRef() throws NotDefinedOnUTMGridException
NotDefinedOnUTMGridException
- if an attempt is made to convert a LatLng that falls outside the
area covered by the UTM grid. The UTM grid is only defined for
latitudes south of 84°N and north of 80°S.public MGRSRef toMGRSRef()
public void toWGS84()
public void toDatum(Datum d)
d
- public void toOSGB36()
public double distance(LatLng ll)
ll
- the LatLng object to measure the distance to.
public double distanceMiles(LatLng ll)
ll
- the LatLng object to measure the distance to.
public double getLat()
getLatitude()
instead.
public double getLatitude()
public int getLatitudeDegrees()
public int getLatitudeMinutes()
public double getLatitudeSeconds()
public double getLng()
getLongitude()
instead.
public double getLongitude()
public int getLongitudeDegrees()
public int getLongitudeMinutes()
public double getLongitudeSeconds()
public double getHeight()
public Datum getDatum()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |