Package 

Object SphericalUtil

    • Method Summary

      Modifier and Type Method Description
      final static Double computeHeading(LatLng from, LatLng to) Returns the heading from one LatLng to another LatLng.
      final static LatLng computeOffset(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).
      final static LatLng computeOffsetOrigin(LatLng to, Double distance, Double heading) Returns the location of origin when provided with a LatLng destination, meters travelled and original heading.
      final static LatLng interpolate(LatLng from, LatLng to, Double fraction) Returns the LatLng which lies the given fraction of the way between the origin LatLng and the destination LatLng.
      final static Double computeAngleBetween(LatLng from, LatLng to) Returns the angle between two LatLngs, in radians.
      final static Double computeDistanceBetween(LatLng from, LatLng to) Returns the distance between two LatLngs, in meters.
      final static Double computeLength(List<LatLng> path) Returns the length of the given path, in meters, on Earth.
      final static Double computeArea(List<LatLng> path) Returns the area of a closed path on Earth.
      final static Double computeSignedArea(List<LatLng> path) Returns the signed area of a closed path on Earth.
      final static Double computeSignedArea(List<LatLng> path, Double radius) Returns the signed area of a closed path on a sphere of given radius.
      final static LatLng getPointOnPolyline(List<LatLng> polyline, Double percentage) Returns the point on a polyline that is a given percentage of the total length of the polyline.
      final static List<LatLng> getPolylinePrefix(List<LatLng> polyline, Double percentage) Returns a new polyline that is a prefix of the original polyline, representing a given percentage of the original polyline's length.
      • Methods inherited from class java.lang.Object

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

      • computeHeading

         final static Double computeHeading(LatLng from, LatLng to)

        Returns the heading from one LatLng to another LatLng. Headings are expressed in degrees clockwise from North within the range [-180,180).

      • computeOffset

         final static LatLng computeOffset(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

         final static LatLng computeOffsetOrigin(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

         final static LatLng interpolate(LatLng from, 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.
      • computeAngleBetween

         final static Double computeAngleBetween(LatLng from, LatLng to)

        Returns the angle between two LatLngs, in radians. This is the same as the distance on the unit sphere.

      • computeDistanceBetween

         final static Double computeDistanceBetween(LatLng from, LatLng to)

        Returns the distance between two LatLngs, in meters.

      • computeLength

         final static Double computeLength(List<LatLng> path)

        Returns the length of the given path, in meters, on Earth.

      • computeArea

         final static Double computeArea(List<LatLng> path)

        Returns the area of a closed path on Earth.

        Parameters:
        path - A closed path.
      • computeSignedArea

         final static Double computeSignedArea(List<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.
      • computeSignedArea

         final static Double computeSignedArea(List<LatLng> path, Double radius)

        Returns the signed area of a closed path on a sphere of given radius. The computed area uses the same units as the radius squared. Used by SphericalUtilTest.

      • getPointOnPolyline

         final static LatLng getPointOnPolyline(List<LatLng> polyline, Double percentage)

        Returns the point on a polyline that is a given percentage of the total length of the polyline.

        Parameters:
        polyline - the polyline
        percentage - the percentage of the total length of the polyline to find the point for
      • getPolylinePrefix

         final static List<LatLng> getPolylinePrefix(List<LatLng> polyline, Double percentage)

        Returns a new polyline that is a prefix of the original polyline, representing a given percentage of the original polyline's length.

        Note: The returned polyline should be displayed on the map with geodesic set to true to ensure it follows the same spherical path as the calculation.

        Parameters:
        polyline - the original polyline
        percentage - the percentage of the original polyline's length to include in the prefix