Skip to content

Commit

Permalink
Update PhysicalDataFormatter.java
Browse files Browse the repository at this point in the history
  • Loading branch information
GrazianoCapelli authored Mar 21, 2017
1 parent 9c060c0 commit 9a44ce2
Showing 1 changed file with 55 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,61 @@
import android.location.Location;

public class PhysicalDataFormatter {
private static final int UM_METRIC_MS    = 0;
private static final int UM_METRIC_KMH   = 1;
private static final int UM_IMPERIAL_FPS = 8;
private static final int UM_IMPERIAL_MPH = 9;

public static final byte FORMAT_LATITUDE = 1;
public static final byte FORMAT_LONGITUDE = 2;
public static final byte FORMAT_ALTITUDE = 3;
private static final int NOT_AVAILABLE = -100000;

private static final int UM_METRIC_MS    = 0;
private static final int UM_METRIC_KMH   = 1;
private static final int UM_IMPERIAL_FPS = 8;
private static final int UM_IMPERIAL_MPH = 9;

private static final float M_TO_FT = 3.280839895f;
private static final float MS_TO_MPH = 2.2369363f;
public static final byte FORMAT_LATITUDE = 1;
public static final byte FORMAT_LONGITUDE = 2;
public static final byte FORMAT_ALTITUDE = 3;

private static final float M_TO_FT = 3.280839895f;
private static final float MS_TO_MPH = 2.2369363f;

private PhysicalData _PhysicalData;


public PhysicalData format(long Number, byte Format) {
switch (Format) {
case FORMAT_LATITUDE:

}
}
private PhysicalData _PhysicalData;
private GPSApplication gpsApplication = GPSApplication.getInstance();

public PhysicalData format(double Number, byte Format) {
_PhysicalData.Value = "";
_PhysicalData.UM = "";

if (Number == NOT_AVAILABLE) return(_PhysicalData); // Returns empty fields if the data is not available

switch (Format) {
case FORMAT_LATITUDE: // Latitude
_PhysicalData.Value = gpsApplication.getPrefShowDecimalCoordinates() ?
String.format("%.9f", Math.abs(Number)) :
Location.convert(Math.abs(Number), Location.FORMAT_SECONDS);
_PhysicalData.UM = Number >= 0 ?
gpsApplication.getString(R.string.north) :
gpsApplication.getString(R.string.south);
break;

case FORMAT_LONGITUDE: // Longitude
_PhysicalData.Value = gpsApplication.getPrefShowDecimalCoordinates() ?
String.format("%.9f", Math.abs(Number)) :
Location.convert(Math.abs(Number), Location.FORMAT_SECONDS);
_PhysicalData.UM = Number >= 0 ?
gpsApplication.getString(R.string.east) :
gpsApplication.getString(R.string.west);
break;

case FORMAT_ALTITUDE: // Altitude
switch (gpsApplication.getPrefUM()) {
case UM_METRIC_KMH:
case UM_METRIC_MS:
_PhysicalData.Value = String.valueOf(Math.round(Number));
...
case UM_IMPERIAL_MPH:

case UM_IMPERIAL_FPS:
}
break;
}
return(_PhysicalData);
}
}
}



0 comments on commit 9a44ce2

Please sign in to comment.