0

We started building our mobile app a while ago when the premium SDK was still maintained. Now Here decided to deprecate that SDK and we must switch to another one. However we were using the Turn-By-Turn navigation where we were getting the ETA information real time using the NavigationManager GetETA(). This way we could get the ETA updated along the route without having to use multiple API requests (which would be insanely cost consuming). How can I achieve that with the Explore SDK ? I see the following note on the Explore SDK documentation: https://developer.here.com/documentation/android-sdk-explore/4.13.5.0/dev_guide/topics/routing.html

Note Tip: If a driver is moving, the bearing value can help to improve the route calculation: startWaypoint.headingInDegrees = location.bearingInDegrees;.

Can someone confirm that I can get the ETA updated real time without calling multiple times the Get Route API ?

Thanks in advance for helping.

Sixk
  • 1
  • 1

1 Answers1

0

Updating the ETA can be costly, so it is made more transparent in the 4.x version of the HERE SDK. Take a look at this guide and scroll to the "Update Traffic on Route" section.

The RouteProgress event delivers the estimated travel time:

List<SectionProgress> sectionProgressList = routeProgress.sectionProgress;
// sectionProgressList is guaranteed to be non-empty.
SectionProgress lastSectionProgress = sectionProgressList.get(sectionProgressList.size() - 1);
Log.d(TAG, "Estimated travel time including traffic delay: " + lastSectionProgress.remainingDuration.getSeconds());
Log.d(TAG, "Traffic delay ahead in seconds: " + lastSectionProgress.trafficDelay.getSeconds());

However, this is not automatically updating real-time traffic during the run, so the updated time reflects only the time from route calculation while progressing to destination.

So, if you want to update the traffic, call refreshRoute() whenever you need a new ETA or call it periodically. Since refreshRoute() will not modify the current route, you only need to set the route to the navigator (this can be done any time) - and then RouteProgress will contain the updated times.

If you want to take the ETA from the Route, you can do it like this:

LocationTime eta = route.getArrivalLocationTime();
long estimatedTravelTimeInSeconds = route.getDuration().getSeconds();
long estimatedTrafficDelayInSeconds = route.getTrafficDelay().getSeconds();
int lengthInMeters = route.getLengthInMeters();

You can get the ETA only directly from the Route (or you can calculate it from the remaining duration).

Alternatively, you can also use the DynamicRouteEngine to find better route alternatives and to bypass traffic obstacles automatically.

Nusatad
  • 3,231
  • 3
  • 11
  • 17
  • Hi, Thanks for your help. Just to make sure I understand: - Option 1: I just use the elapsed time since the route has started - Option 2: Use refreshRoute() --> This one seems more reliable to me if I understand properly but my concern is : would a refresh count as a new API request ? Thanks again :) – Sixk Apr 18 '23 at 21:26
  • Yes, calling refreshRoute() is a new API request, but MAU are counted only once per month. – Nusatad Jul 17 '23 at 14:27