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
@@ -187,7 +187,7 @@ public class CompoundMark extends XMLCompoundMark{
}
//finds the mark furthest west and east
if(this.getMark1Position().getLongitude() > this.getMark2Position().getLongitude()){
if(this.getMark1Position().getLongitude() < this.getMark2Position().getLongitude()){
westMostMark = this.mark1;
eastMostMark = this.mark2;
}else{
@@ -33,7 +33,7 @@ public class Constants {
* Frame periods are multiplied by this to get the amount of time a single frame represents.
* E.g., frame period = 20ms, scale = 5, frame represents 20 * 5 = 100ms, and so boats are simulated for 100ms, even though only 20ms actually occurred.
*/
public static final int RaceTimeScale = 2;//10;
public static final int RaceTimeScale = 10;//10;
/**
* The race pre-start time, in milliseconds. 3 minutes.
@@ -0,0 +1,78 @@
package shared.model;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* This class contains a sequence of points that describe the mark rounding order for a course.
*/
public class MarkRoundingSequence {
/**
* Legs in the race.
*/
private List<Leg> legs;
/**
* For each leg, a sequence of rounding points.
*/
private Map<Leg, List<GPSCoordinate>> roundingPoints;
public MarkRoundingSequence(List<Leg> legs) {
this.legs = legs;
generateRoundingPoints();
}
/**
* Generates the rounding points for all legs in the race.
*/
private void generateRoundingPoints() {
this.roundingPoints = new HashMap<>(this.legs.size());
for (int i = 0; i < this.legs.size(); i++) {
Leg currentLeg = this.legs.get(i);
Optional<Leg> nextLeg = Optional.ofNullable(this.legs.get(i + 1));
generateRoundingPoint(currentLeg, nextLeg);
}
}
/**
* Generates the rounding points for a specific leg.
* @param currentLeg The leg to generate rounding points for.
* @param nextLeg The following leg, used to help generate rounding points.
*/
private void generateRoundingPoint(Leg currentLeg, Optional<Leg> nextLeg) {
//Rounding points:
//each mark/gate has a specific mark to round. Call this ROUNDINGMARK
// with a mark, it is the mark
// with a gate, it depends if it is a starboard or port gate.
// it is the mark that allows the boat to enter between both marks of the gate, whilst obeying the starboard/port requirement.
//let the bearing between start of leg and end of leg be called LEGBEARING
//the first rounding point is ROUNDINGDISTANCE units away from the ROUNDINGMARK, on an angle perpendicular to LEGBEARING.
// the angle means that the rounding mark is at the center of a gate, for gates.
//the second rounding point is the same as the first, except LEGBEARING is the bearing between end of current leg, and start of next leg.
}
}