Reads data from boat XML file
- Creates marks for building CompoundMarks (formerly Markers) - Rearranged Boat constructor and removed velocity #story[782]
This commit is contained in:
@@ -4,17 +4,13 @@ package seng302;
|
|||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import seng302.DataInput.RaceDataSource;
|
import seng302.DataInput.*;
|
||||||
import seng302.DataInput.RaceXMLReader;
|
|
||||||
import seng302.DataInput.RegattaDataSource;
|
|
||||||
import seng302.DataInput.RegattaXMLReader;
|
|
||||||
import seng302.Model.Event;
|
import seng302.Model.Event;
|
||||||
|
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
@@ -39,9 +35,10 @@ public class App extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
try {
|
try {
|
||||||
RaceDataSource raceData = new RaceXMLReader("raceXML/bermuda_AC35.xml");
|
RaceDataSource raceData = new RaceXMLReader("mockXML/raceTest.xml");
|
||||||
RegattaDataSource regattaData = new RegattaXMLReader("mockXML/regattaTest.xml");
|
RegattaDataSource regattaData = new RegattaXMLReader("mockXML/regattaTest.xml");
|
||||||
Event raceEvent = new Event(raceData, regattaData);
|
BoatDataSource boatData = new BoatXMLReader("mockXML/boatTest.xml");
|
||||||
|
Event raceEvent = new Event(raceData, regattaData, boatData);
|
||||||
raceEvent.start();
|
raceEvent.start();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ public class BoatData {
|
|||||||
private void appendStoweName(Element boat, int i) {
|
private void appendStoweName(Element boat, int i) {
|
||||||
//StoweName attribute
|
//StoweName attribute
|
||||||
Attr attrStoweName = doc.createAttribute("StoweName");
|
Attr attrStoweName = doc.createAttribute("StoweName");
|
||||||
attrStoweName.setValue(boatData.get(i).getAbbrev());
|
attrStoweName.setValue(boatData.get(i).getCountry());
|
||||||
boat.setAttributeNode(attrStoweName);
|
boat.setAttributeNode(attrStoweName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ public class BoatData {
|
|||||||
private void appendShortName(Element boat, int i) {
|
private void appendShortName(Element boat, int i) {
|
||||||
//ShortName attribute
|
//ShortName attribute
|
||||||
Attr attrShortName = doc.createAttribute("ShortName");
|
Attr attrShortName = doc.createAttribute("ShortName");
|
||||||
attrShortName.setValue(boatData.get(i).getAbbrev());
|
attrShortName.setValue(boatData.get(i).getCountry());
|
||||||
boat.setAttributeNode(attrShortName);
|
boat.setAttributeNode(attrShortName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import org.w3c.dom.Element;
|
|||||||
import seng302.DataInput.RaceDataSource;
|
import seng302.DataInput.RaceDataSource;
|
||||||
import seng302.Exceptions.InvalidRaceDataException;
|
import seng302.Exceptions.InvalidRaceDataException;
|
||||||
import seng302.Model.Boat;
|
import seng302.Model.Boat;
|
||||||
|
import seng302.Model.CompoundMarker;
|
||||||
import seng302.Model.GPSCoordinate;
|
import seng302.Model.GPSCoordinate;
|
||||||
import seng302.Model.Marker;
|
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
@@ -151,9 +151,9 @@ public class RaceData {
|
|||||||
Element compoundMarkSeqElement = doc.createElement("CompoundMarkSequence");
|
Element compoundMarkSeqElement = doc.createElement("CompoundMarkSequence");
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (Marker marker : dataSource.getMarkers()) {
|
for (CompoundMarker compoundMarker : dataSource.getCompoundMarkers()) {
|
||||||
|
|
||||||
courseElement.appendChild(createCompoundMarker(marker, i));
|
courseElement.appendChild(createCompoundMarker(compoundMarker, i));
|
||||||
compoundMarkSeqElement.appendChild(createCornerElement(i));
|
compoundMarkSeqElement.appendChild(createCornerElement(i));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -177,21 +177,21 @@ public class RaceData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a compound marker holding one or two marks,and a sequence number
|
* Creates a compound compoundMarker holding one or two marks,and a sequence number
|
||||||
*
|
*
|
||||||
* @param marker marker
|
* @param compoundMarker compoundMarker
|
||||||
* @param i sequence number
|
* @param i sequence number
|
||||||
* @return Element compound mark element
|
* @return Element compound mark element
|
||||||
*/
|
*/
|
||||||
private Element createCompoundMarker(Marker marker, int i) {
|
private Element createCompoundMarker(CompoundMarker compoundMarker, int i) {
|
||||||
Element compoundMarkElement = doc.createElement("CompoundMark");
|
Element compoundMarkElement = doc.createElement("CompoundMark");
|
||||||
compoundMarkElement.setAttribute("CompoundMarkID", i + "");
|
compoundMarkElement.setAttribute("CompoundMarkID", i + "");
|
||||||
compoundMarkElement.setAttribute("Name", marker.getName());
|
compoundMarkElement.setAttribute("Name", compoundMarker.getName());
|
||||||
|
|
||||||
compoundMarkElement.appendChild(createMark(marker.getMark1()));
|
compoundMarkElement.appendChild(createMark(compoundMarker.getMark1()));
|
||||||
|
|
||||||
if (!(marker.getMark1().equals(marker.getMark2()))) {
|
if (!(compoundMarker.getMark1().equals(compoundMarker.getMark2()))) {
|
||||||
compoundMarkElement.appendChild(createMark(marker.getMark2()));
|
compoundMarkElement.appendChild(createMark(compoundMarker.getMark2()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return compoundMarkElement;
|
return compoundMarkElement;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package seng302.DataInput;
|
package seng302.DataInput;
|
||||||
|
|
||||||
import seng302.Model.Boat;
|
import seng302.Model.Boat;
|
||||||
|
import seng302.Model.Mark;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -9,5 +10,5 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface BoatDataSource {
|
public interface BoatDataSource {
|
||||||
List<Boat> getBoats();
|
List<Boat> getBoats();
|
||||||
List<Boat> getMarkerBoats();
|
List<Mark> getMarkerBoats();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,111 @@
|
|||||||
|
package seng302.DataInput;
|
||||||
|
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import seng302.Model.Boat;
|
||||||
|
import seng302.Model.Mark;
|
||||||
|
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by cbt24 on 10/05/17.
|
||||||
|
*/
|
||||||
|
public class BoatXMLReader extends XMLReader implements BoatDataSource {
|
||||||
|
private final Map<Integer, Boat> boatMap = new HashMap<>();
|
||||||
|
private final Map<Integer, Mark> markerMap = new HashMap<>();
|
||||||
|
|
||||||
|
public BoatXMLReader(String filePath) throws ParserConfigurationException, SAXException, IOException {
|
||||||
|
this(filePath, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* COnstructor for Boat XML
|
||||||
|
*
|
||||||
|
* @param filePath file path to read
|
||||||
|
* @param read whether or not to read and store the files straight away.
|
||||||
|
* @throws IOException error
|
||||||
|
* @throws SAXException error
|
||||||
|
* @throws ParserConfigurationException error
|
||||||
|
*/
|
||||||
|
public BoatXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException {
|
||||||
|
super(filePath);
|
||||||
|
if (read) {
|
||||||
|
read();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void read() {
|
||||||
|
readSettings();
|
||||||
|
readShapes();
|
||||||
|
readBoats();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void readBoats() {
|
||||||
|
Element nBoats = (Element) doc.getElementsByTagName("Boats").item(0);
|
||||||
|
for (int i = 0; i < nBoats.getChildNodes().getLength(); i++) {
|
||||||
|
Node boat = nBoats.getChildNodes().item(i);
|
||||||
|
if (boat.getNodeName().equals("Boat")) {
|
||||||
|
readSingleBoat(boat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ignored data
|
||||||
|
*/
|
||||||
|
private void readShapes() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ignored data
|
||||||
|
*/
|
||||||
|
private void readSettings() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isYachtNode(Node boatNode) {
|
||||||
|
return boatNode.getAttributes().getNamedItem("Type").getTextContent().toLowerCase().equals("yacht");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the information about one boat
|
||||||
|
* Ignored values: ShapeID, StoweName, HullNum, Skipper, Type
|
||||||
|
*/
|
||||||
|
private void readSingleBoat(Node boatNode) {
|
||||||
|
Boat boat;
|
||||||
|
String country = null;
|
||||||
|
int sourceID = Integer.parseInt(boatNode.getAttributes().getNamedItem("SourceID").getTextContent());
|
||||||
|
String name = boatNode.getAttributes().getNamedItem("BoatName").getTextContent();
|
||||||
|
String shortName = boatNode.getAttributes().getNamedItem("ShortName").getTextContent();
|
||||||
|
if (exists(boatNode, "Country")) country = boatNode.getAttributes().getNamedItem("Country").getTextContent();
|
||||||
|
|
||||||
|
if (isYachtNode(boatNode)) {
|
||||||
|
if (country != null) {
|
||||||
|
boat = new Boat(sourceID, name, country);
|
||||||
|
} else {
|
||||||
|
boat = new Boat(sourceID, name, shortName);
|
||||||
|
}
|
||||||
|
boatMap.put(sourceID, boat);
|
||||||
|
} else {
|
||||||
|
Mark mark = new Mark(name);
|
||||||
|
markerMap.put(sourceID, mark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Boat> getBoats() {
|
||||||
|
return new ArrayList<>(boatMap.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Mark> getMarkerBoats() {
|
||||||
|
return new ArrayList<>(markerMap.values());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ package seng302.DataInput;
|
|||||||
import seng302.Model.Boat;
|
import seng302.Model.Boat;
|
||||||
import seng302.Model.GPSCoordinate;
|
import seng302.Model.GPSCoordinate;
|
||||||
import seng302.Model.Leg;
|
import seng302.Model.Leg;
|
||||||
import seng302.Model.Marker;
|
import seng302.Model.CompoundMarker;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ public interface RaceDataSource {
|
|||||||
|
|
||||||
List<GPSCoordinate> getBoundary();
|
List<GPSCoordinate> getBoundary();
|
||||||
|
|
||||||
List<Marker> getMarkers();
|
List<CompoundMarker> getCompoundMarkers();
|
||||||
|
|
||||||
int getRaceId();
|
int getRaceId();
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import org.w3c.dom.NodeList;
|
|||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import seng302.Model.Boat;
|
import seng302.Model.Boat;
|
||||||
|
import seng302.Model.CompoundMarker;
|
||||||
import seng302.Model.GPSCoordinate;
|
import seng302.Model.GPSCoordinate;
|
||||||
import seng302.Model.Leg;
|
import seng302.Model.Leg;
|
||||||
import seng302.Model.Marker;
|
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -27,7 +27,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
private GPSCoordinate mark, startPt1, startPt2, finishPt1, finishPt2, leewardPt1, leewardPt2, windwardPt1, windwardPt2;
|
private GPSCoordinate mark, startPt1, startPt2, finishPt1, finishPt2, leewardPt1, leewardPt2, windwardPt1, windwardPt2;
|
||||||
private GPSCoordinate mapTopLeft, mapBottomRight;
|
private GPSCoordinate mapTopLeft, mapBottomRight;
|
||||||
private List<GPSCoordinate> boundary = new ArrayList<>();
|
private List<GPSCoordinate> boundary = new ArrayList<>();
|
||||||
private List<Marker> markers = new ArrayList<>();
|
private List<CompoundMarker> compoundMarkers = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constractor for Race XML
|
* Constractor for Race XML
|
||||||
@@ -86,10 +86,9 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
|
|
||||||
for (int i = 0; i < nBoats.getLength(); i++) {
|
for (int i = 0; i < nBoats.getLength(); i++) {
|
||||||
String name = getTextValueOfNode((Element) nBoats.item(i), "name");
|
String name = getTextValueOfNode((Element) nBoats.item(i), "name");
|
||||||
String abbrev = getTextValueOfNode((Element) nBoats.item(i), "abbr");
|
String country = getTextValueOfNode((Element) nBoats.item(i), "abbr");
|
||||||
double velo = Double.parseDouble(getTextValueOfNode((Element) nBoats.item(i), "speed"));
|
|
||||||
int sourceID = Integer.parseInt(getTextValueOfNode((Element) nBoats.item(i), "sourceID"));
|
int sourceID = Integer.parseInt(getTextValueOfNode((Element) nBoats.item(i), "sourceID"));
|
||||||
Boat boat = new Boat(name, velo, abbrev, sourceID);
|
Boat boat = new Boat(sourceID, name, country);
|
||||||
boat.setCurrentPosition(startPt1);
|
boat.setCurrentPosition(startPt1);
|
||||||
if (legs.size() > 0) {
|
if (legs.size() > 0) {
|
||||||
boat.setCurrentLeg(legs.get(0));
|
boat.setCurrentLeg(legs.get(0));
|
||||||
@@ -107,8 +106,8 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
NodeList nMarkers = doc.getElementsByTagName("marker");
|
NodeList nMarkers = doc.getElementsByTagName("marker");
|
||||||
|
|
||||||
for (int i = 0; i < nMarkers.getLength(); i++) {
|
for (int i = 0; i < nMarkers.getLength(); i++) {
|
||||||
Marker marker = getMarker((Element) nMarkers.item(i));
|
CompoundMarker compoundMarker = getMarker((Element) nMarkers.item(i));
|
||||||
if (marker.getName() != null) markers.add(marker);
|
if (compoundMarker.getName() != null) compoundMarkers.add(compoundMarker);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,10 +121,10 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
for (int i = 0; i < nLegs.getLength(); i++) {
|
for (int i = 0; i < nLegs.getLength(); i++) {
|
||||||
String label = getTextValueOfNode((Element) nLegs.item(i), "name");
|
String label = getTextValueOfNode((Element) nLegs.item(i), "name");
|
||||||
NodeList start = ((Element) nLegs.item(i)).getElementsByTagName("start");
|
NodeList start = ((Element) nLegs.item(i)).getElementsByTagName("start");
|
||||||
Marker startMarker = getMarker(start);
|
CompoundMarker startCompoundMarker = getMarker(start);
|
||||||
NodeList finish = ((Element) nLegs.item(i)).getElementsByTagName("finish");
|
NodeList finish = ((Element) nLegs.item(i)).getElementsByTagName("finish");
|
||||||
Marker finishMarker = getMarker(finish);
|
CompoundMarker finishCompoundMarker = getMarker(finish);
|
||||||
legs.add(new Leg(label, startMarker, finishMarker, i));
|
legs.add(new Leg(label, startCompoundMarker, finishCompoundMarker, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,7 +204,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
|
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Marker getMarker(NodeList start) {
|
private CompoundMarker getMarker(NodeList start) {
|
||||||
return getMarker(start, 0);
|
return getMarker(start, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,7 +215,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
* @param startIndex index in the node that has the coordinate tag
|
* @param startIndex index in the node that has the coordinate tag
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Marker getMarker(NodeList start, int startIndex) {
|
private CompoundMarker getMarker(NodeList start, int startIndex) {
|
||||||
return getMarker(start, startIndex, 0);
|
return getMarker(start, startIndex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +227,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
* @param nodeIndex coordinate index
|
* @param nodeIndex coordinate index
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Marker getMarker(NodeList start, int startIndex, int nodeIndex) {
|
private CompoundMarker getMarker(NodeList start, int startIndex, int nodeIndex) {
|
||||||
NodeList nodeList = ((Element) start.item(startIndex)).getElementsByTagName("marker");
|
NodeList nodeList = ((Element) start.item(startIndex)).getElementsByTagName("marker");
|
||||||
Element marker = (Element) nodeList.item(nodeIndex);
|
Element marker = (Element) nodeList.item(nodeIndex);
|
||||||
return getMarker(marker);
|
return getMarker(marker);
|
||||||
@@ -240,7 +239,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
* @param markerNode marker to turn into coordinates
|
* @param markerNode marker to turn into coordinates
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Marker getMarker(Element markerNode) {
|
private CompoundMarker getMarker(Element markerNode) {
|
||||||
|
|
||||||
NodeList nCoordinates = markerNode.getElementsByTagName("coordinate");
|
NodeList nCoordinates = markerNode.getElementsByTagName("coordinate");
|
||||||
|
|
||||||
@@ -252,7 +251,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
side2 = side1;
|
side2 = side1;
|
||||||
}
|
}
|
||||||
NodeList name = markerNode.getElementsByTagName("name");
|
NodeList name = markerNode.getElementsByTagName("name");
|
||||||
return name.getLength() == 1 ? new Marker(getTextValueOfNode((Element) markerNode, "name"), side1, side2) : new Marker(side1, side2);
|
return name.getLength() == 1 ? new CompoundMarker(getTextValueOfNode((Element) markerNode, "name"), side1, side2) : new CompoundMarker(side1, side2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -363,8 +362,8 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
return raceID;
|
return raceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Marker> getMarkers() {
|
public List<CompoundMarker> getCompoundMarkers() {
|
||||||
return markers;
|
return compoundMarkers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRaceType() {
|
public String getRaceType() {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package seng302.DataInput;
|
|||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
@@ -60,4 +61,8 @@ public abstract class XMLReader {
|
|||||||
return n.getAttribute(attr);
|
return n.getAttribute(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean exists(Node node, String attribute) {
|
||||||
|
return node.getAttributes().getNamedItem(attribute) != null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ public class Boat {
|
|||||||
private String name;
|
private String name;
|
||||||
private double velocity;
|
private double velocity;
|
||||||
private double scaledVelocity;
|
private double scaledVelocity;
|
||||||
private String abbrev;
|
private String country;
|
||||||
private int sourceID;
|
private int sourceID;
|
||||||
private Leg currentLeg;
|
private Leg currentLeg;
|
||||||
private double distanceTravelledInLeg;
|
private double distanceTravelledInLeg;
|
||||||
@@ -22,14 +22,13 @@ public class Boat {
|
|||||||
/**
|
/**
|
||||||
* Boat initialiser which keeps all of the information of the boat.
|
* Boat initialiser which keeps all of the information of the boat.
|
||||||
*
|
*
|
||||||
* @param name Name of the Boat.
|
|
||||||
* @param velocity Speed in m/s that the boat travels at.
|
|
||||||
* @param abbrev nam abbreviation
|
|
||||||
* @param sourceID id of boat
|
* @param sourceID id of boat
|
||||||
|
* @param name Name of the Boat.
|
||||||
|
* @param country nam abbreviation
|
||||||
*/
|
*/
|
||||||
public Boat(String name, double velocity, String abbrev, int sourceID) {
|
public Boat(int sourceID, String name, String country) {
|
||||||
this.velocity = velocity;
|
this.velocity = 5; // TODO - please dont commit
|
||||||
this.abbrev = abbrev;
|
this.country = this.country;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.sourceID = sourceID;
|
this.sourceID = sourceID;
|
||||||
}
|
}
|
||||||
@@ -42,8 +41,8 @@ public class Boat {
|
|||||||
public double calculateAzimuth() {
|
public double calculateAzimuth() {
|
||||||
|
|
||||||
GeodeticCalculator calc = new GeodeticCalculator();
|
GeodeticCalculator calc = new GeodeticCalculator();
|
||||||
GPSCoordinate start = currentLeg.getStartMarker().getAverageGPSCoordinate();
|
GPSCoordinate start = currentLeg.getStartCompoundMarker().getAverageGPSCoordinate();
|
||||||
GPSCoordinate end = currentLeg.getEndMarker().getAverageGPSCoordinate();
|
GPSCoordinate end = currentLeg.getEndCompoundMarker().getAverageGPSCoordinate();
|
||||||
|
|
||||||
calc.setStartingGeographicPoint(start.getLongitude(), start.getLatitude());
|
calc.setStartingGeographicPoint(start.getLongitude(), start.getLatitude());
|
||||||
calc.setDestinationGeographicPoint(end.getLongitude(), end.getLatitude());
|
calc.setDestinationGeographicPoint(end.getLongitude(), end.getLatitude());
|
||||||
@@ -90,12 +89,12 @@ public class Boat {
|
|||||||
this.scaledVelocity = scaledVelocity;
|
this.scaledVelocity = scaledVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAbbrev() {
|
public String getCountry() {
|
||||||
return abbrev;
|
return country;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAbbrev(String abbrev) {
|
public void setCountry(String country) {
|
||||||
this.abbrev = abbrev;
|
this.country = country;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSourceID() {
|
public int getSourceID() {
|
||||||
|
|||||||
+4
-4
@@ -6,7 +6,7 @@ import java.awt.geom.Point2D;
|
|||||||
/**
|
/**
|
||||||
* Created by esa46 on 29/03/17.
|
* Created by esa46 on 29/03/17.
|
||||||
*/
|
*/
|
||||||
public class Marker {
|
public class CompoundMarker {
|
||||||
|
|
||||||
private GPSCoordinate averageGPSCoordinate;
|
private GPSCoordinate averageGPSCoordinate;
|
||||||
private GPSCoordinate mark1;
|
private GPSCoordinate mark1;
|
||||||
@@ -14,7 +14,7 @@ public class Marker {
|
|||||||
private String name;
|
private String name;
|
||||||
private boolean doubleMarker = false;
|
private boolean doubleMarker = false;
|
||||||
|
|
||||||
public Marker(GPSCoordinate mark1) {
|
public CompoundMarker(GPSCoordinate mark1) {
|
||||||
|
|
||||||
this.mark1 = mark1;
|
this.mark1 = mark1;
|
||||||
this.mark2 = mark1;
|
this.mark2 = mark1;
|
||||||
@@ -22,7 +22,7 @@ public class Marker {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Marker(GPSCoordinate mark1, GPSCoordinate mark2) {
|
public CompoundMarker(GPSCoordinate mark1, GPSCoordinate mark2) {
|
||||||
|
|
||||||
this.mark1 = mark1;
|
this.mark1 = mark1;
|
||||||
this.mark2 = mark2;
|
this.mark2 = mark2;
|
||||||
@@ -30,7 +30,7 @@ public class Marker {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Marker(String name, GPSCoordinate mark1, GPSCoordinate mark2) {
|
public CompoundMarker(String name, GPSCoordinate mark1, GPSCoordinate mark2) {
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.mark1 = mark1;
|
this.mark1 = mark1;
|
||||||
@@ -3,6 +3,7 @@ package seng302.Model;
|
|||||||
import seng302.Data.BoatData;
|
import seng302.Data.BoatData;
|
||||||
import seng302.Data.RaceData;
|
import seng302.Data.RaceData;
|
||||||
import seng302.Data.RegattaData;
|
import seng302.Data.RegattaData;
|
||||||
|
import seng302.DataInput.BoatDataSource;
|
||||||
import seng302.DataInput.RaceDataSource;
|
import seng302.DataInput.RaceDataSource;
|
||||||
import seng302.DataInput.RegattaDataSource;
|
import seng302.DataInput.RegattaDataSource;
|
||||||
import seng302.Exceptions.InvalidBoatDataException;
|
import seng302.Exceptions.InvalidBoatDataException;
|
||||||
@@ -24,12 +25,14 @@ public class Event {
|
|||||||
|
|
||||||
RaceDataSource raceDataSource;
|
RaceDataSource raceDataSource;
|
||||||
RegattaDataSource regattaDataSource;
|
RegattaDataSource regattaDataSource;
|
||||||
|
BoatDataSource boatDataSource;
|
||||||
|
|
||||||
MockOutput mockOutput;
|
MockOutput mockOutput;
|
||||||
|
|
||||||
public Event(RaceDataSource raceData, RegattaDataSource regattaData) {
|
public Event(RaceDataSource raceData, RegattaDataSource regattaData, BoatDataSource boatDataSource) {
|
||||||
this.raceDataSource = raceData;
|
this.raceDataSource = raceData;
|
||||||
this.regattaDataSource = regattaData;
|
this.regattaDataSource = regattaData;
|
||||||
|
this.boatDataSource = boatDataSource;
|
||||||
try {
|
try {
|
||||||
mockOutput = new MockOutput();
|
mockOutput = new MockOutput();
|
||||||
new Thread(mockOutput).start();
|
new Thread(mockOutput).start();
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import seng302.Constants;
|
|||||||
public class Leg {
|
public class Leg {
|
||||||
private String name; //nautical miles
|
private String name; //nautical miles
|
||||||
private double distance;
|
private double distance;
|
||||||
private Marker startMarker;
|
private CompoundMarker startCompoundMarker;
|
||||||
private Marker endMarker;
|
private CompoundMarker endCompoundMarker;
|
||||||
private int legNumber;
|
private int legNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,10 +22,10 @@ public class Leg {
|
|||||||
* @param end marker
|
* @param end marker
|
||||||
* @param number Leg's position in race
|
* @param number Leg's position in race
|
||||||
*/
|
*/
|
||||||
public Leg(String name, Marker start, Marker end, int number) {
|
public Leg(String name, CompoundMarker start, CompoundMarker end, int number) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.startMarker = start;
|
this.startCompoundMarker = start;
|
||||||
this.endMarker = end;
|
this.endCompoundMarker = end;
|
||||||
this.legNumber = number;
|
this.legNumber = number;
|
||||||
calculateDistance();
|
calculateDistance();
|
||||||
}
|
}
|
||||||
@@ -69,20 +69,20 @@ public class Leg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Marker getStartMarker() {
|
public CompoundMarker getStartCompoundMarker() {
|
||||||
return startMarker;
|
return startCompoundMarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStartMarker(Marker startMarker) {
|
public void setStartCompoundMarker(CompoundMarker startCompoundMarker) {
|
||||||
this.startMarker = startMarker;
|
this.startCompoundMarker = startCompoundMarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Marker getEndMarker() {
|
public CompoundMarker getEndCompoundMarker() {
|
||||||
return endMarker;
|
return endCompoundMarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEndMarker(Marker endMarker) {
|
public void setEndCompoundMarker(CompoundMarker endCompoundMarker) {
|
||||||
this.endMarker = endMarker;
|
this.endCompoundMarker = endCompoundMarker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -92,8 +92,8 @@ public class Leg {
|
|||||||
|
|
||||||
GeodeticCalculator calc = new GeodeticCalculator();
|
GeodeticCalculator calc = new GeodeticCalculator();
|
||||||
//Load start and end of leg
|
//Load start and end of leg
|
||||||
GPSCoordinate startMarker = this.startMarker.getAverageGPSCoordinate();
|
GPSCoordinate startMarker = this.startCompoundMarker.getAverageGPSCoordinate();
|
||||||
GPSCoordinate endMarker = this.endMarker.getAverageGPSCoordinate();
|
GPSCoordinate endMarker = this.endCompoundMarker.getAverageGPSCoordinate();
|
||||||
calc.setStartingGeographicPoint(startMarker.getLongitude(), startMarker.getLatitude());
|
calc.setStartingGeographicPoint(startMarker.getLongitude(), startMarker.getLatitude());
|
||||||
calc.setDestinationGeographicPoint(endMarker.getLongitude(), endMarker.getLatitude());
|
calc.setDestinationGeographicPoint(endMarker.getLongitude(), endMarker.getLatitude());
|
||||||
this.distance = calc.getOrthodromicDistance() / Constants.NMToMetersConversion;
|
this.distance = calc.getOrthodromicDistance() / Constants.NMToMetersConversion;
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package seng302.Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by cbt24 on 10/05/17.
|
||||||
|
*/
|
||||||
|
public class Mark {
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public Mark(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -216,17 +216,17 @@ public class Race implements Runnable {
|
|||||||
public void initialiseBoats() {
|
public void initialiseBoats() {
|
||||||
Leg officialStart = legs.get(0);
|
Leg officialStart = legs.get(0);
|
||||||
String name = officialStart.getName();
|
String name = officialStart.getName();
|
||||||
Marker endMarker = officialStart.getEndMarker();
|
CompoundMarker endCompoundMarker = officialStart.getEndCompoundMarker();
|
||||||
|
|
||||||
ArrayList<Marker> startMarkers = getSpreadStartingPositions();
|
ArrayList<CompoundMarker> startCompoundMarkers = getSpreadStartingPositions();
|
||||||
for (int i = 0; i < startingBoats.size(); i++) {
|
for (int i = 0; i < startingBoats.size(); i++) {
|
||||||
Boat boat = startingBoats.get(i);
|
Boat boat = startingBoats.get(i);
|
||||||
if (boat != null) {
|
if (boat != null) {
|
||||||
boat.setScaledVelocity(boat.getVelocity() * scaleFactor);
|
boat.setScaledVelocity(boat.getVelocity() * scaleFactor);
|
||||||
Leg startLeg = new Leg(name, 0);
|
Leg startLeg = new Leg(name, 0);
|
||||||
boat.setCurrentPosition(startMarkers.get(i).getAverageGPSCoordinate());
|
boat.setCurrentPosition(startCompoundMarkers.get(i).getAverageGPSCoordinate());
|
||||||
startLeg.setStartMarker(startMarkers.get(i));
|
startLeg.setStartCompoundMarker(startCompoundMarkers.get(i));
|
||||||
startLeg.setEndMarker(endMarker);
|
startLeg.setEndCompoundMarker(endCompoundMarker);
|
||||||
startLeg.calculateDistance();
|
startLeg.calculateDistance();
|
||||||
boat.setCurrentLeg(startLeg);
|
boat.setCurrentLeg(startLeg);
|
||||||
boat.setHeading(boat.calculateHeading());
|
boat.setHeading(boat.calculateHeading());
|
||||||
@@ -239,27 +239,27 @@ public class Race implements Runnable {
|
|||||||
*
|
*
|
||||||
* @return list of starting positions
|
* @return list of starting positions
|
||||||
*/
|
*/
|
||||||
public ArrayList<Marker> getSpreadStartingPositions() {
|
public ArrayList<CompoundMarker> getSpreadStartingPositions() {
|
||||||
|
|
||||||
int nBoats = startingBoats.size();
|
int nBoats = startingBoats.size();
|
||||||
Marker marker = legs.get(0).getStartMarker();
|
CompoundMarker compoundMarker = legs.get(0).getStartCompoundMarker();
|
||||||
|
|
||||||
GeodeticCalculator initialCalc = new GeodeticCalculator();
|
GeodeticCalculator initialCalc = new GeodeticCalculator();
|
||||||
initialCalc.setStartingGeographicPoint(marker.getMark1().getLongitude(), marker.getMark1().getLatitude());
|
initialCalc.setStartingGeographicPoint(compoundMarker.getMark1().getLongitude(), compoundMarker.getMark1().getLatitude());
|
||||||
initialCalc.setDestinationGeographicPoint(marker.getMark2().getLongitude(), marker.getMark2().getLatitude());
|
initialCalc.setDestinationGeographicPoint(compoundMarker.getMark2().getLongitude(), compoundMarker.getMark2().getLatitude());
|
||||||
|
|
||||||
double azimuth = initialCalc.getAzimuth();
|
double azimuth = initialCalc.getAzimuth();
|
||||||
double distanceBetweenMarkers = initialCalc.getOrthodromicDistance();
|
double distanceBetweenMarkers = initialCalc.getOrthodromicDistance();
|
||||||
double distanceBetweenBoats = distanceBetweenMarkers / (nBoats + 1);
|
double distanceBetweenBoats = distanceBetweenMarkers / (nBoats + 1);
|
||||||
|
|
||||||
GeodeticCalculator positionCalc = new GeodeticCalculator();
|
GeodeticCalculator positionCalc = new GeodeticCalculator();
|
||||||
positionCalc.setStartingGeographicPoint(marker.getMark1().getLongitude(), marker.getMark1().getLatitude());
|
positionCalc.setStartingGeographicPoint(compoundMarker.getMark1().getLongitude(), compoundMarker.getMark1().getLatitude());
|
||||||
ArrayList<Marker> positions = new ArrayList<>();
|
ArrayList<CompoundMarker> positions = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < nBoats; i++) {
|
for (int i = 0; i < nBoats; i++) {
|
||||||
positionCalc.setDirection(azimuth, distanceBetweenBoats);
|
positionCalc.setDirection(azimuth, distanceBetweenBoats);
|
||||||
Point2D position = positionCalc.getDestinationGeographicPoint();
|
Point2D position = positionCalc.getDestinationGeographicPoint();
|
||||||
positions.add(new Marker(new GPSCoordinate(position.getY(), position.getX())));
|
positions.add(new CompoundMarker(new GPSCoordinate(position.getY(), position.getX())));
|
||||||
|
|
||||||
positionCalc = new GeodeticCalculator();
|
positionCalc = new GeodeticCalculator();
|
||||||
positionCalc.setStartingGeographicPoint(position);
|
positionCalc.setStartingGeographicPoint(position);
|
||||||
@@ -302,7 +302,7 @@ public class Race implements Runnable {
|
|||||||
//update boat's distance travelled
|
//update boat's distance travelled
|
||||||
boat.setDistanceTravelledInLeg(totalDistanceTravelled);
|
boat.setDistanceTravelledInLeg(totalDistanceTravelled);
|
||||||
//Calculate boat's new position by adding the distance travelled onto the start point of the leg
|
//Calculate boat's new position by adding the distance travelled onto the start point of the leg
|
||||||
boat.setCurrentPosition(calculatePosition(boat.getCurrentLeg().getStartMarker().getAverageGPSCoordinate(),
|
boat.setCurrentPosition(calculatePosition(boat.getCurrentLeg().getStartCompoundMarker().getAverageGPSCoordinate(),
|
||||||
totalDistanceTravelled, boat.calculateAzimuth()));
|
totalDistanceTravelled, boat.calculateAzimuth()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
<leg>
|
<leg>
|
||||||
<name>Start to Mark 1</name>
|
<name>Start to Mark 1</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.296577</latitude>
|
<latitude>32.296577</latitude>
|
||||||
<longitude>-64.854304</longitude>
|
<longitude>-64.854304</longitude>
|
||||||
@@ -57,29 +57,29 @@
|
|||||||
<latitude>32.293771</latitude>
|
<latitude>32.293771</latitude>
|
||||||
<longitude>-64.855242</longitude>
|
<longitude>-64.855242</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.293039</latitude>
|
<latitude>32.293039</latitude>
|
||||||
<longitude>-64.843983</longitude>
|
<longitude>-64.843983</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Mark 1 to Leeward Gate</name>
|
<name>Mark 1 to Leeward Gate</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.293039</latitude>
|
<latitude>32.293039</latitude>
|
||||||
<longitude>-64.843983</longitude>
|
<longitude>-64.843983</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -88,13 +88,13 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Leeward Gate to Windward Gate</name>
|
<name>Leeward Gate to Windward Gate</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -103,10 +103,10 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.284680</latitude>
|
<latitude>32.284680</latitude>
|
||||||
<longitude>-64.850045</longitude>
|
<longitude>-64.850045</longitude>
|
||||||
@@ -115,13 +115,13 @@
|
|||||||
<latitude>32.280164</latitude>
|
<latitude>32.280164</latitude>
|
||||||
<longitude>-64.847591</longitude>
|
<longitude>-64.847591</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Windward Gate to Leeward Gate</name>
|
<name>Windward Gate to Leeward Gate</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.284680</latitude>
|
<latitude>32.284680</latitude>
|
||||||
<longitude>-64.850045</longitude>
|
<longitude>-64.850045</longitude>
|
||||||
@@ -130,10 +130,10 @@
|
|||||||
<latitude>32.280164</latitude>
|
<latitude>32.280164</latitude>
|
||||||
<longitude>-64.847591</longitude>
|
<longitude>-64.847591</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -142,13 +142,13 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Leeward Gate to Finish</name>
|
<name>Leeward Gate to Finish</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -157,10 +157,10 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.317379</latitude>
|
<latitude>32.317379</latitude>
|
||||||
<longitude>-64.839291</longitude>
|
<longitude>-64.839291</longitude>
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
<latitude>32.317257</latitude>
|
<latitude>32.317257</latitude>
|
||||||
<longitude>-64.836260</longitude>
|
<longitude>-64.836260</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
</legs>
|
</legs>
|
||||||
@@ -220,7 +220,7 @@
|
|||||||
<longitude>-64.849184</longitude>
|
<longitude>-64.849184</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</boundaries>
|
</boundaries>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Start Line</name>
|
<name>Start Line</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.296577</latitude>
|
<latitude>32.296577</latitude>
|
||||||
@@ -230,15 +230,15 @@
|
|||||||
<latitude>32.293771</latitude>
|
<latitude>32.293771</latitude>
|
||||||
<longitude>-64.855242</longitude>
|
<longitude>-64.855242</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Mark</name>
|
<name>Mark</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.293039</latitude>
|
<latitude>32.293039</latitude>
|
||||||
<longitude>-64.843983</longitude>
|
<longitude>-64.843983</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Windward Gate</name>
|
<name>Windward Gate</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.284680</latitude>
|
<latitude>32.284680</latitude>
|
||||||
@@ -248,8 +248,8 @@
|
|||||||
<latitude>32.280164</latitude>
|
<latitude>32.280164</latitude>
|
||||||
<longitude>-64.847591</longitude>
|
<longitude>-64.847591</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Leeward Gate</name>
|
<name>Leeward Gate</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
@@ -259,8 +259,8 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Windward Gate</name>
|
<name>Windward Gate</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.284680</latitude>
|
<latitude>32.284680</latitude>
|
||||||
@@ -270,8 +270,8 @@
|
|||||||
<latitude>32.280164</latitude>
|
<latitude>32.280164</latitude>
|
||||||
<longitude>-64.847591</longitude>
|
<longitude>-64.847591</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Finish Line</name>
|
<name>Finish Line</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.317379</latitude>
|
<latitude>32.317379</latitude>
|
||||||
@@ -281,6 +281,6 @@
|
|||||||
<latitude>32.317257</latitude>
|
<latitude>32.317257</latitude>
|
||||||
<longitude>-64.836260</longitude>
|
<longitude>-64.836260</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</course>
|
</course>
|
||||||
</race>
|
</race>
|
||||||
|
|||||||
@@ -13,23 +13,23 @@ public class BoatTest {
|
|||||||
|
|
||||||
|
|
||||||
private GPSCoordinate ORIGIN_COORDS = new GPSCoordinate(0, 0);
|
private GPSCoordinate ORIGIN_COORDS = new GPSCoordinate(0, 0);
|
||||||
private Boat TEST_BOAT = new Boat("Test", 1, "tt", 1);
|
private Boat TEST_BOAT = new Boat(1, "Test", "tt");
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDueNorthAzimuthReturns0() {
|
public void calculateDueNorthAzimuthReturns0() {
|
||||||
|
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(50, 0));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateAzimuth(), 0, 1e-8);
|
assertEquals(TEST_BOAT.calculateAzimuth(), 0, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDueSouthAzimuthReturns180() {
|
public void calculateDueSouthAzimuthReturns180() {
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
|
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(-50, 0));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateAzimuth(), 180, 1e-8);
|
assertEquals(TEST_BOAT.calculateAzimuth(), 180, 1e-8);
|
||||||
}
|
}
|
||||||
@@ -38,9 +38,9 @@ public class BoatTest {
|
|||||||
@Test
|
@Test
|
||||||
public void calculateDueEastAzimuthReturns90() {
|
public void calculateDueEastAzimuthReturns90() {
|
||||||
|
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(0, 50));
|
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(0, 50));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateAzimuth(), 90, 1e-8);
|
assertEquals(TEST_BOAT.calculateAzimuth(), 90, 1e-8);
|
||||||
}
|
}
|
||||||
@@ -48,9 +48,9 @@ public class BoatTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDueWestAzimuthReturnsNegative90() {
|
public void calculateDueWestAzimuthReturnsNegative90() {
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(0, -50));
|
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(0, -50));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateAzimuth(), -90, 1e-8);
|
assertEquals(TEST_BOAT.calculateAzimuth(), -90, 1e-8);
|
||||||
|
|
||||||
@@ -59,9 +59,9 @@ public class BoatTest {
|
|||||||
@Test
|
@Test
|
||||||
public void calculateDueNorthHeadingReturns0() {
|
public void calculateDueNorthHeadingReturns0() {
|
||||||
|
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(50, 0));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateHeading(), 0, 1e-8);
|
assertEquals(TEST_BOAT.calculateHeading(), 0, 1e-8);
|
||||||
}
|
}
|
||||||
@@ -69,27 +69,27 @@ public class BoatTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDueEastHeadingReturns90() {
|
public void calculateDueEastHeadingReturns90() {
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(0, 50));
|
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(0, 50));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateHeading(), 90, 1e-8);
|
assertEquals(TEST_BOAT.calculateHeading(), 90, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDueSouthHeadingReturns180() {
|
public void calculateDueSouthHeadingReturns180() {
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
|
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(-50, 0));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateHeading(), 180, 1e-8);
|
assertEquals(TEST_BOAT.calculateHeading(), 180, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDueWestHeadingReturns270() {
|
public void calculateDueWestHeadingReturns270() {
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMarker startCompoundMarker = new CompoundMarker(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(0, -50));
|
CompoundMarker endCompoundMarker = new CompoundMarker(new GPSCoordinate(0, -50));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMarker, endCompoundMarker, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8);
|
assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -8,14 +8,14 @@ import static org.junit.Assert.assertTrue;
|
|||||||
/**
|
/**
|
||||||
* Created by esa46 on 29/03/17.
|
* Created by esa46 on 29/03/17.
|
||||||
*/
|
*/
|
||||||
public class MarkerTest {
|
public class CompoundMarkerTest {
|
||||||
|
|
||||||
GPSCoordinate ORIGIN_COORD = new GPSCoordinate(0, 0);
|
GPSCoordinate ORIGIN_COORD = new GPSCoordinate(0, 0);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void averageOfSingleMarkAtOriginIsSingleMark() {
|
public void averageOfSingleMarkAtOriginIsSingleMark() {
|
||||||
|
|
||||||
Marker testMark = new Marker(ORIGIN_COORD);
|
CompoundMarker testMark = new CompoundMarker(ORIGIN_COORD);
|
||||||
assertTrue(testMark.getAverageGPSCoordinate().equals(ORIGIN_COORD));
|
assertTrue(testMark.getAverageGPSCoordinate().equals(ORIGIN_COORD));
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ public class MarkerTest {
|
|||||||
public void averageOfSingleMarkIsSingleMark() {
|
public void averageOfSingleMarkIsSingleMark() {
|
||||||
|
|
||||||
GPSCoordinate testCoord = new GPSCoordinate(20, 25);
|
GPSCoordinate testCoord = new GPSCoordinate(20, 25);
|
||||||
Marker testMark = new Marker(testCoord);
|
CompoundMarker testMark = new CompoundMarker(testCoord);
|
||||||
assertTrue(testMark.getAverageGPSCoordinate().equals(testCoord));
|
assertTrue(testMark.getAverageGPSCoordinate().equals(testCoord));
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ public class MarkerTest {
|
|||||||
public void averageLatOfTwoMarksIsAccurate() {
|
public void averageLatOfTwoMarksIsAccurate() {
|
||||||
|
|
||||||
GPSCoordinate testCoord = new GPSCoordinate(10, 0);
|
GPSCoordinate testCoord = new GPSCoordinate(10, 0);
|
||||||
Marker testMark = new Marker(ORIGIN_COORD, testCoord);
|
CompoundMarker testMark = new CompoundMarker(ORIGIN_COORD, testCoord);
|
||||||
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(5, 0)));
|
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(5, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ public class MarkerTest {
|
|||||||
public void averageLongOfTwoMarksIsAccurate() {
|
public void averageLongOfTwoMarksIsAccurate() {
|
||||||
|
|
||||||
GPSCoordinate testCoord = new GPSCoordinate(0, 10);
|
GPSCoordinate testCoord = new GPSCoordinate(0, 10);
|
||||||
Marker testMark = new Marker(ORIGIN_COORD, testCoord);
|
CompoundMarker testMark = new CompoundMarker(ORIGIN_COORD, testCoord);
|
||||||
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(0, 5)));
|
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(0, 5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ public class MarkerTest {
|
|||||||
|
|
||||||
GPSCoordinate testCoord1 = new GPSCoordinate(10, 30);
|
GPSCoordinate testCoord1 = new GPSCoordinate(10, 30);
|
||||||
GPSCoordinate testCoord2 = new GPSCoordinate(30, 60);
|
GPSCoordinate testCoord2 = new GPSCoordinate(30, 60);
|
||||||
Marker testMark = new Marker(testCoord1, testCoord2);
|
CompoundMarker testMark = new CompoundMarker(testCoord1, testCoord2);
|
||||||
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(020.644102, 44.014817)));
|
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(020.644102, 44.014817)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ import static junit.framework.TestCase.assertEquals;
|
|||||||
*/
|
*/
|
||||||
public class LegTest {
|
public class LegTest {
|
||||||
|
|
||||||
private Marker ORIGIN_MARKER = new Marker(new GPSCoordinate(0, 0));
|
private CompoundMarker ORIGIN_Compound_MARKER = new CompoundMarker(new GPSCoordinate(0, 0));
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDistanceHandles5nmNorth() {
|
public void calculateDistanceHandles5nmNorth() {
|
||||||
@@ -22,8 +22,8 @@ public class LegTest {
|
|||||||
calc.setStartingGeographicPoint(0, 0);
|
calc.setStartingGeographicPoint(0, 0);
|
||||||
calc.setDirection(0, 5 * Constants.NMToMetersConversion);
|
calc.setDirection(0, 5 * Constants.NMToMetersConversion);
|
||||||
|
|
||||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
CompoundMarker endCompoundMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||||
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
|
Leg test = new Leg("Test", ORIGIN_Compound_MARKER, endCompoundMarker, 0);
|
||||||
assertEquals(test.getDistance(), 5, 1e-8);
|
assertEquals(test.getDistance(), 5, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,8 +33,8 @@ public class LegTest {
|
|||||||
calc.setStartingGeographicPoint(0, 0);
|
calc.setStartingGeographicPoint(0, 0);
|
||||||
calc.setDirection(90, 12 * Constants.NMToMetersConversion);
|
calc.setDirection(90, 12 * Constants.NMToMetersConversion);
|
||||||
|
|
||||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
CompoundMarker endCompoundMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||||
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
|
Leg test = new Leg("Test", ORIGIN_Compound_MARKER, endCompoundMarker, 0);
|
||||||
assertEquals(test.getDistance(), 12, 1e-8);
|
assertEquals(test.getDistance(), 12, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,8 +44,8 @@ public class LegTest {
|
|||||||
calc.setStartingGeographicPoint(0, 0);
|
calc.setStartingGeographicPoint(0, 0);
|
||||||
calc.setDirection(180, 0.5 * Constants.NMToMetersConversion);
|
calc.setDirection(180, 0.5 * Constants.NMToMetersConversion);
|
||||||
|
|
||||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
CompoundMarker endCompoundMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||||
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
|
Leg test = new Leg("Test", ORIGIN_Compound_MARKER, endCompoundMarker, 0);
|
||||||
assertEquals(test.getDistance(), 0.5, 1e-8);
|
assertEquals(test.getDistance(), 0.5, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,23 +55,23 @@ public class LegTest {
|
|||||||
calc.setStartingGeographicPoint(0, 0);
|
calc.setStartingGeographicPoint(0, 0);
|
||||||
calc.setDirection(-90, 0.1 * Constants.NMToMetersConversion);
|
calc.setDirection(-90, 0.1 * Constants.NMToMetersConversion);
|
||||||
|
|
||||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
CompoundMarker endCompoundMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
||||||
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
|
Leg test = new Leg("Test", ORIGIN_Compound_MARKER, endCompoundMarker, 0);
|
||||||
assertEquals(test.getDistance(), 0.1, 1e-8);
|
assertEquals(test.getDistance(), 0.1, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDistanceHandlesZeroDifference() {
|
public void calculateDistanceHandlesZeroDifference() {
|
||||||
|
|
||||||
Leg test = new Leg("Test", ORIGIN_MARKER, ORIGIN_MARKER, 0);
|
Leg test = new Leg("Test", ORIGIN_Compound_MARKER, ORIGIN_Compound_MARKER, 0);
|
||||||
assertEquals(test.getDistance(), 0, 1e-8);
|
assertEquals(test.getDistance(), 0, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Marker getEndMarker(Point2D point) {
|
private CompoundMarker getEndMarker(Point2D point) {
|
||||||
|
|
||||||
GPSCoordinate coords = new GPSCoordinate(point.getY(), point.getX());
|
GPSCoordinate coords = new GPSCoordinate(point.getY(), point.getX());
|
||||||
|
|
||||||
return new Marker(coords);
|
return new CompoundMarker(coords);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,8 @@
|
|||||||
//public class RaceTest{
|
//public class RaceTest{
|
||||||
//
|
//
|
||||||
// private static MockOutput mockOutput;
|
// private static MockOutput mockOutput;
|
||||||
// SharedModel.Leg START_LEG = new SharedModel.Leg("Start", new SharedModel.Marker(new SharedModel.GPSCoordinate(0, 0)), new SharedModel.Marker(new SharedModel.GPSCoordinate(1, 1)), 0);
|
// SharedModel.Leg START_LEG = new SharedModel.Leg("Start", new SharedModel.CompoundMarker(new SharedModel.GPSCoordinate(0, 0)), new SharedModel.CompoundMarker(new SharedModel.GPSCoordinate(1, 1)), 0);
|
||||||
// SharedModel.Leg FINISH_LEG = new SharedModel.Leg("Finish", new SharedModel.Marker(new SharedModel.GPSCoordinate(1, 1)), new SharedModel.Marker(new SharedModel.GPSCoordinate(2, 2)), 0);
|
// SharedModel.Leg FINISH_LEG = new SharedModel.Leg("Finish", new SharedModel.CompoundMarker(new SharedModel.GPSCoordinate(1, 1)), new SharedModel.CompoundMarker(new SharedModel.GPSCoordinate(2, 2)), 0);
|
||||||
//
|
//
|
||||||
//// @Override
|
//// @Override
|
||||||
//// public void start(Stage primaryStage) throws Exception{}
|
//// public void start(Stage primaryStage) throws Exception{}
|
||||||
|
|||||||
@@ -37,23 +37,23 @@ public class RaceXMLTest {
|
|||||||
//test boat 2
|
//test boat 2
|
||||||
assertEquals(boats.get(1).getName(), "Land Rover BAR");
|
assertEquals(boats.get(1).getName(), "Land Rover BAR");
|
||||||
assertTrue(boats.get(1).getVelocity() == 30);
|
assertTrue(boats.get(1).getVelocity() == 30);
|
||||||
assertEquals(boats.get(1).getAbbrev(), "GBR");
|
assertEquals(boats.get(1).getCountry(), "GBR");
|
||||||
//test boat 3
|
//test boat 3
|
||||||
assertEquals(boats.get(2).getName(), "SoftBank Team Japan");
|
assertEquals(boats.get(2).getName(), "SoftBank Team Japan");
|
||||||
assertTrue(boats.get(2).getVelocity() == 25);
|
assertTrue(boats.get(2).getVelocity() == 25);
|
||||||
assertEquals(boats.get(2).getAbbrev(), "JPN");
|
assertEquals(boats.get(2).getCountry(), "JPN");
|
||||||
//test boat 4
|
//test boat 4
|
||||||
assertEquals(boats.get(3).getName(), "Groupama Team France");
|
assertEquals(boats.get(3).getName(), "Groupama Team France");
|
||||||
assertTrue(boats.get(3).getVelocity() == 20);
|
assertTrue(boats.get(3).getVelocity() == 20);
|
||||||
assertEquals(boats.get(3).getAbbrev(), "FRA");
|
assertEquals(boats.get(3).getCountry(), "FRA");
|
||||||
//test boat 5
|
//test boat 5
|
||||||
assertEquals(boats.get(4).getName(), "Artemis Racing");
|
assertEquals(boats.get(4).getName(), "Artemis Racing");
|
||||||
assertTrue(boats.get(4).getVelocity() == 29);
|
assertTrue(boats.get(4).getVelocity() == 29);
|
||||||
assertEquals(boats.get(4).getAbbrev(), "SWE");
|
assertEquals(boats.get(4).getCountry(), "SWE");
|
||||||
//test boat 6
|
//test boat 6
|
||||||
assertEquals(boats.get(5).getName(), "Emirates Team New Zealand");
|
assertEquals(boats.get(5).getName(), "Emirates Team New Zealand");
|
||||||
assertTrue(boats.get(5).getVelocity() == 62);
|
assertTrue(boats.get(5).getVelocity() == 62);
|
||||||
assertEquals(boats.get(5).getAbbrev(), "NZL");
|
assertEquals(boats.get(5).getCountry(), "NZL");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail("Boat Unreadable");
|
fail("Boat Unreadable");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
<leg>
|
<leg>
|
||||||
<name>Start to Mark 1</name>
|
<name>Start to Mark 1</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.296577</latitude>
|
<latitude>32.296577</latitude>
|
||||||
<longitude>-64.854304</longitude>
|
<longitude>-64.854304</longitude>
|
||||||
@@ -57,29 +57,29 @@
|
|||||||
<latitude>32.293771</latitude>
|
<latitude>32.293771</latitude>
|
||||||
<longitude>-64.855242</longitude>
|
<longitude>-64.855242</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.293039</latitude>
|
<latitude>32.293039</latitude>
|
||||||
<longitude>-64.843983</longitude>
|
<longitude>-64.843983</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Mark 1 to Leeward Gate</name>
|
<name>Mark 1 to Leeward Gate</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.293039</latitude>
|
<latitude>32.293039</latitude>
|
||||||
<longitude>-64.843983</longitude>
|
<longitude>-64.843983</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -88,13 +88,13 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Leeward Gate to Windward Gate</name>
|
<name>Leeward Gate to Windward Gate</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -103,10 +103,10 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.284680</latitude>
|
<latitude>32.284680</latitude>
|
||||||
<longitude>-64.850045</longitude>
|
<longitude>-64.850045</longitude>
|
||||||
@@ -115,13 +115,13 @@
|
|||||||
<latitude>32.280164</latitude>
|
<latitude>32.280164</latitude>
|
||||||
<longitude>-64.847591</longitude>
|
<longitude>-64.847591</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Windward Gate to Leeward Gate</name>
|
<name>Windward Gate to Leeward Gate</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.284680</latitude>
|
<latitude>32.284680</latitude>
|
||||||
<longitude>-64.850045</longitude>
|
<longitude>-64.850045</longitude>
|
||||||
@@ -130,10 +130,10 @@
|
|||||||
<latitude>32.280164</latitude>
|
<latitude>32.280164</latitude>
|
||||||
<longitude>-64.847591</longitude>
|
<longitude>-64.847591</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -142,13 +142,13 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Leeward Gate to Finish</name>
|
<name>Leeward Gate to Finish</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -157,10 +157,10 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.317379</latitude>
|
<latitude>32.317379</latitude>
|
||||||
<longitude>-64.839291</longitude>
|
<longitude>-64.839291</longitude>
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
<latitude>32.317257</latitude>
|
<latitude>32.317257</latitude>
|
||||||
<longitude>-64.836260</longitude>
|
<longitude>-64.836260</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
</legs>
|
</legs>
|
||||||
@@ -220,7 +220,7 @@
|
|||||||
<longitude>-64.849184</longitude>
|
<longitude>-64.849184</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</boundaries>
|
</boundaries>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Start Line</name>
|
<name>Start Line</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.296577</latitude>
|
<latitude>32.296577</latitude>
|
||||||
@@ -230,15 +230,15 @@
|
|||||||
<latitude>32.293771</latitude>
|
<latitude>32.293771</latitude>
|
||||||
<longitude>-64.855242</longitude>
|
<longitude>-64.855242</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Mark</name>
|
<name>Mark</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.293039</latitude>
|
<latitude>32.293039</latitude>
|
||||||
<longitude>-64.843983</longitude>
|
<longitude>-64.843983</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Windward Gate</name>
|
<name>Windward Gate</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.284680</latitude>
|
<latitude>32.284680</latitude>
|
||||||
@@ -248,8 +248,8 @@
|
|||||||
<latitude>32.280164</latitude>
|
<latitude>32.280164</latitude>
|
||||||
<longitude>-64.847591</longitude>
|
<longitude>-64.847591</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Leeward Gate</name>
|
<name>Leeward Gate</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
@@ -259,8 +259,8 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Finish Line</name>
|
<name>Finish Line</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.317379</latitude>
|
<latitude>32.317379</latitude>
|
||||||
@@ -270,6 +270,6 @@
|
|||||||
<latitude>32.317257</latitude>
|
<latitude>32.317257</latitude>
|
||||||
<longitude>-64.836260</longitude>
|
<longitude>-64.836260</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</course>
|
</course>
|
||||||
</race>
|
</race>
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package seng302.Mock;
|
|||||||
|
|
||||||
import seng302.GPSCoordinate;
|
import seng302.GPSCoordinate;
|
||||||
import seng302.Model.Boat;
|
import seng302.Model.Boat;
|
||||||
|
import seng302.Model.CompoundMark;
|
||||||
import seng302.Model.Leg;
|
import seng302.Model.Leg;
|
||||||
import seng302.Model.Marker;
|
|
||||||
import seng302.RaceDataSource;
|
import seng302.RaceDataSource;
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
@@ -82,7 +82,7 @@ public class StreamedCourse extends Observable implements RaceDataSource {
|
|||||||
return streamedCourseXMLReader.getLegs();
|
return streamedCourseXMLReader.getLegs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Marker> getMarkers() { return streamedCourseXMLReader.getMarkers(); }
|
public List<CompoundMark> getMarkers() { return streamedCourseXMLReader.getCompoundMarks(); }
|
||||||
|
|
||||||
public List<GPSCoordinate> getBoundary() {
|
public List<GPSCoordinate> getBoundary() {
|
||||||
return streamedCourseXMLReader.getBoundary();
|
return streamedCourseXMLReader.getBoundary();
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import org.w3c.dom.Node;
|
|||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import seng302.GPSCoordinate;
|
import seng302.GPSCoordinate;
|
||||||
|
import seng302.Model.CompoundMark;
|
||||||
import seng302.Model.Leg;
|
import seng302.Model.Leg;
|
||||||
import seng302.Model.Marker;
|
|
||||||
import seng302.XMLReader;
|
import seng302.XMLReader;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
@@ -25,10 +25,10 @@ public class StreamedCourseXMLReader extends XMLReader {
|
|||||||
private static final double COORDINATEPADDING = 0.000;
|
private static final double COORDINATEPADDING = 0.000;
|
||||||
private GPSCoordinate mapTopLeft, mapBottomRight;
|
private GPSCoordinate mapTopLeft, mapBottomRight;
|
||||||
private final List<GPSCoordinate> boundary = new ArrayList<>();
|
private final List<GPSCoordinate> boundary = new ArrayList<>();
|
||||||
private final Map<Integer,Element> compoundMarks = new HashMap<>();
|
private final Map<Integer,Element> compoundMarkMap = new HashMap<>();
|
||||||
private final Map<Integer, StreamedBoat> participants = new HashMap<>();
|
private final Map<Integer, StreamedBoat> participants = new HashMap<>();
|
||||||
private final List<Leg> legs = new ArrayList<>();
|
private final List<Leg> legs = new ArrayList<>();
|
||||||
private final List<Marker> markers = new ArrayList<>();
|
private final List<CompoundMark> compoundMarks = new ArrayList<>();
|
||||||
private ZonedDateTime creationTimeDate;
|
private ZonedDateTime creationTimeDate;
|
||||||
private ZonedDateTime raceStartTime;
|
private ZonedDateTime raceStartTime;
|
||||||
private int raceID;
|
private int raceID;
|
||||||
@@ -138,7 +138,7 @@ public class StreamedCourseXMLReader extends XMLReader {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Indexes CompoundMark elements by their ID for use in generating the course, and populates list of Markers.
|
* Indexes CompoundMark elements by their ID for use in generating the course, and populates list of Markers.
|
||||||
* @see seng302.Model.Marker
|
* @see CompoundMark
|
||||||
*/
|
*/
|
||||||
private void readCompoundMarks() throws StreamedCourseXMLException {
|
private void readCompoundMarks() throws StreamedCourseXMLException {
|
||||||
Element nCourse = (Element) doc.getElementsByTagName("Course").item(0);
|
Element nCourse = (Element) doc.getElementsByTagName("Course").item(0);
|
||||||
@@ -146,27 +146,27 @@ public class StreamedCourseXMLReader extends XMLReader {
|
|||||||
Node compoundMark = nCourse.getChildNodes().item(i);
|
Node compoundMark = nCourse.getChildNodes().item(i);
|
||||||
if(compoundMark.getNodeName().equals("CompoundMark")) {
|
if(compoundMark.getNodeName().equals("CompoundMark")) {
|
||||||
int compoundMarkID = getCompoundMarkID((Element) compoundMark);
|
int compoundMarkID = getCompoundMarkID((Element) compoundMark);
|
||||||
compoundMarks.put(compoundMarkID, (Element)compoundMark);
|
compoundMarkMap.put(compoundMarkID, (Element)compoundMark);
|
||||||
markers.add(getMarker(compoundMarkID));
|
compoundMarks.add(getMarker(compoundMarkID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a Marker from the CompoundMark element with given ID.
|
* Generates a CompoundMark from the CompoundMark element with given ID.
|
||||||
* @param compoundMarkID index of required CompoundMark element
|
* @param compoundMarkID index of required CompoundMark element
|
||||||
* @return generated Marker
|
* @return generated CompoundMark
|
||||||
* @throws StreamedCourseXMLException if CompoundMark element contains unhandled number of compoundMarks
|
* @throws StreamedCourseXMLException if CompoundMark element contains unhandled number of compoundMarks
|
||||||
* @see seng302.Model.Marker
|
* @see CompoundMark
|
||||||
*/
|
*/
|
||||||
private Marker getMarker(int compoundMarkID) throws StreamedCourseXMLException {
|
private CompoundMark getMarker(int compoundMarkID) throws StreamedCourseXMLException {
|
||||||
Element compoundMark = compoundMarks.get(compoundMarkID);
|
Element compoundMark = compoundMarkMap.get(compoundMarkID);
|
||||||
NodeList nMarks = compoundMark.getElementsByTagName("Mark");
|
NodeList nMarks = compoundMark.getElementsByTagName("Mark");
|
||||||
Marker marker;
|
CompoundMark marker;
|
||||||
|
|
||||||
switch(nMarks.getLength()) {
|
switch(nMarks.getLength()) {
|
||||||
case 1: marker = new Marker(getCoordinate((Element)nMarks.item(0))); break;
|
case 1: marker = new CompoundMark(getCoordinate((Element)nMarks.item(0))); break;
|
||||||
case 2: marker = new Marker(getCoordinate((Element)nMarks.item(0)), getCoordinate((Element)nMarks.item(1))); break;
|
case 2: marker = new CompoundMark(getCoordinate((Element)nMarks.item(0)), getCoordinate((Element)nMarks.item(1))); break;
|
||||||
default: throw new StreamedCourseXMLException();
|
default: throw new StreamedCourseXMLException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,24 +194,24 @@ public class StreamedCourseXMLReader extends XMLReader {
|
|||||||
* @return value of "name" attribute
|
* @return value of "name" attribute
|
||||||
*/
|
*/
|
||||||
private String getCompoundMarkName(int compoundMarkID) {
|
private String getCompoundMarkName(int compoundMarkID) {
|
||||||
return compoundMarks.get(compoundMarkID).getAttribute("Name");
|
return compoundMarkMap.get(compoundMarkID).getAttribute("Name");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populates list of legs given CompoundMarkSequence element and referenced CompoundMark elements.
|
* Populates list of legs given CompoundMarkSequence element and referenced CompoundMark elements.
|
||||||
* @throws StreamedCourseXMLException if markers cannot be resolved from CompoundMark
|
* @throws StreamedCourseXMLException if compoundMarks cannot be resolved from CompoundMark
|
||||||
*/
|
*/
|
||||||
private void readCompoundMarkSequence() throws StreamedCourseXMLException {
|
private void readCompoundMarkSequence() throws StreamedCourseXMLException {
|
||||||
Element nCompoundMarkSequence = (Element) doc.getElementsByTagName("CompoundMarkSequence").item(0);
|
Element nCompoundMarkSequence = (Element) doc.getElementsByTagName("CompoundMarkSequence").item(0);
|
||||||
NodeList nCorners = nCompoundMarkSequence.getElementsByTagName("Corner");
|
NodeList nCorners = nCompoundMarkSequence.getElementsByTagName("Corner");
|
||||||
Element markXML = (Element)nCorners.item(0);
|
Element markXML = (Element)nCorners.item(0);
|
||||||
Marker lastMarker = getMarker(getCompoundMarkID(markXML));
|
CompoundMark lastCompoundMark = getMarker(getCompoundMarkID(markXML));
|
||||||
String legName = getCompoundMarkName(getCompoundMarkID(markXML));
|
String legName = getCompoundMarkName(getCompoundMarkID(markXML));
|
||||||
for(int i = 1; i < nCorners.getLength(); i++) {
|
for(int i = 1; i < nCorners.getLength(); i++) {
|
||||||
markXML = (Element)nCorners.item(i);
|
markXML = (Element)nCorners.item(i);
|
||||||
Marker currentMarker = getMarker(getCompoundMarkID(markXML));
|
CompoundMark currentCompoundMark = getMarker(getCompoundMarkID(markXML));
|
||||||
legs.add(new Leg(legName, lastMarker, currentMarker, i-1));
|
legs.add(new Leg(legName, lastCompoundMark, currentCompoundMark, i-1));
|
||||||
lastMarker = currentMarker;
|
lastCompoundMark = currentCompoundMark;
|
||||||
legName = getCompoundMarkName(getCompoundMarkID(markXML));
|
legName = getCompoundMarkName(getCompoundMarkID(markXML));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -253,7 +253,7 @@ public class StreamedCourseXMLReader extends XMLReader {
|
|||||||
return legs;
|
return legs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Marker> getMarkers() { return markers; }
|
public List<CompoundMark> getCompoundMarks() { return compoundMarks; }
|
||||||
|
|
||||||
public Double getPadding() {
|
public Double getPadding() {
|
||||||
return COORDINATEPADDING;
|
return COORDINATEPADDING;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import seng302.Controllers.RaceController;
|
|||||||
import seng302.GPSCoordinate;
|
import seng302.GPSCoordinate;
|
||||||
import seng302.Model.Boat;
|
import seng302.Model.Boat;
|
||||||
import seng302.Model.Leg;
|
import seng302.Model.Leg;
|
||||||
import seng302.Model.Marker;
|
import seng302.Model.CompoundMark;
|
||||||
import seng302.Model.Race;
|
import seng302.Model.Race;
|
||||||
import seng302.Networking.Messages.BoatLocation;
|
import seng302.Networking.Messages.BoatLocation;
|
||||||
import seng302.Networking.Messages.BoatStatus;
|
import seng302.Networking.Messages.BoatStatus;
|
||||||
@@ -25,13 +25,13 @@ public class StreamedRace extends Race {
|
|||||||
public void initialiseBoats() {
|
public void initialiseBoats() {
|
||||||
Leg officialStart = legs.get(0);
|
Leg officialStart = legs.get(0);
|
||||||
String name = officialStart.getName();
|
String name = officialStart.getName();
|
||||||
Marker endMarker = officialStart.getEndMarker();
|
CompoundMark endCompoundMark = officialStart.getEndCompoundMark();
|
||||||
|
|
||||||
for (int i = 0; i < startingBoats.size(); i++) {
|
for (int i = 0; i < startingBoats.size(); i++) {
|
||||||
Boat boat = startingBoats.get(i);
|
Boat boat = startingBoats.get(i);
|
||||||
if (boat != null) {
|
if (boat != null) {
|
||||||
Leg startLeg = new Leg(name, 0);
|
Leg startLeg = new Leg(name, 0);
|
||||||
startLeg.setEndMarker(endMarker);
|
startLeg.setEndCompoundMark(endCompoundMark);
|
||||||
boat.setCurrentLeg(startLeg);
|
boat.setCurrentLeg(startLeg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ public class BoatInRace extends Boat {
|
|||||||
public double calculateAzimuth() {
|
public double calculateAzimuth() {
|
||||||
|
|
||||||
GeodeticCalculator calc = new GeodeticCalculator();
|
GeodeticCalculator calc = new GeodeticCalculator();
|
||||||
GPSCoordinate start = currentLeg.getStartMarker().getAverageGPSCoordinate();
|
GPSCoordinate start = currentLeg.getStartCompoundMark().getAverageGPSCoordinate();
|
||||||
GPSCoordinate end = currentLeg.getEndMarker().getAverageGPSCoordinate();
|
GPSCoordinate end = currentLeg.getEndCompoundMark().getAverageGPSCoordinate();
|
||||||
|
|
||||||
calc.setStartingGeographicPoint(start.getLongitude(), start.getLatitude());
|
calc.setStartingGeographicPoint(start.getLongitude(), start.getLatitude());
|
||||||
calc.setDestinationGeographicPoint(end.getLongitude(), end.getLatitude());
|
calc.setDestinationGeographicPoint(end.getLongitude(), end.getLatitude());
|
||||||
|
|||||||
+3
-3
@@ -8,12 +8,12 @@ import java.awt.geom.Point2D;
|
|||||||
/**
|
/**
|
||||||
* Created by esa46 on 29/03/17.
|
* Created by esa46 on 29/03/17.
|
||||||
*/
|
*/
|
||||||
public class Marker {
|
public class CompoundMark {
|
||||||
private final GPSCoordinate averageGPSCoordinate;
|
private final GPSCoordinate averageGPSCoordinate;
|
||||||
private final GPSCoordinate mark1;
|
private final GPSCoordinate mark1;
|
||||||
private final GPSCoordinate mark2;
|
private final GPSCoordinate mark2;
|
||||||
|
|
||||||
public Marker(GPSCoordinate mark1) {
|
public CompoundMark(GPSCoordinate mark1) {
|
||||||
|
|
||||||
this.mark1 = mark1;
|
this.mark1 = mark1;
|
||||||
this.mark2 = mark1;
|
this.mark2 = mark1;
|
||||||
@@ -21,7 +21,7 @@ public class Marker {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Marker(GPSCoordinate mark1, GPSCoordinate mark2) {
|
public CompoundMark(GPSCoordinate mark1, GPSCoordinate mark2) {
|
||||||
|
|
||||||
this.mark1 = mark1;
|
this.mark1 = mark1;
|
||||||
this.mark2 = mark2;
|
this.mark2 = mark2;
|
||||||
@@ -60,19 +60,19 @@
|
|||||||
// public void initialiseBoats() {
|
// public void initialiseBoats() {
|
||||||
// Leg officialStart = legs.get(0);
|
// Leg officialStart = legs.get(0);
|
||||||
// String name = officialStart.getName();
|
// String name = officialStart.getName();
|
||||||
// Marker endMarker = officialStart.getEndMarker();
|
// CompoundMark endMarker = officialStart.getEndCompoundMark();
|
||||||
//
|
//
|
||||||
// BoatInRace.setTrackPointTimeInterval(BoatInRace.getBaseTrackPointTimeInterval() / scaleFactor);
|
// BoatInRace.setTrackPointTimeInterval(BoatInRace.getBaseTrackPointTimeInterval() / scaleFactor);
|
||||||
//
|
//
|
||||||
// ArrayList<Marker> startMarkers = getSpreadStartingPositions();
|
// ArrayList<CompoundMark> startMarkers = getSpreadStartingPositions();
|
||||||
// for (int i = 0; i < startingBoats.size(); i++) {
|
// for (int i = 0; i < startingBoats.size(); i++) {
|
||||||
// BoatInRace boat = startingBoats.get(i);
|
// BoatInRace boat = startingBoats.get(i);
|
||||||
// if (boat != null) {
|
// if (boat != null) {
|
||||||
// boat.setScaledVelocity(boat.getVelocity() * scaleFactor);
|
// boat.setScaledVelocity(boat.getVelocity() * scaleFactor);
|
||||||
// Leg startLeg = new Leg(name, 0);
|
// Leg startLeg = new Leg(name, 0);
|
||||||
// boat.setCurrentPosition(startMarkers.get(i).getAverageGPSCoordinate());
|
// boat.setCurrentPosition(startMarkers.get(i).getAverageGPSCoordinate());
|
||||||
// startLeg.setStartMarker(startMarkers.get(i));
|
// startLeg.setStartCompoundMark(startMarkers.get(i));
|
||||||
// startLeg.setEndMarker(endMarker);
|
// startLeg.setEndCompoundMark(endMarker);
|
||||||
// startLeg.calculateDistance();
|
// startLeg.calculateDistance();
|
||||||
// boat.setCurrentLeg(startLeg);
|
// boat.setCurrentLeg(startLeg);
|
||||||
// boat.setHeading(boat.calculateHeading());
|
// boat.setHeading(boat.calculateHeading());
|
||||||
@@ -85,10 +85,10 @@
|
|||||||
// *
|
// *
|
||||||
// * @return list of starting positions
|
// * @return list of starting positions
|
||||||
// */
|
// */
|
||||||
// public ArrayList<Marker> getSpreadStartingPositions() {
|
// public ArrayList<CompoundMark> getSpreadStartingPositions() {
|
||||||
//
|
//
|
||||||
// int nBoats = startingBoats.size();
|
// int nBoats = startingBoats.size();
|
||||||
// Marker marker = legs.get(0).getStartMarker();
|
// CompoundMark marker = legs.get(0).getStartCompoundMark();
|
||||||
//
|
//
|
||||||
// GeodeticCalculator initialCalc = new GeodeticCalculator();
|
// GeodeticCalculator initialCalc = new GeodeticCalculator();
|
||||||
// initialCalc.setStartingGeographicPoint(marker.getMark1().getLongitude(), marker.getMark1().getLatitude());
|
// initialCalc.setStartingGeographicPoint(marker.getMark1().getLongitude(), marker.getMark1().getLatitude());
|
||||||
@@ -100,12 +100,12 @@
|
|||||||
//
|
//
|
||||||
// GeodeticCalculator positionCalc = new GeodeticCalculator();
|
// GeodeticCalculator positionCalc = new GeodeticCalculator();
|
||||||
// positionCalc.setStartingGeographicPoint(marker.getMark1().getLongitude(), marker.getMark1().getLatitude());
|
// positionCalc.setStartingGeographicPoint(marker.getMark1().getLongitude(), marker.getMark1().getLatitude());
|
||||||
// ArrayList<Marker> positions = new ArrayList<>();
|
// ArrayList<CompoundMark> positions = new ArrayList<>();
|
||||||
//
|
//
|
||||||
// for (int i = 0; i < nBoats; i++) {
|
// for (int i = 0; i < nBoats; i++) {
|
||||||
// positionCalc.setDirection(azimuth, distanceBetweenBoats);
|
// positionCalc.setDirection(azimuth, distanceBetweenBoats);
|
||||||
// Point2D position = positionCalc.getDestinationGeographicPoint();
|
// Point2D position = positionCalc.getDestinationGeographicPoint();
|
||||||
// positions.add(new Marker(new GPSCoordinate(position.getY(), position.getX())));
|
// positions.add(new CompoundMark(new GPSCoordinate(position.getY(), position.getX())));
|
||||||
//
|
//
|
||||||
// positionCalc = new GeodeticCalculator();
|
// positionCalc = new GeodeticCalculator();
|
||||||
// positionCalc.setStartingGeographicPoint(position);
|
// positionCalc.setStartingGeographicPoint(position);
|
||||||
@@ -147,7 +147,7 @@
|
|||||||
// //update boat's distance travelled
|
// //update boat's distance travelled
|
||||||
// boat.setDistanceTravelledInLeg(totalDistanceTravelled);
|
// boat.setDistanceTravelledInLeg(totalDistanceTravelled);
|
||||||
// //Calculate boat's new position by adding the distance travelled onto the start point of the leg
|
// //Calculate boat's new position by adding the distance travelled onto the start point of the leg
|
||||||
// boat.setCurrentPosition(calculatePosition(boat.getCurrentLeg().getStartMarker().getAverageGPSCoordinate(),
|
// boat.setCurrentPosition(calculatePosition(boat.getCurrentLeg().getStartCompoundMark().getAverageGPSCoordinate(),
|
||||||
// totalDistanceTravelled, boat.calculateAzimuth()));
|
// totalDistanceTravelled, boat.calculateAzimuth()));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import seng302.GPSCoordinate;
|
|||||||
public class Leg {
|
public class Leg {
|
||||||
private final String name; //nautical miles
|
private final String name; //nautical miles
|
||||||
private double distance;
|
private double distance;
|
||||||
private Marker startMarker;
|
private CompoundMark startCompoundMark;
|
||||||
private Marker endMarker;
|
private CompoundMark endCompoundMark;
|
||||||
private final int legNumber;
|
private final int legNumber;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,10 +22,10 @@ public class Leg {
|
|||||||
* @param end marker
|
* @param end marker
|
||||||
* @param number Leg's position in race
|
* @param number Leg's position in race
|
||||||
*/
|
*/
|
||||||
public Leg(String name, Marker start, Marker end, int number) {
|
public Leg(String name, CompoundMark start, CompoundMark end, int number) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.startMarker = start;
|
this.startCompoundMark = start;
|
||||||
this.endMarker = end;
|
this.endCompoundMark = end;
|
||||||
this.legNumber = number;
|
this.legNumber = number;
|
||||||
calculateDistance();
|
calculateDistance();
|
||||||
}
|
}
|
||||||
@@ -70,20 +70,20 @@ public class Leg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Marker getStartMarker() {
|
public CompoundMark getStartCompoundMark() {
|
||||||
return startMarker;
|
return startCompoundMark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStartMarker(Marker startMarker) {
|
public void setStartCompoundMark(CompoundMark startCompoundMark) {
|
||||||
this.startMarker = startMarker;
|
this.startCompoundMark = startCompoundMark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Marker getEndMarker() {
|
public CompoundMark getEndCompoundMark() {
|
||||||
return endMarker;
|
return endCompoundMark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEndMarker(Marker endMarker) {
|
public void setEndCompoundMark(CompoundMark endCompoundMark) {
|
||||||
this.endMarker = endMarker;
|
this.endCompoundMark = endCompoundMark;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,8 +93,8 @@ public class Leg {
|
|||||||
|
|
||||||
GeodeticCalculator calc = new GeodeticCalculator();
|
GeodeticCalculator calc = new GeodeticCalculator();
|
||||||
//Load start and end of leg
|
//Load start and end of leg
|
||||||
GPSCoordinate startMarker = this.startMarker.getAverageGPSCoordinate();
|
GPSCoordinate startMarker = this.startCompoundMark.getAverageGPSCoordinate();
|
||||||
GPSCoordinate endMarker = this.endMarker.getAverageGPSCoordinate();
|
GPSCoordinate endMarker = this.endCompoundMark.getAverageGPSCoordinate();
|
||||||
calc.setStartingGeographicPoint(startMarker.getLongitude(), startMarker.getLatitude());
|
calc.setStartingGeographicPoint(startMarker.getLongitude(), startMarker.getLatitude());
|
||||||
calc.setDestinationGeographicPoint(endMarker.getLongitude(), endMarker.getLatitude());
|
calc.setDestinationGeographicPoint(endMarker.getLongitude(), endMarker.getLatitude());
|
||||||
this.distance = calc.getOrthodromicDistance() / Constants.NMToMetersConversion;
|
this.distance = calc.getOrthodromicDistance() / Constants.NMToMetersConversion;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|||||||
private boolean annoSpeed = true;
|
private boolean annoSpeed = true;
|
||||||
private boolean annoPath = true;
|
private boolean annoPath = true;
|
||||||
private List<Color> colours;
|
private List<Color> colours;
|
||||||
private final List<Marker> markers;
|
private final List<CompoundMark> compoundMarks;
|
||||||
double[] xpoints = {}, ypoints = {};
|
double[] xpoints = {}, ypoints = {};
|
||||||
private final RaceDataSource raceData;
|
private final RaceDataSource raceData;
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|||||||
|
|
||||||
setMap(new RaceMap(lat1, long1, lat2, long2, (int) getWidth(), (int) getHeight()));
|
setMap(new RaceMap(lat1, long1, lat2, long2, (int) getWidth(), (int) getHeight()));
|
||||||
|
|
||||||
this.markers = raceData.getMarkers();
|
this.compoundMarks = raceData.getMarkers();
|
||||||
makeColours();
|
makeColours();
|
||||||
this.raceData = raceData;
|
this.raceData = raceData;
|
||||||
}
|
}
|
||||||
@@ -201,15 +201,15 @@ public class ResizableRaceCanvas extends ResizableCanvas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw race markers
|
* Draw race compoundMarks
|
||||||
*/
|
*/
|
||||||
private void drawMarkers() {
|
private void drawMarkers() {
|
||||||
for(Marker marker: markers) {
|
for(CompoundMark compoundMark : compoundMarks) {
|
||||||
GraphCoordinate mark1 = this.map.convertGPS(marker.getMark1());
|
GraphCoordinate mark1 = this.map.convertGPS(compoundMark.getMark1());
|
||||||
// removed drawing of lines between the marks as only
|
// removed drawing of lines between the marks as only
|
||||||
// the start and finish line should have a line drawn
|
// the start and finish line should have a line drawn
|
||||||
if(marker.isCompoundMark()) {
|
if(compoundMark.isCompoundMark()) {
|
||||||
GraphCoordinate mark2 = this.map.convertGPS(marker.getMark2());
|
GraphCoordinate mark2 = this.map.convertGPS(compoundMark.getMark2());
|
||||||
displayPoint(mark1, Color.LIMEGREEN);
|
displayPoint(mark1, Color.LIMEGREEN);
|
||||||
displayPoint(mark2, Color.LIMEGREEN);
|
displayPoint(mark2, Color.LIMEGREEN);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package seng302;
|
package seng302;
|
||||||
|
|
||||||
import seng302.Model.Boat;
|
import seng302.Model.Boat;
|
||||||
|
import seng302.Model.CompoundMark;
|
||||||
import seng302.Model.Leg;
|
import seng302.Model.Leg;
|
||||||
import seng302.Model.Marker;
|
|
||||||
|
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
public interface RaceDataSource {
|
public interface RaceDataSource {
|
||||||
List<Boat> getBoats();
|
List<Boat> getBoats();
|
||||||
List<Leg> getLegs();
|
List<Leg> getLegs();
|
||||||
List<Marker> getMarkers();
|
List<CompoundMark> getMarkers();
|
||||||
List<GPSCoordinate> getBoundary();
|
List<GPSCoordinate> getBoundary();
|
||||||
|
|
||||||
ZonedDateTime getZonedDateTime();
|
ZonedDateTime getZonedDateTime();
|
||||||
|
|||||||
@@ -89,10 +89,10 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
for (int i = 0; i < nLegs.getLength(); i++) {
|
for (int i = 0; i < nLegs.getLength(); i++) {
|
||||||
String label = getTextValueOfNode((Element) nLegs.item(i), "name");
|
String label = getTextValueOfNode((Element) nLegs.item(i), "name");
|
||||||
NodeList start = ((Element) nLegs.item(i)).getElementsByTagName("start");
|
NodeList start = ((Element) nLegs.item(i)).getElementsByTagName("start");
|
||||||
Marker startMarker = getMarker(start);
|
CompoundMark startCompoundMark = getMarker(start);
|
||||||
NodeList finish = ((Element) nLegs.item(i)).getElementsByTagName("finish");
|
NodeList finish = ((Element) nLegs.item(i)).getElementsByTagName("finish");
|
||||||
Marker finishMarker = getMarker(finish);
|
CompoundMark finishCompoundMark = getMarker(finish);
|
||||||
legs.add(new Leg(label, startMarker, finishMarker, i));
|
legs.add(new Leg(label, startCompoundMark, finishCompoundMark, i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
|
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Marker getMarker(NodeList start) {
|
private CompoundMark getMarker(NodeList start) {
|
||||||
return getMarker(start, 0);
|
return getMarker(start, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
* @param startIndex index in the node that has the coordinate tag
|
* @param startIndex index in the node that has the coordinate tag
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Marker getMarker(NodeList start, int startIndex) {
|
private CompoundMark getMarker(NodeList start, int startIndex) {
|
||||||
return getMarker(start, startIndex, 0);
|
return getMarker(start, startIndex, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
* @param nodeIndex coordinate index
|
* @param nodeIndex coordinate index
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Marker getMarker(NodeList start, int startIndex, int nodeIndex) {
|
private CompoundMark getMarker(NodeList start, int startIndex, int nodeIndex) {
|
||||||
NodeList nodeList = ((Element) start.item(startIndex)).getElementsByTagName("marker");
|
NodeList nodeList = ((Element) start.item(startIndex)).getElementsByTagName("marker");
|
||||||
Element marker = (Element) nodeList.item(nodeIndex);
|
Element marker = (Element) nodeList.item(nodeIndex);
|
||||||
return getMarker(marker);
|
return getMarker(marker);
|
||||||
@@ -204,7 +204,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
* @param markerNode marker to turn into coordinates
|
* @param markerNode marker to turn into coordinates
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Marker getMarker(Element markerNode) {
|
private CompoundMark getMarker(Element markerNode) {
|
||||||
|
|
||||||
NodeList nCoordinates = markerNode.getElementsByTagName("coordinate");
|
NodeList nCoordinates = markerNode.getElementsByTagName("coordinate");
|
||||||
|
|
||||||
@@ -215,7 +215,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
} else {
|
} else {
|
||||||
side2 = side1;
|
side2 = side1;
|
||||||
}
|
}
|
||||||
return new Marker(side1, side2);
|
return new CompoundMark(side1, side2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +265,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Marker> getMarkers() {
|
public List<CompoundMark> getMarkers() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
<leg>
|
<leg>
|
||||||
<name>Start to Mark 1</name>
|
<name>Start to Mark 1</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.296577</latitude>
|
<latitude>32.296577</latitude>
|
||||||
<longitude>-64.854304</longitude>
|
<longitude>-64.854304</longitude>
|
||||||
@@ -51,29 +51,29 @@
|
|||||||
<latitude>32.293771</latitude>
|
<latitude>32.293771</latitude>
|
||||||
<longitude>-64.855242</longitude>
|
<longitude>-64.855242</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.293039</latitude>
|
<latitude>32.293039</latitude>
|
||||||
<longitude>-64.843983</longitude>
|
<longitude>-64.843983</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Mark 1 to Leeward Gate</name>
|
<name>Mark 1 to Leeward Gate</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.293039</latitude>
|
<latitude>32.293039</latitude>
|
||||||
<longitude>-64.843983</longitude>
|
<longitude>-64.843983</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -82,13 +82,13 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Leeward Gate to Windward Gate</name>
|
<name>Leeward Gate to Windward Gate</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -97,10 +97,10 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.284680</latitude>
|
<latitude>32.284680</latitude>
|
||||||
<longitude>-64.850045</longitude>
|
<longitude>-64.850045</longitude>
|
||||||
@@ -109,13 +109,13 @@
|
|||||||
<latitude>32.280164</latitude>
|
<latitude>32.280164</latitude>
|
||||||
<longitude>-64.847591</longitude>
|
<longitude>-64.847591</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Windward Gate to Leeward Gate</name>
|
<name>Windward Gate to Leeward Gate</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.284680</latitude>
|
<latitude>32.284680</latitude>
|
||||||
<longitude>-64.850045</longitude>
|
<longitude>-64.850045</longitude>
|
||||||
@@ -124,10 +124,10 @@
|
|||||||
<latitude>32.280164</latitude>
|
<latitude>32.280164</latitude>
|
||||||
<longitude>-64.847591</longitude>
|
<longitude>-64.847591</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -136,13 +136,13 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Leeward Gate to Finish</name>
|
<name>Leeward Gate to Finish</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -151,10 +151,10 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.317379</latitude>
|
<latitude>32.317379</latitude>
|
||||||
<longitude>-64.839291</longitude>
|
<longitude>-64.839291</longitude>
|
||||||
@@ -163,7 +163,7 @@
|
|||||||
<latitude>32.317257</latitude>
|
<latitude>32.317257</latitude>
|
||||||
<longitude>-64.836260</longitude>
|
<longitude>-64.836260</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
</legs>
|
</legs>
|
||||||
@@ -214,7 +214,7 @@
|
|||||||
<longitude>-64.849184</longitude>
|
<longitude>-64.849184</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</boundaries>
|
</boundaries>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Start Line</name>
|
<name>Start Line</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.296577</latitude>
|
<latitude>32.296577</latitude>
|
||||||
@@ -224,15 +224,15 @@
|
|||||||
<latitude>32.293771</latitude>
|
<latitude>32.293771</latitude>
|
||||||
<longitude>-64.855242</longitude>
|
<longitude>-64.855242</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Mark</name>
|
<name>Mark</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.293039</latitude>
|
<latitude>32.293039</latitude>
|
||||||
<longitude>-64.843983</longitude>
|
<longitude>-64.843983</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Windward Gate</name>
|
<name>Windward Gate</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.284680</latitude>
|
<latitude>32.284680</latitude>
|
||||||
@@ -242,8 +242,8 @@
|
|||||||
<latitude>32.280164</latitude>
|
<latitude>32.280164</latitude>
|
||||||
<longitude>-64.847591</longitude>
|
<longitude>-64.847591</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Leeward Gate</name>
|
<name>Leeward Gate</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
@@ -253,8 +253,8 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Finish Line</name>
|
<name>Finish Line</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.317379</latitude>
|
<latitude>32.317379</latitude>
|
||||||
@@ -264,6 +264,6 @@
|
|||||||
<latitude>32.317257</latitude>
|
<latitude>32.317257</latitude>
|
||||||
<longitude>-64.836260</longitude>
|
<longitude>-64.836260</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</course>
|
</course>
|
||||||
</race>
|
</race>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import org.junit.Ignore;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import seng302.GPSCoordinate;
|
import seng302.GPSCoordinate;
|
||||||
import seng302.Model.Leg;
|
import seng302.Model.Leg;
|
||||||
import seng302.Model.Marker;
|
import seng302.Model.CompoundMark;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -87,8 +87,8 @@ public class StreamedRaceTest {
|
|||||||
GPSCoordinate topLeft = streamedCourseXMLReader.getMapTopLeft();
|
GPSCoordinate topLeft = streamedCourseXMLReader.getMapTopLeft();
|
||||||
GPSCoordinate bottomRight = streamedCourseXMLReader.getMapBottomRight();
|
GPSCoordinate bottomRight = streamedCourseXMLReader.getMapBottomRight();
|
||||||
|
|
||||||
for(Marker marker: streamedCourseXMLReader.getMarkers()) {
|
for(CompoundMark compoundMark : streamedCourseXMLReader.getCompoundMarks()) {
|
||||||
GPSCoordinate centre = marker.getAverageGPSCoordinate();
|
GPSCoordinate centre = compoundMark.getAverageGPSCoordinate();
|
||||||
assertTrue(centre.getLatitude() < bottomRight.getLatitude());
|
assertTrue(centre.getLatitude() < bottomRight.getLatitude());
|
||||||
assertTrue(centre.getLatitude() > topLeft.getLatitude());
|
assertTrue(centre.getLatitude() > topLeft.getLatitude());
|
||||||
assertTrue(centre.getLongitude() > bottomRight.getLongitude());
|
assertTrue(centre.getLongitude() > bottomRight.getLongitude());
|
||||||
|
|||||||
@@ -19,18 +19,18 @@ public class BoatInRaceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void calculateDueNorthAzimuthReturns0() {
|
public void calculateDueNorthAzimuthReturns0() {
|
||||||
|
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(50, 0));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateAzimuth(), 0, 1e-8);
|
assertEquals(TEST_BOAT.calculateAzimuth(), 0, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDueSouthAzimuthReturns180() {
|
public void calculateDueSouthAzimuthReturns180() {
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
|
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(-50, 0));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateAzimuth(), 180, 1e-8);
|
assertEquals(TEST_BOAT.calculateAzimuth(), 180, 1e-8);
|
||||||
}
|
}
|
||||||
@@ -39,9 +39,9 @@ public class BoatInRaceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void calculateDueEastAzimuthReturns90() {
|
public void calculateDueEastAzimuthReturns90() {
|
||||||
|
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(0, 50));
|
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(0, 50));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateAzimuth(), 90, 1e-8);
|
assertEquals(TEST_BOAT.calculateAzimuth(), 90, 1e-8);
|
||||||
}
|
}
|
||||||
@@ -49,9 +49,9 @@ public class BoatInRaceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDueWestAzimuthReturnsNegative90() {
|
public void calculateDueWestAzimuthReturnsNegative90() {
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(0, -50));
|
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(0, -50));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateAzimuth(), -90, 1e-8);
|
assertEquals(TEST_BOAT.calculateAzimuth(), -90, 1e-8);
|
||||||
|
|
||||||
@@ -60,9 +60,9 @@ public class BoatInRaceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void calculateDueNorthHeadingReturns0() {
|
public void calculateDueNorthHeadingReturns0() {
|
||||||
|
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(50, 0));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateHeading(), 0, 1e-8);
|
assertEquals(TEST_BOAT.calculateHeading(), 0, 1e-8);
|
||||||
}
|
}
|
||||||
@@ -70,27 +70,27 @@ public class BoatInRaceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDueEastHeadingReturns90() {
|
public void calculateDueEastHeadingReturns90() {
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(0, 50));
|
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(0, 50));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateHeading(), 90, 1e-8);
|
assertEquals(TEST_BOAT.calculateHeading(), 90, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDueSouthHeadingReturns180() {
|
public void calculateDueSouthHeadingReturns180() {
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(-50, 0));
|
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(-50, 0));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateHeading(), 180, 1e-8);
|
assertEquals(TEST_BOAT.calculateHeading(), 180, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDueWestHeadingReturns270() {
|
public void calculateDueWestHeadingReturns270() {
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(0, -50));
|
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(0, -50));
|
||||||
Leg start = new Leg("Start", startMarker, endMarker, 0);
|
Leg start = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||||
TEST_BOAT.setCurrentLeg(start);
|
TEST_BOAT.setCurrentLeg(start);
|
||||||
assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8);
|
assertEquals(TEST_BOAT.calculateHeading(), 270, 1e-8);
|
||||||
}
|
}
|
||||||
@@ -117,16 +117,16 @@ public class BoatInRaceTest {
|
|||||||
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
BoatInRace boat = new BoatInRace("Test", 1, Color.ALICEBLUE, "tt");
|
||||||
|
|
||||||
// Construct leg of 0 degrees
|
// Construct leg of 0 degrees
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(50, 0));
|
||||||
Leg leg0deg = new Leg("Start", startMarker, endMarker, 0);
|
Leg leg0deg = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||||
boat.setCurrentLeg(leg0deg);
|
boat.setCurrentLeg(leg0deg);
|
||||||
boat.setCurrentPosition(new GPSCoordinate(0, 0));
|
boat.setCurrentPosition(new GPSCoordinate(0, 0));
|
||||||
|
|
||||||
assertEquals(0, boat.calculateHeading(), 1e-8);
|
assertEquals(0, boat.calculateHeading(), 1e-8);
|
||||||
|
|
||||||
// Construct leg from wake - heading should be 180 degrees
|
// Construct leg from wake - heading should be 180 degrees
|
||||||
Leg leg180deg = new Leg("Start", startMarker, new Marker(boat.getWake()), 0);
|
Leg leg180deg = new Leg("Start", startCompoundMark, new CompoundMark(boat.getWake()), 0);
|
||||||
boat.setCurrentLeg(leg180deg);
|
boat.setCurrentLeg(leg180deg);
|
||||||
|
|
||||||
assertEquals(180, boat.calculateHeading(), 1e-8);
|
assertEquals(180, boat.calculateHeading(), 1e-8);
|
||||||
@@ -138,9 +138,9 @@ public class BoatInRaceTest {
|
|||||||
BoatInRace boat = new BoatInRace("Test", 10, Color.ALICEBLUE, "tt");
|
BoatInRace boat = new BoatInRace("Test", 10, Color.ALICEBLUE, "tt");
|
||||||
|
|
||||||
// Construct leg of 0 degrees at 0 N
|
// Construct leg of 0 degrees at 0 N
|
||||||
Marker startMarker = new Marker(ORIGIN_COORDS);
|
CompoundMark startCompoundMark = new CompoundMark(ORIGIN_COORDS);
|
||||||
Marker endMarker = new Marker(new GPSCoordinate(50, 0));
|
CompoundMark endCompoundMark = new CompoundMark(new GPSCoordinate(50, 0));
|
||||||
Leg leg0deg = new Leg("Start", startMarker, endMarker, 0);
|
Leg leg0deg = new Leg("Start", startCompoundMark, endCompoundMark, 0);
|
||||||
boat.setCurrentLeg(leg0deg);
|
boat.setCurrentLeg(leg0deg);
|
||||||
boat.setCurrentPosition(new GPSCoordinate(0, 0));
|
boat.setCurrentPosition(new GPSCoordinate(0, 0));
|
||||||
|
|
||||||
|
|||||||
+6
-6
@@ -8,14 +8,14 @@ import static org.junit.Assert.assertTrue;
|
|||||||
/**
|
/**
|
||||||
* Created by esa46 on 29/03/17.
|
* Created by esa46 on 29/03/17.
|
||||||
*/
|
*/
|
||||||
public class MarkerTest {
|
public class CompoundMarkTest {
|
||||||
|
|
||||||
private final GPSCoordinate ORIGIN_COORD = new GPSCoordinate(0, 0);
|
private final GPSCoordinate ORIGIN_COORD = new GPSCoordinate(0, 0);
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void averageOfSingleMarkAtOriginIsSingleMark() {
|
public void averageOfSingleMarkAtOriginIsSingleMark() {
|
||||||
|
|
||||||
Marker testMark = new Marker(ORIGIN_COORD);
|
CompoundMark testMark = new CompoundMark(ORIGIN_COORD);
|
||||||
assertTrue(testMark.getAverageGPSCoordinate().equals(ORIGIN_COORD));
|
assertTrue(testMark.getAverageGPSCoordinate().equals(ORIGIN_COORD));
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ public class MarkerTest {
|
|||||||
public void averageOfSingleMarkIsSingleMark() {
|
public void averageOfSingleMarkIsSingleMark() {
|
||||||
|
|
||||||
GPSCoordinate testCoord = new GPSCoordinate(20, 25);
|
GPSCoordinate testCoord = new GPSCoordinate(20, 25);
|
||||||
Marker testMark = new Marker(testCoord);
|
CompoundMark testMark = new CompoundMark(testCoord);
|
||||||
assertTrue(testMark.getAverageGPSCoordinate().equals(testCoord));
|
assertTrue(testMark.getAverageGPSCoordinate().equals(testCoord));
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,7 @@ public class MarkerTest {
|
|||||||
public void averageLatOfTwoMarksIsAccurate() {
|
public void averageLatOfTwoMarksIsAccurate() {
|
||||||
|
|
||||||
GPSCoordinate testCoord = new GPSCoordinate(10, 0);
|
GPSCoordinate testCoord = new GPSCoordinate(10, 0);
|
||||||
Marker testMark = new Marker(ORIGIN_COORD, testCoord);
|
CompoundMark testMark = new CompoundMark(ORIGIN_COORD, testCoord);
|
||||||
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(5, 0)));
|
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(5, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ public class MarkerTest {
|
|||||||
public void averageLongOfTwoMarksIsAccurate() {
|
public void averageLongOfTwoMarksIsAccurate() {
|
||||||
|
|
||||||
GPSCoordinate testCoord = new GPSCoordinate(0, 10);
|
GPSCoordinate testCoord = new GPSCoordinate(0, 10);
|
||||||
Marker testMark = new Marker(ORIGIN_COORD, testCoord);
|
CompoundMark testMark = new CompoundMark(ORIGIN_COORD, testCoord);
|
||||||
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(0, 5)));
|
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(0, 5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ public class MarkerTest {
|
|||||||
|
|
||||||
GPSCoordinate testCoord1 = new GPSCoordinate(10, 30);
|
GPSCoordinate testCoord1 = new GPSCoordinate(10, 30);
|
||||||
GPSCoordinate testCoord2 = new GPSCoordinate(30, 60);
|
GPSCoordinate testCoord2 = new GPSCoordinate(30, 60);
|
||||||
Marker testMark = new Marker(testCoord1, testCoord2);
|
CompoundMark testMark = new CompoundMark(testCoord1, testCoord2);
|
||||||
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(020.644102, 44.014817)));
|
assertTrue(testMark.getAverageGPSCoordinate().equals(new GPSCoordinate(020.644102, 44.014817)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,8 +17,8 @@
|
|||||||
// */
|
// */
|
||||||
//public class ConstantVelocityRaceTest {
|
//public class ConstantVelocityRaceTest {
|
||||||
//
|
//
|
||||||
// Marker START_MARKER = new Marker(new GPSCoordinate(0, 0));
|
// CompoundMark START_MARKER = new CompoundMark(new GPSCoordinate(0, 0));
|
||||||
// Marker END_MARKER = new Marker(new GPSCoordinate(10, 10));
|
// CompoundMark END_MARKER = new CompoundMark(new GPSCoordinate(10, 10));
|
||||||
// Leg START_LEG = new Leg("Start", START_MARKER, END_MARKER, 0);
|
// Leg START_LEG = new Leg("Start", START_MARKER, END_MARKER, 0);
|
||||||
//
|
//
|
||||||
// int ONE_HOUR = 3600000; //1 hour in milliseconds
|
// int ONE_HOUR = 3600000; //1 hour in milliseconds
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import static junit.framework.TestCase.assertEquals;
|
|||||||
*/
|
*/
|
||||||
public class LegTest {
|
public class LegTest {
|
||||||
|
|
||||||
private final Marker ORIGIN_MARKER = new Marker(new GPSCoordinate(0, 0));
|
private final CompoundMark ORIGIN_CompoundMark = new CompoundMark(new GPSCoordinate(0, 0));
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDistanceHandles5nmNorth() {
|
public void calculateDistanceHandles5nmNorth() {
|
||||||
@@ -22,8 +22,8 @@ public class LegTest {
|
|||||||
calc.setStartingGeographicPoint(0, 0);
|
calc.setStartingGeographicPoint(0, 0);
|
||||||
calc.setDirection(0, 5 * Constants.NMToMetersConversion);
|
calc.setDirection(0, 5 * Constants.NMToMetersConversion);
|
||||||
|
|
||||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
CompoundMark endCompoundMark = getEndMarker(calc.getDestinationGeographicPoint());
|
||||||
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
|
Leg test = new Leg("Test", ORIGIN_CompoundMark, endCompoundMark, 0);
|
||||||
assertEquals(test.getDistance(), 5, 1e-8);
|
assertEquals(test.getDistance(), 5, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,8 +33,8 @@ public class LegTest {
|
|||||||
calc.setStartingGeographicPoint(0, 0);
|
calc.setStartingGeographicPoint(0, 0);
|
||||||
calc.setDirection(90, 12 * Constants.NMToMetersConversion);
|
calc.setDirection(90, 12 * Constants.NMToMetersConversion);
|
||||||
|
|
||||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
CompoundMark endCompoundMark = getEndMarker(calc.getDestinationGeographicPoint());
|
||||||
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
|
Leg test = new Leg("Test", ORIGIN_CompoundMark, endCompoundMark, 0);
|
||||||
assertEquals(test.getDistance(), 12, 1e-8);
|
assertEquals(test.getDistance(), 12, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,8 +44,8 @@ public class LegTest {
|
|||||||
calc.setStartingGeographicPoint(0, 0);
|
calc.setStartingGeographicPoint(0, 0);
|
||||||
calc.setDirection(180, 0.5 * Constants.NMToMetersConversion);
|
calc.setDirection(180, 0.5 * Constants.NMToMetersConversion);
|
||||||
|
|
||||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
CompoundMark endCompoundMark = getEndMarker(calc.getDestinationGeographicPoint());
|
||||||
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
|
Leg test = new Leg("Test", ORIGIN_CompoundMark, endCompoundMark, 0);
|
||||||
assertEquals(test.getDistance(), 0.5, 1e-8);
|
assertEquals(test.getDistance(), 0.5, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,23 +55,23 @@ public class LegTest {
|
|||||||
calc.setStartingGeographicPoint(0, 0);
|
calc.setStartingGeographicPoint(0, 0);
|
||||||
calc.setDirection(-90, 0.1 * Constants.NMToMetersConversion);
|
calc.setDirection(-90, 0.1 * Constants.NMToMetersConversion);
|
||||||
|
|
||||||
Marker endMarker = getEndMarker(calc.getDestinationGeographicPoint());
|
CompoundMark endCompoundMark = getEndMarker(calc.getDestinationGeographicPoint());
|
||||||
Leg test = new Leg("Test", ORIGIN_MARKER, endMarker, 0);
|
Leg test = new Leg("Test", ORIGIN_CompoundMark, endCompoundMark, 0);
|
||||||
assertEquals(test.getDistance(), 0.1, 1e-8);
|
assertEquals(test.getDistance(), 0.1, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void calculateDistanceHandlesZeroDifference() {
|
public void calculateDistanceHandlesZeroDifference() {
|
||||||
|
|
||||||
Leg test = new Leg("Test", ORIGIN_MARKER, ORIGIN_MARKER, 0);
|
Leg test = new Leg("Test", ORIGIN_CompoundMark, ORIGIN_CompoundMark, 0);
|
||||||
assertEquals(test.getDistance(), 0, 1e-8);
|
assertEquals(test.getDistance(), 0, 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Marker getEndMarker(Point2D point) {
|
private CompoundMark getEndMarker(Point2D point) {
|
||||||
|
|
||||||
GPSCoordinate coords = new GPSCoordinate(point.getY(), point.getX());
|
GPSCoordinate coords = new GPSCoordinate(point.getY(), point.getX());
|
||||||
|
|
||||||
return new Marker(coords);
|
return new CompoundMark(coords);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
<leg>
|
<leg>
|
||||||
<name>Start to Mark 1</name>
|
<name>Start to Mark 1</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.296577</latitude>
|
<latitude>32.296577</latitude>
|
||||||
<longitude>-64.854304</longitude>
|
<longitude>-64.854304</longitude>
|
||||||
@@ -50,29 +50,29 @@
|
|||||||
<latitude>32.293771</latitude>
|
<latitude>32.293771</latitude>
|
||||||
<longitude>-64.855242</longitude>
|
<longitude>-64.855242</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.293039</latitude>
|
<latitude>32.293039</latitude>
|
||||||
<longitude>-64.843983</longitude>
|
<longitude>-64.843983</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Mark 1 to Leeward Gate</name>
|
<name>Mark 1 to Leeward Gate</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.293039</latitude>
|
<latitude>32.293039</latitude>
|
||||||
<longitude>-64.843983</longitude>
|
<longitude>-64.843983</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -81,13 +81,13 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Leeward Gate to Windward Gate</name>
|
<name>Leeward Gate to Windward Gate</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -96,10 +96,10 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.284680</latitude>
|
<latitude>32.284680</latitude>
|
||||||
<longitude>-64.850045</longitude>
|
<longitude>-64.850045</longitude>
|
||||||
@@ -108,13 +108,13 @@
|
|||||||
<latitude>32.280164</latitude>
|
<latitude>32.280164</latitude>
|
||||||
<longitude>-64.847591</longitude>
|
<longitude>-64.847591</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Windward Gate to Leeward Gate</name>
|
<name>Windward Gate to Leeward Gate</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.284680</latitude>
|
<latitude>32.284680</latitude>
|
||||||
<longitude>-64.850045</longitude>
|
<longitude>-64.850045</longitude>
|
||||||
@@ -123,10 +123,10 @@
|
|||||||
<latitude>32.280164</latitude>
|
<latitude>32.280164</latitude>
|
||||||
<longitude>-64.847591</longitude>
|
<longitude>-64.847591</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -135,13 +135,13 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
<leg>
|
<leg>
|
||||||
<name>Leeward Gate to Finish</name>
|
<name>Leeward Gate to Finish</name>
|
||||||
<start>
|
<start>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
<longitude>-64.835249</longitude>
|
<longitude>-64.835249</longitude>
|
||||||
@@ -150,10 +150,10 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</start>
|
</start>
|
||||||
<finish>
|
<finish>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.317379</latitude>
|
<latitude>32.317379</latitude>
|
||||||
<longitude>-64.839291</longitude>
|
<longitude>-64.839291</longitude>
|
||||||
@@ -162,7 +162,7 @@
|
|||||||
<latitude>32.317257</latitude>
|
<latitude>32.317257</latitude>
|
||||||
<longitude>-64.836260</longitude>
|
<longitude>-64.836260</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</finish>
|
</finish>
|
||||||
</leg>
|
</leg>
|
||||||
</legs>
|
</legs>
|
||||||
@@ -213,7 +213,7 @@
|
|||||||
<longitude>-64.849184</longitude>
|
<longitude>-64.849184</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</boundaries>
|
</boundaries>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Start Line</name>
|
<name>Start Line</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.296577</latitude>
|
<latitude>32.296577</latitude>
|
||||||
@@ -223,15 +223,15 @@
|
|||||||
<latitude>32.293771</latitude>
|
<latitude>32.293771</latitude>
|
||||||
<longitude>-64.855242</longitude>
|
<longitude>-64.855242</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Mark</name>
|
<name>Mark</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.293039</latitude>
|
<latitude>32.293039</latitude>
|
||||||
<longitude>-64.843983</longitude>
|
<longitude>-64.843983</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Windward Gate</name>
|
<name>Windward Gate</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.284680</latitude>
|
<latitude>32.284680</latitude>
|
||||||
@@ -241,8 +241,8 @@
|
|||||||
<latitude>32.280164</latitude>
|
<latitude>32.280164</latitude>
|
||||||
<longitude>-64.847591</longitude>
|
<longitude>-64.847591</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Leeward Gate</name>
|
<name>Leeward Gate</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.309693</latitude>
|
<latitude>32.309693</latitude>
|
||||||
@@ -252,8 +252,8 @@
|
|||||||
<latitude>32.308046</latitude>
|
<latitude>32.308046</latitude>
|
||||||
<longitude>-64.831785</longitude>
|
<longitude>-64.831785</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
<marker>
|
<compoundMark>
|
||||||
<name>Finish Line</name>
|
<name>Finish Line</name>
|
||||||
<coordinate>
|
<coordinate>
|
||||||
<latitude>32.317379</latitude>
|
<latitude>32.317379</latitude>
|
||||||
@@ -263,6 +263,6 @@
|
|||||||
<latitude>32.317257</latitude>
|
<latitude>32.317257</latitude>
|
||||||
<longitude>-64.836260</longitude>
|
<longitude>-64.836260</longitude>
|
||||||
</coordinate>
|
</coordinate>
|
||||||
</marker>
|
</compoundMark>
|
||||||
</course>
|
</course>
|
||||||
</race>
|
</race>
|
||||||
|
|||||||
Reference in New Issue
Block a user