diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index e7f172508c..05806f1f78 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -258,8 +258,16 @@ public class SavingTrackHelper extends SQLiteOpenHelper { public void insertData(double lat, double lon, double alt, double speed, double hdop, long time, OsmandSettings settings){ if (time - lastTimeUpdated > settings.SAVE_TRACK_INTERVAL.get() * 1000) { execWithClose(updateScript, new Object[] { lat, lon, alt, speed, hdop, time }); + if (lastPoint == null || (time - lastTimeUpdated) > 180000) { + lastPoint = new LatLon(lat, lon); + } lastTimeUpdated = time; - updateDistance(lat, lon); + if ((lastPoint.getLatitude() != lat) || (lastPoint.getLongitude() != lon)) { + float[] lastInterval = new float[1]; + Location.distanceBetween(lat, lon, lastPoint.getLatitude(), lastPoint.getLongitude(), lastInterval); + distance += lastInterval[0]; + lastPoint = new LatLon(lat, lon); + } if (settings.SHOW_CURRENT_GPX_TRACK.get()) { WptPt pt = new GPXUtilities.WptPt(lat, lon, time, alt, speed, hdop); @@ -308,19 +316,4 @@ public class SavingTrackHelper extends SQLiteOpenHelper { return OsmAndFormatter.getFormattedDistance(distance, map); } - private void updateDistance (double lat, double lon) { - if (lastPoint == null) { - lastPoint = new LatLon(lat, lon); - } - double lastLat = lastPoint.getLatitude(); - double lastLon = lastPoint.getLongitude(); - if ((lat == lastLat) && (lon == lastLon)) { - return; - } else { - float[] lastInterval = new float[1]; - Location.distanceBetween(lat, lon, lastLat, lastLon, lastInterval); - distance += lastInterval[0]; - lastPoint = new LatLon(lat, lon); - } - } } diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index 87ec9dfffd..3a689824c0 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -671,7 +671,7 @@ public class RouteCalculationResult { while(aInfo < alarmInfo.size()) { AlarmInfo inf = alarmInfo.get(aInfo); int d = dist - listDistance[inf.locationIndex]; - if(d > 3000){ + if(d > 700){ break; } float time = speed > 0 ? d / speed : 0;