|
|
|
|
@ -466,14 +466,20 @@ public class MockRace extends Race {
|
|
|
|
|
* Checks to be run on boats rounding marks on the port side
|
|
|
|
|
* @param boat the boat that is rounding a mark
|
|
|
|
|
* @param roundingChecks the checks to run
|
|
|
|
|
* @param legBearing the direction of the leg
|
|
|
|
|
*/
|
|
|
|
|
private void boatRoundingCheckPort(MockBoat boat, List<GPSCoordinate> roundingChecks, Bearing legBearing){
|
|
|
|
|
private void boatRoundingCheckPort(MockBoat boat, List<GPSCoordinate> roundingChecks, Bearing legBearing) {
|
|
|
|
|
//boats must pass all checks in order to round a mark
|
|
|
|
|
|
|
|
|
|
//boolean for if boat has to/needs to pass through a gate
|
|
|
|
|
boolean gateCheck = boat.getCurrentLeg().getEndCompoundMark().getMark2() == null || boat.isBetweenGate(boat.getCurrentLeg().getEndCompoundMark());
|
|
|
|
|
|
|
|
|
|
switch (boat.getRoundingStatus()) {
|
|
|
|
|
case 0://hasn't started rounding
|
|
|
|
|
if (boat.isPortSide(boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing)) &&
|
|
|
|
|
GPSCoordinate.passesLine(boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing).getPosition(),
|
|
|
|
|
roundingChecks.get(0), boat.getCurrentPosition(), legBearing)) {
|
|
|
|
|
roundingChecks.get(0), boat.getCurrentPosition(), legBearing) &&
|
|
|
|
|
gateCheck) {
|
|
|
|
|
boat.increaseRoundingStatus();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
@ -499,14 +505,20 @@ public class MockRace extends Race {
|
|
|
|
|
* Checks to be run on boats rounding marks on the starboard side
|
|
|
|
|
* @param boat the boat that is rounding a mark
|
|
|
|
|
* @param roundingChecks the checks to run
|
|
|
|
|
* @param legBearing the direction of the leg
|
|
|
|
|
*/
|
|
|
|
|
private void boatRoundingCheckStarboard(MockBoat boat, List<GPSCoordinate> roundingChecks, Bearing legBearing){
|
|
|
|
|
//boats must pass all checks in order to round a mark
|
|
|
|
|
|
|
|
|
|
//boolean for if boat has to/needs to pass through a gate
|
|
|
|
|
boolean gateCheck = boat.getCurrentLeg().getEndCompoundMark().getMark2() == null || boat.isBetweenGate(boat.getCurrentLeg().getEndCompoundMark());
|
|
|
|
|
|
|
|
|
|
switch (boat.getRoundingStatus()) {
|
|
|
|
|
case 0://hasn't started rounding
|
|
|
|
|
if (boat.isPortSide(boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing)) &&
|
|
|
|
|
GPSCoordinate.passesLine(boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(legBearing).getPosition(),
|
|
|
|
|
roundingChecks.get(0), boat.getCurrentPosition(), legBearing)) {
|
|
|
|
|
roundingChecks.get(0), boat.getCurrentPosition(), legBearing) &&
|
|
|
|
|
gateCheck) {
|
|
|
|
|
boat.increaseRoundingStatus();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
@ -533,7 +545,7 @@ public class MockRace extends Race {
|
|
|
|
|
*/
|
|
|
|
|
protected void checkPosition(MockBoat boat, long timeElapsed) {
|
|
|
|
|
//The distance, in nautical miles, within which the boat needs to get in order to consider that it has reached the marker.
|
|
|
|
|
double epsilonNauticalMiles = 250.0 / Constants.NMToMetersConversion; //250 meters.
|
|
|
|
|
double epsilonNauticalMiles = boat.getCurrentLeg().getEndCompoundMark().getRoundingDistance(); //250 meters.
|
|
|
|
|
|
|
|
|
|
if (boat.calculateDistanceToNextMarker() < epsilonNauticalMiles) {
|
|
|
|
|
//Boat is within an acceptable distance from the mark.
|
|
|
|
|
@ -545,10 +557,25 @@ public class MockRace extends Race {
|
|
|
|
|
//use the direction line to create three invisible points that act as crossover lines a boat must cross
|
|
|
|
|
//to round a mark
|
|
|
|
|
GPSCoordinate roundCheck1 = GPSCoordinate.calculateNewPosition(endDirectionLinePoint,
|
|
|
|
|
epsilonNauticalMiles, Azimuth.fromDegrees(bearingOfDirectionLine.degrees() + 90));//adding 90 so the check line is parallel
|
|
|
|
|
epsilonNauticalMiles, Azimuth.fromDegrees(bearingOfDirectionLine.degrees() - 90));//adding 90 so the check line is parallel
|
|
|
|
|
|
|
|
|
|
GPSCoordinate roundCheck2;
|
|
|
|
|
try{
|
|
|
|
|
Leg nextLeg = legs.get(legs.indexOf(boat.getCurrentLeg()) + 1);
|
|
|
|
|
|
|
|
|
|
GPSCoordinate startNextDirectionLinePoint = nextLeg.getStartCompoundMark().getMark1Position();
|
|
|
|
|
GPSCoordinate endNextDirectionLinePoint = nextLeg.getEndCompoundMark().getMark1Position();
|
|
|
|
|
Bearing bearingOfNextDirectionLine = GPSCoordinate.calculateBearing(startNextDirectionLinePoint, endNextDirectionLinePoint);
|
|
|
|
|
|
|
|
|
|
roundCheck2 = GPSCoordinate.calculateNewPosition(endDirectionLinePoint,
|
|
|
|
|
epsilonNauticalMiles, Azimuth.fromDegrees(bearingOfNextDirectionLine.degrees() + 90));
|
|
|
|
|
}catch(NullPointerException e){
|
|
|
|
|
//this is caused by the last leg not being having a leg after it
|
|
|
|
|
roundCheck2 = roundCheck1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GPSCoordinate roundCheck2 = GPSCoordinate.calculateNewPosition(endDirectionLinePoint,
|
|
|
|
|
epsilonNauticalMiles, Azimuth.fromDegrees(bearingOfDirectionLine.degrees()));
|
|
|
|
|
|
|
|
|
|
List<GPSCoordinate> roundingChecks = new ArrayList<GPSCoordinate>(Arrays.asList(roundCheck1, roundCheck2));
|
|
|
|
|
|
|
|
|
|
|