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:
William Muir
2017-08-03 17:39:07 +12:00
parent 423f1acdb6
commit 874cdec654
3 changed files with 43 additions and 27 deletions
+39 -23
View File
@@ -28,6 +28,8 @@ public class Yacht {
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
private String boatType;
private Integer sourceId;
@@ -37,9 +39,10 @@ public class Yacht {
private String country;
private Long estimateTimeAtFinish;
private Long timeTillNext;
private Double distanceToNextMark;
private Long lastMark;
private Long markRoundTime;
private Double distanceToNextMark;
private Long timeTillNext;
private CompoundMark nextMark;
private Double heading;
private Integer legNumber = 0;
@@ -51,6 +54,11 @@ public class Yacht {
private GeoPoint location;
private Integer boatStatus;
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
private List<YachtLocationListener> locationListeners = new ArrayList<>();
@@ -71,8 +79,13 @@ public class Yacht {
this.country = country;
this.sailIn = false;
this.location = new GeoPoint(57.670341, 11.826856);
this.lastLocation = location;
this.heading = 120.0; //In degrees
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;
location = GeoUtility.getGeoCoordinate(location, heading, metersCovered);
//UPDATE BOAT LOCATION
location = GeoUtility.getGeoCoordinate(location, heading, velocity * secondsElapsed);
//CHECK FOR MARK ROUNDING
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;
}
public Double getLat() {
return location.getLat();
public GeoPoint getLocation() {
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);
}
public Double getLon() {
return location.getLng();
}
public void setLon(Double lon) {
location.setLng(lon);
location.setLng(lng);
}
public Double getHeading() {
@@ -378,10 +399,6 @@ public class Yacht {
return boatName;
}
public GeoPoint getLocation() {
return location;
}
public void updateTimeSinceLastMarkProperty(long timeSinceLastMark) {
this.timeSinceLastMarkProperty.set(timeSinceLastMark);
}
@@ -416,14 +433,13 @@ public class Yacht {
return distanceToNextMark;
}
public void updateLocation (double lat, double lon, double heading, double velocity) {
location.setLat(lat);
location.setLng(lon);
public void updateLocation(double lat, double lng, double heading, double velocity) {
setLocation(lat, lng);
this.heading = heading;
this.velocity = velocity;
updateVelocityProperty(velocity);
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));
}
/**
* 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
+1 -2
View File
@@ -31,8 +31,7 @@ public class YachtTest {
"HaomingIsOk",
"NZL");
yacht.setLat(57.670333);
yacht.setLon(11.827833);
yacht.setLocation(57.670333, 11.827833);
compoundMark = new CompoundMark(0, "HaomingsMark");
Mark subMark1 = new Mark("H", 57.671524, 11.844495, 0);