Fixed merge issue
- Strange Issue where there was a null pointer from convertGPS however it has resolved itself may crop in the future htough. #story[782]
This commit is contained in:
@@ -164,8 +164,7 @@ public class StreamedCourseXMLReader extends XMLReader {
|
|||||||
* @return value of "compoundMarkID" attribute
|
* @return value of "compoundMarkID" attribute
|
||||||
*/
|
*/
|
||||||
private int getCompoundMarkID(Element element) {
|
private int getCompoundMarkID(Element element) {
|
||||||
//return Integer.parseInt(element.getAttribute("CompoundMarkID"));
|
return Integer.parseInt(element.getAttribute("CompoundMarkID"));
|
||||||
return 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -184,10 +183,11 @@ public class StreamedCourseXMLReader extends XMLReader {
|
|||||||
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");
|
||||||
Marker lastMarker = getMarker(getCompoundMarkID((Element)nCorners.item(0)));
|
Element markXML = (Element)nCorners.item(0);
|
||||||
String legName = getCompoundMarkName(getCompoundMarkID((Element)nCorners.item(0)));
|
Marker lastMarker = getMarker(getCompoundMarkID(markXML));
|
||||||
|
String legName = getCompoundMarkName(getCompoundMarkID(markXML));
|
||||||
for(int i = 1; i < nCorners.getLength(); i++) {
|
for(int i = 1; i < nCorners.getLength(); i++) {
|
||||||
Element markXML = (Element)nCorners.item(i);
|
markXML = (Element)nCorners.item(i);
|
||||||
Marker currentMarker = getMarker(getCompoundMarkID(markXML));
|
Marker currentMarker = getMarker(getCompoundMarkID(markXML));
|
||||||
legs.add(new Leg(legName, lastMarker, currentMarker, i-1));
|
legs.add(new Leg(legName, lastMarker, currentMarker, i-1));
|
||||||
lastMarker = currentMarker;
|
lastMarker = currentMarker;
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import seng302.*;
|
|||||||
import seng302.Controllers.RaceController;
|
import seng302.Controllers.RaceController;
|
||||||
import seng302.Model.*;
|
import seng302.Model.*;
|
||||||
import seng302.Networking.MessageDecoders.BoatLocationDecoder;
|
import seng302.Networking.MessageDecoders.BoatLocationDecoder;
|
||||||
|
import seng302.Networking.Utils.BoatStatusMessage;
|
||||||
|
import seng302.Networking.Utils.ByteConverter;
|
||||||
|
import seng302.Networking.Utils.Enums.BoatStatus;
|
||||||
import seng302.Networking.Utils.BoatLocationMessage;
|
import seng302.Networking.Utils.BoatLocationMessage;
|
||||||
|
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
@@ -48,18 +51,26 @@ public class StreamedRace extends Race {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the position of the boat, this updates the boats current position.
|
* Checks the position of the boat.
|
||||||
*
|
*
|
||||||
* @param boat Boat that the position is to be updated for.
|
* @param boat Boat that the position is to be updated for.
|
||||||
* @param timeElapsed Time that has elapse since the start of the the race.
|
* @param timeElapsed Time that has elapse since the start of the the race.
|
||||||
* @see BoatInRace
|
* @see BoatInRace
|
||||||
*/
|
*/
|
||||||
protected void checkPosition(Boat boat, long timeElapsed) {
|
protected void checkPosition(Boat boat, long timeElapsed) {
|
||||||
if (boat.getCurrentLeg().getName().toLowerCase().contains("finish")) {
|
StreamedCourse raceData = visualiserInput.getCourse();
|
||||||
//boat has finished
|
BoatStatusMessage boatStatusMessage = visualiserInput.getBoatStatus().get(boat.getSourceID());
|
||||||
|
BoatStatus boatStatus = BoatStatus.valueOf(boatStatusMessage.getBoatStatus());
|
||||||
|
int legNumber = boatStatusMessage.getLegNumber();
|
||||||
|
|
||||||
|
if (boatStatus == BoatStatus.DNF) {
|
||||||
|
boat.setDnf(true);
|
||||||
|
} else if (boatStatus == BoatStatus.FINISHED || legNumber > raceData.getLegs().size()) {
|
||||||
boatsFinished++;
|
boatsFinished++;
|
||||||
boat.setFinished(true);
|
|
||||||
boat.setTimeFinished(timeElapsed);
|
boat.setTimeFinished(timeElapsed);
|
||||||
|
boat.setFinished(true);
|
||||||
|
} else {
|
||||||
|
boat.setCurrentLeg(raceData.getLegs().get(legNumber));
|
||||||
}
|
}
|
||||||
//Update the boat display table in the GUI to reflect the leg change
|
//Update the boat display table in the GUI to reflect the leg change
|
||||||
updatePositions();
|
updatePositions();
|
||||||
|
|||||||
@@ -76,7 +76,9 @@ public class StreamedRaceTest {
|
|||||||
"M2",
|
"M2",
|
||||||
"Gate"
|
"Gate"
|
||||||
};
|
};
|
||||||
for(int i = 0; i < legs.size(); i++) assertEquals(expectedNames[i], legs.get(i).getName());
|
for(int i = 0; i < legs.size(); i++) {
|
||||||
|
assertEquals(expectedNames[i], legs.get(i).getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user