Class LatLongPosition
-
- All Implemented Interfaces:
-
it.unibo.alchemist.model.GeoPosition
,it.unibo.alchemist.model.Position
,it.unibo.alchemist.model.Position2D
,java.io.Serializable
public final class LatLongPosition implements GeoPosition
Unmodifiable state version of LatLng, also implementing the GeoPosition interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enum
LatLongPosition.DistanceFormula
Possible methods to compute the distance between two latitude-longitude points.
-
Field Summary
Fields Modifier and Type Field Description public final static LatLongPosition.DistanceFormula
DEFAULT_DISTANCE_FORMULA
public final static double
EARTH_MEAN_RADIUS_METERS
-
Constructor Summary
Constructors Constructor Description LatLongPosition(double lat, double lon)
LatLongPosition(double lat, double lon, LatLongPosition.DistanceFormula distanceFormula)
LatLongPosition(double lat, double lon, int distanceFormula)
LatLongPosition(Number lat, Number lon)
-
Method Summary
Modifier and Type Method Description List<GeoPosition>
boundingBox(double range)
static double
distance(LatLng point1, LatLng point2, LatLongPosition.DistanceFormula df)
Distance between two points. static double
distance(LatLng point1, LatLng point2, LengthUnit unit, LatLongPosition.DistanceFormula df)
Distance between two points with arbitrary LengthUnit. double
distanceTo(@Nonnull() GeoPosition other)
boolean
equals(Object obj)
Array<double>
getCoordinates()
double
getCoordinate(int dimension)
int
getDimensions()
double
getLatitude()
double
getLongitude()
double
getX()
double
getY()
int
hashCode()
GeoPosition
minus(@Nonnull() GeoPosition other)
GeoPosition
minus(@Nonnull() Array<double> other)
GeoPosition
plus(@Nonnull() Array<double> other)
GeoPosition
plus(@Nonnull() GeoPosition other)
String
toString()
static double
distanceInRadians(LatLng point1, LatLng point2, LatLongPosition.DistanceFormula precision)
This "distance" function is mostly for internal use. -
-
Constructor Detail
-
LatLongPosition
LatLongPosition(double lat, double lon)
- Parameters:
lat
- latitudelon
- longitude
-
LatLongPosition
LatLongPosition(double lat, double lon, LatLongPosition.DistanceFormula distanceFormula)
- Parameters:
lat
- latitudelon
- longitudedistanceFormula
- the formula to use to compute distances
-
LatLongPosition
LatLongPosition(double lat, double lon, int distanceFormula)
- Parameters:
lat
- latitudelon
- longitudedistanceFormula
- the index of the formula to use to compute distances
-
-
Method Detail
-
boundingBox
@Nonnull() List<GeoPosition> boundingBox(double range)
-
distance
static double distance(LatLng point1, LatLng point2, LatLongPosition.DistanceFormula df)
Distance between two points.
- Parameters:
point1
- the first point.point2
- the second point.df
- the formula to use to compute distances- Returns:
the distance in the chosen unit of measure.
-
distance
static double distance(LatLng point1, LatLng point2, LengthUnit unit, LatLongPosition.DistanceFormula df)
Distance between two points with arbitrary LengthUnit.
- Parameters:
point1
- the first point.point2
- the second point.unit
- the unit of measure in which to receive the result.df
- the formula to use to compute distances- Returns:
the distance in the chosen unit of measure.
-
distanceTo
double distanceTo(@Nonnull() GeoPosition other)
-
getCoordinates
@Nonnull() Array<double> getCoordinates()
-
getCoordinate
double getCoordinate(int dimension)
-
getDimensions
int getDimensions()
-
getLatitude
double getLatitude()
- Returns:
the latitude
-
getLongitude
double getLongitude()
- Returns:
the longitude
-
getX
double getX()
-
getY
double getY()
-
hashCode
int hashCode()
-
minus
GeoPosition minus(@Nonnull() GeoPosition other)
-
minus
@Nonnull() GeoPosition minus(@Nonnull() Array<double> other)
-
plus
@Nonnull() GeoPosition plus(@Nonnull() Array<double> other)
-
plus
GeoPosition plus(@Nonnull() GeoPosition other)
-
distanceInRadians
static double distanceInRadians(LatLng point1, LatLng point2, LatLongPosition.DistanceFormula precision)
This "distance" function is mostly for internal use. Most users will simply rely upon distance
Yields the internal angle for an arc between two points on the surface of a sphere in radians. This angle is in the plane of the great circle connecting the two points measured from an axis through one of the points and the center of the Earth. Multiply this value by the sphere's radius to get the length of the arc.
- Parameters:
point1
- the first pointpoint2
- the second pointprecision
- the formula to use- Returns:
the internal angle for the arc connecting the two points in radians.
-
-
-
-