add 360 degree setting
fixes for rounding azimuth results
This commit is contained in:
parent
49285e49a0
commit
3efc5519ae
3 changed files with 25 additions and 5 deletions
|
@ -40,6 +40,8 @@ public class OsmAndFormatter {
|
|||
private static final SimpleDateFormat SIMPLE_TIME_OF_DAY_FORMAT = new SimpleDateFormat("HH:mm", Locale.getDefault());
|
||||
private static final String[] localDaysStr = getLettersStringArray(DateFormatSymbols.getInstance().getShortWeekdays(), 3);
|
||||
|
||||
public static final float MILS_IN_DEGREE = 17.777778f;
|
||||
|
||||
public static final int FORMAT_DEGREES_SHORT = 6;
|
||||
public static final int FORMAT_DEGREES = LocationConvert.FORMAT_DEGREES;
|
||||
public static final int FORMAT_MINUTES = LocationConvert.FORMAT_MINUTES;
|
||||
|
@ -195,12 +197,23 @@ public class OsmAndFormatter {
|
|||
while(bearing > 360.0) {
|
||||
bearing -= 360;
|
||||
}
|
||||
int azimuth = (int) bearing;
|
||||
|
||||
if (app.getSettings().ANGULAR_UNITS.get() == AngularConstants.MILLIRADS) {
|
||||
return (int) (azimuth * 17.4533) + " " + AngularConstants.MILLIRADS.getUnitSymbol();
|
||||
if (bearing < 0) {
|
||||
return Math.round((360 + bearing) * MILS_IN_DEGREE) + " " + AngularConstants.MILLIRADS.getUnitSymbol();
|
||||
} else {
|
||||
return Math.round(bearing * MILS_IN_DEGREE) + " " + AngularConstants.MILLIRADS.getUnitSymbol();
|
||||
}
|
||||
} else if (app.getSettings().ANGULAR_UNITS.get() == AngularConstants.DEGREES360) {
|
||||
if (bearing < -0.5) {
|
||||
return (360 + Math.round(bearing)) + AngularConstants.DEGREES360.getUnitSymbol();
|
||||
} else if (bearing >= -0.5 && bearing < 0) {
|
||||
return 0 + AngularConstants.DEGREES360.getUnitSymbol();
|
||||
} else {
|
||||
return Math.round(bearing) + AngularConstants.DEGREES360.getUnitSymbol();
|
||||
}
|
||||
} else {
|
||||
return azimuth + AngularConstants.DEGREES.getUnitSymbol();
|
||||
return Math.round(bearing) + AngularConstants.DEGREES.getUnitSymbol();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2967,6 +2967,7 @@ public class OsmandSettings {
|
|||
|
||||
public enum AngularConstants {
|
||||
DEGREES(R.string.shared_string_degrees, "°"),
|
||||
DEGREES360(R.string.shared_string_degrees, "°"),
|
||||
MILLIRADS(R.string.shared_string_milliradians, "mil");
|
||||
|
||||
private final int key;
|
||||
|
|
|
@ -213,7 +213,13 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
|
|||
AngularConstants[] ac = AngularConstants.values();
|
||||
entries = new String[ac.length];
|
||||
for (int i = 0; i < entries.length; i++) {
|
||||
entries[i] = ac[i].toHumanString(getMyApplication());
|
||||
if (ac[i] == AngularConstants.DEGREES) {
|
||||
entries[i] = AngularConstants.DEGREES.toHumanString(getMyApplication()) + " 180";
|
||||
} else if (ac [i] == AngularConstants.DEGREES360) {
|
||||
entries[i] = AngularConstants.DEGREES.toHumanString(getMyApplication()) + " 360";
|
||||
} else {
|
||||
entries[i] = ac[i].toHumanString(getMyApplication());
|
||||
}
|
||||
}
|
||||
registerListPreference(settings.ANGULAR_UNITS, screen, entries, ac);
|
||||
|
||||
|
|
Loading…
Reference in a new issue