libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationEngine.java
private void handleRequest(final NewLocationModel newLocationModel) {

    final MapboxNavigation mapboxNavigation = newLocationModel.mapboxNavigation();
    boolean snapToRouteEnabled = mapboxNavigation.options().snapToRoute();
    RingBuffer recentDistances = newLocationModel.distancesAwayFromManeuver();

    final Location rawLocation = newLocationModel.location();

    // Generate a new route progress given the raw location update
    RouteProgress routeProgress = buildNewRouteProgress(mapboxNavigation, rawLocation, recentDistances);

    // Check if user has gone off-route
    final boolean userOffRoute = isUserOffRoute(newLocationModel, routeProgress, this);

    // If needed, increase step index and generate new route progress
    checkIncreaseStepIndex(mapboxNavigation.getRoute(), recentDistances);

    // Check milestone list to see if any should be triggered
    final List<Milestone> milestones = checkMilestones(
      previousRouteProgress, routeProgress, mapboxNavigation);

    // Create snapped location if enabled, otherwise return raw location
    final Location location = buildSnappedLocation(mapboxNavigation, snapToRouteEnabled,
      rawLocation, routeProgress, userOffRoute);

    // Check for faster route only if enabled and not off-route
    boolean fasterRouteEnabled = mapboxNavigation.options().enableFasterRouteDetection();
    final boolean checkFasterRoute = fasterRouteEnabled && !userOffRoute
      && shouldCheckFasterRoute(newLocationModel, routeProgress);

    // Copy route progress to final object for callback
    final RouteProgress finalRouteProgress = routeProgress;
    previousRouteProgress = finalRouteProgress;

    responseHandler.post(new Runnable() {
      @Override
      public void run() {
        callback.onNewRouteProgress(location, finalRouteProgress);
        callback.onMilestoneTrigger(milestones, finalRouteProgress);
        callback.onUserOffRoute(location, userOffRoute);
        callback.onCheckFasterRoute(location, finalRouteProgress, checkFasterRoute);
      }
    });
  }
/**
   * Takes a new location model and runs all related engine checks against it
   * (off-route, milestones, snapped location, and faster-route).
   * <p>
   * After running through the engines, all data is submitted to {@link NavigationService} via
   * {@link NavigationEngine.Callback}.
   *
   * @param newLocationModel hold location, navigation (with options), and distances away from maneuver
   */
Takes a new location model and runs all related engine checks against it
(off-route, milestones, snapped location, and faster-route).

After running through the engines, all data is submitted to  NavigationService via
NavigationEngine.Callback.

@param newLocationModel hold location, navigation (with options), and distances away from maneuver
Takes a new location model and runs all related engine checks against it ( off - route milestones snapped location and faster - route ) . After running through the engines all data is submitted to NavigationService via NavigationEngine . Callback . @param newLocationModel hold location navigation ( with options ) and distances away from maneuver
private void handleRequest(final NewLocationModel newLocationModel) {
    final MapboxNavigation mapboxNavigation = newLocationModel.mapboxNavigation();
    boolean snapToRouteEnabled = mapboxNavigation.options().snapToRoute();
    RingBuffer recentDistances = newLocationModel.distancesAwayFromManeuver();
    final Location rawLocation = newLocationModel.location();
    RouteProgress routeProgress = buildNewRouteProgress(mapboxNavigation, rawLocation, recentDistances);
    final boolean userOffRoute = isUserOffRoute(newLocationModel, routeProgress, this);
    checkIncreaseStepIndex(mapboxNavigation.getRoute(), recentDistances);
    final List<Milestone> milestones = checkMilestones(
      previousRouteProgress, routeProgress, mapboxNavigation);
    final Location location = buildSnappedLocation(mapboxNavigation, snapToRouteEnabled,
      rawLocation, routeProgress, userOffRoute);
    boolean fasterRouteEnabled = mapboxNavigation.options().enableFasterRouteDetection();
    final boolean checkFasterRoute = fasterRouteEnabled && !userOffRoute
      && shouldCheckFasterRoute(newLocationModel, routeProgress);
    final RouteProgress finalRouteProgress = routeProgress;
    previousRouteProgress = finalRouteProgress;
    responseHandler.post(new Runnable() {
      @Override
      public void run() {
        callback.onNewRouteProgress(location, finalRouteProgress);
        callback.onMilestoneTrigger(milestones, finalRouteProgress);
        callback.onUserOffRoute(location, userOffRoute);
        callback.onCheckFasterRoute(location, finalRouteProgress, checkFasterRoute);
      }
    });
  }
private void handleRequest ( final NewLocationModel newLocationModel ) { final MapboxNavigation mapboxNavigation = newLocationModel . mapboxNavigation ( ) ; boolean snapToRouteEnabled = mapboxNavigation . options ( ) . snapToRoute ( ) ; RingBuffer recentDistances = newLocationModel . distancesAwayFromManeuver ( ) ; final Location rawLocation = newLocationModel . location ( ) ; RouteProgress routeProgress = buildNewRouteProgress ( mapboxNavigation , rawLocation , recentDistances ) ; final boolean userOffRoute = isUserOffRoute ( newLocationModel , routeProgress , this ) ; checkIncreaseStepIndex ( mapboxNavigation . getRoute ( ) , recentDistances ) ; final List < Milestone > milestones = checkMilestones ( previousRouteProgress , routeProgress , mapboxNavigation ) ; final Location location = buildSnappedLocation ( mapboxNavigation , snapToRouteEnabled , rawLocation , routeProgress , userOffRoute ) ; boolean fasterRouteEnabled = mapboxNavigation . options ( ) . enableFasterRouteDetection ( ) ; final boolean checkFasterRoute = fasterRouteEnabled && ! userOffRoute && shouldCheckFasterRoute ( newLocationModel , routeProgress ) ; final RouteProgress finalRouteProgress = routeProgress ; previousRouteProgress = finalRouteProgress ; responseHandler . post ( new Runnable ( ) { @ Override public void run ( ) { callback . onNewRouteProgress ( location , finalRouteProgress ) ; callback . onMilestoneTrigger ( milestones , finalRouteProgress ) ; callback . onUserOffRoute ( location , userOffRoute ) ; callback . onCheckFasterRoute ( location , finalRouteProgress , checkFasterRoute ) ; } } ) ; }
Takes a new location model and runs all related engine checks against it
 (off-route, milestones, snapped location, and faster-route).
Takes a new location model and runs all related engine checks against it ( off - route milestones snapped location and faster - route ) .
// Generate a new route progress given the raw location update // Check if user has gone off-route // If needed, increase step index and generate new route progress // Check milestone list to see if any should be triggered // Create snapped location if enabled, otherwise return raw location // Check for faster route only if enabled and not off-route // Copy route progress to final object for callback