Skip to content

Commit

Permalink
#67 Trim the locations in the CSV log file to 6 decimal places
Browse files Browse the repository at this point in the history
  • Loading branch information
christianrowlands committed Jan 2, 2025
1 parent 92f8aa9 commit 6fa5440
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ private String[] convertToObjectArray(BluetoothRecord record)

return new String[]{
data.getDeviceTime(),
String.valueOf(data.getLatitude()),
String.valueOf(data.getLongitude()),
trimToSixDecimalPlaces(data.getLatitude()),
trimToSixDecimalPlaces(data.getLongitude()),
String.valueOf(data.getAltitude()),
String.valueOf(data.getSpeed()),
String.valueOf(data.getAccuracy()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ private String[] convertToObjectArray(CdmaRecord record)

return new String[]{
data.getDeviceTime(),
String.valueOf(data.getLatitude()),
String.valueOf(data.getLongitude()),
trimToSixDecimalPlaces(data.getLatitude()),
trimToSixDecimalPlaces(data.getLongitude()),
String.valueOf(data.getAltitude()),
String.valueOf(data.getSpeed()),
String.valueOf(data.getAccuracy()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.atomic.AtomicInteger;

import timber.log.Timber;
Expand Down Expand Up @@ -425,4 +426,15 @@ public void reset()
recordCount.set(0);
}
}

/**
* Trims a double (location) to six decimal places.
*
* @param value The double to trim.
* @return The trimmed double as a string.
*/
String trimToSixDecimalPlaces(double value)
{
return String.format(Locale.getDefault(), "%.6f", value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ private String[] convertToObjectArray(DeviceStatus record)

return new String[]{
data.getDeviceTime(),
String.valueOf(data.getLatitude()),
String.valueOf(data.getLongitude()),
trimToSixDecimalPlaces(data.getLatitude()),
trimToSixDecimalPlaces(data.getLongitude()),
String.valueOf(data.getAltitude()),
String.valueOf(data.getSpeed()),
String.valueOf(data.getAccuracy()),
data.hasBatteryLevelPercent() ? String.valueOf(data.getBatteryLevelPercent().getValue()) : "",

hasGnssLocation ? String.valueOf(gnssLatitude) : "",
hasGnssLocation ? String.valueOf(gnssLongitude) : "",
hasGnssLocation ? trimToSixDecimalPlaces(gnssLatitude) : "",
hasGnssLocation ? trimToSixDecimalPlaces(gnssLongitude) : "",
hasGnssLocation ? String.valueOf(data.getGnssAltitude()) : "",
hasGnssLocation ? String.valueOf(data.getGnssAccuracy()) : "",

hasNetworkLocation ? String.valueOf(networkLatitude) : "",
hasNetworkLocation ? String.valueOf(networkLongitude) : "",
hasNetworkLocation ? trimToSixDecimalPlaces(networkLatitude) : "",
hasNetworkLocation ? trimToSixDecimalPlaces(networkLongitude) : "",
hasNetworkLocation ? String.valueOf(data.getNetworkAltitude()) : "",
hasNetworkLocation ? String.valueOf(data.getNetworkAccuracy()) : "",
data.getDeviceSerialNumber()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ private String[] convertToObjectArray(GnssRecord record)

return new String[]{
data.getDeviceTime(),
String.valueOf(data.getLatitude()),
String.valueOf(data.getLongitude()),
trimToSixDecimalPlaces(data.getLatitude()),
trimToSixDecimalPlaces(data.getLongitude()),
String.valueOf(data.getAltitude()),
String.valueOf(data.getSpeed()),
String.valueOf(data.getAccuracy()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ private String[] convertToObjectArray(GsmRecord record)

return new String[]{
data.getDeviceTime(),
String.valueOf(data.getLatitude()),
String.valueOf(data.getLongitude()),
trimToSixDecimalPlaces(data.getLatitude()),
trimToSixDecimalPlaces(data.getLongitude()),
String.valueOf(data.getAltitude()),
String.valueOf(data.getSpeed()),
String.valueOf(data.getAccuracy()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ private String[] convertToObjectArray(LteRecord record)

return new String[]{
data.getDeviceTime(),
String.valueOf(data.getLatitude()),
String.valueOf(data.getLongitude()),
trimToSixDecimalPlaces(data.getLatitude()),
trimToSixDecimalPlaces(data.getLongitude()),
String.valueOf(data.getAltitude()),
String.valueOf(data.getSpeed()),
String.valueOf(data.getAccuracy()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ private String[] convertToObjectArray(NrRecord record)

return new String[]{
data.getDeviceTime(),
String.valueOf(data.getLatitude()),
String.valueOf(data.getLongitude()),
trimToSixDecimalPlaces(data.getLatitude()),
trimToSixDecimalPlaces(data.getLongitude()),
String.valueOf(data.getAltitude()),
String.valueOf(data.getSpeed()),
String.valueOf(data.getAccuracy()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ private String[] convertToObjectArray(PhoneState record)

return new String[]{
data.getDeviceTime(),
String.valueOf(data.getLatitude()),
String.valueOf(data.getLongitude()),
trimToSixDecimalPlaces(data.getLatitude()),
trimToSixDecimalPlaces(data.getLongitude()),
String.valueOf(data.getAltitude()),
String.valueOf(data.getSpeed()),
String.valueOf(data.getAccuracy()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ private String[] convertToObjectArray(UmtsRecord record)

return new String[]{
data.getDeviceTime(),
String.valueOf(data.getLatitude()),
String.valueOf(data.getLongitude()),
trimToSixDecimalPlaces(data.getLatitude()),
trimToSixDecimalPlaces(data.getLongitude()),
String.valueOf(data.getAltitude()),
String.valueOf(data.getSpeed()),
String.valueOf(data.getAccuracy()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ private String[] convertToObjectArray(WifiRecordWrapper wrapper)

return new String[]{
data.getDeviceTime(),
String.valueOf(data.getLatitude()),
String.valueOf(data.getLongitude()),
trimToSixDecimalPlaces(data.getLatitude()),
trimToSixDecimalPlaces(data.getLongitude()),
String.valueOf(data.getAltitude()),
String.valueOf(data.getSpeed()),
String.valueOf(data.getAccuracy()),
Expand Down

0 comments on commit 6fa5440

Please sign in to comment.