Fixed nullpointer when boat passes finish line.
- Added a condition in calculateBearingToNextMethod to avoid nullpointer
This commit is contained in:
@@ -75,7 +75,15 @@ public class MockBoat extends Boat {
|
|||||||
|
|
||||||
//Get the start and end points.
|
//Get the start and end points.
|
||||||
GPSCoordinate currentPosition = this.getCurrentPosition();
|
GPSCoordinate currentPosition = this.getCurrentPosition();
|
||||||
GPSCoordinate nextMarkerPosition = this.getCurrentLeg().getEndCompoundMark().getAverageGPSCoordinate();
|
GPSCoordinate nextMarkerPosition;
|
||||||
|
|
||||||
|
// if boat is at the finish
|
||||||
|
if (this.getCurrentLeg().getEndCompoundMark() == null) {
|
||||||
|
nextMarkerPosition = currentPosition;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nextMarkerPosition = this.getCurrentLeg().getEndCompoundMark().getAverageGPSCoordinate();
|
||||||
|
}
|
||||||
|
|
||||||
//Calculate bearing.
|
//Calculate bearing.
|
||||||
Bearing bearing = GPSCoordinate.calculateBearing(currentPosition, nextMarkerPosition);
|
Bearing bearing = GPSCoordinate.calculateBearing(currentPosition, nextMarkerPosition);
|
||||||
|
|||||||
Reference in New Issue
Block a user