add 360 degree setting

fixes for rounding azimuth results
This commit is contained in:
madwasp79 2019-07-09 15:46:32 +03:00
parent 49285e49a0
commit 3efc5519ae
3 changed files with 25 additions and 5 deletions

View file

@ -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 azimuth + AngularConstants.DEGREES.getUnitSymbol();
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 Math.round(bearing) + AngularConstants.DEGREES.getUnitSymbol();
}
}

View file

@ -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;

View file

@ -213,8 +213,14 @@ public class SettingsGeneralActivity extends SettingsBaseActivity implements OnR
AngularConstants[] ac = AngularConstants.values();
entries = new String[ac.length];
for (int i = 0; i < entries.length; i++) {
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);
// See language list and statistics at: https://hosted.weblate.org/projects/osmand/main/