public final class GeoUtils extends Object
Modifier and Type | Field and Description |
---|---|
static double |
EARTH_RADIUS
The earth's radius, in meters.
|
static double |
KM_MILE_CONVERSION_FACTOR
Conversion factor from kilometers to miles.
|
static double |
METER_KM_CONVERSION_FACTOR
Conversion factor from meters to kilometers.
|
static double |
MILE_METER_CONVERSION_FACTOR
Conversion factor from miles to meters.
|
Modifier and Type | Method and Description |
---|---|
static double |
computeDistanceBetween(GeoPoint from,
GeoPoint to)
Returns the distance between two geopositions, in meters.
|
static double |
computeDistanceBetween(Location from,
Location to)
Returns the distance between two geopositions, in meters.
|
static GeoPoint |
computeOffset(GeoPoint from,
double distance,
double heading)
Returns the
GeoPoint resulting from moving a distance from an origin
in the specified heading (expressed in degrees clockwise from north). |
static BoundingBox |
createBoxFromPoints(List<GeoPoint> points)
Calculates a
BoundingBox from a list of points with
BoundingBox.getCorner1() returning the minimum lat/lon and
BoundingBox.getCorner2() returning the maximum lat/lon. |
static double |
distanceKM(double lat1,
double lon1,
double lat2,
double lon2)
Returns the distance in kilometers between two points defined by
longitude and latitude.
|
static double |
distanceKM(GeoPoint point1,
GeoPoint point2)
Returns the distance in kilometers between two points.
|
static double |
getAreaOfBox(GeoPoint corner1,
GeoPoint corner2,
UserPreferences.Unit outputUnits)
Returns the area of a rectangle defined by two corners that are
diagonally opposite each other.
|
static double |
getAreaOfCircle(double radius)
Returns the area of a circle with the specified radius.
|
static float |
getBearing(Location location1,
Location location2)
Calculates bearing between two locations.
|
static GeoPoint |
getCenter(GeoPoint corner1,
GeoPoint corner2)
Gets the bounding box center from specified corners.
|
static double[] |
getMetersPerDegree(GeoPoint point)
Get the meters per degree at the supplied point.
|
static double |
kmToMI(double km)
Convert kilometers to miles.
|
static double |
kmToUserPreference(double km)
Convert the supplied kilometers to units based on the user preference defined by
UserPreferences.getSettingUnits() . |
static double |
metersToMI(double meters)
Convert meters to miles.
|
static double |
metersToUserPreference(double meters)
Convert the supplied metres to units based on the user preference defined by
UserPreferences.getSettingUnits() . |
static double |
metersToUserUnit(double meters) |
static int |
miToMeters(float miles) |
static List<Location> |
pointsToLocations(List<GeoPoint> points)
|
public static final double KM_MILE_CONVERSION_FACTOR
public static final double MILE_METER_CONVERSION_FACTOR
public static final double METER_KM_CONVERSION_FACTOR
public static final double EARTH_RADIUS
public static float getBearing(Location location1, Location location2)
location1
- First location.location2
- Second location.Float.NaN
otherwise.public static double kmToMI(double km)
km
- The kilometers to covert into miles.public static double metersToMI(double meters)
meters
- The meters to covert into miles.public static int miToMeters(float miles)
public static double metersToUserPreference(double meters)
UserPreferences.getSettingUnits()
.meters
- The distance in meters to convert.public static double metersToUserUnit(double meters)
public static double kmToUserPreference(double km)
UserPreferences.getSettingUnits()
.km
- The distance in kilometers to convertpublic static double distanceKM(double lat1, double lon1, double lat2, double lon2)
lat1
- The latitude of the first point.lon1
- The longitude of the first point.lat2
- The latitude of the second point.lon2
- The longitude of the second point.public static double distanceKM(GeoPoint point1, GeoPoint point2)
point1
- The first point.point2
- The second point.public static double getAreaOfBox(GeoPoint corner1, GeoPoint corner2, UserPreferences.Unit outputUnits)
corner1
- The first corner of the rectangle.corner2
- The second corner of the rectangle.outputUnits
- The units of the returned area.public static double getAreaOfCircle(double radius)
radius
- The radius of the circle.public static GeoPoint getCenter(GeoPoint corner1, GeoPoint corner2)
corner1
- Bounding box corner 1.corner2
- Bounding box corner 2, opposite to corner1.null
if one of the corners are invalid.public static BoundingBox createBoxFromPoints(List<GeoPoint> points)
BoundingBox
from a list of points with
BoundingBox.getCorner1()
returning the minimum lat/lon and
BoundingBox.getCorner2()
returning the maximum lat/lon. If there
are no valid points supplied in the list, then the resulting box will return maximum lat/lon
(+90/+180) as corner 1 and minimum lat/lon (-90/-180) as corner 2.points
- The points to calculate a box from.@NonNull public static double[] getMetersPerDegree(@NonNull GeoPoint point)
point
- The point to get the meters per degree at.public static GeoPoint computeOffset(GeoPoint from, double distance, double heading)
GeoPoint
resulting from moving a distance from an origin
in the specified heading (expressed in degrees clockwise from north).public static double computeDistanceBetween(Location from, Location to)
from
- Start location.to
- End location.Location
s, in meters.Copyright © 2013-2018 INRIX, Inc. All Rights Reserved.