-
Notifications
You must be signed in to change notification settings - Fork 319
Add logic to determine faster route #2462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add logic to determine faster route #2462
Conversation
a581b69 to
bbb3c3a
Compare
LukasPaczos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good progress 👍
How about DirectionsSession exposes a callback like in #2455, but instead of calling it FaterRouteCallback, we call it AlternativeRouteObserver.
The session still maintains the timer and makes periodic requests that invoke the observers.
MapboxNavigation can subscribe to this event and based on the route progress determine whether the alternative route is actually faster. If it is, it notifies FaterRouteObservers that now live and are maintained in MapboxNavigation.
This way, we are decreasing the coupling between the 2 classes and simplifying the whole flow.
libnavigation-base/src/main/java/com/mapbox/navigation/base/session/NavigationSession.kt
Outdated
Show resolved
Hide resolved
...avigation-base/src/main/java/com/mapbox/navigation/base/session/NavigationSessionObserver.kt
Outdated
Show resolved
Hide resolved
libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt
Outdated
Show resolved
Hide resolved
libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt
Outdated
Show resolved
Hide resolved
libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt
Outdated
Show resolved
Hide resolved
I had a great discussion with @Guardiola31337 last week on 2 different approaches to implement faster route detection. We explored the possibility of having the The implementation above is the first iteration towards |
LukasPaczos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The location samples are the tiebreaker here. If we don't want to push them to the directions session, which we shouldn't, the timer has to live in MapboxNavigation and exposing additional route request method might be the only way 👍
...-core/src/main/java/com/mapbox/navigation/core/directions/session/MapboxDirectionsSession.kt
Outdated
Show resolved
Hide resolved
...tion-core/src/main/java/com/mapbox/navigation/core/fasterroute/FasterRouteRequestCallback.kt
Outdated
Show resolved
Hide resolved
...e/src/test/java/com/mapbox/navigation/core/directions/session/MapboxDirectionsSessionTest.kt
Show resolved
Hide resolved
...-core/src/main/java/com/mapbox/navigation/core/directions/session/MapboxDirectionsSession.kt
Outdated
Show resolved
Hide resolved
|
I don't see any other outstanding comments here. |
|
Capturing from multiple threads above:
|
@LukasPaczos I would like to give some time to think on what are the possible other ways to expose navigationState in general. I think this is good for first iteration. We should definitely have a broader discussion around this in a separate follow up ticket that is more targeted to |
|
Sounds good, thanks @abhishek1508. |
84477b6 to
4e2974e
Compare
Codecov Report
@@ Coverage Diff @@
## master #2462 +/- ##
=========================================
Coverage 32.29% 32.29%
Complexity 621 621
=========================================
Files 143 143
Lines 5605 5605
Branches 434 434
=========================================
Hits 1810 1810
Misses 3595 3595
Partials 200 200 |
libnavigation-base/src/main/java/com/mapbox/navigation/base/options/NavigationOptions.kt
Outdated
Show resolved
Hide resolved
|
Capturing from internal discussion with @abhishek1508 that we're going to try the following:
cc @LukasPaczos |
LukasPaczos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Minor comments and should be good to merge (when tests are ready).
libnavigation-core/src/main/java/com/mapbox/navigation/core/fasterroute/FasterRouteDetector.kt
Outdated
Show resolved
Hide resolved
...e/src/test/java/com/mapbox/navigation/core/directions/session/MapboxDirectionsSessionTest.kt
Show resolved
Hide resolved
...-core/src/main/java/com/mapbox/navigation/core/directions/session/MapboxDirectionsSession.kt
Show resolved
Hide resolved
...-core/src/main/java/com/mapbox/navigation/core/directions/session/MapboxDirectionsSession.kt
Outdated
Show resolved
Hide resolved
...-core/src/main/java/com/mapbox/navigation/core/directions/session/MapboxDirectionsSession.kt
Outdated
Show resolved
Hide resolved
...gation-core/src/main/java/com/mapbox/navigation/core/directions/session/DirectionsSession.kt
Show resolved
Hide resolved
Guardiola31337
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking pretty good, great work @abhishek1508
Adding to @LukasPaczos's comments I left some other minor ones.
libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt
Show resolved
Hide resolved
libnavigation-core/src/main/java/com/mapbox/navigation/core/MapboxNavigation.kt
Outdated
Show resolved
Hide resolved
...-core/src/main/java/com/mapbox/navigation/core/directions/session/MapboxDirectionsSession.kt
Show resolved
Hide resolved
libnavigation-core/src/main/java/com/mapbox/navigation/core/fasterroute/FasterRouteDetector.kt
Show resolved
Hide resolved
50c9eeb to
7ffa36f
Compare
...-core/src/main/java/com/mapbox/navigation/core/directions/session/MapboxDirectionsSession.kt
Show resolved
Hide resolved
...e/src/test/java/com/mapbox/navigation/core/directions/session/MapboxDirectionsSessionTest.kt
Show resolved
Hide resolved
Guardiola31337
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the feedback @abhishek1508
Left some minor comments. Also it seems that we lost some tests (e.g. fasterRoute_timerStartedOnce and fasterRoute_canceledByNewRequest) 🤔 Not sure if covered by others, could you confirm?
Other than that, this looks good to me 🚀
libnavigation-core/src/main/java/com/mapbox/navigation/core/fasterroute/FasterRouteDetector.kt
Show resolved
Hide resolved
...-core/src/main/java/com/mapbox/navigation/core/directions/session/MapboxDirectionsSession.kt
Show resolved
Hide resolved
libnavigation-core/src/test/java/com/mapbox/navigation/core/MapboxNavigationTest.kt
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| @Test | ||
| fun fasterRoute_timerStarted() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor thing
Normally is good to structure the tests following the triple A 👀 https://speakerdeck.com/guardiola31337/elegant-unit-testing-mobilization-2016?slide=40 http://wiki.c2.com/?ArrangeActAssert
If the Arrange part gets too long we should create factory or builder methods.
This applies to the rest of the tests 👇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT This is still valid
...-core/src/main/java/com/mapbox/navigation/core/directions/session/MapboxDirectionsSession.kt
Outdated
Show resolved
Hide resolved
|
@Guardiola31337 |
bae97ac to
d4fd1ac
Compare
d4fd1ac to
b447eca
Compare
|
👀 @cafesilencio @evabishchevich @JunDai this PR brings some insights and thoughts on what we were discussing today. Please read the threads comments when you have a chance. |
Guardiola31337
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's cut follow up tickets for https://github.com/mapbox/mapbox-navigation-android/pull/2462/files#r380339602 and #2462 (comment) and we should be good to go.
Thanks for addressing the feedback @abhishek1508 🚀
| } | ||
|
|
||
| @Test | ||
| fun fasterRoute_timerStarted() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT This is still valid
Description
Add logic to use user current location to request for faster route. Compare new route with current route to determine if it is faster #221
bug,feature,new API(s),SEMVER, etc.)Goal
Add logic to use user current location to request for faster route. Compare new route with current route to determine if it is faster.
Implementation
Add logic to use user current location to request for faster route. Compare new route with current route to determine if it is faster.
Testing
Please describe the manual tests that you ran to verify your changes
SNAPSHOTupstream dependencies if needed) through testapp/demo app and run all activities to avoid regressionsChecklist
CHANGELOGincluding this PR