Small fixes

This commit is contained in:
Nazar 2019-11-28 10:18:13 +02:00
parent c0c7254930
commit 36c9e2a2e4
4 changed files with 10 additions and 8 deletions

View file

@ -187,7 +187,7 @@ public class GPXUtilities {
public double ele = Double.NaN;
public double speed = 0;
public double hdop = Double.NaN;
public float heading = -1.0f;
public float heading = Float.NaN;
public boolean deleted = false;
public int colourARGB = 0; // point colour (used for altitude/speed colouring)
public double distance = 0.0; // cumulative distance, if in a track
@ -1617,7 +1617,7 @@ public class GPXUtilities {
p.getExtensionsToWrite().put("speed", decimalFormat.format(p.speed));
}
if (p.heading >= 0) {
p.getExtensionsToWrite().put("heading", decimalFormat.format(p.heading));
p.getExtensionsToWrite().put("heading", String.valueOf(Math.round(p.heading)));
}
writeExtensions(serializer, p);
}

View file

@ -411,7 +411,7 @@ public class MapUtils {
return rotate;
}
public static float formatDegrees360(float degrees) {
public static float normalizeDegrees360(float degrees) {
while (degrees < 0.0f) {
degrees += 360.0f;
}

View file

@ -771,7 +771,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
if (continuous) {
scheduleCheckIfGpsLost(location);
}
app.getSavingTrackHelper().updateLocation(location, app.getLocationProvider().heading);
app.getSavingTrackHelper().updateLocation(location, heading);
OsmandPlugin.updateLocationPlugins(location);
app.getRoutingHelper().updateLocation(location);
app.getWaypointHelper().locationChanged(location);
@ -797,7 +797,7 @@ public class OsmAndLocationProvider implements SensorEventListener {
final RoutingHelper routingHelper = app.getRoutingHelper();
// 1. Logging services
if (location != null) {
app.getSavingTrackHelper().updateLocation(location, app.getLocationProvider().heading);
app.getSavingTrackHelper().updateLocation(location, heading);
OsmandPlugin.updateLocationPlugins(location);
}

View file

@ -56,6 +56,8 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
public final static String POINT_COL_CATEGORY = "category"; //$NON-NLS-1$
public final static String POINT_COL_DESCRIPTION = "description"; //$NON-NLS-1$
public final static String POINT_COL_COLOR = "color"; //$NON-NLS-1$
public final static float DEFAULT_DEGREES = -1.0f;
public final static Log log = PlatformUtil.getLog(SavingTrackHelper.class);
@ -409,7 +411,7 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
public void startNewSegment() {
lastTimeUpdated = 0;
lastPoint = null;
execWithClose(updateScript, new Object[] { 0, 0, 0, 0, 0, System.currentTimeMillis(), -1.0f});
execWithClose(updateScript, new Object[] { 0, 0, 0, 0, 0, System.currentTimeMillis(), DEFAULT_DEGREES});
addTrackPoint(null, true, System.currentTimeMillis());
}
@ -418,9 +420,9 @@ public class SavingTrackHelper extends SQLiteOpenHelper {
long locationTime = System.currentTimeMillis();
OsmandSettings settings = ctx.getSettings();
if (heading != null && settings.CALCULATE_HEADING.get()) {
heading = MapUtils.formatDegrees360(heading);
heading = MapUtils.normalizeDegrees360(heading);
} else {
heading = -1.0f;
heading = DEFAULT_DEGREES;
}
boolean record = false;
if (location != null && OsmAndLocationProvider.isNotSimulatedLocation(location)) {