Added some debug statements, and WIP MarkRoundingSequence class.

Temporarily disabled source id allocator time checks.
Added mark rounding stuff to race canvas to help debug.
#story[1185]
This commit is contained in:
fjc40
2017-09-11 11:35:11 +12:00
parent ec82e65ae7
commit 346aa148ef
6 changed files with 217 additions and 34 deletions
@@ -325,18 +325,6 @@ public class ResizableRaceCanvas extends ResizableCanvas {
}
/*
//If the race hasn't started, we set the time since last mark to the current time, to ensure we don't start counting until the race actually starts.
if ((boat.getStatus() != BoatStatusEnum.RACING) && (boat.getStatus() == BoatStatusEnum.FINISHED)) {
boat.setTimeAtLastMark(visualiserRace.getVisualiserRaceState().getRaceClock().getCurrentTime());
}
*/
}
/**
@@ -504,6 +492,87 @@ public class ResizableRaceCanvas extends ResizableCanvas {
}
private void drawRoundingLines() {
//ugly hack
//rounding lines
//Boat is within an acceptable distance from the mark.
VisualiserBoat boat = null;
for (VisualiserBoat visualiserBoat : new ArrayList<>(raceState.getBoats())) {
if (visualiserBoat.isClientBoat()) {
boat = visualiserBoat;
}
}
if (boat == null) {
return;
}
GPSCoordinate startDirectionLinePoint = boat.getCurrentLeg().getStartCompoundMark().getAverageGPSCoordinate();
GPSCoordinate endDirectionLinePoint = boat.getCurrentLeg().getEndCompoundMark().getAverageGPSCoordinate();
Bearing bearingOfDirectionLine = GPSCoordinate.calculateBearing(startDirectionLinePoint, endDirectionLinePoint);
//use the direction line to create three invisible points that act as crossover lines a boat must cross
//to round a mark
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);
gc.strokeLine(
legEnd.getX(),
legEnd.getY(),
round1.getX(),
round1.getY() );
gc.strokeLine(
legEnd.getX(),
legEnd.getY(),
round2.getX(),
round2.getY() );
}
/**
* Draws all of the {@link Mark}s on the canvas.
@@ -513,6 +582,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
for (Mark mark : new ArrayList<>(raceState.getMarks())) {
drawMark(mark);
}
}
@@ -621,6 +691,9 @@ public class ResizableRaceCanvas extends ResizableCanvas {
//Marks.
drawMarks();
//TEMP
drawRoundingLines();
}
/**
@@ -655,7 +728,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
//finds the direction of the current leg as a bearing
startDirectionLinePoint = legStartPoint;
GPSCoordinate tempEndDirectionLinePoint = legs.get(index).getEndCompoundMark().getAverageGPSCoordinate();
GPSCoordinate tempEndDirectionLinePoint = legs.get(index).getEndCompoundMark().getMark1Position();
bearingOfDirectionLine = GPSCoordinate.calculateBearing(startDirectionLinePoint, tempEndDirectionLinePoint);
@@ -826,4 +899,4 @@ public class ResizableRaceCanvas extends ResizableCanvas {
}
}