use of com.mapbox.services.android.navigation.v5.navigation.metrics.RerouteEvent in project mapbox-navigation-android by mapbox.
the class NavigationTelemetry method checkRerouteQueue.
private void checkRerouteQueue() {
Iterator<RerouteEvent> iterator = queuedRerouteEvents.listIterator();
while (iterator.hasNext()) {
RerouteEvent rerouteEvent = iterator.next();
if (shouldSendEvent(rerouteEvent.getSessionState())) {
sendRerouteEvent(rerouteEvent);
iterator.remove();
}
}
}
use of com.mapbox.services.android.navigation.v5.navigation.metrics.RerouteEvent in project mapbox-navigation-android by mapbox.
the class NavigationTelemetry method queueRerouteEvent.
private void queueRerouteEvent() {
updateLifecyclePercentages();
// Create a new session state given the current navigation session
Date eventDate = new Date();
SessionState rerouteEventSessionState = navigationSessionState.toBuilder().eventDate(eventDate).eventRouteProgress(metricProgress).eventLocation(metricLocation.getLocation()).secondsSinceLastReroute(getSecondsSinceLastReroute(eventDate)).mockLocation(metricLocation.getLocation().getProvider().equals(MOCK_PROVIDER)).build();
RerouteEvent rerouteEvent = new RerouteEvent(rerouteEventSessionState);
queuedRerouteEvents.add(rerouteEvent);
}
use of com.mapbox.services.android.navigation.v5.navigation.metrics.RerouteEvent in project mapbox-navigation-android by mapbox.
the class NavigationTelemetry method sendRerouteEvent.
private void sendRerouteEvent(RerouteEvent rerouteEvent) {
// If there isn't an updated geometry, don't send
if (rerouteEvent.getNewRouteGeometry() == null || rerouteEvent.getSessionState().startTimestamp() == null) {
return;
}
// Create arrays with locations from before / after the reroute occurred
List<Location> beforeLocations = createLocationListBeforeEvent(rerouteEvent.getSessionState().eventDate());
List<Location> afterLocations = createLocationListAfterEvent(rerouteEvent.getSessionState().eventDate());
// Update session state with locations after feedback
SessionState rerouteSessionState = rerouteEvent.getSessionState().toBuilder().beforeEventLocations(beforeLocations).afterEventLocations(afterLocations).build();
// Set the updated session state
rerouteEvent.setRerouteSessionState(rerouteSessionState);
NavigationMetricsWrapper.rerouteEvent(rerouteEvent, metricProgress, rerouteEvent.getSessionState().eventLocation());
}
use of com.mapbox.services.android.navigation.v5.navigation.metrics.RerouteEvent in project mapbox-navigation-android by mapbox.
the class NavigationTelemetry method updateLastRerouteEvent.
private void updateLastRerouteEvent(DirectionsRoute newDirectionsRoute) {
if (!queuedRerouteEvents.isEmpty()) {
RerouteEvent rerouteEvent = queuedRerouteEvents.get(queuedRerouteEvents.size() - 1);
List<Point> geometryPositions = PolylineUtils.decode(newDirectionsRoute.geometry(), Constants.PRECISION_6);
PolylineUtils.encode(geometryPositions, Constants.PRECISION_5);
rerouteEvent.setNewRouteGeometry(PolylineUtils.encode(geometryPositions, Constants.PRECISION_5));
int newDistanceRemaining = newDirectionsRoute.distance() == null ? 0 : newDirectionsRoute.distance().intValue();
rerouteEvent.setNewDistanceRemaining(newDistanceRemaining);
int newDurationRemaining = newDirectionsRoute.duration() == null ? 0 : newDirectionsRoute.duration().intValue();
rerouteEvent.setNewDurationRemaining(newDurationRemaining);
}
}
use of com.mapbox.services.android.navigation.v5.navigation.metrics.RerouteEvent 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