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
Compare routes using step names #3301
Conversation
How is @mapbox/navigation-ios approach to tackle this issue? Do you know @1ec5? |
3f4cee6
to
a65947d
Compare
} | ||
every { directionsSession.routes } returns listOf(currentRoute) | ||
every { tripSession.getEnhancedLocation() } returns mockk { | ||
every { latitude } returns -33.874308 | ||
every { longitude } returns 151.206087 | ||
} | ||
every { tripSession.getRouteProgress() } returns mockk { | ||
every { durationRemaining } returns 601.334 |
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.
These test values are covered in FasterRouteDetectorTest
Codecov Report
@@ Coverage Diff @@
## master #3301 +/- ##
=========================================
Coverage 39.30% 39.31%
- Complexity 2312 2314 +2
=========================================
Files 547 548 +1
Lines 20019 20043 +24
Branches 1901 1913 +12
=========================================
+ Hits 7869 7880 +11
- Misses 11228 11229 +1
- Partials 922 934 +12 |
Follow up issue from this, there is a race condition. In the event of a faster route, the current step index can change while requesting. This will cause the requested route to include an extra step. For example, The route will be considered different |
a65947d
to
b53d874
Compare
As mentioned in #3262 (review)
we used Damerau Levenshtein algorithm in the legacy for off-routes and this PR is addressing Faster route only. Should we add same |
This approach seems OK to me: #3116 (comment).
The iOS navigation SDK ranks the routes by edit distance over the summary string, the same approach @kmadsen investigated in #3116. The comparison happens in a bottlenecked part of the code that handles rerouting due to both going off-route and finding a faster route. I think either approach is sufficient for this use case, because a sufficiently different route will rank lower by either measure (leg summary or step names). It’s possible that the step name comparison will be slightly more reliable in cases where the alternative routes differ in a way that isn’t significant enough to result in a difference to the summary, but I’d assume that getting such cases right would be a marginal improvement. (The summary consists of the two most common street names by length along the leg.) If you have a concrete example of where it yields a practical improvement, I’d love to consider it. Note that the iOS navigation SDK only uses the edit distance algorithm to choose from among multiple alternative routes. It doesn’t use the algorithm to decide whether to replace the preexisting route. That determination is based on a much simpler heuristic: whether the new route is at least 10% faster and the user isn’t near the destination. |
b53d874
to
6667ce6
Compare
@1ec5 this is what is being addressed in this pull request. it turns out, the "new route that is 10% faster" is not new. It's more often than not, the same route Note that I agree with everything else though, maybe comparing steps is better than route summaries when the origin and destination are the same. The issue with faster route, is that it has been partially completed and the route summary is no longer a working description for faster route. Also agreeing with performance considerations, there may 10-1000 route steps to compare. This is worth testing |
6667ce6
to
2844b2c
Compare
In the question for performance. Tested creating a route from SF to NYC and this was the result:
considering this operation is run once every 5 minutes, there's little concern here. but it should be executed on a background thread. |
2844b2c
to
1263ce6
Compare
@@ -37,7 +56,7 @@ class FasterRouteDetectorTest { | |||
} | |||
|
|||
@Test | |||
fun shouldDefaultToFalseWhenDurationIsNull() { | |||
fun shouldDefaultToFalseWhenDurationIsNull() = runBlocking { |
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 answer is in, runBlocking is better than runBlockingTest
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.
A couple of minor comments.
libnavigation-core/src/main/java/com/mapbox/navigation/core/fasterroute/RouteComparator.kt
Outdated
Show resolved
Hide resolved
libnavigation-core/src/main/java/com/mapbox/navigation/core/fasterroute/RouteComparator.kt
Outdated
Show resolved
Hide resolved
1263ce6
to
cb565a6
Compare
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 @kmadsen 🚢
Description
Resolves #3144
Midway through a route we request a new route, and we're looking to see if it's faster. This is working as design. The problem is the route we're checking, can be the current route.
This is the 3rd approach considered for this.
Going to test this in a few regions
bug
,feature
,new API(s)
,SEMVER
, etc.)Screenshots
Testing
Please describe the manual tests that you ran to verify your changes
SNAPSHOT
upstream dependencies if needed) through testapp/demo app and run all activities to avoid regressionsChecklist
CHANGELOG
including this PRapi/current.txt
files after running$> make 1.0-core-update-api
(Core) /$> make 1.0-ui-update-api
(UI) if there are changes / errors we're 🆗 with (e.g.AddedMethod
changes are marked as errors but don't break SemVer) 🚀 If there are SemVer breaking changes add theSEMVER
label. See Metalava docs