Class GeoLocation


  • public class GeoLocation
    extends java.lang.Object
    Geo location specified in terms of longitude and latitude.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static double EARTH_RADIUS_KM  
    • Constructor Summary

      Constructors 
      Constructor Description
      GeoLocation​(double latitude, double longitude)
      Creates a new location using the specified coordinates.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double kilometersTo​(GeoLocation other)
      Returns the distance in kilometers, between this location and another.
      double latitude()
      Returns the latitude of this location.
      double longitude()
      Returns the longitude of this location.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • GeoLocation

        public GeoLocation​(double latitude,
                           double longitude)
        Creates a new location using the specified coordinates.
        Parameters:
        latitude - latitude line
        longitude - longitude line
    • Method Detail

      • latitude

        public double latitude()
        Returns the latitude of this location.
        Returns:
        latitude
      • longitude

        public double longitude()
        Returns the longitude of this location.
        Returns:
        longitude
      • kilometersTo

        public double kilometersTo​(GeoLocation other)
        Returns the distance in kilometers, between this location and another.
        Parameters:
        other - other geo location
        Returns:
        distance in kilometers
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object