libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationEngine.java
private RouteProgress buildNewRouteProgress(MapboxNavigation mapboxNavigation, Location location,
                                              RingBuffer recentDistances) {
    DirectionsRoute directionsRoute = mapboxNavigation.getRoute();
    MapboxNavigationOptions options = mapboxNavigation.options();
    double completionOffset = options.maxTurnCompletionOffset();
    double maneuverZoneRadius = options.maneuverZoneRadius();

    // Check if a new route has been provided
    checkNewRoute(directionsRoute);

    double stepDistanceRemaining = calculateStepDistanceRemaining(location, directionsRoute);
    boolean withinManeuverRadius = stepDistanceRemaining < maneuverZoneRadius;
    boolean bearingMatchesManeuver = checkBearingForStepCompletion(
      location, previousRouteProgress, stepDistanceRemaining, completionOffset
    );

    if (bearingMatchesManeuver && withinManeuverRadius) {
      // Advance the step index and create new step distance remaining
      advanceStepIndex(directionsRoute, recentDistances);
      // Re-calculate the step distance remaining based on the new index
      stepDistanceRemaining = calculateStepDistanceRemaining(location, directionsRoute);
    }

    int legIndex = indices.legIndex();
    int stepIndex = indices.stepIndex();
    double legDistanceRemaining = legDistanceRemaining(stepDistanceRemaining, legIndex, stepIndex, directionsRoute);
    double routeDistanceRemaining = routeDistanceRemaining(legDistanceRemaining, legIndex, directionsRoute);

    // Create a RouteProgress.create object using the latest user location
    return RouteProgress.builder()
      .stepDistanceRemaining(stepDistanceRemaining)
      .legDistanceRemaining(legDistanceRemaining)
      .distanceRemaining(routeDistanceRemaining)
      .directionsRoute(directionsRoute)
      .stepIndex(stepIndex)
      .legIndex(legIndex)
      .build();
  }
/**
   * Will take a given location update and create a new {@link RouteProgress}
   * based on our calculations of the distances remaining.
   * <p>
   * Also in charge of detecting if a step / leg has finished and incrementing the
   * indices if needed ({@link NavigationEngine#advanceStepIndex(DirectionsRoute, RingBuffer)} handles
   * the decoding of the next step point list).
   *
   * @param mapboxNavigation for the current route / options
   * @param location         for step / leg / route distance remaining
   * @param recentDistances  for advancing the step index
   * @return new route progress along the route
   */
Will take a given location update and create a new  RouteProgress
based on our calculations of the distances remaining.

Also in charge of detecting if a step / leg has finished and incrementing the
indices if needed ( NavigationEngine#advanceStepIndex(DirectionsRoute, RingBuffer) handles
the decoding of the next step point list).

@param mapboxNavigation for the current route / options
@param location         for step / leg / route distance remaining
@param recentDistances  for advancing the step index
@return new route progress along the route
Will take a given location update and create a new RouteProgress based on our calculations of the distances remaining . Also in charge of detecting if a step / leg has finished and incrementing the indices if needed ( NavigationEngine#advanceStepIndex ( DirectionsRoute RingBuffer ) handles the decoding of the next step point list ) . @param mapboxNavigation for the current route / options @param location for step / leg / route distance remaining @param recentDistances for advancing the step index @return new route progress along the route
private RouteProgress buildNewRouteProgress(MapboxNavigation mapboxNavigation, Location location,
                                              RingBuffer recentDistances) {
    DirectionsRoute directionsRoute = mapboxNavigation.getRoute();
    MapboxNavigationOptions options = mapboxNavigation.options();
    double completionOffset = options.maxTurnCompletionOffset();
    double maneuverZoneRadius = options.maneuverZoneRadius();
    checkNewRoute(directionsRoute);
    double stepDistanceRemaining = calculateStepDistanceRemaining(location, directionsRoute);
    boolean withinManeuverRadius = stepDistanceRemaining < maneuverZoneRadius;
    boolean bearingMatchesManeuver = checkBearingForStepCompletion(
      location, previousRouteProgress, stepDistanceRemaining, completionOffset
    );
    if (bearingMatchesManeuver && withinManeuverRadius) {
      advanceStepIndex(directionsRoute, recentDistances);
      stepDistanceRemaining = calculateStepDistanceRemaining(location, directionsRoute);
    }
    int legIndex = indices.legIndex();
    int stepIndex = indices.stepIndex();
    double legDistanceRemaining = legDistanceRemaining(stepDistanceRemaining, legIndex, stepIndex, directionsRoute);
    double routeDistanceRemaining = routeDistanceRemaining(legDistanceRemaining, legIndex, directionsRoute);
    return RouteProgress.builder()
      .stepDistanceRemaining(stepDistanceRemaining)
      .legDistanceRemaining(legDistanceRemaining)
      .distanceRemaining(routeDistanceRemaining)
      .directionsRoute(directionsRoute)
      .stepIndex(stepIndex)
      .legIndex(legIndex)
      .build();
  }
private RouteProgress buildNewRouteProgress ( MapboxNavigation mapboxNavigation , Location location , RingBuffer recentDistances ) { DirectionsRoute directionsRoute = mapboxNavigation . getRoute ( ) ; MapboxNavigationOptions options = mapboxNavigation . options ( ) ; double completionOffset = options . maxTurnCompletionOffset ( ) ; double maneuverZoneRadius = options . maneuverZoneRadius ( ) ; checkNewRoute ( directionsRoute ) ; double stepDistanceRemaining = calculateStepDistanceRemaining ( location , directionsRoute ) ; boolean withinManeuverRadius = stepDistanceRemaining < maneuverZoneRadius ; boolean bearingMatchesManeuver = checkBearingForStepCompletion ( location , previousRouteProgress , stepDistanceRemaining , completionOffset ) ; if ( bearingMatchesManeuver && withinManeuverRadius ) { advanceStepIndex ( directionsRoute , recentDistances ) ; stepDistanceRemaining = calculateStepDistanceRemaining ( location , directionsRoute ) ; } int legIndex = indices . legIndex ( ) ; int stepIndex = indices . stepIndex ( ) ; double legDistanceRemaining = legDistanceRemaining ( stepDistanceRemaining , legIndex , stepIndex , directionsRoute ) ; double routeDistanceRemaining = routeDistanceRemaining ( legDistanceRemaining , legIndex , directionsRoute ) ; return RouteProgress . builder ( ) . stepDistanceRemaining ( stepDistanceRemaining ) . legDistanceRemaining ( legDistanceRemaining ) . distanceRemaining ( routeDistanceRemaining ) . directionsRoute ( directionsRoute ) . stepIndex ( stepIndex ) . legIndex ( legIndex ) . build ( ) ; }
Will take a given location update and create a new {@link RouteProgress}
 based on our calculations of the distances remaining.
Will take a given location update and create a new { @link RouteProgress } based on our calculations of the distances remaining .
// Check if a new route has been provided // Advance the step index and create new step distance remaining // Re-calculate the step distance remaining based on the new index // Create a RouteProgress.create object using the latest user location