@ -357,4 +357,89 @@ public class BoatLocationMessage
{
this . rudderAngle = rudderAngle ;
}
/ * *
* Converts a double representing a latitude or longitude coordinate to an int , as required by the streaming spec format .
* @param coordinate Latitude or longitude to convert . Double .
* @return int representation of coordinate .
* /
public static int convertCoordinateDoubleToInt ( double coordinate )
{
int coordinateInt = ( int ) ( ( coordinate / 180.0 ) * 2147483648.0 ) ;
return coordinateInt ;
}
/ * *
* Converts an int representing a latitude or longitude coordinate to a double , as required by the streaming spec format .
* @param coordinate Latitude or longitude to convert . int .
* @return double representation of coordinate .
* /
public static double convertCoordinateIntToDouble ( int coordinate )
{
double coordinateDouble = ( double ) ( ( coordinate * 180.0 ) / 2147483648.0 ) ;
return coordinateDouble ;
}
/ * *
* Converts an int representing a heading to a double , as required by the streaming spec format .
* @param heading Heading to convert . int .
* @return double representation of heading .
* /
public static double convertHeadingIntToDouble ( int heading )
{
double headingDouble = ( double ) ( ( heading * 360.0 ) / 65536.0 ) ;
return headingDouble ;
}
/ * *
* Converts a double representing a heading to an int , as required by the streaming spec format .
* @param heading Heading to convert . double .
* @return int representation of heading .
* /
public static int convertHeadingDoubleToInt ( double heading )
{
int headingInt = ( int ) ( ( heading / 360.0 ) * 65536.0 ) ;
return headingInt ;
}
/ * *
* Converts a short representing the wind ' s true angle to a double , as required by the streaming spec format .
* @param angle Angle to convert . short .
* @return double representation of heading .
* /
public static double convertTrueWindAngleShortToDouble ( short angle )
{
double angleDouble = ( double ) ( ( angle * 180.0 ) / 32768.0 ) ;
return angleDouble ;
}
/ * *
* Converts a double representing the wind ' s true angle to a short , as required by the streaming spec format .
* @param angle Angle to convert . double .
* @return short representation of heading .
* /
public static short convertTrueWindAngleShortToDouble ( double angle )
{
short angleShort = ( short ) ( ( angle / 180.0 ) * 32768.0 ) ;
return angleShort ;
}
}