|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.microedition.location.Coordinates
public class Coordinates
This class has been designed to manage coordinates using JSR-179 Location API http://www.jcp.org/en/jsr/detail?id=179
Field Summary | |
---|---|
static int |
DD_MM
Identifier for string coordinate representation Degrees, Minutes, decimal fractions of a minute See Also:Constant Field Values |
static int |
DD_MM_SS
Identifier for string coordinate representation Degrees, Minutes, Seconds and decimal fractions of a second See Also:Constant Field Values |
Constructor Summary | |
---|---|
Coordinates(double latitude,
double longitude)
|
|
Coordinates(double latitude,
double longitude,
double altitude)
Create a Coordinate object with 3 parameters: latitude, longitude and altitude |
Method Summary | |
---|---|
double |
azimuthTo(Coordinates to)
Calculates the azimuth between the two points according to the ellipsoid model of WGS84. |
static String |
convert(double coordinate,
int outputType)
UNTESTED as of April 7, 2009 - BB / /** Converts a double representation of a coordinate with decimal degrees into a string representation. |
static double |
convert(String coordinate)
Converts a String representation of a coordinate into the double representation as used in this API. |
double |
distance(Coordinates to)
Calculates the geodetic distance between the two points according to the ellipsoid model of WGS84. |
double |
getAltitude()
Altitude above mean sea level. |
double |
getLatitude()
Get latitude |
double |
getLongitude()
Get Longitude |
void |
setAltitude(double altitude)
|
void |
setLatitude(double latitude)
|
void |
setLongitude(double longitude)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DD_MM
public static final int DD_MM_SS
Constructor Detail |
---|
public Coordinates(double latitude, double longitude, double altitude)
latitude
- longitude
- altitude
- public Coordinates(double latitude, double longitude)
Method Detail |
---|
public double getLatitude()
public void setLatitude(double latitude)
public void setLongitude(double longitude)
public double getLongitude()
public void setAltitude(double altitude)
public double getAltitude()
public double azimuthTo(Coordinates to)
public static String convert(double coordinate, int outputType) throws IllegalArgumentException
coordinate
- a double representation of a coordinateoutputType
- identifier of the type of the string representation wanted for output
The constant DD_MM_SS
identifies the syntax 1 and the constant
DD_MM
identifies the syntax 2.
IllegalArgumentException
- if the outputType is not one of the two constant values defined in this
class or if the coordinate value is not within the range [-180.0,
180.0) or is Double.NaNconvert(String)
public static double convert(String coordinate) throws IllegalArgumentException, NullPointerException
1. Degrees, minutes, seconds and decimal fractions of seconds. This is expressed as a string complying with the following BNF definition where the degrees are within the range [-179, 179] and the minutes and seconds are within the range [0, 59], or the degrees is -180 and the minutes, seconds and decimal fractions are 0:
coordinate = degrees ":" minutes ":" seconds "."
decimalfrac | degrees ":" minutes ":" seconds | degrees
":" minutes
degrees = degreedigits | "-" degreedigits
degreedigits = digit | nonzerodigit digit | "1" digit digit
minutes = minsecfirstdigit digit
seconds = minsecfirstdigit digit
decimalfrac = 1*3digit
digit = "0" | "1" | "2" | "3" |
"4" | "5" | "6" | "7" | "8" |
"9"
nonzerodigit = "1" | "2" | "3" | "4" |
"5" | "6" | "7" | "8" | "9"
minsecfirstdigit = "0" | "1" | "2" | "3" |
"4" | "5"
2. Degrees, minutes and decimal fractions of minutes. This is expressed as a string complying with the following BNF definition where the degrees are within the range [-179, 179] and the minutes are within the range [0, 59], or the degrees is -180 and the minutes and decimal fractions are 0:
coordinate = degrees ":" minutes "." decimalfrac | degrees
":" minutes
degrees = degreedigits | "-" degreedigits
degreedigits = digit | nonzerodigit digit | "1" digit digit
minutes =
minsecfirstdigit digit
decimalfrac = 1*5digit
digit = "0" |
"1" | "2" | "3" | "4" | "5" |
"6" | "7" | "8" | "9"
nonzerodigit =
"1" | "2" | "3" | "4" | "5" |
"6" | "7" | "8" | "9"
minsecfirstdigit = "0" | "1" | "2" | "3" |
"4" | "5"
For example, for the double value of the coordinate 61.51d, the corresponding syntax 1 string is "61:30:36" and the corresponding syntax 2 string is "61:30.6".
coordinate
- a String in either of the two representation specified above
IllegalArgumentException
- if the coordinate input parameter does not comply with the defined
syntax for the specified types
NullPointerException
- if the coordinate string is null convertpublic double distance(Coordinates to)
to
- the point to calculate the geodetic to
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |