mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Added booleans: has entered rounding zone, has crossed first line, has crossed second line
All for purposes of checking mark rounding. Currently not yet finished tags: #story[1124] #pair[hyi25, wmu16]
This commit is contained in:
@@ -28,6 +28,8 @@ public class Yacht {
|
|||||||
void notifyLocation(Yacht yacht, double lat, double lon, double heading, double velocity);
|
void notifyLocation(Yacht yacht, double lat, double lon, double heading, double velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final Double ROUNDING_DISTANCE = 15d; // TODO: 3/08/17 wmu16 - Look into this value further
|
||||||
|
|
||||||
//BOTH AFAIK
|
//BOTH AFAIK
|
||||||
private String boatType;
|
private String boatType;
|
||||||
private Integer sourceId;
|
private Integer sourceId;
|
||||||
@@ -37,9 +39,10 @@ public class Yacht {
|
|||||||
private String country;
|
private String country;
|
||||||
|
|
||||||
private Long estimateTimeAtFinish;
|
private Long estimateTimeAtFinish;
|
||||||
private Long timeTillNext;
|
private Long lastMark;
|
||||||
private Double distanceToNextMark;
|
|
||||||
private Long markRoundTime;
|
private Long markRoundTime;
|
||||||
|
private Double distanceToNextMark;
|
||||||
|
private Long timeTillNext;
|
||||||
private CompoundMark nextMark;
|
private CompoundMark nextMark;
|
||||||
private Double heading;
|
private Double heading;
|
||||||
private Integer legNumber = 0;
|
private Integer legNumber = 0;
|
||||||
@@ -51,6 +54,11 @@ public class Yacht {
|
|||||||
private GeoPoint location;
|
private GeoPoint location;
|
||||||
private Integer boatStatus;
|
private Integer boatStatus;
|
||||||
private Double velocity;
|
private Double velocity;
|
||||||
|
//MARK ROUNDING INFO
|
||||||
|
private GeoPoint lastLocation; //For purposes of mark rounding calculations
|
||||||
|
private Boolean hasEnteredRoundingZone; //The distance that the boat must be from the mark to round
|
||||||
|
private Boolean hasPassedFirstLine; //The line extrapolated from the next mark to the current mark
|
||||||
|
private Boolean hasPassedSecondLine; //The line extrapolated from the last mark to the current mark
|
||||||
|
|
||||||
//CLIENT SIDE
|
//CLIENT SIDE
|
||||||
private List<YachtLocationListener> locationListeners = new ArrayList<>();
|
private List<YachtLocationListener> locationListeners = new ArrayList<>();
|
||||||
@@ -71,8 +79,13 @@ public class Yacht {
|
|||||||
this.country = country;
|
this.country = country;
|
||||||
this.sailIn = false;
|
this.sailIn = false;
|
||||||
this.location = new GeoPoint(57.670341, 11.826856);
|
this.location = new GeoPoint(57.670341, 11.826856);
|
||||||
|
this.lastLocation = location;
|
||||||
this.heading = 120.0; //In degrees
|
this.heading = 120.0; //In degrees
|
||||||
this.velocity = 0d; //in mms-1
|
this.velocity = 0d; //in mms-1
|
||||||
|
|
||||||
|
this.hasEnteredRoundingZone = false;
|
||||||
|
this.hasPassedFirstLine = false;
|
||||||
|
this.hasPassedSecondLine = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -108,9 +121,16 @@ public class Yacht {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Double metersCovered = velocity * secondsElapsed;
|
//UPDATE BOAT LOCATION
|
||||||
location = GeoUtility.getGeoCoordinate(location, heading, metersCovered);
|
location = GeoUtility.getGeoCoordinate(location, heading, velocity * secondsElapsed);
|
||||||
|
|
||||||
|
//CHECK FOR MARK ROUNDING
|
||||||
distanceToNextMark = calcDistanceToNextMark();
|
distanceToNextMark = calcDistanceToNextMark();
|
||||||
|
if (distanceToNextMark < ROUNDING_DISTANCE) {
|
||||||
|
hasEnteredRoundingZone = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: 3/08/17 wmu16 - Implement line cross check here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -345,20 +365,21 @@ public class Yacht {
|
|||||||
return nextMark;
|
return nextMark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getLat() {
|
public GeoPoint getLocation() {
|
||||||
return location.getLat();
|
return location;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLat(Double lat) {
|
/**
|
||||||
|
* Sets the current location of the boat in lat and long whilst preserving the last location
|
||||||
|
*
|
||||||
|
* @param lat Latitude
|
||||||
|
* @param lng Longitude
|
||||||
|
*/
|
||||||
|
public void setLocation(Double lat, Double lng) {
|
||||||
|
lastLocation.setLat(location.getLat());
|
||||||
|
lastLocation.setLng(location.getLng());
|
||||||
location.setLat(lat);
|
location.setLat(lat);
|
||||||
}
|
location.setLng(lng);
|
||||||
|
|
||||||
public Double getLon() {
|
|
||||||
return location.getLng();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLon(Double lon) {
|
|
||||||
location.setLng(lon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getHeading() {
|
public Double getHeading() {
|
||||||
@@ -378,10 +399,6 @@ public class Yacht {
|
|||||||
return boatName;
|
return boatName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeoPoint getLocation() {
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateTimeSinceLastMarkProperty(long timeSinceLastMark) {
|
public void updateTimeSinceLastMarkProperty(long timeSinceLastMark) {
|
||||||
this.timeSinceLastMarkProperty.set(timeSinceLastMark);
|
this.timeSinceLastMarkProperty.set(timeSinceLastMark);
|
||||||
}
|
}
|
||||||
@@ -416,14 +433,13 @@ public class Yacht {
|
|||||||
return distanceToNextMark;
|
return distanceToNextMark;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLocation (double lat, double lon, double heading, double velocity) {
|
public void updateLocation(double lat, double lng, double heading, double velocity) {
|
||||||
location.setLat(lat);
|
setLocation(lat, lng);
|
||||||
location.setLng(lon);
|
|
||||||
this.heading = heading;
|
this.heading = heading;
|
||||||
this.velocity = velocity;
|
this.velocity = velocity;
|
||||||
updateVelocityProperty(velocity);
|
updateVelocityProperty(velocity);
|
||||||
for (YachtLocationListener yll : locationListeners) {
|
for (YachtLocationListener yll : locationListeners) {
|
||||||
yll.notifyLocation(this, lat, lon, heading, velocity);
|
yll.notifyLocation(this, lat, lng, heading, velocity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ public class GeoUtility {
|
|||||||
return new GeoPoint(Math.toDegrees(endLat), Math.toDegrees(endLng));
|
return new GeoPoint(Math.toDegrees(endLat), Math.toDegrees(endLng));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs the line function on two points of a line and a test point to test which side of the line that point is
|
* Performs the line function on two points of a line and a test point to test which side of the line that point is
|
||||||
* on. If the return value is
|
* on. If the return value is
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ public class YachtTest {
|
|||||||
"HaomingIsOk",
|
"HaomingIsOk",
|
||||||
"NZL");
|
"NZL");
|
||||||
|
|
||||||
yacht.setLat(57.670333);
|
yacht.setLocation(57.670333, 11.827833);
|
||||||
yacht.setLon(11.827833);
|
|
||||||
|
|
||||||
compoundMark = new CompoundMark(0, "HaomingsMark");
|
compoundMark = new CompoundMark(0, "HaomingsMark");
|
||||||
Mark subMark1 = new Mark("H", 57.671524, 11.844495, 0);
|
Mark subMark1 = new Mark("H", 57.671524, 11.844495, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user