Package huskymaps
Class Location
- java.lang.Object
-
- huskymaps.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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
distance(Location other)
Returns the great-circle (haversine) distance between geographic coordinates.boolean
equals(Object o)
int
hashCode()
static Location
parse(String lat, String lon)
Returns a new location from parsing the string latitude and string longitude.String
toString()
-
-
-
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.
-
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
-
-