Skip to content
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

NAVAND-714 - Added Waypoints to NavigationRoute; - RouteOptionsUpdater refactored; #6005

Conversation

RingerJK
Copy link
Contributor

@RingerJK RingerJK commented Jul 4, 2022

Description

@RingerJK RingerJK self-assigned this Jul 4, 2022
@RingerJK RingerJK force-pushed the kyv-directions-route-missing-conditions-and-fix-waypoints-source branch from 1c8ac6d to 4caf1be Compare July 5, 2022 12:14
@RingerJK RingerJK added skip changelog Should not be added into version changelog. ⚠️ DO NOT MERGE PR should not be merged! labels Jul 5, 2022
@RingerJK RingerJK force-pushed the kyv-directions-route-missing-conditions-and-fix-waypoints-source branch from ee11d88 to 1f91ae4 Compare July 13, 2022 10:43
@codecov
Copy link

codecov bot commented Jul 13, 2022

Codecov Report

Merging #6005 (0636da9) into main (5e27577) will decrease coverage by 0.12%.
The diff coverage is 62.22%.

❗ Current head 0636da9 differs from pull request most recent head 8270348. Consider uploading reports for the commit 8270348 to get more accurate results

Impacted file tree graph

@@             Coverage Diff              @@
##               main    #6005      +/-   ##
============================================
- Coverage     70.35%   70.22%   -0.13%     
- Complexity     4913     4914       +1     
============================================
  Files           718      722       +4     
  Lines         27980    28023      +43     
  Branches       3299     3303       +4     
============================================
- Hits          19685    19680       -5     
- Misses         7017     7068      +51     
+ Partials       1278     1275       -3     
Impacted Files Coverage Δ
...avigation/base/internal/utils/DirectionsRouteEx.kt 40.00% <0.00%> (-36.93%) ⬇️
.../mapbox/navigation/base/internal/utils/RouterEx.kt 45.45% <0.00%> (-4.55%) ⬇️
.../navigation/base/internal/utils/WaypointFactory.kt 0.00% <0.00%> (ø)
...mapbox/navigation/base/trip/model/RouteProgress.kt 0.00% <ø> (ø)
...pbox/navigation/core/accounts/BillingController.kt 88.09% <ø> (ø)
...avigation/core/history/model/HistoryEventMapper.kt 0.00% <0.00%> (ø)
.../mapbox/navigation/base/internal/route/Waypoint.kt 11.53% <11.53%> (ø)
...x/navigation/ui/maps/building/BuildingProcessor.kt 68.00% <62.50%> (+2.37%) ⬆️
...avigation/core/routeoptions/RouteOptionsUpdater.kt 83.33% <85.05%> (-4.44%) ⬇️
.../navigation/base/internal/extensions/WaypointEx.kt 94.73% <94.73%> (ø)
... and 13 more

@RingerJK RingerJK force-pushed the kyv-directions-route-missing-conditions-and-fix-waypoints-source branch from c2936a0 to fcb5e56 Compare October 24, 2022 10:51
@RingerJK RingerJK force-pushed the kyv-directions-route-missing-conditions-and-fix-waypoints-source branch from fcb5e56 to 1cef0e9 Compare October 25, 2022 10:40
@RingerJK RingerJK removed the ⚠️ DO NOT MERGE PR should not be merged! label Oct 25, 2022
@RingerJK RingerJK marked this pull request as ready for review October 25, 2022 12:22
@RingerJK RingerJK requested a review from a team as a code owner October 25, 2022 12:22
@dzinad
Copy link
Contributor

dzinad commented Oct 25, 2022

Which ticket is it?

@RingerJK RingerJK changed the title - Added Waypoints to NavigationRoute; - RouteOptionsUpdater refactored; NAVAND-714?- Added Waypoints to NavigationRoute; - RouteOptionsUpdater refactored; Oct 25, 2022
@RingerJK RingerJK changed the title NAVAND-714?- Added Waypoints to NavigationRoute; - RouteOptionsUpdater refactored; NAVAND-714 - Added Waypoints to NavigationRoute; - RouteOptionsUpdater refactored; Oct 25, 2022
@RingerJK
Copy link
Contributor Author

Which ticket is it?

Added ticket in the title

@dzinad
Copy link
Contributor

dzinad commented Oct 26, 2022

