Class SphericalUtil


  • public class SphericalUtil
    extends java.lang.Object
    • 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 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.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • computeHeading

        public 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. Headings are expressed in degrees clockwise from North within the range [-180,180).
        Returns:
        The heading in degrees clockwise from north.
      • computeOffset

        public 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).
        Parameters:
        from - The LatLng from which to start.
        distance - The distance to travel.
        heading - The heading in degrees clockwise from north.
      • computeOffsetOrigin

        public 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. 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.
      • interpolate

        public static 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.
        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.
      • computeDistanceBetween

        public 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.
      • computeLength

        public 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.
      • computeArea

        public static double computeArea​(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​(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.