use of com.mapbox.services.android.navigation.v5.routeprogress.MetricsRouteProgress in project mapbox-navigation-android by mapbox.
the class NavigationMetricsWrapper method arriveEvent.
static void arriveEvent(SessionState sessionState, RouteProgress routeProgress, Location location) {
Hashtable<String, Object> arriveEvent = MapboxNavigationEvent.buildArriveEvent(sdkIdentifier, BuildConfig.MAPBOX_NAVIGATION_VERSION_NAME, sessionState.sessionIdentifier(), location.getLatitude(), location.getLongitude(), sessionState.currentGeometry(), routeProgress.directionsRoute().routeOptions().profile(), routeProgress.directionsRoute().distance().intValue(), routeProgress.directionsRoute().duration().intValue(), sessionState.rerouteCount(), sessionState.startTimestamp(), (int) (sessionState.eventRouteDistanceCompleted() + routeProgress.distanceTraveled()), (int) routeProgress.distanceRemaining(), (int) routeProgress.durationRemaining(), sessionState.mockLocation(), sessionState.originalRequestIdentifier(), sessionState.requestIdentifier(), sessionState.originalGeometry(), sessionState.originalDistance(), sessionState.originalDuration(), null, sessionState.currentStepCount(), sessionState.originalStepCount());
MetricsRouteProgress metricsRouteProgress = new MetricsRouteProgress(routeProgress);
int absoluteDistance = DistanceUtils.calculateAbsoluteDistance(location, metricsRouteProgress);
MapboxTelemetry.getInstance().addPercentTimeInForeground(sessionState.percentInForeground(), arriveEvent);
MapboxTelemetry.getInstance().addPercentTimeInPortrait(sessionState.percentInPortrait(), arriveEvent);
MapboxTelemetry.getInstance().addAbsoluteDistanceToDestination(absoluteDistance, arriveEvent);
MapboxTelemetry.getInstance().addLocationEngineName(sessionState.locationEngineName(), arriveEvent);
MapboxTelemetry.getInstance().pushEvent(arriveEvent);
MapboxTelemetry.getInstance().flushEventsQueueImmediately(false);
}
use of com.mapbox.services.android.navigation.v5.routeprogress.MetricsRouteProgress in project mapbox-navigation-android by mapbox.
the class NavigationTelemetry method onRouteProgressUpdate.
@Override
public void onRouteProgressUpdate(RouteProgress routeProgress) {
this.metricProgress = new MetricsRouteProgress(routeProgress);
boolean isValidDeparture = navigationSessionState.startTimestamp() == null && routeProgress.currentLegProgress().distanceTraveled() > 0;
if (isValidDeparture) {
navigationSessionState = navigationSessionState.toBuilder().startTimestamp(new Date()).build();
updateLifecyclePercentages();
NavigationMetricsWrapper.departEvent(navigationSessionState, metricProgress, metricLocation.getLocation());
}
}
use of com.mapbox.services.android.navigation.v5.routeprogress.MetricsRouteProgress in project mapbox-navigation-android by mapbox.
the class NavigationMetricsWrapper method rerouteEvent.
static void rerouteEvent(RerouteEvent rerouteEvent, MetricsRouteProgress metricProgress, Location location) {
SessionState sessionState = rerouteEvent.getSessionState();
updateRouteProgressSessionData(metricProgress);
Hashtable<String, Object> navRerouteEvent = MapboxNavigationEvent.buildRerouteEvent(sdkIdentifier, BuildConfig.MAPBOX_NAVIGATION_VERSION_NAME, sessionState.sessionIdentifier(), location.getLatitude(), location.getLongitude(), sessionState.currentGeometry(), metricProgress.getDirectionsRouteProfile(), metricProgress.getDirectionsRouteDistance(), metricProgress.getDirectionsRouteDuration(), sessionState.rerouteCount(), sessionState.startTimestamp(), convertToArray(sessionState.beforeEventLocations()), convertToArray(sessionState.afterEventLocations()), // distanceCompleted
(int) sessionState.eventRouteDistanceCompleted(), // distanceRemaining
sessionState.eventRouteProgress().getDistanceRemaining(), // durationRemaining
sessionState.eventRouteProgress().getDurationRemaining(), // new distanceRemaining
rerouteEvent.getNewDistanceRemaining(), // new durationRemaining
rerouteEvent.getNewDurationRemaining(), sessionState.secondsSinceLastReroute(), TelemetryUtils.buildUUID(), rerouteEvent.getNewRouteGeometry(), sessionState.mockLocation(), sessionState.originalRequestIdentifier(), sessionState.requestIdentifier(), sessionState.originalGeometry(), sessionState.originalDistance(), sessionState.originalDuration(), null, upcomingInstruction, upcomingType, upcomingModifier, upcomingName, previousInstruction, previousType, previousModifier, previousName, metricProgress.getCurrentStepDistance(), metricProgress.getCurrentStepDuration(), metricProgress.getCurrentStepDistanceRemaining(), metricProgress.getCurrentStepDurationRemaining(), sessionState.currentStepCount(), sessionState.originalStepCount());
navRerouteEvent.put(MapboxNavigationEvent.KEY_CREATED, TelemetryUtils.generateCreateDate(location));
int absoluteDistance = DistanceUtils.calculateAbsoluteDistance(location, metricProgress);
MapboxTelemetry.getInstance().addPercentTimeInForeground(sessionState.percentInForeground(), navRerouteEvent);
MapboxTelemetry.getInstance().addPercentTimeInPortrait(sessionState.percentInPortrait(), navRerouteEvent);
MapboxTelemetry.getInstance().addAbsoluteDistanceToDestination(absoluteDistance, navRerouteEvent);
MapboxTelemetry.getInstance().addLocationEngineName(sessionState.locationEngineName(), navRerouteEvent);
MapboxTelemetry.getInstance().pushEvent(navRerouteEvent);
MapboxTelemetry.getInstance().flushEventsQueueImmediately(false);
}
Aggregations