rounding checks are now done by port or starboard side depending on what the compound marks type is

#story[1101]
main
hba56 8 years ago
parent be8b0e672d
commit db1efab225

@ -4,18 +4,17 @@ import javafx.animation.AnimationTimer;
import network.Messages.BoatLocation; import network.Messages.BoatLocation;
import network.Messages.BoatStatus; import network.Messages.BoatStatus;
import network.Messages.Enums.BoatStatusEnum; import network.Messages.Enums.BoatStatusEnum;
import network.Messages.Enums.RaceStatusEnum;
import network.Messages.LatestMessages; import network.Messages.LatestMessages;
import network.Messages.RaceStatus; import network.Messages.RaceStatus;
import network.Utils.AC35UnitConverter; import network.Utils.AC35UnitConverter;
import shared.dataInput.BoatDataSource; import shared.dataInput.BoatDataSource;
import shared.dataInput.RaceDataSource; import shared.dataInput.RaceDataSource;
import network.Messages.Enums.RaceStatusEnum;
import shared.dataInput.RegattaDataSource; import shared.dataInput.RegattaDataSource;
import shared.model.*; import shared.model.*;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.util.*; import java.util.*;
import static java.lang.Math.cos; import static java.lang.Math.cos;
@ -771,6 +770,68 @@ 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
*/
private void boatRoundingCheckPort(MockBoat boat, List<GPSCoordinate> roundingChecks){
//boats must pass all checks in order to round a mark
switch (boat.getRoundingStatus()) {
case 0://hasn't started rounding
if (boat.isPortSide(boat.getCurrentLeg().getEndCompoundMark().getMark1()) &&
GPSCoordinate.intersects(boat.getCurrentLeg().getEndCompoundMark().getMark1().getPosition(),
roundingChecks.get(0), boat.getCurrentPosition())) {
boat.increaseRoundingStatus();
}
break;
case 1://has been parallel to the mark
if (boat.isPortSide(boat.getCurrentLeg().getEndCompoundMark().getMark1()) &&
GPSCoordinate.intersects(boat.getCurrentLeg().getEndCompoundMark().getMark1().getPosition(),
roundingChecks.get(1), boat.getCurrentPosition())) {
boat.increaseRoundingStatus();
}
break;
case 2://has traveled 180 degrees around the mark
//Move boat on to next leg.
boat.resetRoundingStatus();
Leg nextLeg = this.legs.get(boat.getCurrentLeg().getLegNumber() + 1);
boat.setCurrentLeg(nextLeg);
break;
}
}
/**
* 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
*/
private void boatRoundingCheckStarboard(MockBoat boat, List<GPSCoordinate> roundingChecks){
//boats must pass all checks in order to round a mark
switch (boat.getRoundingStatus()) {
case 0://hasn't started rounding
if (boat.isStarboardSide(boat.getCurrentLeg().getEndCompoundMark().getMark1()) &&
GPSCoordinate.intersects(boat.getCurrentLeg().getEndCompoundMark().getMark1().getPosition(),
roundingChecks.get(0), boat.getCurrentPosition())) {
boat.increaseRoundingStatus();
}
break;
case 1://has been parallel to the mark
if (boat.isStarboardSide(boat.getCurrentLeg().getEndCompoundMark().getMark1()) &&
GPSCoordinate.intersects(boat.getCurrentLeg().getEndCompoundMark().getMark1().getPosition(),
roundingChecks.get(1), boat.getCurrentPosition())) {
boat.increaseRoundingStatus();
}
break;
case 2://has traveled 180 degrees around the mark
//Move boat on to next leg.
boat.resetRoundingStatus();
Leg nextLeg = this.legs.get(boat.getCurrentLeg().getLegNumber() + 1);
boat.setCurrentLeg(nextLeg);
break;
}
}
/** /**
* Checks if a boat has finished any legs, or has pulled out of race (DNF). * Checks if a boat has finished any legs, or has pulled out of race (DNF).
* @param boat The boat to check. * @param boat The boat to check.
@ -798,28 +859,16 @@ public class MockRace extends Race {
GPSCoordinate roundCheck2 = GPSCoordinate.calculateNewPosition(startDirectionLinePoint, GPSCoordinate roundCheck2 = GPSCoordinate.calculateNewPosition(startDirectionLinePoint,
epsilonNauticalMiles, Azimuth.fromDegrees(bearingOfDirectionLine.degrees())); epsilonNauticalMiles, Azimuth.fromDegrees(bearingOfDirectionLine.degrees()));
List<GPSCoordinate> roundingChecks = new ArrayList<GPSCoordinate>(Arrays.asList(roundCheck1, roundCheck2));
//boats must pass all checks in order to round a mark switch (boat.getCurrentLeg().getEndCompoundMark().getRoundingType()) {
switch (boat.getRoundingStatus()){ case SP://Not yet implemented so these gates will be rounded port side
case 0://hasn't started rounding case Port:
if (boat.isPortSide(boat.getCurrentLeg().getEndCompoundMark().getMark1()) && boatRoundingCheckPort(boat, roundingChecks);
GPSCoordinate.intersects(boat.getCurrentLeg().getEndCompoundMark().getMark1().getPosition(),
roundCheck1, boat.getCurrentPosition())){
boat.increaseRoundingStatus();
}
break;
case 1://has been parallel to the mark
if (boat.isPortSide(boat.getCurrentLeg().getEndCompoundMark().getMark1()) &&
GPSCoordinate.intersects(boat.getCurrentLeg().getEndCompoundMark().getMark1().getPosition(),
roundCheck2, boat.getCurrentPosition())){
boat.increaseRoundingStatus();
}
break; break;
case 2://has traveled 180 degrees around the mark case PS://not yet implemented so these gates will be rounded starboard side
//Move boat on to next leg. case Starboard:
boat.resetRoundingStatus(); boatRoundingCheckStarboard(boat, roundingChecks);
Leg nextLeg = this.legs.get(boat.getCurrentLeg().getLegNumber() + 1);
boat.setCurrentLeg(nextLeg);
break; break;
} }

Loading…
Cancel
Save