public class CoordinateHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DD_MM
Coordinate format corresponding to degrees and minutes, with fractional minutes.
|
static int |
DD_MM_SS
Coordinate format corresponding to degrees, minutes and seconds, with fractional seconds.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
canUseGeocodingApi()
Check to see if this handset has access to geocoding capabilities.
|
static java.lang.String |
convert(double coordinate,
int outputType)
Convert a double representation of a coordinate into a more human-readable String.
|
static double |
convert(java.lang.String coordinate)
Convert a String representation of a coordinate into a double value.
|
static double |
distance(Location from,
Location to)
Calculate a shortest-path distance between two
Location values, according to the WGS84 ellipsoid model. |
static void |
findLocationsBy(java.lang.String address,
int maxResults,
IGeocodingCallback callback)
For a given
String address, find out where in the world this is. |
static void |
findPlacesBy(Location loc,
int maxResults,
IGeocodingCallback callback)
For a given
Location , find a list of places as close to this area as possible. |
public static final int DD_MM
public static final int DD_MM_SS
public static double convert(java.lang.String coordinate)
DD_MM_SS
).
DD_MM
).
double
value 20.67d
, this would require an input value of 20:40:12.0 for type 1, or 20:40.200 for type 2.coordinate
- the String
representation of the coordinate in either of the two expected formats.double
value, expressed in degrees, that corresponds to the String
coordinate given.java.lang.IllegalArgumentException
- if the input coordinate does not conform to one of the expected formats.java.lang.NullPointerException
- if the input String is null.public static java.lang.String convert(double coordinate, int outputType)
coordinate
- the double
value to convert, given in degrees.outputType
- one of DD_MM
or DD_MM_SS
, depending on the required output format.String
corresponding to the required output format.java.lang.IllegalArgumentException
- if the coordinate is not in the range -180.0 < x <= 180.0, is Double.NaN
or if the outputType
is not one of DD_MM
or DD_MM_SS
public static double distance(Location from, Location to)
Location
values, according to the WGS84 ellipsoid model.
Altitude is ignored entirely for the purposes of this calculation. Note that this will not give an exact value, but aims
to get as close as possible in a reasonable timeframe (expected to be within 0.36% of a "true" value for most inputs).from
- the Location
to act as the start point.to
- the Location
to act as the end point.public static boolean canUseGeocodingApi()
findPlacesBy(Location, int, IGeocodingCallback)
or
findLocationsBy(String, int, IGeocodingCallback)
.public static void findPlacesBy(Location loc, int maxResults, IGeocodingCallback callback)
Location
, find a list of places as close to this area as possible.loc
- the Location
to search frommaxResults
- the maximum number of results to returncallback
- the Object where the Placemark
s will be returnedpublic static void findLocationsBy(java.lang.String address, int maxResults, IGeocodingCallback callback)
String
address, find out where in the world this is.address
- the place to search for, e.g. "10 Downing Street, London, England".maxResults
- the maximum number of results to return.callback
- the Object to return Location
results to.