use of com.mapbox.api.directions.v5.models.DirectionsRoute in project mapbox-navigation-android by mapbox.
the class NavigationMapRoute method findClickedRoute.
private boolean findClickedRoute(@NonNull LatLng point) {
HashMap<Double, DirectionsRoute> routeDistancesAwayFromClick = new HashMap<>();
com.mapbox.geojson.Point clickPoint = com.mapbox.geojson.Point.fromLngLat(point.getLongitude(), point.getLatitude());
if (calculateClickDistancesFromRoutes(routeDistancesAwayFromClick, clickPoint)) {
return true;
}
List<Double> distancesAwayFromClick = new ArrayList<>(routeDistancesAwayFromClick.keySet());
Collections.sort(distancesAwayFromClick);
DirectionsRoute clickedRoute = routeDistancesAwayFromClick.get(distancesAwayFromClick.get(0));
primaryRouteIndex = directionsRoutes.indexOf(clickedRoute);
return false;
}
use of com.mapbox.api.directions.v5.models.DirectionsRoute in project mapbox-navigation-android by mapbox.
the class RouteViewModel method extractRouteFromOptions.
/**
* Extracts the {@link DirectionsRoute}, adds a destination marker,
* and starts navigation.
*
* @param options containing route
*/
private void extractRouteFromOptions(NavigationViewOptions options) {
DirectionsRoute route = options.directionsRoute();
if (route != null) {
cacheRouteInformation(options, route);
this.route.setValue(route);
}
}
use of com.mapbox.api.directions.v5.models.DirectionsRoute in project mapbox-navigation-android by mapbox.
the class RouteViewModel method processRoute.
private void processRoute(@NonNull Response<DirectionsResponse> response) {
if (isValidRoute(response)) {
List<DirectionsRoute> routes = response.body().routes();
DirectionsRoute bestRoute = routes.get(FIRST_ROUTE);
DirectionsRoute chosenRoute = route.getValue();
if (isNavigationRunning(chosenRoute)) {
bestRoute = obtainMostSimilarRoute(routes, bestRoute, chosenRoute);
}
route.setValue(bestRoute);
}
}
Aggregations