Finished MarkRoundingSequence class. Added MarkRoundingData class.
RaceState has a MarkRoundingSequenceMember. The temporary rounding line drawing in canvas uses MarkRoundingSequence. MockRace now uses MarkRoundingSequence. #story[1185]
This commit is contained in:
@@ -495,8 +495,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
private void drawRoundingLines() {
|
||||
|
||||
|
||||
|
||||
|
||||
//ugly hack
|
||||
//rounding lines
|
||||
|
||||
@@ -511,52 +509,16 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
return;
|
||||
}
|
||||
|
||||
GPSCoordinate startDirectionLinePoint = boat.getCurrentLeg().getStartCompoundMark().getAverageGPSCoordinate();
|
||||
GPSCoordinate endDirectionLinePoint = boat.getCurrentLeg().getEndCompoundMark().getAverageGPSCoordinate();
|
||||
Bearing bearingOfDirectionLine = GPSCoordinate.calculateBearing(startDirectionLinePoint, endDirectionLinePoint);
|
||||
Leg currentLeg = boat.getCurrentLeg();
|
||||
|
||||
//use the direction line to create three invisible points that act as crossover lines a boat must cross
|
||||
//to round a mark
|
||||
MarkRoundingData roundingData = raceState.getMarkRoundingSequence().getRoundingData(currentLeg);
|
||||
|
||||
double bearingToAdd;
|
||||
if (boat.getCurrentLeg().getEndCompoundMark().getRoundingType() == RoundingType.Port ||
|
||||
boat.getCurrentLeg().getEndCompoundMark().getRoundingType() == RoundingType.SP) {
|
||||
bearingToAdd = 90;
|
||||
}else{
|
||||
bearingToAdd = -90;
|
||||
}
|
||||
|
||||
double epsilonMeters = boat.getCurrentLeg().getEndCompoundMark().getRoundingDistance();
|
||||
|
||||
GPSCoordinate endMarkPos = boat.getCurrentLeg().getEndCompoundMark().getMarkForRounding(bearingOfDirectionLine).getPosition();
|
||||
|
||||
GPSCoordinate roundCheck1 = GPSCoordinate.calculateNewPosition(
|
||||
endMarkPos,
|
||||
epsilonMeters,
|
||||
Azimuth.fromDegrees(bearingOfDirectionLine.degrees() + bearingToAdd) );
|
||||
|
||||
GPSCoordinate roundCheck2;
|
||||
try{
|
||||
Leg nextLeg = raceState.getLegs().get(raceState.getLegs().indexOf(boat.getCurrentLeg()) + 1);
|
||||
|
||||
GPSCoordinate startNextDirectionLinePoint = nextLeg.getStartCompoundMark().getAverageGPSCoordinate();
|
||||
GPSCoordinate endNextDirectionLinePoint = nextLeg.getEndCompoundMark().getAverageGPSCoordinate();
|
||||
Bearing bearingOfNextDirectionLine = GPSCoordinate.calculateBearing(startNextDirectionLinePoint, endNextDirectionLinePoint);
|
||||
|
||||
roundCheck2 = GPSCoordinate.calculateNewPosition(
|
||||
endDirectionLinePoint,
|
||||
epsilonMeters,
|
||||
Azimuth.fromDegrees(bearingOfNextDirectionLine.degrees() + bearingToAdd) );
|
||||
} catch(NullPointerException e) {
|
||||
//this is caused by the last leg not being having a leg after it
|
||||
roundCheck2 = roundCheck1;
|
||||
}
|
||||
|
||||
//To screen coords.
|
||||
GraphCoordinate legEnd = map.convertGPS(endDirectionLinePoint);
|
||||
GraphCoordinate round1 = map.convertGPS(roundCheck1);
|
||||
GraphCoordinate round2 = map.convertGPS(roundCheck2);
|
||||
|
||||
GraphCoordinate legEnd = map.convertGPS(roundingData.getMarkToRound().getPosition());
|
||||
GraphCoordinate round1 = map.convertGPS(roundingData.getRoundCheck1());
|
||||
GraphCoordinate round2 = map.convertGPS(roundingData.getRoundCheck2());
|
||||
|
||||
|
||||
gc.strokeLine(
|
||||
@@ -571,6 +533,9 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
||||
round2.getX(),
|
||||
round2.getY() );
|
||||
|
||||
drawCircle(round1, 12, Color.ORANGE);
|
||||
drawCircle(round2, 12, Color.GREEN);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user