diff --git a/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java b/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java index bb4112aadf..bf32afdeab 100644 --- a/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java +++ b/OsmAnd-java/src/net/osmand/search/core/SearchCoreFactory.java @@ -547,7 +547,7 @@ public class SearchCoreFactory { res.objectType = ObjectType.POI_TYPE; resultMatcher.publish(res); } - for(int i =0 ; i< customPoiFilters.size(); i++) { + for (int i = 0; i < customPoiFilters.size(); i++) { CustomSearchPoiFilter csf = customPoiFilters.get(i); int p = customPoiFiltersPriorites.get(i); if (!phrase.isUnknownSearchWordPresent() || nm.matches(csf.getName())) { diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index ae376bfb0c..e003119db3 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -1053,6 +1053,26 @@ public class OsmandSettings { SAVE_TRACK_INTERVAL.setModeDefaultValue(ApplicationMode.BICYCLE, 7000); SAVE_TRACK_INTERVAL.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 10000); } + + + public final CommonPreference SAVE_TRACK_PRECISION = new IntPreference("save_track_precision", 0).makeProfile(); + { +// SAVE_TRACK_PRECISION.setModeDefaultValue(ApplicationMode.CAR, 50); +// SAVE_TRACK_PRECISION.setModeDefaultValue(ApplicationMode.BICYCLE, 50); +// SAVE_TRACK_PRECISION.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 50); + } + public final CommonPreference SAVE_TRACK_MIN_SPEED = new FloatPreference("save_track_min_speed", 0.f).makeProfile(); + { +// SAVE_TRACK_MIN_SPEED.setModeDefaultValue(ApplicationMode.CAR, 1.f); +// SAVE_TRACK_MIN_SPEED.setModeDefaultValue(ApplicationMode.BICYCLE, 1.f); +// SAVE_TRACK_MIN_SPEED.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 0.f); + } + public final CommonPreference SAVE_TRACK_MIN_DISTANCE = new IntPreference("save_track_min_distance", 5).makeProfile(); + { +// SAVE_TRACK_MIN_DISTANCE.setModeDefaultValue(ApplicationMode.CAR, 5); +// SAVE_TRACK_MIN_DISTANCE.setModeDefaultValue(ApplicationMode.BICYCLE, 5); +// SAVE_TRACK_MIN_DISTANCE.setModeDefaultValue(ApplicationMode.PEDESTRIAN, 5); + } // this value string is synchronized with settings_pref.xml preference name public final CommonPreference LIVE_MONITORING = new BooleanPreference("live_monitoring", false).makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java index 43857cec00..b1096b0d14 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/SavingTrackHelper.java @@ -4,7 +4,6 @@ import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.text.format.DateFormat; - import net.osmand.PlatformUtil; import net.osmand.data.LatLon; import net.osmand.plus.GPXUtilities; @@ -19,6 +18,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; import net.osmand.plus.monitoring.OsmandMonitoringPlugin; +import net.osmand.util.MapUtils; import org.apache.commons.logging.Log; @@ -365,6 +365,19 @@ public class SavingTrackHelper extends SQLiteOpenHelper { && locationTime - lastTimeUpdated > settings.SAVE_GLOBAL_TRACK_INTERVAL.get()) { record = true; } + int minDistance = settings.SAVE_TRACK_MIN_DISTANCE.get(); + if(minDistance > 0 && lastPoint != null && MapUtils.getDistance(lastPoint, location.getLatitude(), location.getLongitude()) < + minDistance) { + record = false; + } + int precision = settings.SAVE_TRACK_PRECISION.get(); + if(precision > 0 && (!location.hasAccuracy() || location.getAccuracy() < precision)) { + record = false; + } + int minSpeed = settings.SAVE_TRACK_MIN_SPEED.get(); + if(minSpeed > 0 && (!location.hasSpeed() || location.getSpeed() < minSpeed)) { + record = false; + } } } if (record) {