|
|
|
@ -1,7 +1,10 @@
|
|
|
|
package seng302.Model;
|
|
|
|
package seng302.Model;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.geotools.referencing.GeodeticCalculator;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import org.opengis.geometry.coordinate.Geodesic;
|
|
|
|
|
|
|
|
import seng302.Constants;
|
|
|
|
import seng302.GPSCoordinate;
|
|
|
|
import seng302.GPSCoordinate;
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.geom.Point2D;
|
|
|
|
import java.awt.geom.Point2D;
|
|
|
|
@ -13,12 +16,72 @@ import static org.junit.Assert.assertEquals;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class ConstantVelocityRaceTest {
|
|
|
|
public class ConstantVelocityRaceTest {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
|
|
|
|
// public void
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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
|
|
|
|
@Test
|
|
|
|
public void travelling5nmNorthGivesCorrectNewCoordinates() {
|
|
|
|
public void travelling10nmEastGivesCorrectNewCoordinates() {
|
|
|
|
GPSCoordinate oldPos = new GPSCoordinate(0, 0);
|
|
|
|
GPSCoordinate oldPos = new GPSCoordinate(0, 0);
|
|
|
|
GPSCoordinate newPos = ConstantVelocityRace.calculatePosition(oldPos, 5, 0);
|
|
|
|
GPSCoordinate newPos = ConstantVelocityRace.calculatePosition(oldPos, 10, 90);
|
|
|
|
// assertEquals(newPos.getLatitude(), 0.08374461297528203, );
|
|
|
|
|
|
|
|
// assertEquals(ConstantVelocityRace.calculatePosition(oldPos, 5, 90).getLatitude(), 0.08, 1e-1);
|
|
|
|
GeodeticCalculator calc = new GeodeticCalculator();
|
|
|
|
System.out.println(ConstantVelocityRace.calculatePosition(oldPos, 5, 0).getLongitude());
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|