Package huskymaps

Class Location


  • public class Location
    extends Object
    A physical place in the world represented as latitude, longitude, and (optionally) a name.
    See Also:
    Location.Builder, MapGraph
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Location.Builder
      Interactively constructs a new location when the fields are not all immediately available.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      double lat
      The latitude of this location.
      double lon
      The longitude of this location.
      String name
      The name of this location (or null).
    • Constructor Summary

      Constructors 
      Constructor Description
      Location​(double lat, double lon, String name)
      Constructs a new location from the given latitude, longitude, and name.
    • Field Detail

      • lat

        public final double lat
        The latitude of this location.
      • lon

        public final double lon
        The longitude of this location.
      • name

        public final String name
        The name of this location (or null).
    • Constructor Detail

      • Location

        public Location​(double lat,
                        double lon,
                        String name)
        Constructs a new location from the given latitude, longitude, and name.
        Parameters:
        lat - the latitude.
        lon - the longitude.
        name - the name.
    • Method Detail

      • parse

        public static Location parse​(String lat,
                                     String lon)
        Returns a new location from parsing the string latitude and string longitude.
        Parameters:
        lat - the numeric String representing the latitude.
        lon - the numeric String representing the longitude.
        Returns:
        a new location from parsing the string latitude and string longitude.
      • distance

        public double distance​(Location other)
        Returns the great-circle (haversine) distance between geographic coordinates.
        Parameters:
        other - The other location.
        Returns:
        The great-circle distance between the two vertices.
        See Also:
        https://www.movable-type.co.uk/scripts/latlong.html
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object