@ -98,7 +98,6 @@ public class BoatInRace extends Boat {
if ( currentLeg ! = null ) {
if ( currentLeg ! = null ) {
currentLegName . setValue ( currentLeg . getName ( ) ) ;
currentLegName . setValue ( currentLeg . getName ( ) ) ;
}
}
return currentLegName ;
return currentLegName ;
}
}
@ -136,17 +135,38 @@ public class BoatInRace extends Boat {
}
}
/ * *
/ * *
* Calculates the bearing of the travel via map coordinates of the raceMarkers
* Calculates the azimuth of the travel via map coordinates of the raceMarkers
* @return the hea ding that the boat is heading towards in degrees .
* @return the directio n that the boat is heading towards in degrees ( - 180 to 180 ) .
* /
* /
public double calculateAzimuth ( ) {
public double calculateAzimuth ( ) {
//to be changed to coordinates when used to match reality.
GeodeticCalculator calc = new GeodeticCalculator ( ) ;
GeodeticCalculator calc = new GeodeticCalculator ( ) ;
calc . setStartingGeographicPoint ( currentLeg . getStartGraphCoordinate ( ) . getLongitude ( ) , currentLeg . getStartGraphCoordinate ( ) . getLatitude ( ) ) ;
calc . setStartingGeographicPoint ( currentLeg . getStartGraphCoordinate ( ) . getLongitude ( ) , currentLeg . getStartGraphCoordinate ( ) . getLatitude ( ) ) ;
calc . setDestinationGeographicPoint ( currentLeg . getEndGraphCoordinate ( ) . getLongitude ( ) , currentLeg . getEndGraphCoordinate ( ) . getLatitude ( ) ) ;
calc . setDestinationGeographicPoint ( currentLeg . getEndGraphCoordinate ( ) . getLongitude ( ) , currentLeg . getEndGraphCoordinate ( ) . getLatitude ( ) ) ;
return calc . getAzimuth ( ) ;
return calc . getAzimuth ( ) ;
}
/ * *
* Converts an azimuth to a bearing
* @param azimuth azimuth valuye 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 ) ;
}
}
}