Merge remote-tracking branch 'origin/splitIntoTwoModules' into splitIntoTwoModules

This commit is contained in:
Joseph Gardner
2017-05-01 19:15:44 +12:00
12 changed files with 82 additions and 65 deletions
@@ -96,6 +96,7 @@ public class StreamedCourseXMLReader extends XMLReader {
private void readParticipants() {
Element nParticipants = (Element) doc.getElementsByTagName("Participants").item(0);
nParticipants.getChildNodes().getLength();
for (int i = 0; i < nParticipants.getChildNodes().getLength(); i++) {
int sourceID;
Node yacht = nParticipants.getChildNodes().item(i);
@@ -163,7 +164,8 @@ public class StreamedCourseXMLReader extends XMLReader {
* @return value of "compoundMarkID" attribute
*/
private int getCompoundMarkID(Element element) {
return Integer.parseInt(element.getAttribute("CompoundMarkID"));
//return Integer.parseInt(element.getAttribute("CompoundMarkID"));
return 3;
}
/**
@@ -6,7 +6,10 @@ import seng302.Constants;
import seng302.Controllers.RaceController;
import seng302.GPSCoordinate;
import seng302.Model.*;
import seng302.Networking.MessageDecoders.BoatLocationDecoder;
import seng302.Networking.Utils.BoatLocationMessage;
import seng302.RaceDataSource;
import seng302.VisualiserInput;
import java.awt.geom.Point2D;
import java.util.*;
@@ -15,12 +18,12 @@ import java.util.*;
* Created by jjg64 on 21/04/17.
*/
public class StreamedRace extends Race {
private RaceDataSource raceData;
private VisualiserInput visualiserInput;
private double MMPS_TO_KN = 0.001944;
public StreamedRace(RaceDataSource raceData, RaceController controller, int scaleFactor) {
super(raceData.getBoats(), raceData.getLegs(), controller, scaleFactor);
this.raceData = raceData;
this.scaleFactor = 1; // There will be no scaling in a live streamed race
public StreamedRace(VisualiserInput visualiserInput, RaceController controller) {
super(visualiserInput.getCourse(), controller, 1);
this.visualiserInput = visualiserInput;
}
public void initialiseBoats() {
@@ -72,8 +75,16 @@ public class StreamedRace extends Race {
* @param millisecondsElapsed time since last update
*/
protected void updatePosition(Boat boat, int millisecondsElapsed) {
//TODO Grab info from network
// setPosition(boat, coordinate);
int sourceID = boat.getSourceID();
BoatLocationMessage boatLocationMessage = visualiserInput.getBoatLocationMessage(sourceID);
if(boatLocationMessage != null) {
System.out.println(sourceID);
double lat = boatLocationMessage.getLatitudeDouble();
double lon = boatLocationMessage.getLongitudeDouble();
boat.setCurrentPosition(new GPSCoordinate(lat, lon));
boat.setHeading(boatLocationMessage.getHeadingDegrees());
boat.setVelocity(boatLocationMessage.getBoatSpeed() * MMPS_TO_KN);
}
}
protected void setPosition(Boat boat, GPSCoordinate coordinate) {