use of com.mapbox.api.directions.v5.models.LegStep in project mapbox-navigation-android by mapbox.
the class OffRouteDetectorTest method setupStepPoints.
private void setupStepPoints(OffRouteDetector offRouteDetector) throws Exception {
RouteProgress routeProgress = buildDefaultRouteProgress();
LegStep currentStep = routeProgress.currentLegProgress().currentStep();
LineString lineString = LineString.fromPolyline(currentStep.geometry(), Constants.PRECISION_6);
List<Point> stepPoints = lineString.coordinates();
offRouteDetector.updateStepPoints(stepPoints);
}
use of com.mapbox.api.directions.v5.models.LegStep in project mapbox-navigation-android by mapbox.
the class DynamicCamera method createCameraPosition.
/**
* Creates a camera position with the current location and upcoming maneuver location.
* <p>
* Using {@link MapboxMap#getCameraForLatLngBounds(LatLngBounds, int[])} with a {@link LatLngBounds}
* that includes the current location and upcoming maneuver location.
*
* @param location for current location
* @param routeProgress for upcoming maneuver location
* @return camera position that encompasses both locations
*/
private CameraPosition createCameraPosition(Location location, RouteProgress routeProgress) {
LegStep upComingStep = routeProgress.currentLegProgress().upComingStep();
if (upComingStep != null) {
Point stepManeuverPoint = upComingStep.maneuver().location();
List<LatLng> latLngs = new ArrayList<>();
LatLng currentLatLng = new LatLng(location);
LatLng maneuverLatLng = new LatLng(stepManeuverPoint.latitude(), stepManeuverPoint.longitude());
latLngs.add(currentLatLng);
latLngs.add(maneuverLatLng);
if (latLngs.size() < 1 || currentLatLng.equals(maneuverLatLng)) {
return mapboxMap.getCameraPosition();
}
LatLngBounds cameraBounds = new LatLngBounds.Builder().includes(latLngs).build();
int[] padding = { 0, 0, 0, 0 };
CameraPosition positionForLatLngBounds = mapboxMap.getCameraForLatLngBounds(cameraBounds, padding);
if (positionForLatLngBounds != null) {
return positionForLatLngBounds;
}
}
return mapboxMap.getCameraPosition();
}
use of com.mapbox.api.directions.v5.models.LegStep in project mapbox-navigation-android by mapbox.
the class InstructionStepResources method intersectionTurnLanes.
private void intersectionTurnLanes(LegStep step) {
StepIntersection intersection = step.intersections().get(0);
List<IntersectionLanes> lanes = intersection.lanes();
if (checkForNoneIndications(lanes)) {
turnLanes = null;
return;
}
turnLanes = lanes;
}
use of com.mapbox.api.directions.v5.models.LegStep in project mapbox-navigation-android by mapbox.
the class InstructionStepResources method extractStepResources.
private void extractStepResources(RouteProgress progress) {
LegStep currentStep = progress.currentLegProgress().currentStep();
LegStep upcomingStep = progress.currentLegProgress().upComingStep();
LegStep followOnStep = progress.currentLegProgress().followOnStep();
// Type / Modifier / Text
if (upcomingStep != null) {
maneuverViewType = upcomingStep.maneuver().type();
maneuverViewModifier = upcomingStep.maneuver().modifier();
// Then step (step after upcoming)
if (followOnStep != null) {
thenStep(upcomingStep, followOnStep, progress.currentLegProgress().currentStepProgress().durationRemaining());
}
// Turn lane data
if (hasIntersections(upcomingStep)) {
intersectionTurnLanes(upcomingStep);
}
} else {
maneuverViewType = currentStep.maneuver().type();
maneuverViewModifier = currentStep.maneuver().modifier();
}
}
use of com.mapbox.api.directions.v5.models.LegStep in project mapbox-navigation-android by mapbox.
the class InstructionListAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(InstructionViewHolder holder, int position) {
if (stepList.get(position) != null) {
LegStep step = stepList.get(position);
if (hasBannerInstructions(step)) {
updatePrimaryText(holder, step.bannerInstructions().get(0).primary());
updateSecondaryText(holder, step.bannerInstructions().get(0).secondary());
} else {
holder.stepPrimaryText.setText(step.maneuver().instruction());
updateSecondaryText(holder, null);
}
updateManeuverView(holder, step);
SpannableString distanceText = distanceUtils.formatDistance(step.distance());
holder.stepDistanceText.setText(distanceText);
}
}
Aggregations