Merged with visualiser side of mark boats
#story[881]
This commit is contained in:
@@ -5,7 +5,7 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import seng302.GPSCoordinate;
|
||||
import seng302.Model.Leg;
|
||||
import seng302.Model.CompoundMark;
|
||||
import seng302.Model.Marker;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -87,7 +87,7 @@ public class StreamedRaceTest {
|
||||
GPSCoordinate topLeft = streamedCourseXMLReader.getMapTopLeft();
|
||||
GPSCoordinate bottomRight = streamedCourseXMLReader.getMapBottomRight();
|
||||
|
||||
for(CompoundMark compoundMark : streamedCourseXMLReader.getCompoundMarks()) {
|
||||
for(Marker compoundMark : streamedCourseXMLReader.getMarkers()) {
|
||||
GPSCoordinate centre = compoundMark.getAverageGPSCoordinate();
|
||||
assertTrue(centre.getLatitude() < bottomRight.getLatitude());
|
||||
assertTrue(centre.getLatitude() > topLeft.getLatitude());
|
||||
|
||||
@@ -19,18 +19,18 @@ public class BoatInRaceTest {
|
||||
@Test
|
||||
public void calculateDueNorthAzimuthReturns0() {
|
||||
|
||||
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(50, 0));
|
||||
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateAzimuth(), 0, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueSouthAzimuthReturns180() {
|
||||
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(-50, 0));
|
||||
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateAzimuth(), 180, 1e-8);
|
||||
}
|
||||
@@ -39,9 +39,9 @@ public class BoatInRaceTest {
|
||||
@Test
|
||||
public void calculateDueEastAzimuthReturns90() {
|
||||
|
||||
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(0, 50));
|
||||
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(0, 50));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateAzimuth(), 90, 1e-8);
|
||||
}
|
||||
@@ -49,9 +49,9 @@ public class BoatInRaceTest {
|
||||
|
||||
@Test
|
||||
public void calculateDueWestAzimuthReturnsNegative90() {
|
||||
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(0, -50));
|
||||
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(0, -50));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateAzimuth(), -90, 1e-8);
|
||||
|
||||
@@ -60,9 +60,9 @@ public class BoatInRaceTest {
|
||||
@Test
|
||||
public void calculateDueNorthHeadingReturns0() {
|
||||
|
||||
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(50, 0));
|
||||
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateHeading(), 0, 1e-8);
|
||||
}
|
||||
@@ -70,27 +70,27 @@ public class BoatInRaceTest {
|
||||
|
||||
@Test
|
||||
public void calculateDueEastHeadingReturns90() {
|
||||
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(0, 50));
|
||||
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(0, 50));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateHeading(), 90, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueSouthHeadingReturns180() {
|
||||
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(-50, 0));
|
||||
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateHeading(), 180, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDueWestHeadingReturns270() {
|
||||
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(0, -50));
|
||||
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(0, -50));
|
||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
||||
TEST_BOAT.setCurrentLeg(start);
|
||||
assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8);
|
||||
}
|
||||
@@ -117,16 +117,16 @@ public class BoatInRaceTest {
|
||||
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||
|
||||
// Construct leg of 0 degrees
|
||||
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(50, 0));
|
||||
Leg leg0deg = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
||||
Leg leg0deg = new Leg("Start", startMarker, endMarker, 0);
|
||||
boat.setCurrentLeg(leg0deg);
|
||||
boat.setCurrentPosition(new GPSCoordinate(0, 0));
|
||||
|
||||
assertEquals(0, boat.calculateHeading(), 1e-8);
|
||||
|
||||
// Construct leg from wake - heading should be 180 degrees
|
||||
Leg leg180deg = new Leg("Start", startCompoundMark, new CompoundMark(boat.getWake()), 0);
|
||||
Leg leg180deg = new Leg("Start", startMarker, new Marker(boat.getWake()), 0);
|
||||
boat.setCurrentLeg(leg180deg);
|
||||
|
||||
assertEquals(180, boat.calculateHeading(), 1e-8);
|
||||
@@ -138,9 +138,9 @@ public class BoatInRaceTest {
|
||||
BoatInRace boat = new BoatInRace("Test", 10, Color.ALICEBLUE, "tt");
|
||||
|
||||
// Construct leg of 0 degrees at 0 N
|
||||
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(50, 0));
|
||||
Leg leg0deg = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
||||
Leg leg0deg = new Leg("Start", startMarker, endMarker, 0);
|
||||
boat.setCurrentLeg(leg0deg);
|
||||
boat.setCurrentPosition(new GPSCoordinate(0, 0));
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import static seng302.Model.Leg.NM_TO_METERS;
|
||||
*/
|
||||
public class LegTest {
|
||||
|
||||
private final CompoundMark ORIGIN_CompoundMark = new CompoundMark(new GPSCoordinate(0, 0));
|
||||
private final Marker ORIGIN_Marker = new Marker(new GPSCoordinate(0, 0));
|
||||
|
||||
@Test
|
||||
public void calculateDistanceHandles5nmNorth() {
|
||||
@@ -22,8 +22,8 @@ public class LegTest {
|
||||
calc.setStartingGeographicPoint(0, 0);
|
||||
calc.setDirection(0, 5 * NM_TO_METERS);
|
||||
|
||||
CompoundMark endCompoundMark = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_CompoundMark, endCompoundMark, 0);
|
||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_Marker, endMarker, 0);
|
||||
assertEquals(test.getDistance(), 5, 1e-8);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ public class LegTest {
|
||||
calc.setStartingGeographicPoint(0, 0);
|
||||
calc.setDirection(90, 12 * NM_TO_METERS);
|
||||
|
||||
CompoundMark endCompoundMark = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_CompoundMark, endCompoundMark, 0);
|
||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_Marker, endMarker, 0);
|
||||
assertEquals(test.getDistance(), 12, 1e-8);
|
||||
}
|
||||
|
||||
@@ -44,8 +44,8 @@ public class LegTest {
|
||||
calc.setStartingGeographicPoint(0, 0);
|
||||
calc.setDirection(180, 0.5 * NM_TO_METERS);
|
||||
|
||||
CompoundMark endCompoundMark = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_CompoundMark, endCompoundMark, 0);
|
||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_Marker, endMarker, 0);
|
||||
assertEquals(test.getDistance(), 0.5, 1e-8);
|
||||
}
|
||||
|
||||
@@ -55,23 +55,23 @@ public class LegTest {
|
||||
calc.setStartingGeographicPoint(0, 0);
|
||||
calc.setDirection(-90, 0.1 * NM_TO_METERS);
|
||||
|
||||
CompoundMark endCompoundMark = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_CompoundMark, endCompoundMark, 0);
|
||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||
Leg test = new Leg("Test", ORIGIN_Marker, endMarker, 0);
|
||||
assertEquals(test.getDistance(), 0.1, 1e-8);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculateDistanceHandlesZeroDifference() {
|
||||
|
||||
Leg test = new Leg("Test", ORIGIN_CompoundMark, ORIGIN_CompoundMark, 0);
|
||||
Leg test = new Leg("Test", ORIGIN_Marker, ORIGIN_Marker, 0);
|
||||
assertEquals(test.getDistance(), 0, 1e-8);
|
||||
}
|
||||
|
||||
private CompoundMark getEndMarker(Point2D point) {
|
||||
private Marker getEndMarker(Point2D point) {
|
||||
|
||||
GPSCoordinate coords = new GPSCoordinate(point.getY(), point.getX());
|
||||
|
||||
return new CompoundMark(coords);
|
||||
return new Marker(coords);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -8,14 +8,14 @@ import static org.junit.Assert.assertTrue;
|
||||
/**
|
||||
* Created by esa46 on 29/03/17.
|
||||
*/
|
||||
public class CompoundMarkTest {
|
||||
public class MarkerTest {
|
||||
|
||||
private final GPSCoordinate ORIGIN_COORD = new GPSCoordinate(0, 0);
|
||||
|
||||
@Test
|
||||
public void averageOfSingleMarkAtOriginIsSingleMark() {
|
||||
|
||||
CompoundMark testMark = new CompoundMark(ORIGIN_COORD);
|
||||
Marker testMark = new Marker(ORIGIN_COORD);
|
||||
assertTrue(testMark.getAverageGPSCoordinate().equals(ORIGIN_COORD));
|
||||
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class CompoundMarkTest {
|
||||
public void averageOfSingleMarkIsSingleMark() {
|
||||
|
||||
GPSCoordinate testCoord = new GPSCoordinate(20, 25);
|
||||
CompoundMark testMark = new CompoundMark(testCoord);
|
||||
Marker testMark = new Marker(testCoord);
|
||||
assertTrue(testMark.getAverageGPSCoordinate().equals(testCoord));
|
||||
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class CompoundMarkTest {
|
||||
public void averageLatOfTwoMarksIsAccurate() {
|
||||
|
||||
GPSCoordinate testCoord = new GPSCoordinate(10, 0);
|
||||
CompoundMark testMark = new CompoundMark(ORIGIN_COORD, testCoord);
|
||||
Marker testMark = new Marker(ORIGIN_COORD, testCoord);
|
||||
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(5, 0)));
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class CompoundMarkTest {
|
||||
public void averageLongOfTwoMarksIsAccurate() {
|
||||
|
||||
GPSCoordinate testCoord = new GPSCoordinate(0, 10);
|
||||
CompoundMark testMark = new CompoundMark(ORIGIN_COORD, testCoord);
|
||||
Marker testMark = new Marker(ORIGIN_COORD, testCoord);
|
||||
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(0, 5)));
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ public class CompoundMarkTest {
|
||||
|
||||
GPSCoordinate testCoord1 = new GPSCoordinate(10, 30);
|
||||
GPSCoordinate testCoord2 = new GPSCoordinate(30, 60);
|
||||
CompoundMark testMark = new CompoundMark(testCoord1, testCoord2);
|
||||
Marker testMark = new Marker(testCoord1, testCoord2);
|
||||
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(020.644102, 44.014817)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user