Skip to content
Merged
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
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ext {
mapboxMapSdk : '6.5.0',
mapboxSdkServices : '4.0.0',
mapboxEvents : '3.2.0',
mapboxNavigator : '3.0.1',
mapboxNavigator : '3.1.1',
locationLayerPlugin: '0.8.1',
autoValue : '1.5.4',
autoValueParcel : '0.2.5',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.google.auto.value.AutoValue;
import com.mapbox.services.android.navigation.v5.navigation.notification.NavigationNotification;

import static com.mapbox.services.android.navigation.v5.navigation.NavigationConstants
.NAVIGATION_LOCATION_ENGINE_INTERVAL_LAG;
import static com.mapbox.services.android.navigation.v5.navigation.NavigationConstants.ROUNDING_INCREMENT_FIFTY;

/**
Expand Down Expand Up @@ -56,6 +58,8 @@ public abstract class MapboxNavigationOptions {

public abstract int locationAcceptableAccuracyInMetersThreshold();

public abstract int navigationLocationEngineIntervalLagInMilliseconds();

public abstract Builder toBuilder();

@AutoValue.Builder
Expand Down Expand Up @@ -101,6 +105,8 @@ public abstract static class Builder {

public abstract Builder locationAcceptableAccuracyInMetersThreshold(int accuracyInMetersThreshold);

public abstract Builder navigationLocationEngineIntervalLagInMilliseconds(int lagInMilliseconds);

public abstract MapboxNavigationOptions build();
}

Expand All @@ -124,6 +130,7 @@ public static Builder builder() {
.isDebugLoggingEnabled(false)
.roundingIncrement(ROUNDING_INCREMENT_FIFTY)
.timeFormatType(NavigationTimeFormat.NONE_SPECIFIED)
.locationAcceptableAccuracyInMetersThreshold(NavigationConstants.ONE_HUNDRED_METER_ACCEPTABLE_ACCURACY_THRESHOLD);
.locationAcceptableAccuracyInMetersThreshold(NavigationConstants.ONE_HUNDRED_METER_ACCEPTABLE_ACCURACY_THRESHOLD)
.navigationLocationEngineIntervalLagInMilliseconds(NAVIGATION_LOCATION_ENGINE_INTERVAL_LAG);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ synchronized void updateRoute(String routeJson) {
navigator.setRoute(routeJson, 0, 0);
}

synchronized NavigationStatus retrieveStatus(Date date) {
synchronized NavigationStatus retrieveStatus(Date date, long lagInMilliseconds) {
// We ask for a point slightly in the future to account for lag in location services
if (lagInMilliseconds > 0) {
date.setTime(date.getTime() + lagInMilliseconds);
}
return navigator.getStatus(date);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,17 @@ private NavigationConstants() {
*/
static final int ONE_HUNDRED_METER_ACCEPTABLE_ACCURACY_THRESHOLD = 100;

/**
* Default approximate location engine interval lag in milliseconds
* <p>
* This value will be used to offset the time at which the current location was calculated
* in such a way as to project the location forward along the current trajectory so as to
* appear more in sync with the users ground-truth location
*
* @since 0.20.0
*/
static final int NAVIGATION_LOCATION_ENGINE_INTERVAL_LAG = 1500;

static final String NON_NULL_APPLICATION_CONTEXT_REQUIRED = "Non-null application context required.";

public static final Float[] WAYNAME_OFFSET = {0.0f, 40.0f};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ private void process() {
MapboxNavigationOptions options = navigation.options();
DirectionsRoute route = navigation.getRoute();

NavigationStatus status = mapboxNavigator.retrieveStatus(new Date());
NavigationStatus status = mapboxNavigator.retrieveStatus(new Date(),
options.navigationLocationEngineIntervalLagInMilliseconds());
RouteProgress routeProgress = routeProcessor.buildNewRouteProgress(status, route);

NavigationEngineFactory engineFactory = navigation.retrieveEngineFactory();
Expand Down