|
|
|
|
@ -7,7 +7,6 @@ import org.geotools.referencing.GeodeticCalculator;
|
|
|
|
|
import seng302.GPSCoordinate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Boat in the Race extends Boat.
|
|
|
|
|
* Created by esa46 on 15/03/17.
|
|
|
|
|
@ -25,6 +24,7 @@ public class BoatInRace extends Boat {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor method.
|
|
|
|
|
*
|
|
|
|
|
* @param name Name of the boat.
|
|
|
|
|
* @param velocity Speed that the boat travels.
|
|
|
|
|
* @param colour Colour the boat will be displayed as on the map
|
|
|
|
|
@ -35,16 +35,60 @@ public class BoatInRace extends Boat {
|
|
|
|
|
currentLegName = new SimpleStringProperty("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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() {
|
|
|
|
|
|
|
|
|
|
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 value 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Scaled velocity of the boat
|
|
|
|
|
*/
|
|
|
|
|
public double getScaledVelocity() {
|
|
|
|
|
return scaledVelocity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the boat's scaled velocity
|
|
|
|
|
* @param velocity
|
|
|
|
|
*/
|
|
|
|
|
public void setScaledVelocity(double velocity) {
|
|
|
|
|
this.scaledVelocity = velocity;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return Returns the current position of the boat in a GPSCoordinate Class.
|
|
|
|
|
* @see GPSCoordinate
|
|
|
|
|
*/
|
|
|
|
|
@ -53,7 +97,16 @@ public class BoatInRace extends Boat {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the current position on the GPS that the boat.
|
|
|
|
|
*
|
|
|
|
|
* @param position GPSCoordinate of the position that the boat is currently on.
|
|
|
|
|
* @see GPSCoordinate
|
|
|
|
|
*/
|
|
|
|
|
public void setCurrentPosition(GPSCoordinate position) {
|
|
|
|
|
this.currentPosition = position;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns the time that the boat finished the race.
|
|
|
|
|
*/
|
|
|
|
|
public long getTimeFinished() {
|
|
|
|
|
@ -61,7 +114,15 @@ public class BoatInRace extends Boat {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the time that the boat finished the race.
|
|
|
|
|
*
|
|
|
|
|
* @param timeFinished Time the boat finished the race.
|
|
|
|
|
*/
|
|
|
|
|
public void setTimeFinished(long timeFinished) {
|
|
|
|
|
this.timeFinished = timeFinished;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Returns the colour of the boat.
|
|
|
|
|
*/
|
|
|
|
|
public Color getColour() {
|
|
|
|
|
@ -70,6 +131,7 @@ public class BoatInRace extends Boat {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the colour that boat will be shown as when drawn on the ResizableRaceCanvas.
|
|
|
|
|
*
|
|
|
|
|
* @param colour Colour that the boat is to be set to.
|
|
|
|
|
* @see ResizableRaceCanvas
|
|
|
|
|
*/
|
|
|
|
|
@ -77,16 +139,9 @@ public class BoatInRace extends Boat {
|
|
|
|
|
this.colour = colour;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the time that the boat finished the race.
|
|
|
|
|
* @param timeFinished Time the boat finished the race.
|
|
|
|
|
*/
|
|
|
|
|
public void setTimeFinished(long timeFinished) {
|
|
|
|
|
this.timeFinished = timeFinished;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the current leg that the boat is on.
|
|
|
|
|
*
|
|
|
|
|
* @return returns the leg the boat is on in a Leg class
|
|
|
|
|
* @see Leg
|
|
|
|
|
*/
|
|
|
|
|
@ -95,7 +150,8 @@ public class BoatInRace extends Boat {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the current Leg of that the boat is on.
|
|
|
|
|
* Sets the boat's current leg.
|
|
|
|
|
*
|
|
|
|
|
* @param currentLeg Leg class that the boat is currently on.
|
|
|
|
|
* @see Leg
|
|
|
|
|
*/
|
|
|
|
|
@ -104,76 +160,44 @@ public class BoatInRace extends Boat {
|
|
|
|
|
this.currentLegName.setValue(currentLeg.getName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return Name of boat's current leg
|
|
|
|
|
*/
|
|
|
|
|
public StringProperty getCurrentLegName() {
|
|
|
|
|
return currentLegName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the distance travelled by the boat in the leg.
|
|
|
|
|
*
|
|
|
|
|
* @return Returns the value in nautical miles (1.852km) that the boat has traversed.
|
|
|
|
|
*/
|
|
|
|
|
public double getDistanceTravelledInLeg() {
|
|
|
|
|
return distanceTravelledInLeg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the current position on the GPS that the boat.
|
|
|
|
|
* @param position GPSCoordinate of the position that the boat is currently on.
|
|
|
|
|
* @see GPSCoordinate
|
|
|
|
|
*/
|
|
|
|
|
public void setCurrentPosition(GPSCoordinate position) {
|
|
|
|
|
this.currentPosition = position;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the distance travelled by the boat in the leg in nautical miles (1.852km)
|
|
|
|
|
*
|
|
|
|
|
* @param distanceTravelledInLeg Distance travelled by the boat in nautical miles.
|
|
|
|
|
*/
|
|
|
|
|
public void setDistanceTravelledInLeg(double distanceTravelledInLeg) {
|
|
|
|
|
this.distanceTravelledInLeg = distanceTravelledInLeg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isFinished() {
|
|
|
|
|
return this.finished;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFinished(boolean bool) {
|
|
|
|
|
this.finished = bool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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).
|
|
|
|
|
* @return true if boat has finished, fals eif not
|
|
|
|
|
*/
|
|
|
|
|
public double calculateAzimuth(){
|
|
|
|
|
|
|
|
|
|
GeodeticCalculator calc = new GeodeticCalculator();
|
|
|
|
|
calc.setStartingGeographicPoint(currentLeg.getStartGraphCoordinate().getLongitude(), currentLeg.getStartGraphCoordinate().getLatitude());
|
|
|
|
|
calc.setDestinationGeographicPoint(currentLeg.getEndGraphCoordinate().getLongitude(), currentLeg.getEndGraphCoordinate().getLatitude());
|
|
|
|
|
|
|
|
|
|
return calc.getAzimuth();
|
|
|
|
|
public boolean isFinished() {
|
|
|
|
|
return this.finished;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Converts an azimuth to a bearing
|
|
|
|
|
* @param azimuth azimuth valuye to be converted
|
|
|
|
|
* @return the bearings in degrees (0 to 360).
|
|
|
|
|
* Sets whether boat is finished or not
|
|
|
|
|
* @param bool
|
|
|
|
|
*/
|
|
|
|
|
public static double calculateHeading(double azimuth) {
|
|
|
|
|
if (azimuth >= 0) {
|
|
|
|
|
return azimuth;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return azimuth + 360;
|
|
|
|
|
}
|
|
|
|
|
public void setFinished(boolean bool) {
|
|
|
|
|
this.finished = bool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|