@Test public void gprmcEncode_LatLongAccuracy() { Location loc = MockLocations.builder("GPS", 51.3579941, -0.1952438).withTime(1457205869949l).withAccuracy(20).build(); SerializableLocation sloc = new SerializableLocation(loc); PreferenceHelper pm = mock(PreferenceHelper.class); OpenGTSManager client = new OpenGTSManager(pm); assertThat("GPRMC generated", client.gprmcEncode(sloc) , is("$GPRMC,192429,A,5121.47965,N,011.71463,W,0.000000,0.000000,050316,,*02")); }
public static String gprmcEncode(SerializableLocation loc) { DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US); DecimalFormat f = new DecimalFormat("0.000000", dfs); String gprmc = String.format("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,,", "$GPRMC", getNmeaGprmcTime(new Date(loc.getTime())), "A", getNmeaGprmcCoordinates(Math.abs(loc.getLatitude())), (loc.getLatitude() >= 0) ? "N" : "S", getNmeaGprmcCoordinates(Math.abs(loc.getLongitude())), (loc.getLongitude() >= 0) ? "E" : "W", f.format(Maths.mpsToKnots(loc.getSpeed())), f.format(loc.getBearing()), getNmeaGprmcDate(new Date(loc.getTime())) ); gprmc += "*" + getNmeaChecksum(gprmc); return gprmc; }
OpenGTSManager extends FileSender { public static String gprmcEncode(SerializableLocation loc) { DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US); DecimalFormat f = new DecimalFormat("0.000000", dfs); String gprmc = String.format("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,,", "$GPRMC", getNmeaGprmcTime(new Date(loc.getTime())), "A", getNmeaGprmcCoordinates(Math.abs(loc.getLatitude())), (loc.getLatitude() >= 0) ? "N" : "S", getNmeaGprmcCoordinates(Math.abs(loc.getLongitude())), (loc.getLongitude() >= 0) ? "E" : "W", f.format(Maths.mpsToKnots(loc.getSpeed())), f.format(loc.getBearing()), getNmeaGprmcDate(new Date(loc.getTime())) ); gprmc += "*" + getNmeaChecksum(gprmc); return gprmc; } }
OpenGTSManager extends FileSender { public static String gprmcEncode(SerializableLocation loc) { DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US); DecimalFormat f = new DecimalFormat("0.000000", dfs); String gprmc = String.format("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,,", "$GPRMC", getNmeaGprmcTime(new Date(loc.getTime())), "A", getNmeaGprmcCoordinates(Math.abs(loc.getLatitude())), (loc.getLatitude() >= 0) ? "N" : "S", getNmeaGprmcCoordinates(Math.abs(loc.getLongitude())), (loc.getLongitude() >= 0) ? "E" : "W", f.format(Maths.mpsToKnots(loc.getSpeed())), f.format(loc.getBearing()), getNmeaGprmcDate(new Date(loc.getTime())) ); gprmc += "*" + getNmeaChecksum(gprmc); return gprmc; } OpenGTSManager(PreferenceHelper preferenceHelper);  OpenGTSManager(PreferenceHelper preferenceHelper, int batteryLevel); }
OpenGTSManager extends FileSender { public static String gprmcEncode(SerializableLocation loc) { DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US); DecimalFormat f = new DecimalFormat("0.000000", dfs); String gprmc = String.format("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,,", "$GPRMC", getNmeaGprmcTime(new Date(loc.getTime())), "A", getNmeaGprmcCoordinates(Math.abs(loc.getLatitude())), (loc.getLatitude() >= 0) ? "N" : "S", getNmeaGprmcCoordinates(Math.abs(loc.getLongitude())), (loc.getLongitude() >= 0) ? "E" : "W", f.format(Maths.mpsToKnots(loc.getSpeed())), f.format(loc.getBearing()), getNmeaGprmcDate(new Date(loc.getTime())) ); gprmc += "*" + getNmeaChecksum(gprmc); return gprmc; } OpenGTSManager(PreferenceHelper preferenceHelper);  OpenGTSManager(PreferenceHelper preferenceHelper, int batteryLevel); @Override void uploadFile(List<File> files); void sendLocations(SerializableLocation[] locations); static String gprmcEncode(SerializableLocation loc); static String getNmeaGprmcTime(Date dateToFormat); static String getNmeaGprmcDate(Date dateToFormat); static String getNmeaGprmcCoordinates(double coord); static String getNmeaChecksum(String msg); static String getUrl(String id, String accountName, SerializableLocation loc, String communication, String path, String server, int port, int batteryLevel); @Override boolean isAvailable(); @Override boolean hasUserAllowedAutoSending(); @Override boolean accept(File dir, String name); }
OpenGTSManager extends FileSender { public static String gprmcEncode(SerializableLocation loc) { DecimalFormatSymbols dfs = new DecimalFormatSymbols(Locale.US); DecimalFormat f = new DecimalFormat("0.000000", dfs); String gprmc = String.format("%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,,", "$GPRMC", getNmeaGprmcTime(new Date(loc.getTime())), "A", getNmeaGprmcCoordinates(Math.abs(loc.getLatitude())), (loc.getLatitude() >= 0) ? "N" : "S", getNmeaGprmcCoordinates(Math.abs(loc.getLongitude())), (loc.getLongitude() >= 0) ? "E" : "W", f.format(Maths.mpsToKnots(loc.getSpeed())), f.format(loc.getBearing()), getNmeaGprmcDate(new Date(loc.getTime())) ); gprmc += "*" + getNmeaChecksum(gprmc); return gprmc; } OpenGTSManager(PreferenceHelper preferenceHelper);  OpenGTSManager(PreferenceHelper preferenceHelper, int batteryLevel); @Override void uploadFile(List<File> files); void sendLocations(SerializableLocation[] locations); static String gprmcEncode(SerializableLocation loc); static String getNmeaGprmcTime(Date dateToFormat); static String getNmeaGprmcDate(Date dateToFormat); static String getNmeaGprmcCoordinates(double coord); static String getNmeaChecksum(String msg); static String getUrl(String id, String accountName, SerializableLocation loc, String communication, String path, String server, int port, int batteryLevel); @Override boolean isAvailable(); @Override boolean hasUserAllowedAutoSending(); @Override boolean accept(File dir, String name);  }