diff --git a/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/LocationUpdatedThread.java b/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/LocationUpdatedThread.java index 6a48f46a08e..45c91d8cc18 100644 --- a/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/LocationUpdatedThread.java +++ b/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/LocationUpdatedThread.java @@ -47,11 +47,13 @@ class LocationUpdatedThread extends HandlerThread { private boolean userOffRoute; private boolean snapToRoute; private DirectionsRoute directionsRoute; + private MapboxNavigationOptions options; private Location location; - LocationUpdatedThread(Handler responseHandler) { + LocationUpdatedThread(Handler responseHandler, MapboxNavigationOptions options) { super(TAG); this.responseHandler = responseHandler; + this.options = options; // By default we snap to route when possible. snapToRoute = true; } @@ -153,8 +155,8 @@ private RouteProgress monitorStepProgress(@NonNull RouteProgress routeProgress, boolean courseMatchesManeuverFinalHeading = false; // TODO set to eventually adjust for different direction profiles. - int minimumDistanceForHighAlert = NavigationConstants.MINIMUM_DISTANCE_FOR_HIGH_ALERT; - int minimumDistanceForMediumAlert = NavigationConstants.MINIMUM_DISTANCE_FOR_MEDIUM_ALERT; + double minimumDistanceForHighAlert = options.getMinimumHighAlertDistance(); + double minimumDistanceForMediumAlert = options.getMinimumMediumAlertDistance(); // Bearings need to be normalized so when the bearingAfter is 359 and the user heading is 1, we count this as // within the MAXIMUM_ALLOWED_DEGREE_OFFSET_FOR_TURN_COMPLETION. @@ -164,19 +166,19 @@ private RouteProgress monitorStepProgress(@NonNull RouteProgress routeProgress, double userHeadingNormalized = MathUtils.wrap(location.getBearing(), 0, 360); courseMatchesManeuverFinalHeading = MathUtils.differenceBetweenAngles( finalHeadingNormalized, userHeadingNormalized - ) <= NavigationConstants.MAXIMUM_ALLOWED_DEGREE_OFFSET_FOR_TURN_COMPLETION; + ) <= options.getMaxTurnCompletionOffset(); } // When departing, userSnapToStepDistanceFromManeuver is most often less than RouteControllerManeuverZoneRadius // since the user will most often be at the beginning of the route, in the maneuver zone if (alertLevel == NavigationConstants.DEPART_ALERT_LEVEL && userSnapToStepDistanceFromManeuver - <= NavigationConstants.MANEUVER_ZONE_RADIUS) { + <= options.getManeuverZoneRadius()) { // If the user is close to the maneuver location, don't give a departure instruction, instead, give a high alert. - if (secondsToEndOfStep <= NavigationConstants.HIGH_ALERT_INTERVAL) { + if (secondsToEndOfStep <= options.getHighAlertInterval()) { alertLevel = NavigationConstants.HIGH_ALERT_LEVEL; } - } else if (userSnapToStepDistanceFromManeuver <= NavigationConstants.MANEUVER_ZONE_RADIUS) { + } else if (userSnapToStepDistanceFromManeuver <= options.getManeuverZoneRadius()) { // Use the currentStep if there is not a next step, this occurs when arriving. if (routeProgress.getCurrentLegProgress().getUpComingStep() != null) { @@ -189,7 +191,7 @@ private RouteProgress monitorStepProgress(@NonNull RouteProgress routeProgress, // userAbsoluteDistanceToManeuverLocation is set to nil by default // If it's set to nil, we know the user has never entered the maneuver radius if (userDistanceToManeuverLocation == 0.0) { - userDistanceToManeuverLocation = NavigationConstants.MANEUVER_ZONE_RADIUS; + userDistanceToManeuverLocation = options.getManeuverZoneRadius(); } double lastKnownUserAbsoluteDistance = userDistanceToManeuverLocation; @@ -218,15 +220,15 @@ private RouteProgress monitorStepProgress(@NonNull RouteProgress routeProgress, routeProgress.getCurrentLegProgress().getStepIndex() ); secondsToEndOfStep = userSnapToStepDistanceFromManeuver / location.getSpeed(); - alertLevel = secondsToEndOfStep <= NavigationConstants.MEDIUM_ALERT_INTERVAL + alertLevel = secondsToEndOfStep <= options.getMediumAlertInterval() ? NavigationConstants.MEDIUM_ALERT_LEVEL : NavigationConstants.LOW_ALERT_LEVEL; } - } else if (secondsToEndOfStep <= NavigationConstants.HIGH_ALERT_INTERVAL + } else if (secondsToEndOfStep <= options.getHighAlertInterval() && routeProgress.getCurrentLegProgress().getCurrentStep().getDistance() > minimumDistanceForHighAlert) { alertLevel = NavigationConstants.HIGH_ALERT_LEVEL; // Don't alert if the route segment is shorter than X however, if it's the beginning of the route There needs to // be an alert - } else if (secondsToEndOfStep <= NavigationConstants.MEDIUM_ALERT_INTERVAL + } else if (secondsToEndOfStep <= options.getMediumAlertInterval() && routeProgress.getCurrentLegProgress().getCurrentStep().getDistance() > minimumDistanceForMediumAlert) { alertLevel = NavigationConstants.MEDIUM_ALERT_LEVEL; } @@ -257,14 +259,14 @@ private RouteProgress monitorStepProgress(@NonNull RouteProgress routeProgress, private boolean userIsOnRoute(Location location, RouteLeg routeLeg) { Position locationToPosition = Position.fromCoordinates(location.getLongitude(), location.getLatitude()); // Find future location of user - double metersInFrontOfUser = location.getSpeed() * NavigationConstants.DEAD_RECKONING_TIME_INTERVAL; + double metersInFrontOfUser = location.getSpeed() * options.getDeadReckoningTimeInterval(); Position locationInFrontOfUser = TurfMeasurement.destination( locationToPosition, metersInFrontOfUser, location.getBearing(), TurfConstants.UNIT_METERS ); return RouteUtils.isOffRoute(locationInFrontOfUser, routeLeg, - NavigationConstants.MAXIMUM_DISTANCE_BEFORE_OFF_ROUTE); + options.getMaximumDistanceOffRoute()); } private float snapUserBearing(RouteProgress routeProgress) { @@ -279,7 +281,7 @@ private float snapUserBearing(RouteProgress routeProgress) { newCoordinate = Position.fromCoordinates(location.getLongitude(), location.getLatitude()); } - double userDistanceBuffer = location.getSpeed() * NavigationConstants.DEAD_RECKONING_TIME_INTERVAL; + double userDistanceBuffer = location.getSpeed() * options.getDeadReckoningTimeInterval(); if (routeProgress.getDistanceTraveled() + userDistanceBuffer > RouteUtils.getDistanceToEndOfRoute( @@ -311,11 +313,11 @@ private float snapUserBearing(RouteProgress routeProgress) { double absoluteBearing = MathUtils.wrap(wrappedCurrentBearing + averageRelativeAngle, 0, 360); if (MathUtils.differenceBetweenAngles(absoluteBearing, location.getBearing()) - > NavigationConstants.MAX_MANIPULATED_COURSE_ANGLE) { + > options.getMaxManipulatedCourseAngle()) { return location.getBearing(); } - return averageRelativeAngle <= NavigationConstants.MAXIMUM_ALLOWED_DEGREE_OFFSET_FOR_TURN_COMPLETION ? (float) + return averageRelativeAngle <= options.getMaxTurnCompletionOffset() ? (float) absoluteBearing : location.getBearing(); } diff --git a/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/MapboxNavigation.java b/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/MapboxNavigation.java index 9388252b857..020482ee3a5 100644 --- a/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/MapboxNavigation.java +++ b/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/MapboxNavigation.java @@ -7,6 +7,7 @@ import android.content.ServiceConnection; import android.os.IBinder; import android.support.annotation.IntRange; +import android.support.annotation.NonNull; import com.mapbox.services.Experimental; import com.mapbox.services.android.location.LostLocationEngine; @@ -41,6 +42,7 @@ public class MapboxNavigation { // Navigation service variables private NavigationServiceConnection connection; private NavigationService navigationService; + private MapboxNavigationOptions options; private Context context; private boolean isBound; @@ -53,7 +55,7 @@ public class MapboxNavigation { private boolean snapToRoute; // Requesting route variables - private String profile = DirectionsCriteria.PROFILE_DRIVING_TRAFFIC; + private String profile; private DirectionsRoute route; private Position destination; private Integer userBearing; @@ -64,14 +66,36 @@ public class MapboxNavigation { * Constructor */ - public MapboxNavigation(Context context, String accessToken) { + /** + * Creates a new MapboxNavigation object. + * + * @param context {@link Context} used for various things internally, cannot be null. + * @param accessToken A valid Mapbox access token. + * @since 0.1.0 + */ + public MapboxNavigation(@NonNull Context context, @NonNull String accessToken) { + this(context, accessToken, new MapboxNavigationOptions()); + } + + /** + * Creates a new MapboxNavigation object. + * + * @param context {@link Context} used for various things internally, cannot be null. + * @param accessToken A valid Mapbox access token. + * @param options a {@link MapboxNavigationOptions} with your customized options. + * @since 0.2.0 + */ + public MapboxNavigation(@NonNull Context context, @NonNull String accessToken, + @NonNull MapboxNavigationOptions options) { Timber.d("MapboxNavigation initiated."); this.context = context; this.accessToken = accessToken; + this.options = options; connection = new NavigationServiceConnection(); isBound = false; navigationService = null; snapToRoute = true; + profile = DirectionsCriteria.PROFILE_DRIVING_TRAFFIC; alertLevelChangeListeners = new CopyOnWriteArrayList<>(); navigationEventListeners = new CopyOnWriteArrayList<>(); progressChangeListeners = new CopyOnWriteArrayList<>(); @@ -415,6 +439,7 @@ public void onServiceConnected(ComponentName componentName, IBinder service) { NavigationService.LocalBinder binder = (NavigationService.LocalBinder) service; navigationService = binder.getService(); navigationService.setLocationEngine(getLocationEngine()); + navigationService.setOptions(options); navigationService.setNavigationEventListeners(navigationEventListeners); if (alertLevelChangeListeners != null) { diff --git a/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/MapboxNavigationOptions.java b/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/MapboxNavigationOptions.java new file mode 100644 index 00000000000..aef586e964b --- /dev/null +++ b/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/MapboxNavigationOptions.java @@ -0,0 +1,273 @@ +package com.mapbox.services.android.navigation.v5; + +import android.location.Location; +import android.support.annotation.FloatRange; + +public class MapboxNavigationOptions { + + private double maxTurnCompletionOffset; + private double maneuverZoneRadius; + + private int mediumAlertInterval; + private int highAlertInterval; + + private double minimumMediumAlertDistance; + private double minimumHighAlertDistance; + + private double maximumDistanceOffRoute; + private double deadReckoningTimeInterval; + private double maxManipulatedCourseAngle; + + /** + * Creates a new MapboxNavigationOptions object. + * + * @since 0.2.0 + */ + public MapboxNavigationOptions() { + // Set the initial variables to equal the default. + maxTurnCompletionOffset = NavigationConstants.MAXIMUM_ALLOWED_DEGREE_OFFSET_FOR_TURN_COMPLETION; + maneuverZoneRadius = NavigationConstants.MANEUVER_ZONE_RADIUS; + mediumAlertInterval = NavigationConstants.MEDIUM_ALERT_INTERVAL; + highAlertInterval = NavigationConstants.HIGH_ALERT_INTERVAL; + minimumMediumAlertDistance = NavigationConstants.MINIMUM_DISTANCE_FOR_MEDIUM_ALERT; + minimumHighAlertDistance = NavigationConstants.MINIMUM_DISTANCE_FOR_HIGH_ALERT; + maximumDistanceOffRoute = NavigationConstants.MAXIMUM_DISTANCE_BEFORE_OFF_ROUTE; + deadReckoningTimeInterval = NavigationConstants.DEAD_RECKONING_TIME_INTERVAL; + maxManipulatedCourseAngle = NavigationConstants.MAX_MANIPULATED_COURSE_ANGLE; + } + + /** + * Set the threshold user must be within to count as completing a + * {@link com.mapbox.services.api.directions.v5.models.LegStep}. When checking if the users completed the step, the + * users {@link Location#getBearing()} and the + * {@link com.mapbox.services.api.directions.v5.models.StepManeuver#bearingAfter} are compared. If this number is + * within the {@code setMaxTurnCompletionOffset} the user has completed the step. This is one of the two heuristics + * used to know when a user completes a step, the other being {@link NavigationConstants#MANEUVER_ZONE_RADIUS}. + * + * @param maxTurnCompletionOffset degree double value between 0 and 359 representing the threshold used to consider if + * the user has completed the step maneuver. + * @return This. + * @since 0.2.0 + */ + public MapboxNavigationOptions setMaxTurnCompletionOffset( + @FloatRange(from = 0, to = 359) double maxTurnCompletionOffset) { + this.maxTurnCompletionOffset = maxTurnCompletionOffset; + return this; + } + + /** + * Radius, in meters, the user must enter to count as completing a step. This is one of the two heuristics used to + * know when a user completes a step, the other being + * {@link NavigationConstants#MAXIMUM_ALLOWED_DEGREE_OFFSET_FOR_TURN_COMPLETION} + * + * @param maneuverZoneRadius double radius value with unit meters representing the area the user must enter to count + * as completing a step. + * @return This. + * @since 0.2.0 + */ + public MapboxNavigationOptions setManeuverZoneRadius(double maneuverZoneRadius) { + this.maneuverZoneRadius = maneuverZoneRadius; + return this; + } + + /** + * Number of seconds left on step when a {@link NavigationConstants#MEDIUM_ALERT_LEVEL} alert occurs. + * + * @param mediumAlertInterval integer value in unit seconds representing the seconds left till a {@code medium} alert + * level occurs. + * @return this; + * @since 0.2.0 + */ + public MapboxNavigationOptions setMediumAlertInterval(int mediumAlertInterval) { + this.mediumAlertInterval = mediumAlertInterval; + return this; + } + + /** + * Number of seconds left on step when a {@link NavigationConstants#HIGH_ALERT_LEVEL} alert occurs. + * + * @param highAlertInterval integer value in unit seconds representing the seconds left till a {@code high} alert + * level occurs. + * @return this. + * @since 0.2.0 + */ + public MapboxNavigationOptions setHighAlertInterval(int highAlertInterval) { + this.highAlertInterval = highAlertInterval; + return this; + } + + /** + * Distance in meters representing the minimum length of a step for a {@link NavigationConstants#MEDIUM_ALERT_LEVEL} + * to occur. + * + * @param minimumMediumAlertDistance double value in unit meters representing the minimum step length for a + * {@code medium} alert to occur. + * @return this. + * @since 0.2.0 + */ + public MapboxNavigationOptions setMinimumMediumAlertDistance(double minimumMediumAlertDistance) { + this.minimumMediumAlertDistance = minimumMediumAlertDistance; + return this; + } + + /** + * Distance in meters representing the minimum length of a step for a {@link NavigationConstants#HIGH_ALERT_LEVEL} + * to occur. + * + * @param minimumHighAlertDistance double value in unit meters representing the minimum step length for a + * {@code high} alert to occur. + * @return this. + * @since 0.2.0 + */ + public MapboxNavigationOptions setMinimumHighAlertDistance(double minimumHighAlertDistance) { + this.minimumHighAlertDistance = minimumHighAlertDistance; + return this; + } + + /** + * Maximum distance in meters a user can travel away from the step geometry before the + * {@link com.mapbox.services.android.navigation.v5.listeners.OffRouteListener}'s called. + * + * @param maximumDistanceOffRoute double value in unit meters representing the maximum distance a user can travel + * before the {@code OffRouteListener} gets called. + * @return this. + * @since 0.2.0 + */ + public MapboxNavigationOptions setMaximumDistanceOffRoute(double maximumDistanceOffRoute) { + this.maximumDistanceOffRoute = maximumDistanceOffRoute; + return this; + } + + /** + * When calculating whether or not the user is on the route, we look where the user will be given their speed and + * this {@code deadReckoningTimeInterval} variable. + * + * @param deadReckoningTimeInterval time interval in unit seconds we use for dead reckoning purposes. + * @return this. + * @since 0.2.0 + */ + public MapboxNavigationOptions setDeadReckoningTimeInterval(double deadReckoningTimeInterval) { + this.deadReckoningTimeInterval = deadReckoningTimeInterval; + return this; + } + + /** + * Maximum angle the user puck will be rotated when snapping the user's course to the route line. + * + * @param maxManipulatedCourseAngle degree int value between 0 and 359 representing the maximum angle the user puck + * will be rotated + * @return this. + * @since 0.2.0 + */ + public MapboxNavigationOptions setMaxManipulatedCourseAngle( + @FloatRange(from = 0, to = 359) double maxManipulatedCourseAngle) { + this.maxManipulatedCourseAngle = maxManipulatedCourseAngle; + return this; + } + + /* + * Getters + */ + + /** + * Get the current set threshold user must be within to count as completing a + * {@link com.mapbox.services.api.directions.v5.models.LegStep}. When checking if the user completed the step, the + * users {@link com.mapbox.services.api.directions.v5.models.StepManeuver#bearingAfter} are compared. If this number + * is within the {@code setMaxTurnCompletionOffset} the user has completed the step. This is one of the two heuristics + * used to know when a user completes a step, the other being {@link NavigationConstants#MANEUVER_ZONE_RADIUS}. + * + * @return degree double value between 0 and 359 representing the threshold being used to consider if the user has + * completed the step maneuver. + * @since 0.2.0 + */ + public double getMaxTurnCompletionOffset() { + return maxTurnCompletionOffset; + } + + /** + * Get the current radius, in meters, the user must enter to count as completing a step. This is one of the two + * heuristics used to know when a user completes a step, the other being + * {@link NavigationConstants#MAXIMUM_ALLOWED_DEGREE_OFFSET_FOR_TURN_COMPLETION} + * + * @return double radius value with unit meters representing the area the user must enter to count as completing a + * step. + * @since 0.2.0 + */ + public double getManeuverZoneRadius() { + return maneuverZoneRadius; + } + + /** + * Get the current number of seconds required for a {@link NavigationConstants#MEDIUM_ALERT_LEVEL} alert to occur. + * + * @return integer value in unit seconds representing the seconds left till a {@code medium} alert level occurs. + * @since 0.2.0 + */ + public int getMediumAlertInterval() { + return mediumAlertInterval; + } + + /** + * Get the current number of seconds required for a {@link NavigationConstants#HIGH_ALERT_LEVEL} alert to occurs. + * + * @return integer value in unit seconds representing the seconds left till a {@code high} alert level occurs. + * @since 0.2.0 + */ + public int getHighAlertInterval() { + return highAlertInterval; + } + + /** + * Get the current required distance in meters representing the minimum length of a step for a + * {@link NavigationConstants#MEDIUM_ALERT_LEVEL} to occur. + * + * @return double value in unit meters representing the minimum step length for a {@code medium} alert to occur. + * @since 0.2.0 + */ + public double getMinimumMediumAlertDistance() { + return minimumMediumAlertDistance; + } + + /** + * Get the current required distance in meters representing the minimum length of a step for a + * {@link NavigationConstants#HIGH_ALERT_LEVEL} to occur. + * + * @return double value in unit meters representing the minimum step length for a {@code high} alert to occur. + * @since 0.2.0 + */ + public double getMinimumHighAlertDistance() { + return minimumHighAlertDistance; + } + + /** + * Get the current required maximum distance in meters a user can travel away from the step geometry before the + * {@link com.mapbox.services.android.navigation.v5.listeners.OffRouteListener}'s called. + * + * @return double value in unit meters representing the maximum distance a user can travel before the + * {@code OffRouteListener} gets called. + * @since 0.2.0 + */ + public double getMaximumDistanceOffRoute() { + return maximumDistanceOffRoute; + } + + /** + * Get the current time interval being used to calculate dead reckoning values. + * + * @return time interval in unit seconds being used for dead reckoning purposes. + * @since 0.2.0 + */ + public double getDeadReckoningTimeInterval() { + return deadReckoningTimeInterval; + } + + /** + * Get the maximum angle the user puck will be rotated when snapping the user's course to the route line. + * + * @return degree int value between 0 and 359 representing the maximum angle the user puck will be rotated. + * @since 0.2.0 + */ + public double getMaxManipulatedCourseAngle() { + return maxManipulatedCourseAngle; + } +} diff --git a/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/NavigationConstants.java b/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/NavigationConstants.java index 6eb17b49371..f7c6a0b76cb 100644 --- a/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/NavigationConstants.java +++ b/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/NavigationConstants.java @@ -13,8 +13,6 @@ public class NavigationConstants { @Experimental public static final int MEDIUM_ALERT_LEVEL = 3; @Experimental public static final int HIGH_ALERT_LEVEL = 4; @Experimental public static final int ARRIVE_ALERT_LEVEL = 5; - @Experimental public static final int METERS_TO_INTERSECTION = 50; - @Experimental public static final int DEFAULT_ANGLE_TOLERANCE = 45; /** * Threshold user must be in within to count as completing a step. One of two heuristics used to know when a user @@ -65,5 +63,5 @@ public class NavigationConstants { /** * Maximum angle the user puck will be rotated when snapping the user's course to the route line. */ - @Experimental public static final double MAX_MANIPULATED_COURSE_ANGLE = 25; + @Experimental public static final int MAX_MANIPULATED_COURSE_ANGLE = 25; } diff --git a/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/NavigationService.java b/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/NavigationService.java index e021eb82e56..52976a11d9c 100644 --- a/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/NavigationService.java +++ b/navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/NavigationService.java @@ -48,6 +48,7 @@ public class NavigationService extends Service implements LocationEngineListener private NotificationCompat.Builder notifyBuilder; private CopyOnWriteArrayList progressChangeListeners; private LocationUpdatedThread locationUpdatedThread; + private MapboxNavigationOptions options; private Handler responseHandler; private RouteProgress routeProgress; @@ -127,6 +128,10 @@ public void setSnapToRoute(boolean snapToRoute) { locationUpdatedThread.setSnapToRoute(snapToRoute); } + public void setOptions(MapboxNavigationOptions options) { + this.options = options; + } + private void startNavigation() { Timber.d("Navigation session started."); if (navigationEventListeners != null) { @@ -136,7 +141,7 @@ private void startNavigation() { } responseHandler = new Handler(); - locationUpdatedThread = new LocationUpdatedThread(responseHandler); + locationUpdatedThread = new LocationUpdatedThread(responseHandler, options); locationUpdatedThread.start(); locationUpdatedThread.getLooper(); Timber.d("Background thread started"); diff --git a/navigation/libandroid-navigation/src/test/java/com/mapbox/services/android/navigation/v5/MapboxNavigationOptionsTest.java b/navigation/libandroid-navigation/src/test/java/com/mapbox/services/android/navigation/v5/MapboxNavigationOptionsTest.java new file mode 100644 index 00000000000..dfd150076fe --- /dev/null +++ b/navigation/libandroid-navigation/src/test/java/com/mapbox/services/android/navigation/v5/MapboxNavigationOptionsTest.java @@ -0,0 +1,126 @@ +package com.mapbox.services.android.navigation.v5; + +import org.junit.Test; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +public class MapboxNavigationOptionsTest extends BaseTest { + + @Test + public void testSanity() { + assertNotNull("should not be null", new MapboxNavigationOptions()); + } + + @Test + public void testMaxTurnCompletionOffset() { + assertEquals( + new MapboxNavigationOptions().getMaxTurnCompletionOffset(), + NavigationConstants.MAXIMUM_ALLOWED_DEGREE_OFFSET_FOR_TURN_COMPLETION, + DELTA + ); + assertEquals( + new MapboxNavigationOptions().setMaxTurnCompletionOffset(100).getMaxTurnCompletionOffset(), 100, DELTA + ); + } + + @Test + public void testManeuverZoneRadius() { + assertEquals( + new MapboxNavigationOptions().getManeuverZoneRadius(), NavigationConstants.MANEUVER_ZONE_RADIUS, DELTA + ); + assertEquals(new MapboxNavigationOptions().setManeuverZoneRadius(100).getManeuverZoneRadius(), 100, DELTA); + } + + @Test + public void testMediumAlertInterval() { + assertEquals( + new MapboxNavigationOptions().getMediumAlertInterval(), NavigationConstants.MEDIUM_ALERT_INTERVAL, DELTA + ); + assertEquals(new MapboxNavigationOptions().setMediumAlertInterval(100).getMediumAlertInterval(), 100, DELTA); + } + + @Test + public void testHighAlertInterval() { + assertEquals( + new MapboxNavigationOptions().getHighAlertInterval(), + NavigationConstants.HIGH_ALERT_INTERVAL, + DELTA + ); + assertEquals( + new MapboxNavigationOptions().setHighAlertInterval(100).getHighAlertInterval(), + 100, + DELTA + ); + } + + @Test + public void testMinimumMediumAlertDistance() { + assertEquals( + new MapboxNavigationOptions().getMinimumMediumAlertDistance(), + NavigationConstants.MINIMUM_DISTANCE_FOR_MEDIUM_ALERT, + DELTA + ); + assertEquals( + new MapboxNavigationOptions().setMinimumMediumAlertDistance(100).getMinimumMediumAlertDistance(), + 100, + DELTA + ); + } + + @Test + public void testMinimumHighAlertDistance() { + assertEquals( + new MapboxNavigationOptions().getMinimumHighAlertDistance(), + NavigationConstants.MINIMUM_DISTANCE_FOR_HIGH_ALERT, + DELTA + ); + assertEquals( + new MapboxNavigationOptions().setMinimumHighAlertDistance(100).getMinimumHighAlertDistance(), + 100, + DELTA + ); + } + + @Test + public void testMaximumDistanceOffRoute() { + assertEquals( + new MapboxNavigationOptions().getMaximumDistanceOffRoute(), + NavigationConstants.MAXIMUM_DISTANCE_BEFORE_OFF_ROUTE, + DELTA + ); + assertEquals( + new MapboxNavigationOptions().setMaximumDistanceOffRoute(100).getMaximumDistanceOffRoute(), + 100, + DELTA + ); + } + + @Test + public void testDeadReckoningTimeInterval() { + assertEquals( + new MapboxNavigationOptions().getDeadReckoningTimeInterval(), + NavigationConstants.DEAD_RECKONING_TIME_INTERVAL, + DELTA + ); + assertEquals( + new MapboxNavigationOptions().setDeadReckoningTimeInterval(100).getDeadReckoningTimeInterval(), + 100, + DELTA + ); + } + + @Test + public void testMaxManipulatedCourseAngle() { + assertEquals( + new MapboxNavigationOptions().getMaxManipulatedCourseAngle(), + NavigationConstants.MAX_MANIPULATED_COURSE_ANGLE, + DELTA + ); + assertEquals( + new MapboxNavigationOptions().setMaxManipulatedCourseAngle(100).getMaxManipulatedCourseAngle(), + 100, + DELTA + ); + } +}