Package com.mapsindoors.mapssdk
Class SphericalUtil
- java.lang.Object
-
- com.mapsindoors.mapssdk.SphericalUtil
-
public class SphericalUtil extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description SphericalUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static double
computeArea(java.util.List<com.google.android.gms.maps.model.LatLng> path)
Returns the area of a closed path on Earth.static double
computeDistanceBetween(com.google.android.gms.maps.model.LatLng from, com.google.android.gms.maps.model.LatLng to)
Returns the distance between two LatLngs, in meters.static double
computeHeading(com.google.android.gms.maps.model.LatLng from, com.google.android.gms.maps.model.LatLng to)
Returns the heading from one LatLng to another LatLng.static double
computeLength(java.util.List<com.google.android.gms.maps.model.LatLng> path)
Returns the length of the given path, in meters, on Earth.static com.google.android.gms.maps.model.LatLng
computeOffset(com.google.android.gms.maps.model.LatLng from, double distance, double heading)
Returns the LatLng resulting from moving a distance from an origin in the specified heading (expressed in degrees clockwise from north).static com.google.android.gms.maps.model.LatLng
computeOffsetOrigin(com.google.android.gms.maps.model.LatLng to, double distance, double heading)
Returns the location of origin when provided with a LatLng destination, meters travelled and original heading.static double
computeSignedArea(java.util.List<com.google.android.gms.maps.model.LatLng> path)
Returns the signed area of a closed path on Earth.static double
distanceRadians(double lat1, double lng1, double lat2, double lng2)
Returns distance on the unit sphere; the arguments are in radians.static double
distanceTo(com.google.android.gms.maps.model.LatLng from, com.google.android.gms.maps.model.LatLng to)
Computes the distance between the given coordinates, in metersstatic com.google.android.gms.maps.model.LatLng
fastComputeOffset(com.google.android.gms.maps.model.LatLng from, double distanceX, double distanceY)
Returns the LatLng resulting from moving a distance from an originstatic com.google.android.gms.maps.model.LatLng
interpolate(com.google.android.gms.maps.model.LatLng from, com.google.android.gms.maps.model.LatLng to, double fraction)
Returns the LatLng which lies the given fraction of the way between the origin LatLng and the destination LatLng.
-
-
-
Method Detail
-
computeHeading
public static double computeHeading(@NonNull com.google.android.gms.maps.model.LatLng from, @NonNull com.google.android.gms.maps.model.LatLng to)
Returns the heading from one LatLng to another LatLng. Headings are expressed in degrees clockwise from North within the range [-180,180).- Returns:
- The heading in degrees clockwise from north.
-
computeOffset
@NonNull public static com.google.android.gms.maps.model.LatLng computeOffset(@NonNull com.google.android.gms.maps.model.LatLng from, double distance, double heading)
Returns the LatLng resulting from moving a distance from an origin in the specified heading (expressed in degrees clockwise from north).- Parameters:
from
- The LatLng from which to start.distance
- The distance travelled, in meters.heading
- The heading in degrees clockwise from north.
-
fastComputeOffset
@NonNull public static com.google.android.gms.maps.model.LatLng fastComputeOffset(@NonNull com.google.android.gms.maps.model.LatLng from, double distanceX, double distanceY)
Returns the LatLng resulting from moving a distance from an origin- Parameters:
from
- The LatLng from which to start.distanceX
- The distance to travel, in metersdistanceY
- The distance to travel, in meters
-
computeOffsetOrigin
@Nullable public static com.google.android.gms.maps.model.LatLng computeOffsetOrigin(@NonNull com.google.android.gms.maps.model.LatLng to, double distance, double heading)
Returns the location of origin when provided with a LatLng destination, meters travelled and original heading. Headings are expressed in degrees clockwise from North. This function returns null when no solution is available.- Parameters:
to
- The destination LatLng.distance
- The distance travelled, in meters.heading
- The heading in degrees clockwise from north.- Returns:
- A new point or
null
-
interpolate
@NonNull public static com.google.android.gms.maps.model.LatLng interpolate(@NonNull com.google.android.gms.maps.model.LatLng from, @NonNull com.google.android.gms.maps.model.LatLng to, double fraction)
Returns the LatLng which lies the given fraction of the way between the origin LatLng and the destination LatLng.- Parameters:
from
- The LatLng from which to start.to
- The LatLng toward which to travel.fraction
- A fraction of the distance to travel.- Returns:
- The interpolated LatLng.
-
distanceRadians
public static double distanceRadians(double lat1, double lng1, double lat2, double lng2)
Returns distance on the unit sphere; the arguments are in radians.
-
computeDistanceBetween
public static double computeDistanceBetween(@NonNull com.google.android.gms.maps.model.LatLng from, @NonNull com.google.android.gms.maps.model.LatLng to)
Returns the distance between two LatLngs, in meters.
-
computeLength
public static double computeLength(@NonNull java.util.List<com.google.android.gms.maps.model.LatLng> path)
Returns the length of the given path, in meters, on Earth.
-
computeArea
public static double computeArea(@NonNull java.util.List<com.google.android.gms.maps.model.LatLng> path)
Returns the area of a closed path on Earth.- Parameters:
path
- A closed path.- Returns:
- The path's area in square meters.
-
computeSignedArea
public static double computeSignedArea(@NonNull java.util.List<com.google.android.gms.maps.model.LatLng> path)
Returns the signed area of a closed path on Earth. The sign of the area may be used to determine the orientation of the path. "inside" is the surface that does not contain the South Pole.- Parameters:
path
- A closed path.- Returns:
- The loop's area in square meters.
-
distanceTo
public static double distanceTo(@NonNull com.google.android.gms.maps.model.LatLng from, @NonNull com.google.android.gms.maps.model.LatLng to)
Computes the distance between the given coordinates, in meters- Parameters:
from
-to
-- Returns:
- The distance, in meters
-
-