Skip to content

Check distance remaining before running OffRouteDetector logic#977

Merged
danesfeder merged 1 commit into
masterfrom
dan-arrival-offroute
Jun 4, 2018
Merged

Check distance remaining before running OffRouteDetector logic#977
danesfeder merged 1 commit into
masterfrom
dan-arrival-offroute

Conversation

@danesfeder
Copy link
Copy Markdown
Contributor

After we arrive at the final waypoint along the route, we remove the off route listener, so off route events are no longer given to the user. Internally the core SDK was still running off route logic and would reset ever few seconds with OffRouteDetector#isValidOffRoute.

This PR adds a check to see if the route distance remaining is 0. If it is we return true for every off route check. This way, the snap logic returns the raw user Location, which makes sense because we are no longer following a route.

@danesfeder danesfeder added bug Defect to be fixed. ✓ ready for review labels May 25, 2018
@danesfeder danesfeder added this to the 0.14.0 milestone May 25, 2018
@danesfeder danesfeder self-assigned this May 25, 2018
@danesfeder danesfeder force-pushed the dan-arrival-offroute branch from a00edd4 to b96d2fe Compare May 25, 2018 13:45
@danesfeder
Copy link
Copy Markdown
Contributor Author

Before:

ezgif com-video-to-gif

After:

ezgif com-video-to-gif 1

Copy link
Copy Markdown
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple nit picks - overall this looks great.


Point currentPoint = Point.fromLngLat(location.getLongitude(), location.getLatitude());

// Get distance from the current step to future point
Copy link
Copy Markdown
Contributor

@Guardiola31337 Guardiola31337 May 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about extracting blocks of code into well-named (based on the comments) private methods? We should keep public methods as clean as possible so they read like pseudocode (i.e. no conditionals, fors, etc.).

@Override
public boolean isUserOffRoute(Location location, RouteProgress routeProgress, MapboxNavigationOptions options) {

if (checkDistanceRemaining(routeProgress)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should reflect this new check in the Javadoc ☝️

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be great if we add a test in OffRouteDetectorTest around this new check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these have been addressed 👍

@danesfeder danesfeder force-pushed the dan-arrival-offroute branch 2 times, most recently from 5e94ec0 to 86258bd Compare May 29, 2018 19:32
@danesfeder danesfeder modified the milestones: 0.14.0, 0.15.0 May 30, 2018
Copy link
Copy Markdown
Contributor

@Guardiola31337 Guardiola31337 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of minor details not blocking the PR.

}

@Test
public void isUserOffRoute_assertTrueWhenRouteDistanceRemainingIsZero() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️


// If not offRoute at this point, do not continue with remaining logic
if (!isOffRoute) {
// Even though the current point is not considered off-route, check to see if the user is
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we remove somehow these comments from here and include them into the Javadoc ☝️?

return isMovingAwayFromManeuver(location, routeProgress, distancesAwayFromManeuver, currentPoint);
}

// If the user is considered off-route at this point, but they are close to the upcoming step,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here ☝️

@danesfeder danesfeder force-pushed the dan-arrival-offroute branch from 86258bd to d933e0e Compare June 4, 2018 14:51
@danesfeder
Copy link
Copy Markdown
Contributor Author

@Guardiola31337 I removed the comments, each of the methods already had Javadoc, so the comments you pointed out were redundant 👍

@danesfeder danesfeder merged commit 4c4a7c1 into master Jun 4, 2018
@danesfeder danesfeder deleted the dan-arrival-offroute branch June 4, 2018 15:22
@danesfeder danesfeder mentioned this pull request Jun 21, 2018
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Defect to be fixed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants