Merged with visualiser side of mark boats
#story[881]
This commit is contained in:
@@ -2,8 +2,8 @@ package seng302.Mock;
|
||||
|
||||
import seng302.GPSCoordinate;
|
||||
import seng302.Model.Boat;
|
||||
import seng302.Model.CompoundMark;
|
||||
import seng302.Model.Leg;
|
||||
import seng302.Model.Marker;
|
||||
import seng302.RaceDataSource;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
@@ -75,7 +75,7 @@ public class StreamedCourse extends Observable implements RaceDataSource {
|
||||
return streamedCourseXMLReader.getLegs();
|
||||
}
|
||||
|
||||
public List<CompoundMark> getMarkers() { return streamedCourseXMLReader.getCompoundMarks(); }
|
||||
public List<Marker> getMarkers() { return streamedCourseXMLReader.getMarkers(); }
|
||||
|
||||
public List<GPSCoordinate> getBoundary() {
|
||||
return streamedCourseXMLReader.getBoundary();
|
||||
|
||||
@@ -4,7 +4,7 @@ import seng302.Controllers.RaceController;
|
||||
import seng302.GPSCoordinate;
|
||||
import seng302.Model.Boat;
|
||||
import seng302.Model.Leg;
|
||||
import seng302.Model.CompoundMark;
|
||||
import seng302.Model.Marker;
|
||||
import seng302.Model.Race;
|
||||
import seng302.Networking.Messages.BoatLocation;
|
||||
import seng302.Networking.Messages.BoatStatus;
|
||||
@@ -25,12 +25,12 @@ public class StreamedRace extends Race {
|
||||
public void initialiseBoats() {
|
||||
Leg officialStart = legs.get(0);
|
||||
String name = officialStart.getName();
|
||||
CompoundMark endCompoundMark = officialStart.getEndCompoundMark();
|
||||
Marker endCompoundMark = officialStart.getEndMarker();
|
||||
|
||||
for (Boat boat : startingBoats) {
|
||||
if (boat != null) {
|
||||
Leg startLeg = new Leg(name, 0);
|
||||
startLeg.setEndCompoundMark(endCompoundMark);
|
||||
startLeg.setEndMarker(endCompoundMark);
|
||||
boat.setCurrentLeg(startLeg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ public class BoatInRace extends Boat {
|
||||
public double calculateAzimuth() {
|
||||
|
||||
GeodeticCalculator calc = new GeodeticCalculator();
|
||||
GPSCoordinate start = currentLeg.getStartCompoundMark().getAverageGPSCoordinate();
|
||||
GPSCoordinate end = currentLeg.getEndCompoundMark().getAverageGPSCoordinate();
|
||||
GPSCoordinate start = currentLeg.getStartMarker().getAverageGPSCoordinate();
|
||||
GPSCoordinate end = currentLeg.getEndMarker().getAverageGPSCoordinate();
|
||||
|
||||
calc.setStartingGeographicPoint(start.getLongitude(), start.getLatitude());
|
||||
calc.setDestinationGeographicPoint(end.getLongitude(), end.getLatitude());
|
||||
|
||||
@@ -9,8 +9,8 @@ import seng302.GPSCoordinate;
|
||||
public class Leg {
|
||||
private final String name; //nautical miles
|
||||
private double distance;
|
||||
private CompoundMark startCompoundMark;
|
||||
private CompoundMark endCompoundMark;
|
||||
private Marker startMarker;
|
||||
private Marker endMarker;
|
||||
private final int legNumber;
|
||||
// 1 nautical mile = 1852 meters
|
||||
public static final int NM_TO_METERS = 1852;
|
||||
@@ -23,10 +23,10 @@ public class Leg {
|
||||
* @param end marker
|
||||
* @param number Leg's position in race
|
||||
*/
|
||||
public Leg(String name, CompoundMark start, CompoundMark end, int number) {
|
||||
public Leg(String name, Marker start, Marker end, int number) {
|
||||
this.name = name;
|
||||
this.startCompoundMark = start;
|
||||
this.endCompoundMark = end;
|
||||
this.startMarker = start;
|
||||
this.endMarker = end;
|
||||
this.legNumber = number;
|
||||
calculateDistance();
|
||||
}
|
||||
@@ -71,20 +71,20 @@ public class Leg {
|
||||
}
|
||||
|
||||
|
||||
public CompoundMark getStartCompoundMark() {
|
||||
return startCompoundMark;
|
||||
public Marker getStartMarker() {
|
||||
return startMarker;
|
||||
}
|
||||
|
||||
public void setStartCompoundMark(CompoundMark startCompoundMark) {
|
||||
this.startCompoundMark = startCompoundMark;
|
||||
public void setStartMarker(Marker startMarker) {
|
||||
this.startMarker = startMarker;
|
||||
}
|
||||
|
||||
public CompoundMark getEndCompoundMark() {
|
||||
return endCompoundMark;
|
||||
public Marker getEndMarker() {
|
||||
return endMarker;
|
||||
}
|
||||
|
||||
public void setEndCompoundMark(CompoundMark endCompoundMark) {
|
||||
this.endCompoundMark = endCompoundMark;
|
||||
public void setEndMarker(Marker endMarker) {
|
||||
this.endMarker = endMarker;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,8 +94,8 @@ public class Leg {
|
||||
|
||||
GeodeticCalculator calc = new GeodeticCalculator();
|
||||
//Load start and end of leg
|
||||
GPSCoordinate startMarker = this.startCompoundMark.getAverageGPSCoordinate();
|
||||
GPSCoordinate endMarker = this.endCompoundMark.getAverageGPSCoordinate();
|
||||
GPSCoordinate startMarker = this.startMarker.getAverageGPSCoordinate();
|
||||
GPSCoordinate endMarker = this.endMarker.getAverageGPSCoordinate();
|
||||
calc.setStartingGeographicPoint(startMarker.getLongitude(), startMarker.getLatitude());
|
||||
calc.setDestinationGeographicPoint(endMarker.getLongitude(), endMarker.getLatitude());
|
||||
this.distance = calc.getOrthodromicDistance() / NM_TO_METERS;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package seng302;
|
||||
|
||||
import seng302.Model.Boat;
|
||||
import seng302.Model.CompoundMark;
|
||||
import seng302.Model.Leg;
|
||||
import seng302.Model.Marker;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
public interface RaceDataSource {
|
||||
List<Boat> getBoats();
|
||||
List<Leg> getLegs();
|
||||
List<CompoundMark> getMarkers();
|
||||
List<Marker> getMarkers();
|
||||
List<GPSCoordinate> getBoundary();
|
||||
|
||||
ZonedDateTime getZonedDateTime();
|
||||
|
||||
@@ -89,10 +89,10 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
||||
for (int i = 0; i < nLegs.getLength(); i++) {
|
||||
String label = getTextValueOfNode((Element) nLegs.item(i), "name");
|
||||
NodeList start = ((Element) nLegs.item(i)).getElementsByTagName("start");
|
||||
CompoundMark startCompoundMark = getMarker(start);
|
||||
Marker startMarker = getMarker(start);
|
||||
NodeList finish = ((Element) nLegs.item(i)).getElementsByTagName("finish");
|
||||
CompoundMark finishCompoundMark = getMarker(finish);
|
||||
legs.add(new Leg(label, startCompoundMark, finishCompoundMark, i));
|
||||
Marker finishMarker = getMarker(finish);
|
||||
legs.add(new Leg(label, startMarker, finishMarker, 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>
|
||||
* @return
|
||||
*/
|
||||
private CompoundMark getMarker(NodeList start) {
|
||||
private Marker getMarker(NodeList start) {
|
||||
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
|
||||
* @return
|
||||
*/
|
||||
private CompoundMark getMarker(NodeList start, int startIndex) {
|
||||
private Marker getMarker(NodeList start, int startIndex) {
|
||||
return getMarker(start, startIndex, 0);
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
||||
* @param nodeIndex coordinate index
|
||||
* @return
|
||||
*/
|
||||
private CompoundMark getMarker(NodeList start, int startIndex, int nodeIndex) {
|
||||
private Marker getMarker(NodeList start, int startIndex, int nodeIndex) {
|
||||
NodeList nodeList = ((Element) start.item(startIndex)).getElementsByTagName("marker");
|
||||
Element marker = (Element) nodeList.item(nodeIndex);
|
||||
return getMarker(marker);
|
||||
@@ -204,7 +204,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
||||
* @param markerNode marker to turn into coordinates
|
||||
* @return
|
||||
*/
|
||||
private CompoundMark getMarker(Element markerNode) {
|
||||
private Marker getMarker(Element markerNode) {
|
||||
|
||||
NodeList nCoordinates = markerNode.getElementsByTagName("coordinate");
|
||||
|
||||
@@ -215,7 +215,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
||||
} else {
|
||||
side2 = side1;
|
||||
}
|
||||
return new CompoundMark(side1, side2);
|
||||
return new Marker(side1, side2);
|
||||
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CompoundMark> getMarkers() {
|
||||
public List<Marker> getMarkers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user