# Conflicts: # src/main/java/seng302/Constants.java # src/main/java/seng302/Model/Race.java # src/main/java/seng302/Model/ResizableRaceCanvas.javamain
commit
f8147be4df
@ -0,0 +1,182 @@
|
|||||||
|
<race>
|
||||||
|
<boats>
|
||||||
|
<boat>
|
||||||
|
<name>ORACLE TEAM USA</name>
|
||||||
|
<speed>300</speed>
|
||||||
|
<abbr>USA</abbr>
|
||||||
|
<colour>BLUEVIOLET</colour>
|
||||||
|
</boat>
|
||||||
|
<boat>
|
||||||
|
<name>Land Rover BAR</name>
|
||||||
|
<speed>500</speed>
|
||||||
|
<abbr>BAR</abbr>
|
||||||
|
<colour>BLACK</colour>
|
||||||
|
</boat>
|
||||||
|
<boat>
|
||||||
|
<name>SoftBank Team Japan</name>
|
||||||
|
<speed>400</speed>
|
||||||
|
<abbr>JAP</abbr>
|
||||||
|
<colour>RED</colour>
|
||||||
|
</boat>
|
||||||
|
<boat>
|
||||||
|
<name>Groupama Team France</name>
|
||||||
|
<speed>350</speed>
|
||||||
|
<abbr>FRN</abbr>
|
||||||
|
<colour>ORANGE</colour>
|
||||||
|
</boat>
|
||||||
|
<boat>
|
||||||
|
<name>Artemis Racing</name>
|
||||||
|
<speed>440</speed>
|
||||||
|
<abbr>ART</abbr>
|
||||||
|
<colour>DARKOLIVEGREEN</colour>
|
||||||
|
</boat>
|
||||||
|
<boat>
|
||||||
|
<name>Emirates Team New Zealand</name>
|
||||||
|
<speed>620</speed>
|
||||||
|
<abbr>ENZ</abbr>
|
||||||
|
<colour>LIMEGREEN</colour>
|
||||||
|
</boat>
|
||||||
|
</boats>
|
||||||
|
<legs>
|
||||||
|
<leg>
|
||||||
|
<name>Start to Mark 1</name>
|
||||||
|
<start>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.296577</latitude>
|
||||||
|
<longitude>-64.854304</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</start>
|
||||||
|
<finish>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.293039</latitude>
|
||||||
|
<longitude>-64.843983</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</finish>
|
||||||
|
</leg>
|
||||||
|
<leg>
|
||||||
|
<name>Mark 1 to Leeward Gate</name>
|
||||||
|
<start>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.293039</latitude>
|
||||||
|
<longitude>-64.843983</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</start>
|
||||||
|
<finish>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.309693</latitude>
|
||||||
|
<longitude>-64.835249</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</finish>
|
||||||
|
</leg>
|
||||||
|
<leg>
|
||||||
|
<name>Leeward Gate to Windward Gate</name>
|
||||||
|
<start>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.309693</latitude>
|
||||||
|
<longitude>-64.835249</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</start>
|
||||||
|
<finish>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.284680</latitude>
|
||||||
|
<longitude>-64.850045</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</finish>
|
||||||
|
</leg>
|
||||||
|
<leg>
|
||||||
|
<name>Windward Gate to Leeward Gate</name>
|
||||||
|
<start>
|
||||||
|
<coordinate>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.284680</latitude>
|
||||||
|
<longitude>-64.850045</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</coordinate>
|
||||||
|
</start>
|
||||||
|
<finish>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.309693</latitude>
|
||||||
|
<longitude>-64.835249</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</finish>
|
||||||
|
</leg>
|
||||||
|
<leg>
|
||||||
|
<name>Leeward Gate to Finish</name>
|
||||||
|
<start>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.309693</latitude>
|
||||||
|
<longitude>-64.835249</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</start>
|
||||||
|
<finish>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.317379</latitude>
|
||||||
|
<longitude>-64.839291</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</finish>
|
||||||
|
</leg>
|
||||||
|
</legs>
|
||||||
|
<course>
|
||||||
|
<boundaries>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.278</latitude>
|
||||||
|
<longitude>-64.863</longitude>
|
||||||
|
</coordinate>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.30989</latitude>
|
||||||
|
<longitude>-64.821</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</boundaries>
|
||||||
|
<marker>
|
||||||
|
<name>Start Line</name>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.296577</latitude>
|
||||||
|
<longitude>-64.854304</longitude>
|
||||||
|
</coordinate>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.293771</latitude>
|
||||||
|
<longitude>-64.855242</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</marker>
|
||||||
|
<marker>
|
||||||
|
<name>Mark</name>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.293039</latitude>
|
||||||
|
<longitude>-64.843983</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</marker>
|
||||||
|
<marker>
|
||||||
|
<name>Windward Gate</name>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.284680</latitude>
|
||||||
|
<longitude>-64.850045</longitude>
|
||||||
|
</coordinate>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.280164</latitude>
|
||||||
|
<longitude>-64.847591</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</marker>
|
||||||
|
<marker>
|
||||||
|
<name>Leeward Gate</name>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.309693</latitude>
|
||||||
|
<longitude>-64.835249</longitude>
|
||||||
|
</coordinate>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.308046</latitude>
|
||||||
|
<longitude>-64.831785</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</marker>
|
||||||
|
<marker>
|
||||||
|
<name>Finish Line</name>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.317379</latitude>
|
||||||
|
<longitude>-64.839291</longitude>
|
||||||
|
</coordinate>
|
||||||
|
<coordinate>
|
||||||
|
<latitude>32.317257</latitude>
|
||||||
|
<longitude>-64.836260</longitude>
|
||||||
|
</coordinate>
|
||||||
|
</marker>
|
||||||
|
</course>
|
||||||
|
</race>
|
||||||
@ -0,0 +1,114 @@
|
|||||||
|
package seng302.Model;
|
||||||
|
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seng302.GPSCoordinate;
|
||||||
|
|
||||||
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
import static junit.framework.TestCase.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by esa46 on 22/03/17.
|
||||||
|
*/
|
||||||
|
public class BoatInRaceTest {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void calculateDueNorthAzimuthReturns0() {
|
||||||
|
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||||
|
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||||
|
GPSCoordinate endPoint = new GPSCoordinate(50, 0);
|
||||||
|
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||||
|
boat.setCurrentLeg(start);
|
||||||
|
assertEquals(boat.calculateAzimuth(), 0, 1e-8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void calculateDueSouthAzimuthReturns180() {
|
||||||
|
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||||
|
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||||
|
GPSCoordinate endPoint = new GPSCoordinate(-50, 0);
|
||||||
|
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||||
|
boat.setCurrentLeg(start);
|
||||||
|
assertEquals(boat.calculateAzimuth(), 180, 1e-8);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void calculateDueEastAzimuthReturns90() {
|
||||||
|
|
||||||
|
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||||
|
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||||
|
GPSCoordinate endPoint = new GPSCoordinate(0, 50);
|
||||||
|
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||||
|
boat.setCurrentLeg(start);
|
||||||
|
assertEquals(boat.calculateAzimuth(), 90, 1e-8);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void calculateDueWestAzimuthReturnsNegative90() {
|
||||||
|
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||||
|
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||||
|
GPSCoordinate endPoint = new GPSCoordinate(0, -50);
|
||||||
|
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||||
|
boat.setCurrentLeg(start);
|
||||||
|
assertEquals(boat.calculateAzimuth(), -90, 1e-8);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void calculateDueNorthHeadingReturns0() {
|
||||||
|
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||||
|
GPSCoordinate startPoint = new GPSCoordinate(10, 0);
|
||||||
|
GPSCoordinate endPoint = new GPSCoordinate(50, 0);
|
||||||
|
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||||
|
boat.setCurrentLeg(start);
|
||||||
|
assertEquals(boat.calculateHeading(), 0, 1e-8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void calculateDueEastHeadingReturns90() {
|
||||||
|
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||||
|
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||||
|
GPSCoordinate endPoint = new GPSCoordinate(0, 50);
|
||||||
|
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||||
|
boat.setCurrentLeg(start);
|
||||||
|
assertEquals(boat.calculateHeading(), 90, 1e-8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void calculateDueSouthHeadingReturns180() {
|
||||||
|
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||||
|
GPSCoordinate startPoint = new GPSCoordinate(10, 0);
|
||||||
|
GPSCoordinate endPoint = new GPSCoordinate(-50, 0);
|
||||||
|
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||||
|
boat.setCurrentLeg(start);
|
||||||
|
assertEquals(boat.calculateHeading(), 180, 1e-8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void calculateDueWestHeadingReturns270() {
|
||||||
|
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||||
|
GPSCoordinate startPoint = new GPSCoordinate(0, 10);
|
||||||
|
GPSCoordinate endPoint = new GPSCoordinate(0, -50);
|
||||||
|
Leg start = new Leg("Start", startPoint, endPoint, 0);
|
||||||
|
boat.setCurrentLeg(start);
|
||||||
|
assertEquals(boat.calculateHeading(), 270, 1e-8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void createNewBoatCratesInstanceOfSuperClass() {
|
||||||
|
|
||||||
|
BoatInRace testBoat = new BoatInRace("Boat", 20, Color.ALICEBLUE, "tt");
|
||||||
|
testBoat.setName("Name can change");
|
||||||
|
assertTrue(testBoat instanceof Boat);
|
||||||
|
assertTrue(testBoat.getCurrentLeg() == null);
|
||||||
|
assertTrue(testBoat.getCurrentPosition() == null);
|
||||||
|
assertTrue(testBoat.toString().contains("Name can change"));
|
||||||
|
assertEquals(testBoat.getVelocity(), 20.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,71 @@
|
|||||||
|
package seng302.Model;
|
||||||
|
|
||||||
|
import org.geotools.referencing.GeodeticCalculator;
|
||||||
|
import org.junit.Test;
|
||||||
|
import seng302.Constants;
|
||||||
|
import seng302.GPSCoordinate;
|
||||||
|
|
||||||
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by esa46 on 22/03/17.
|
||||||
|
*/
|
||||||
|
public class LegTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void calculateDistanceHandles5nmNorth() {
|
||||||
|
GeodeticCalculator calc = new GeodeticCalculator();
|
||||||
|
calc.setStartingGeographicPoint(0, 0);
|
||||||
|
calc.setDirection(0, 5 * Constants.NMToMetersConversion);
|
||||||
|
|
||||||
|
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||||
|
GPSCoordinate endPoint = new GPSCoordinate(calc.getDestinationGeographicPoint().getY(), calc.getDestinationGeographicPoint().getX());
|
||||||
|
Leg test= new Leg("Test", startPoint, endPoint, 0);
|
||||||
|
assertEquals(test.getDistance(), 5, 1e-8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void calculateDistanceHandles12nmEast() {
|
||||||
|
GeodeticCalculator calc = new GeodeticCalculator();
|
||||||
|
calc.setStartingGeographicPoint(0, 0);
|
||||||
|
calc.setDirection(90, 12 * Constants.NMToMetersConversion);
|
||||||
|
|
||||||
|
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||||
|
GPSCoordinate endPoint = new GPSCoordinate(calc.getDestinationGeographicPoint().getY(), calc.getDestinationGeographicPoint().getX());
|
||||||
|
Leg test= new Leg("Test", startPoint, endPoint, 0);
|
||||||
|
assertEquals(test.getDistance(), 12, 1e-8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void calculateDistanceHandlesHalfnmSouth() {
|
||||||
|
GeodeticCalculator calc = new GeodeticCalculator();
|
||||||
|
calc.setStartingGeographicPoint(0, 0);
|
||||||
|
calc.setDirection(180, 0.5 * Constants.NMToMetersConversion);
|
||||||
|
|
||||||
|
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||||
|
GPSCoordinate endPoint = new GPSCoordinate(calc.getDestinationGeographicPoint().getY(), calc.getDestinationGeographicPoint().getX());
|
||||||
|
Leg test= new Leg("Test", startPoint, endPoint, 0);
|
||||||
|
assertEquals(test.getDistance(), 0.5, 1e-8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void calculateDistanceHandlesPoint1nmWest() {
|
||||||
|
GeodeticCalculator calc = new GeodeticCalculator();
|
||||||
|
calc.setStartingGeographicPoint(0, 0);
|
||||||
|
calc.setDirection(-90, 0.1 * Constants.NMToMetersConversion);
|
||||||
|
|
||||||
|
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||||
|
GPSCoordinate endPoint = new GPSCoordinate(calc.getDestinationGeographicPoint().getY(), calc.getDestinationGeographicPoint().getX());
|
||||||
|
Leg test= new Leg("Test", startPoint, endPoint, 0);
|
||||||
|
assertEquals(test.getDistance(), 0.1, 1e-8);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void calculateDistanceHandlesZeroDifference() {
|
||||||
|
GPSCoordinate startPoint = new GPSCoordinate(0, 0);
|
||||||
|
GPSCoordinate endPoint = new GPSCoordinate(0, 0);
|
||||||
|
Leg test= new Leg("Test", startPoint, endPoint, 0);
|
||||||
|
assertEquals(test.getDistance(), 0, 1e-8);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in new issue