Class Coordinate

java.lang.Object
es.situm.sdk.model.location.Coordinate
All Implemented Interfaces:
android.os.Parcelable, MapperInterface

public class Coordinate extends Object implements android.os.Parcelable, MapperInterface
A structure that contains geographical coordinate. Instances are immutable.

See CoordinateConverter to convert between Coordinate and CartesianCoordinate's building coordinate.

  • Field Details

    • CREATOR

      public static final android.os.Parcelable.Creator<Coordinate> CREATOR
    • EMPTY

      public static final Coordinate EMPTY
  • Constructor Details

    • Coordinate

      public Coordinate(double latitude, double longitude)
    • Coordinate

      public Coordinate(@NonNull Coordinate copy)
  • Method Details

    • getLatitude

      public double getLatitude()
      Returns latitude in degrees
      Returns:
      double. Default is 0
    • getLongitude

      public double getLongitude()
      Returns longitude in degrees
      Returns:
      double. Default is 0
    • distanceTo

      @FloatRange(from=0.0) public double distanceTo(Coordinate coordinate) throws IllegalArgumentException
      Calculates the distance (in meters) between this coordinate and another
      Parameters:
      coordinate - the other coordinate. Can't be null
      Returns:
      distance in meters. Never a negative value
      Throws:
      IllegalArgumentException - if cartesianCoordinate is null
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object
    • describeContents

      public int describeContents()
      Specified by:
      describeContents in interface android.os.Parcelable
    • writeToParcel

      public void writeToParcel(android.os.Parcel dest, int flags)
      Specified by:
      writeToParcel in interface android.os.Parcelable
    • toMap

      public Map<String,Object> toMap()
      Description copied from interface: MapperInterface
      Method to transform object into Map<String, Object>
      Specified by:
      toMap in interface MapperInterface
      Returns:
      Map<String, Object> with the information of the object mapped
    • fromMap

      public static Coordinate fromMap(@NonNull Map<String,Object> map) throws IllegalArgumentException
      Return a new Coordinate instance object containing the data at the given map. Use MapperInterface to populate the Map. The expected fields are those defined at this class.
      Parameters:
      map - Map containing the data used to populate the new object.
      Returns:
      New instance.
      Throws:
      IllegalArgumentException - If there is not enough information at the given map or it is incorrect.