Created a random place token generator.

Generates a location between any leg of the race in a random angle / distance of the radius of the centre point of the two gates to one of the gates

#story[1293]
This commit is contained in:
William Muir
2017-09-27 01:44:01 +13:00
parent 330ccd272d
commit 6d51ea3574
4 changed files with 97 additions and 41 deletions
@@ -24,8 +24,9 @@ import java.util.*;
*/
public class MarkOrder {
private List<CompoundMark> raceMarkOrder;
private List<CompoundMark> orderedUniqueCompoundMarks;
private Logger logger = LoggerFactory.getLogger(MarkOrder.class);
private Set<Mark> allMarks;
private List<Mark> allMarks;
public MarkOrder(){
loadRaceProperties();
@@ -44,6 +45,10 @@ public class MarkOrder {
return Collections.unmodifiableList(raceMarkOrder);
}
public List<CompoundMark> getOrderedUniqueCompoundMarks() {
return orderedUniqueCompoundMarks;
}
/**
* @param seqID The seqID of the current mark the boat is heading to
* @return A Boolean indicating if this coming mark is the last one (finish line)
@@ -75,8 +80,8 @@ public class MarkOrder {
return raceMarkOrder.get(currentSeqID + 1);
}
public Set<Mark> getAllMarks(){
return Collections.unmodifiableSet(allMarks);
public List<Mark> getAllMarks() {
return Collections.unmodifiableList(allMarks);
}
/**
@@ -89,7 +94,7 @@ public class MarkOrder {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db;
Document doc;
allMarks = new HashSet<>();
allMarks = new ArrayList<>();
try {
db = dbf.newDocumentBuilder();
@@ -105,6 +110,7 @@ public class MarkOrder {
logger.debug("Loaded RaceXML for mark order");
List<Corner> corners = data.getMarkSequence();
Map<Integer, CompoundMark> marks = data.getCompoundMarks();
orderedUniqueCompoundMarks = new ArrayList<>(marks.values());
List<CompoundMark> course = new ArrayList<>();
for (Corner corner : corners){
CompoundMark compoundMark = marks.get(corner.getCompoundMarkID());