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
  • Field Details

    • name

      protected String name
    • latitude

      protected double latitude
    • longitude

      protected double longitude
  • Constructor Details

    • Location

      protected Location()
    • Location

      protected Location(long id)
    • Location

      protected Location(long id, double latitude, double longitude)
  • Method Details

    • 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 the TspSolution's DistanceType. 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:
      toString in class AbstractPersistable