1 package au.gov.amsa.navigation; 2 3 import java.util.Date; 4 5 import com.github.davidmoten.grumpy.core.Position; 6 7 public class CollisionCandidate { 8 private final VesselPosition p1; 9 private final VesselPosition p2; 10 private final long time; 11 12 public CollisionCandidate(VesselPosition p1, VesselPosition p2, long time) { 13 this.p1 = p1; 14 this.p2 = p2; 15 this.time = time; 16 } 17 18 public VesselPosition position1() { 19 return p1; 20 } 21 22 public VesselPosition position2() { 23 return p2; 24 } 25 26 public long time() { 27 return time; 28 } 29 30 @Override 31 public String toString() { 32 return "CollisionCandidate [\np1=" + p1 + ", \np2=" + p2 33 + ", \ncollisionTime=" + new Date(time) + "\nseparationKm=" 34 + separationKm() + "]"; 35 } 36 37 public double separationKm() { 38 return new Position(p1.lat(), p1.lon()).getDistanceToKm(new Position(p2 39 .lat(), p2.lon())); 40 } 41 }