use of com.mapbox.geojson.Point in project mapbox-navigation-android by mapbox.
the class RouteViewModel method extractCoordinatesFromOptions.
/**
* Extracts the {@link Point} coordinates, adds a destination marker,
* and fetches a route with the coordinates.
*
* @param options containing origin and destination
*/
private void extractCoordinatesFromOptions(NavigationViewOptions options) {
if (options.origin() != null && options.destination() != null) {
cacheRouteProfile(options);
cacheRouteLanguage(options, null);
Point origin = options.origin();
destination.setValue(options.destination());
fetchRouteFromCoordinates(origin, destination.getValue());
}
}
use of com.mapbox.geojson.Point in project mapbox-navigation-android by mapbox.
the class RouteViewModel method fetchRouteFromOffRouteEvent.
/**
* Requests a new {@link DirectionsRoute}.
* <p>
* Will use {@link Location} bearing if we have a rawLocation with bearing.
* <p>
* Called when an off-route event is fired and a new {@link DirectionsRoute}
* is needed to continue navigating.
*
* @param event found from off-route event
*/
public void fetchRouteFromOffRouteEvent(OffRouteEvent event) {
if (OffRouteEvent.isValid(event)) {
Double bearing = null;
if (rawLocation != null) {
bearing = rawLocation.hasBearing() ? Float.valueOf(rawLocation.getBearing()).doubleValue() : null;
}
Point origin = event.getNewOrigin();
RouteProgress progress = event.getRouteProgress();
NavigationRoute.Builder builder = buildRouteRequestFromCurrentLocation(origin, bearing, progress);
if (builder != null) {
addNavigationViewOptions(builder);
builder.alternatives(true);
builder.build().getRoute(this);
}
}
}
Aggregations