A more general concern: RouteProgress is public API. And it has remainingWaypoints property.

  1. Docs should be updated to specify which waypoints these are;
  2. An idea: would it make sense to add another field for the other type of waypoints? My concern is that we might have to apply the logic that's in RouteOptionsUpdater somewhere else if we use RouteProgress#remainingWaypoints somewhere else. Also the end user can use this property. Now that the waypoints are of different types, it would make sense to allow the user to choose which ones they'd like to use. TBH I don't really understand what's happening in RouteOptionsUpdater. What's refactoring and what's logic change. IMO it would be nice to separate: the logic change would be in calculateRemainingWaypoints or somewhere near it. WDYT?

@dzinad
Copy link
Contributor

dzinad commented Oct 26, 2022

BillingController uses RouteProgress#remainingWaypoints. Should its logic stay the same? I'd think yes, but want to clarify.

mutableListOf<Double?>().also {
it.addAll(
radiusesList.subList(
nextCoordinateIndex - 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it guaranteed somewhere that nextCoordinateIndex is > 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nextCoordinateIndex is receiving from indexOfNextRequestedCoordinate, which is always return value between [1; size_of_waypoint_list) (null is also possible, but it filtered out)

import com.mapbox.geojson.Point

data class Waypoint(
val location: Point,

Choose a reason for hiding this comment

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

Suggested change
val location: Point,
val directionsWaypoint: DirectionsWaypoint?,

This would be handy instead of copying the location/name data. It could be null for silent waypoints or we could have sealed classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you mean fakeing DirectionsWaypoint based on Waypoint instance?

Choose a reason for hiding this comment

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

We don't need be faking them, we can be finding them in the route response object depending on the index.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't always have DirectionsWaypoint: for instance, we don't have it when creating NavigationRoute based on DirecionsRoute(s) and a Waypoint object is created based on the NN's Waypoint.

Choose a reason for hiding this comment

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

Okay, let's revisit later if needed.

@@ -379,7 +380,7 @@ internal class MapboxTripSession(
}

private fun calculateRemainingWaypoints(tripStatus: TripStatus): Int {
val routeCoordinates = tripStatus.route?.routeOptions?.coordinatesList()
val routeCoordinates = tripStatus.route?._waypoints()

Choose a reason for hiding this comment

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

This would now also report silent waypoints which is a breaking change. It should only report regular and EV waypoints, so actually the ones that create legs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why it's breaking changes? We haven't had EV waypoints, as they appeared, now is a part of the API if anybody uses it

Choose a reason for hiding this comment

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

I'm talking about silent waypoints. They are not really waypoints and should not be part of the remaining waypoints count.

Copy link
Contributor Author

@RingerJK RingerJK Oct 26, 2022

Choose a reason for hiding this comment

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

good catch
@LukasPaczos wait a sec, the line tripStatus.route?.routeOptions?.coordinatesList() also take into account silent waypoints 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, silent and Ev waypoints are under NavigationStatus#getNextWaypointIndex(which is root of the remainingWaypoints value)

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe take a look at #6005 (comment), I think it's related to this discussion.

Choose a reason for hiding this comment

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

I think it's rather confusing that we call this a remainingWaypoint when a silent waypoint is not truly a waypoint in the Directions API terminology.

I'm worried that if someone used to use remainingWaypoints to compare it with RouteOptions#coordinates (as that's the only practical usage because remainingWaypoints contains silent waypoints) then the proposed change will break that logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from the SDK side, it seems like not a breaking change, it might be a misunderstanding between the SDK docs and customers. Let's considered it in the API doc and add the warning to the changelog. WDYT?

Choose a reason for hiding this comment

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

Yea, this is fine, refs #6005 (comment). But I agree that we should add a note in the docs that remainingWaypoints now might include more than requested waypoints if EV is used.

@LukasPaczos LukasPaczos removed the skip changelog Should not be added into version changelog. label Oct 26, 2022
@dzinad dzinad mentioned this pull request Oct 26, 2022
@RingerJK RingerJK force-pushed the kyv-directions-route-missing-conditions-and-fix-waypoints-source branch from 1cef0e9 to faa2cc7 Compare October 26, 2022 12:40
@RingerJK
Copy link
Contributor Author

RingerJK commented Oct 26, 2022

@dzinad

  1. Docs should be updated to specify which waypoints these are;

if we are speaking about Waypoint.kt - I'll do it 👍

  1. An idea: would it make sense to add another field for the other type of waypoints? My concern is that we might have to apply the logic that's in RouteOptionsUpdater somewhere else if we use RouteProgress#remainingWaypoints somewhere else. Also the end user can use this property. Now that the waypoints are of different types, it would make sense to allow the user to choose which ones they'd like to use. TBH I don't really understand what's happening in RouteOptionsUpdater. What's refactoring and what's logic change. IMO it would be nice to separate: the logic change would be in calculateRemainingWaypoints or somewhere near it. WDYT?

The Waypoint class is internal itself so we're good to experiment and change it.

  • What fields would you have in mind to add for other types of waypoints?
  • how do you see customers might choose the particular type of waypoints? For now, they are mostly like passive observer
  • Yeah, I agree, the logic is a bit hard to get in RouteOptionsUpdater. Would it help if I move everything into separate functions?

BillingController uses RouteProgress#remainingWaypoints. Should its logic stay the same? I'd think yes, but want to clarify.

great catch actually. I would say it should be switched to the Waypoint as well (I see there's using DirecionsResponce#DirectionsWaypoint. @LukasPaczos do you have objections?

@LukasPaczos
Copy link

We can switch the billing controller to use Waypoint but it should ignore silent waypoints, it's only interested in leg waypoints.

}
}
)
.approachesList(

Choose a reason for hiding this comment

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

Approaches should be specified per waypoint, not per coordinate (capturing from https://docs.mapbox.com/api/navigation/directions/#optional-parameters), so it should use getUpdatedWaypointsList.

Choose a reason for hiding this comment

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

We can address separately, let's cut a ticket.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

NAVAND-834

@LukasPaczos
Copy link

LukasPaczos commented Oct 26, 2022

great catch actually. I would say it should be switched to the Waypoint as well (I see there's using DirecionsResponce#DirectionsWaypoint. @LukasPaczos do you have objections?

We can switch the billing controller to use Waypoint but it should ignore silent waypoints, it's only interested in leg waypoints.

Sorry, this always surprises me time and time again that DirectionsResponse#waypoints contains silent waypoints. Since DirectionsResponse#waypoints contains all of regular, silent, and EV waypoints and RouteProgress#remainingWaypoints is already updated to account for EV waypoints, then we shouldn't need to make any changes in the billing controller. Unless I'm missing something @RingerJK?

.waypointIndicesList(
getUpdatedWaypointIndicesList(
routeOptions.waypointIndicesList(),
coordinatesList.size - remainingWaypoints - 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this really correspond to nextCoordinateIndex?

@dzinad
Copy link
Contributor

dzinad commented Oct 26, 2022

if we are speaking about Waypoint.kt - I'll do it 👍

No, I was talking about RouteProgress#remainingWaypoints doc.

The Waypoint class is internal itself so we're good to experiment and change it.

Again, I was talking about RouteProgress.

What fields would you have in mind to add for other types of waypoints?
how do you see customers might choose the particular type of waypoints? For now, they are mostly like passive observer

Requested waypoints and all waypoints? I don't know how they are used now. As far as I understood from the ticket description, the problem is that now in the response we may have more waypoints than in the request. Who knows hot this data will be used by users, why not expose both numbers?

Yeah, I agree, the logic is a bit hard to get in RouteOptionsUpdater. Would it help if I move everything into separate functions?

Nah, not really. Let's leave as is.

@RingerJK
Copy link
Contributor Author

Sorry, this always surprises me time and time again that DirectionsResponse#waypoints contains silent waypoints. Since DirectionsResponse#waypoints contains all of regular, silent, and EV waypoints and RouteProgress#remainingWaypoints is already updated to account for EV waypoints, then we shouldn't need to make any changes in the billing controller. Unless I'm missing something @RingerJK?

I would say that for now, we can keep it as is, and if the Waypoint experiment becomes a success we can switch to that as a single source of truth.

we also need utils methods for us and customers to work with waypoints, as it's always a challenge to handle them right (for instance getNextRequestedCoordinate might be hard to make on the application side)

@LukasPaczos I think it's a typo in the doc, shouldn't be silent, right?

/**
* Returns a list of [Point]s that mark ends of legs on the route,
* ignoring origin and silent waypoints.
*/
private fun getWaypointsOnRoute(navigationRoute: NavigationRoute): List<Point>? {
return navigationRoute.directionsResponse.waypoints()?.drop(1)?.map {
it.location()
}
}

@LukasPaczos
Copy link

I think it's a typo in the doc, shouldn't be silent, right?

Yes 👍

@RingerJK RingerJK force-pushed the kyv-directions-route-missing-conditions-and-fix-waypoints-source branch from bf165b5 to f3efe77 Compare October 27, 2022 13:49
@RingerJK RingerJK added the skip changelog Should not be added into version changelog. label Oct 27, 2022
@RingerJK RingerJK force-pushed the kyv-directions-route-missing-conditions-and-fix-waypoints-source branch from f3efe77 to ee210c1 Compare October 27, 2022 15:53
@RingerJK
Copy link
Contributor Author

RingerJK commented Oct 27, 2022

latest updates:

}
}
)
.approachesList(

Choose a reason for hiding this comment

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

We can address separately, let's cut a ticket.

Copy link

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

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

LGTM but it'd be great to add an instrumentation test that verifies a re-route with EV routes.

CHANGELOG.md Outdated
@@ -9,6 +9,8 @@ Mapbox welcomes participation and contributions from everyone.
- Fixed an issue with `NavigationView` that caused road label position to not update in some cases. [#6508](https://github.com/mapbox/mapbox-navigation-android/pull/6508)
- Fixed an issue where the SDK was trying to send telemetry events when telemetry is switched off globally. [#6512](https://github.com/mapbox/mapbox-navigation-android/pull/6512)

:warning: `RouteProgress#remainingWaypoints` defines the amount of all remaining waypoints, including explicit (requested with `RouteOptions#coordinatesList`) and implicit (added on the fly, like Electric Vehicle waypoints - [see](https://docs.mapbox.com/api/navigation/directions/#electric-vehicle-routing)) ones.

Choose a reason for hiding this comment

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

Suggested change
:warning: `RouteProgress#remainingWaypoints` defines the amount of all remaining waypoints, including explicit (requested with `RouteOptions#coordinatesList`) and implicit (added on the fly, like Electric Vehicle waypoints - [see](https://docs.mapbox.com/api/navigation/directions/#electric-vehicle-routing)) ones.
- Fixed an issue where re-routes could have failed for EV routes. [#6005](https://github.com/mapbox/mapbox-navigation-android/pull/6005)
- :warning: `RouteProgress#remainingWaypoints` defines the amount of all remaining waypoints, including explicit (requested with `RouteOptions#coordinatesList`) and implicit (added on the fly, like Electric Vehicle waypoints - [see](https://docs.mapbox.com/api/navigation/directions/#electric-vehicle-routing)) ones.

we can address separately when creating the changelog cc @Guardiola31337

Choose a reason for hiding this comment

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

If we're adding the test above then it'd be good to address this as well.

@dzinad
Copy link
Contributor

dzinad commented Oct 28, 2022

LGTM but it'd be great to add an instrumentation test that verifies a re-route with EV routes.

Oh, I was going to add the test in https://mapbox.atlassian.net/browse/NAVAND-775. It's about alternatives but there is no basic test. It would be real nice if it appeared. :)

@RingerJK RingerJK force-pushed the kyv-directions-route-missing-conditions-and-fix-waypoints-source branch from 0636da9 to 4fcb206 Compare October 28, 2022 14:39
@RingerJK RingerJK force-pushed the kyv-directions-route-missing-conditions-and-fix-waypoints-source branch from 4fcb206 to 8270348 Compare October 28, 2022 14:45
@RingerJK RingerJK added skip changelog Should not be added into version changelog. and removed skip changelog Should not be added into version changelog. labels Oct 28, 2022
Copy link

@LukasPaczos LukasPaczos left a comment

Choose a reason for hiding this comment

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

We should be in a good place with the implementation (and unit tests) and this lands only in the alpha but let's prioritize the instrumentation tests right after this.

@RingerJK RingerJK merged commit a45f7d4 into main Oct 28, 2022
@RingerJK RingerJK deleted the kyv-directions-route-missing-conditions-and-fix-waypoints-source branch October 28, 2022 16:02
@RingerJK
Copy link
Contributor Author

We should be in a good place with the implementation (and unit tests) and this lands only in the alpha but let's prioritize the instrumentation tests right after this.

NAVAND-835

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changelog Should not be added into version changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants