//package seng302.Model; // // //import javafx.scene.paint.Color; //import org.geotools.referencing.GeodeticCalculator; //import org.junit.Test; //import seng302.Constants; //import seng302.GPSCoordinate; // //import java.lang.reflect.Array; //import java.util.ArrayList; // //import static org.junit.Assert.assertEquals; // ///** // * Created by esa46 on 16/03/17. // */ //public class ConstantVelocityRaceTest { // // CompoundMark START_MARKER = new CompoundMark(new GPSCoordinate(0, 0)); // CompoundMark END_MARKER = new CompoundMark(new GPSCoordinate(10, 10)); // Leg START_LEG = new Leg("Start", START_MARKER, END_MARKER, 0); // // int ONE_HOUR = 3600000; //1 hour in milliseconds // // // private ArrayList generateLegsArray() { // ArrayList legs = new ArrayList<>(); // legs.add(START_LEG); // return legs; // } // // @Test // public void updatePositionChangesDistanceTravelled() { // ArrayList legs = generateLegsArray(); // BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt"); // boat.setCurrentLeg(legs.get(0)); // boat.setDistanceTravelledInLeg(0); // BoatInRace[] boats = new BoatInRace[]{boat}; // // ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, null, 1); // // race.updatePosition(boat, ONE_HOUR); // assertEquals(boat.getDistanceTravelledInLeg(), boat.getVelocity(), 1e-8); // } // // // @Test // public void updatePositionHandlesNoChangeToDistanceTravelled() { // // ArrayList legs = generateLegsArray(); // BoatInRace boat = new BoatInRace("Test", 0, Color.ALICEBLUE, "tt"); // boat.setCurrentLeg(legs.get(0)); // boat.setDistanceTravelledInLeg(0); // BoatInRace[] boats = new BoatInRace[]{boat}; // // ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, null, 1); // // race.updatePosition(boat, ONE_HOUR); // assertEquals(boat.getDistanceTravelledInLeg(), 0, 1e-8); // } // // @Test // public void changesToDistanceTravelledAreAdditive() { // // ArrayList legs = generateLegsArray(); // BoatInRace boat = new BoatInRace("Test", 5, Color.ALICEBLUE, "tt"); // boat.setCurrentLeg(legs.get(0)); // boat.setDistanceTravelledInLeg(50); // BoatInRace[] boats = new BoatInRace[]{boat}; // // ConstantVelocityRace race = new ConstantVelocityRace(boats, legs, null, 1); // // race.updatePosition(boat, ONE_HOUR); // assertEquals(boat.getDistanceTravelledInLeg(), boat.getVelocity() + 50, 1e-8); // } // // @Test // public void travelling10nmNorthGivesCorrectNewCoordinates() { // GPSCoordinate oldPos = new GPSCoordinate(0, 0); // GPSCoordinate newPos = ConstantVelocityRace.calculatePosition(oldPos, 10, 0); // // GeodeticCalculator calc = new GeodeticCalculator(); // calc.setStartingGeographicPoint(0, 0); // calc.setDirection(0, 10 * Constants.NMToMetersConversion); // // assertEquals(newPos.getLongitude(), 0, 1e-8); // assertEquals(newPos.getLatitude(), calc.getDestinationGeographicPoint().getY(), 1e-8); // assertEquals(newPos.getLongitude(), calc.getDestinationGeographicPoint().getX(), 1e-8); // } // // // @Test // public void travelling10nmEastGivesCorrectNewCoordinates() { // GPSCoordinate oldPos = new GPSCoordinate(0, 0); // GPSCoordinate newPos = ConstantVelocityRace.calculatePosition(oldPos, 10, 90); // // GeodeticCalculator calc = new GeodeticCalculator(); // calc.setStartingGeographicPoint(0, 0); // calc.setDirection(90, 10 * Constants.NMToMetersConversion); // // // assertEquals(newPos.getLatitude(), 0, 1e-8); // assertEquals(newPos.getLatitude(), calc.getDestinationGeographicPoint().getY(), 1e-8); // assertEquals(newPos.getLongitude(), calc.getDestinationGeographicPoint().getX(), 1e-8); // } // // // @Test // public void travelling10nmWestGivesCorrectNewCoordinates() { // GPSCoordinate oldPos = new GPSCoordinate(0, 0); // GPSCoordinate newPos = ConstantVelocityRace.calculatePosition(oldPos, 10, -90); // // GeodeticCalculator calc = new GeodeticCalculator(); // calc.setStartingGeographicPoint(0, 0); // calc.setDirection(-90, 10 * Constants.NMToMetersConversion); // // // assertEquals(newPos.getLatitude(), 0, 1e-8); // assertEquals(newPos.getLatitude(), calc.getDestinationGeographicPoint().getY(), 1e-8); // assertEquals(newPos.getLongitude(), calc.getDestinationGeographicPoint().getX(), 1e-8); // } // // // @Test // public void travelling10nmSouthGivesCorrectNewCoordinates() { // GPSCoordinate oldPos = new GPSCoordinate(0, 0); // GPSCoordinate newPos = ConstantVelocityRace.calculatePosition(oldPos, 10, 180); // // GeodeticCalculator calc = new GeodeticCalculator(); // calc.setStartingGeographicPoint(0, 0); // calc.setDirection(180, 10 * Constants.NMToMetersConversion); // // // assertEquals(newPos.getLongitude(), 0, 1e-8); // assertEquals(newPos.getLatitude(), calc.getDestinationGeographicPoint().getY(), 1e-8); // assertEquals(newPos.getLongitude(), calc.getDestinationGeographicPoint().getX(), 1e-8); // } // //}