You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
157 lines
3.8 KiB
157 lines
3.8 KiB
package seng302.Model;
|
|
|
|
import org.geotools.referencing.GeodeticCalculator;
|
|
|
|
|
|
/**
|
|
* Created by esa46 on 1/05/17.
|
|
*/
|
|
public class Boat {
|
|
private String name;
|
|
private double velocity;
|
|
private double scaledVelocity;
|
|
private String abbrev;
|
|
private int sourceID;
|
|
private Leg currentLeg;
|
|
private double distanceTravelledInLeg;
|
|
private GPSCoordinate currentPosition;
|
|
private long timeFinished = -1;
|
|
private boolean started = false;
|
|
private double heading;
|
|
|
|
/**
|
|
* Boat initialiser which keeps all of the information of the boat.
|
|
*
|
|
* @param name Name of the Boat.
|
|
* @param velocity Speed in m/s that the boat travels at.
|
|
* @param abbrev nam abbreviation
|
|
* @param sourceID id of boat
|
|
*/
|
|
public Boat(String name, double velocity, String abbrev, int sourceID) {
|
|
this.velocity = velocity;
|
|
this.abbrev = abbrev;
|
|
this.name = name;
|
|
this.sourceID = sourceID;
|
|
}
|
|
|
|
/**
|
|
* 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();
|
|
GPSCoordinate start = currentLeg.getStartMarker().getAverageGPSCoordinate();
|
|
GPSCoordinate end = currentLeg.getEndMarker().getAverageGPSCoordinate();
|
|
|
|
calc.setStartingGeographicPoint(start.getLongitude(), start.getLatitude());
|
|
calc.setDestinationGeographicPoint(end.getLongitude(), end.getLatitude());
|
|
|
|
return calc.getAzimuth();
|
|
}
|
|
|
|
/**
|
|
* Calculate the heding depending on the calculated azimuth value
|
|
* @return The azimuth value which is greater than 0
|
|
*/
|
|
public double calculateHeading() {
|
|
double azimuth = this.calculateAzimuth();
|
|
|
|
if (azimuth >= 0) {
|
|
return azimuth;
|
|
} else {
|
|
return azimuth + 360;
|
|
}
|
|
}
|
|
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public double getVelocity() {
|
|
return velocity;
|
|
}
|
|
|
|
public void setVelocity(double velocity) {
|
|
this.velocity = velocity;
|
|
}
|
|
|
|
public double getScaledVelocity() {
|
|
return scaledVelocity;
|
|
}
|
|
|
|
public void setScaledVelocity(double scaledVelocity) {
|
|
this.scaledVelocity = scaledVelocity;
|
|
}
|
|
|
|
public String getAbbrev() {
|
|
return abbrev;
|
|
}
|
|
|
|
public void setAbbrev(String abbrev) {
|
|
this.abbrev = abbrev;
|
|
}
|
|
|
|
public int getSourceID() {
|
|
return sourceID;
|
|
}
|
|
|
|
public void setSourceID(int sourceID) {
|
|
this.sourceID = sourceID;
|
|
}
|
|
|
|
public Leg getCurrentLeg() {
|
|
return currentLeg;
|
|
}
|
|
|
|
public void setCurrentLeg(Leg currentLeg) {
|
|
this.currentLeg = currentLeg;
|
|
}
|
|
|
|
public double getDistanceTravelledInLeg() {
|
|
return distanceTravelledInLeg;
|
|
}
|
|
|
|
public void setDistanceTravelledInLeg(double distanceTravelledInLeg) {
|
|
this.distanceTravelledInLeg = distanceTravelledInLeg;
|
|
}
|
|
|
|
public GPSCoordinate getCurrentPosition() {
|
|
return currentPosition;
|
|
}
|
|
|
|
public void setCurrentPosition(GPSCoordinate currentPosition) {
|
|
this.currentPosition = currentPosition;
|
|
}
|
|
|
|
public long getTimeFinished() {
|
|
return timeFinished;
|
|
}
|
|
|
|
public void setTimeFinished(long timeFinished) {
|
|
this.timeFinished = timeFinished;
|
|
}
|
|
|
|
public boolean isStarted() {
|
|
return started;
|
|
}
|
|
|
|
public void setStarted(boolean started) {
|
|
this.started = started;
|
|
}
|
|
|
|
public double getHeading() {
|
|
return heading;
|
|
}
|
|
|
|
public void setHeading(double heading) {
|
|
this.heading = heading;
|
|
}
|
|
}
|