Class GeoCoordinates

java.lang.Object
com.here.sdk.core.GeoCoordinates

public final class GeoCoordinates extends Object

Represents geographical coordinates in 3D space.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Double
    Optional altitude in meters.
    final double
    Latitude in degrees.
    final double
    Longitude in degrees.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GeoCoordinates(double latitude, double longitude)
    Constructs a GeoCoordinates from the provided latitude and longitude values.
    GeoCoordinates(double latitude, double longitude, double altitude)
    Constructs a GeoCoordinates from the provided latitude, longitude and altitude values.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Computes distance (in meters) along the great circle between two coordinates.
    boolean
     
    Constructs GeoCoordinates from the provided string in specified format.
    int
     
    interpolate(GeoCoordinates towardCoords, double factor)
    Computes the coordinates of the interpolated location along the great circle between the two coordinates.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • latitude

      public final double latitude

      Latitude in degrees.

    • longitude

      public final double longitude

      Longitude in degrees.

    • altitude

      @Nullable public final Double altitude

      Optional altitude in meters. By convention, on iOS devices, altitude is set as meters relative to the mean sea level. On Android devices, altitude is set as meters relative to the WGS 84 reference ellipsoid.

  • Constructor Details

    • GeoCoordinates

      public GeoCoordinates(double latitude, double longitude, double altitude)

      Constructs a GeoCoordinates from the provided latitude, longitude and altitude values. Corrects values of lat and long if they exceed the ranges.

      Parameters:
      latitude -

      Latitude in degrees. Positive value means Northern hemisphere. If the value is out of range of [-90.0, 90.0] it's clamped to that range. NaN value is converted to 0.0.

      longitude -

      Longitude in degrees. Positive value means Eastern hemisphere. If the value is out of range of [-180.0, 180.0] it's replaced with a value within the range, representing effectively the same meridian. NaN value is converted to 0.0.

      altitude -

      Altitude in meters. NaN value is converted to null.

    • GeoCoordinates

      public GeoCoordinates(double latitude, double longitude)

      Constructs a GeoCoordinates from the provided latitude and longitude values. Corrects values of latitude and longitude if they exceed the ranges. Altitude set to null.

      Parameters:
      latitude -

      Latitude in degrees. Positive value means Northern hemisphere. If the value is out of range of [-90.0, 90.0] it's clamped to that range. NaN value is converted to 0.0.

      longitude -

      Longitude in degrees. Positive value means Eastern hemisphere. If the value is out of range of [-180.0, 180.0] it's replaced with a value within the range, representing effectively the same meridian. NaN value is converted to 0.0.

  • Method Details

    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • distanceTo

      public double distanceTo(@NonNull GeoCoordinates point)

      Computes distance (in meters) along the great circle between two coordinates. This method ignores altitude of both points.

      Parameters:
      point -

      Coordinates of the point to which the distance is computed.

      Returns:

      distance in meters.

    • interpolate

      @NonNull public GeoCoordinates interpolate(@NonNull GeoCoordinates towardCoords, double factor)

      Computes the coordinates of the interpolated location along the great circle between the two coordinates.

      The interpolation factor is clamped to the range [0.0, 1.0] where 0.0 identifies this GeoCoordinates and 1.0 indicates the other coordinates.

      The ratio between the distance to the interpolated coordinates and the distance to the other coordinates is approximately equal to the interpolation factor. When both coordinates have the altitude, then the altitude is interpolated as well; null otherwise.

      Parameters:
      towardCoords -

      Coordinates of the point to which the interpolation is directed.

      factor -

      The interpolation factor

      Returns:

      interpolated coordinates

    • fromString

      @Nullable public static GeoCoordinates fromString(@NonNull String input)

      Constructs GeoCoordinates from the provided string in specified format. Corrects values of lat and long if they exceed the ranges. If the latitude value is out of range of [-90.0, 90.0] it's clamped to that range. If the longitude value is out of range of [-180.0, 180.0] it's replaced with a value within the range, representing effectively the same meridian. Examples: 53.43762,-13.65468. 49°59'56.948"N, 15°48'22.989"E 50d4m17.698N 14d24m2.826E 49.9991522N, 150.8063858E 40°26′47″N 79°58′36″W

      Parameters:
      input -

      String representing GeoCoordinates in one of supported formats.

      Returns:

      Created GeoCoordinates, or 'null' if string was not in appropriate format.