Merge branch 'story9' of https://eng-git.canterbury.ac.nz/seng302-2017/team-7 into story9
This commit is contained in:
@@ -20,7 +20,6 @@ public class BoatInRace extends Boat {
|
||||
private long timeFinished;
|
||||
private Color colour;
|
||||
private boolean finished = false;
|
||||
private StringProperty currentLegName;
|
||||
|
||||
/**
|
||||
* Constructor method.
|
||||
@@ -31,7 +30,6 @@ public class BoatInRace extends Boat {
|
||||
public BoatInRace(String name, double velocity, Color colour, String abbrev) {
|
||||
super(name, velocity, abbrev);
|
||||
setColour(colour);
|
||||
currentLegName = new SimpleStringProperty("");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,10 +90,14 @@ public class BoatInRace extends Boat {
|
||||
*/
|
||||
public void setCurrentLeg(Leg currentLeg) {
|
||||
this.currentLeg = currentLeg;
|
||||
this.currentLegName.setValue(currentLeg.getName());
|
||||
}
|
||||
|
||||
public StringProperty getCurrentLegName(){
|
||||
|
||||
StringProperty currentLegName = new SimpleStringProperty("");
|
||||
if (currentLeg != null) {
|
||||
currentLegName.setValue(currentLeg.getName());
|
||||
}
|
||||
return currentLegName;
|
||||
}
|
||||
|
||||
@@ -132,19 +134,39 @@ public class BoatInRace extends Boat {
|
||||
this.finished = bool;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the bearing of the travel via map coordinates of the raceMarkers
|
||||
* @return the heading that the boat is heading towards in degrees.
|
||||
* Calculates the azimuth of the travel via map coordinates of the raceMarkers
|
||||
* @return the direction that the boat is heading towards in degrees (-180 to 180).
|
||||
*/
|
||||
public double calculateAzimuth(){
|
||||
//to be changed to coordinates when used to match reality.
|
||||
|
||||
GeodeticCalculator calc = new GeodeticCalculator();
|
||||
calc.setStartingGeographicPoint(currentLeg.getStartGraphCoordinate().getLongitude(), currentLeg.getStartGraphCoordinate().getLatitude());
|
||||
calc.setDestinationGeographicPoint(currentLeg.getEndGraphCoordinate().getLongitude(), currentLeg.getEndGraphCoordinate().getLatitude());
|
||||
|
||||
return calc.getAzimuth();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an azimuth to a bearing
|
||||
* @param azimuth azimuth valuye to be converted
|
||||
* @return the bearings in degrees (0 to 360).
|
||||
*/
|
||||
public static double calculateHeading(double azimuth) {
|
||||
if (azimuth >= 0) {
|
||||
return azimuth;
|
||||
}
|
||||
else {
|
||||
return azimuth + 360;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the bearing of the travel via map coordinates of the raceMarkers
|
||||
* @return the direction that the boat is heading towards in degrees (0 to 360).
|
||||
*/
|
||||
public double calculateHeading(){
|
||||
double azimuth = this.calculateAzimuth();
|
||||
return calculateHeading(azimuth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.ArrayList;
|
||||
* Created by cbt24 on 6/03/17.
|
||||
*/
|
||||
public class ConstantVelocityRace extends Race {
|
||||
|
||||
/**
|
||||
* Initialiser for a Race with constant velocity.
|
||||
* @param startingBoats array of boats
|
||||
|
||||
@@ -55,15 +55,6 @@ public class Leg {
|
||||
return distance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Returns the name of the Leg
|
||||
*/
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the coordinates in GPSCoordinate class of the boats starting coordinate.
|
||||
* @return Returns the coordinate of the start of the leg.
|
||||
@@ -101,5 +92,6 @@ public class Leg {
|
||||
calc.setStartingGeographicPoint(startGPSCoordinate.getLongitude(), startGPSCoordinate.getLatitude());
|
||||
calc.setDestinationGeographicPoint(endGPSCoordinate.getLongitude(), endGPSCoordinate.getLatitude());
|
||||
return calc.getOrthodromicDistance() / Constants.NMToMetersConversion;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package seng302.Model;
|
||||
|
||||
import com.sun.xml.internal.bind.v2.runtime.reflect.opt.Const;
|
||||
|
||||
import javafx.scene.canvas.Canvas;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.paint.Color;
|
||||
@@ -11,9 +11,6 @@ import seng302.GPSCoordinate;
|
||||
import seng302.GraphCoordinate;
|
||||
import seng302.RaceMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* This creates a JavaFX Canvas that is fills it's parent.
|
||||
* Cannot be downsized.
|
||||
|
||||
Reference in New Issue
Block a user