diff --git a/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java b/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java index 1171fd6b..9bacd840 100644 --- a/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java +++ b/mock/src/main/java/seng302/RaceEventMessages/BoatLocationMessage.java @@ -23,6 +23,21 @@ public class BoatLocationMessage ///Device type of the message (physical source of the message). private byte deviceType; + public static final byte Unknown = 0; + public static final byte RacingYacht = 1; + public static final byte CommitteeBoat = 2; + public static final byte Mark = 3; + public static final byte Pin = 4; + public static final byte ChaseBoat = 5; + public static final byte MedicalBoat = 6; + public static final byte MarshallBoat = 7; + public static final byte UmpireBoat = 8; + public static final byte UmpireSoftwareApplication = 9; + public static final byte PrincipalRaceOfficerApplication = 10; + public static final byte WeatherStation = 11; + public static final byte Helicopter = 12; + public static final byte DataProcessingApplication = 13; + ///Latitude of the boat. private int latitude; @@ -74,7 +89,7 @@ public class BoatLocationMessage /** - * Ctor. + * Ctor. Default. */ public BoatLocationMessage() { @@ -132,7 +147,7 @@ public class BoatLocationMessage //Getters and setters for message properties. - + public byte getMessageVersionNumber() { return messageVersionNumber; @@ -342,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; + } + }