Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/src/main/java/net/osmtracker/OSMTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public static final class Preferences {
public final static String KEY_GPS_IGNORE_CLOCK = "gps.ignoreclock";
public final static String KEY_GPS_LOGGING_INTERVAL = "gps.logging.interval";
public final static String KEY_GPS_LOGGING_MIN_DISTANCE = "gps.logging.min_distance";
public final static String KEY_GPS_LOGGING_DIST_GT_ACCURACY = "gps.logging.dist_gt_accuracy";

public final static String KEY_USE_BAROMETER = "gpx.use_barometer";
public final static String KEY_USE_NOTES = "gpx.notes";
public final static String KEY_OUTPUT_FILENAME = "gpx.filename";
Expand Down Expand Up @@ -61,6 +63,7 @@ public static final class Preferences {
public final static boolean VAL_GPS_IGNORE_CLOCK = false;
public final static String VAL_GPS_LOGGING_INTERVAL = "0";
public final static String VAL_GPS_LOGGING_MIN_DISTANCE = "0";
public final static boolean VAL_GPS_LOGGING_DIST_GT_ACCURACY = false;
public final static boolean VAL_USE_BAROMETER = false;
public final static String VAL_USE_NOTES = "both";

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/net/osmtracker/service/gps/GPSLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public class GPSLogger extends Service implements LocationListener {
*/
private long gpsLoggingInterval;
private long gpsLoggingMinDistance;
private boolean gpsLoggingDistGtAccuracy;

/**
* sensors for magnetic orientation
Expand Down Expand Up @@ -254,6 +255,8 @@ public void onCreate() {
OSMTracker.Preferences.KEY_GPS_LOGGING_MIN_DISTANCE, OSMTracker.Preferences.VAL_GPS_LOGGING_MIN_DISTANCE));
use_barometer = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()).getBoolean(
OSMTracker.Preferences.KEY_USE_BAROMETER, OSMTracker.Preferences.VAL_USE_BAROMETER);
gpsLoggingDistGtAccuracy = PreferenceManager.getDefaultSharedPreferences(this.getApplicationContext()).getBoolean(
OSMTracker.Preferences.KEY_GPS_LOGGING_DIST_GT_ACCURACY, OSMTracker.Preferences.VAL_GPS_LOGGING_DIST_GT_ACCURACY);

// Register our broadcast receiver
IntentFilter filter = new IntentFilter();
Expand Down Expand Up @@ -348,6 +351,12 @@ public void onLocationChanged(Location location) {

// first of all we check if the time from the last used fix to the current fix is greater than the logging interval
if((lastGPSTimestamp + gpsLoggingInterval) < System.currentTimeMillis()){
// next check whether distance is greater than accurracy
if(gpsLoggingDistGtAccuracy &&
lastLocation != null &&
location.distanceTo(lastLocation) <= location.getAccuracy())
return;

lastGPSTimestamp = System.currentTimeMillis(); // save the time of this fix

lastLocation = location;
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings-preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<string name="prefs_gps_logging_min_distance_summary">Min. distance between track points in meters, use 0 for the shortest possible</string>
<string name="prefs_gps_logging_min_distance_meters">meters</string>
<string name="prefs_gps_logging_min_distance_empty">Min. distance between track points cannot be empty</string>
<string name="prefs_gps_logging_distance_gt_accuracy">Log only pts where dist. &gt; accur.</string>
<string name="prefs_gps_logging_distance_gt_accuracy_summary">Log only points which are further away from previous point than GPS accuracy</string>
<string name="prefs_ui">User interface</string>
<string name="prefs_ui_picture_source">Default photo source</string>
<string name="prefs_ui_picture_source_summary">Take photos from camera or gallery?</string>
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
app:key="gps.logging.min_distance"
app:summary="@string/prefs_gps_logging_min_distance_summary"
app:title="@string/prefs_gps_logging_min_distance" />
<CheckBoxPreference
app:defaultValue="false"
app:key="gps.logging.dist_gt_accuracy"
app:summary="@string/prefs_gps_logging_distance_gt_accuracy_summary"
app:title="@string/prefs_gps_logging_distance_gt_accuracy" />
</PreferenceCategory>

<PreferenceCategory app:title="@string/prefs_output">
Expand Down Expand Up @@ -159,4 +164,4 @@
app:title="@string/prefs_ui_orientation" />
</PreferenceCategory>

</PreferenceScreen>
</PreferenceScreen>
Loading