Class Location
- java.lang.Object
-
- org.optaplanner.examples.common.domain.AbstractPersistable
-
- org.optaplanner.examples.tsp.domain.location.Location
-
- Direct Known Subclasses:
AirLocation,RoadLocation
public abstract class Location extends AbstractPersistable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description doublegetAirDistanceDoubleTo(Location location)doublegetAngle(Location location)The angle relative to the direction EAST.abstract longgetDistanceTo(Location location)The distance's unit of measurement depends on theTspSolution'sDistanceType.doublegetLatitude()doublegetLongitude()StringgetName()voidsetLatitude(double latitude)voidsetLongitude(double longitude)voidsetName(String name)StringtoString()-
Methods inherited from class org.optaplanner.examples.common.domain.AbstractPersistable
getId, setId
-
-
-
-
Field Detail
-
name
protected String name
-
latitude
protected double latitude
-
longitude
protected double longitude
-
-
Method Detail
-
getName
public String getName()
-
setName
public void setName(String name)
-
getLatitude
public double getLatitude()
-
setLatitude
public void setLatitude(double latitude)
-
getLongitude
public double getLongitude()
-
setLongitude
public void setLongitude(double longitude)
-
getDistanceTo
public abstract long getDistanceTo(Location location)
The distance's unit of measurement depends on theTspSolution'sDistanceType. It can be in miles or km, but for most cases it's in the TSPLIB's unit of measurement.- Parameters:
location- never null- Returns:
- a positive number, the distance multiplied by 1000 to avoid floating point arithmetic rounding errors
-
getAirDistanceDoubleTo
public double getAirDistanceDoubleTo(Location location)
-
getAngle
public double getAngle(Location location)
The angle relative to the direction EAST.- Parameters:
location- never null- Returns:
- in Cartesian coordinates
-
toString
public String toString()
- Overrides:
toStringin classAbstractPersistable
-
-