use of com.mapbox.api.directions.v5.models.LegStep in project mapbox-navigation-android by mapbox.
the class MeasurementUtilsTest method userTrueDistanceFromStep_onlyOnePointInLineStringStillMeasuresDistanceCorrectly.
@Test
public void userTrueDistanceFromStep_onlyOnePointInLineStringStillMeasuresDistanceCorrectly() {
Point futurePoint = Point.fromLngLat(-95.3676974, 29.7589382);
List<Point> geometryPoints = new ArrayList<>();
geometryPoints.add(Point.fromLngLat(-95.8427, 29.7757));
double[] rawLocation = { 0, 0 };
LegStep step = getLegStep(rawLocation, geometryPoints);
double distance = MeasurementUtils.userTrueDistanceFromStep(futurePoint, step);
assertEquals(45900.73617999494, distance, DELTA);
}
use of com.mapbox.api.directions.v5.models.LegStep in project mapbox-navigation-android by mapbox.
the class InstructionView method updateViews.
private void updateViews(InstructionModel model) {
updateManeuverView(model);
updateDistanceText(model);
updateInstructionList(model);
updateTurnLanes(model);
updateThenStep(model);
if (newStep(model.getProgress())) {
// Pre-fetch the image URLs for the upcoming step
LegStep upComingStep = model.getProgress().currentLegProgress().upComingStep();
InstructionLoader.getInstance().prefetchImageCache(upComingStep);
}
}
use of com.mapbox.api.directions.v5.models.LegStep in project mapbox-navigation-android by mapbox.
the class InstructionListAdapter method updateManeuverView.
private void updateManeuverView(InstructionViewHolder holder, LegStep step) {
LegStep maneuverStep = step;
// Get the upcoming LegStep for the ManeuverView if there is one
int upcomingStepIndex = stepList.indexOf(step) + 1;
if (upcomingStepIndex < stepList.size()) {
maneuverStep = stepList.get(upcomingStepIndex);
}
holder.maneuverView.setManeuverModifier(maneuverStep.maneuver().modifier());
holder.maneuverView.setManeuverType(maneuverStep.maneuver().type());
}
use of com.mapbox.api.directions.v5.models.LegStep in project mapbox-navigation-android by mapbox.
the class InstructionLoader method prefetchImageCache.
/**
* Will pre-fetch images for a given {@link LegStep}.
* <p>
* If loaded successfully, this will allow the images to be displayed
* without delay in the {@link InstructionView}.
*
* @param step providing the image Urls
*/
public void prefetchImageCache(LegStep step) {
if (step == null || step.bannerInstructions() == null || step.bannerInstructions().isEmpty()) {
return;
}
checkIsInitialized();
List<BannerInstructions> bannerInstructionList = new ArrayList<>(step.bannerInstructions());
for (BannerInstructions instructions : bannerInstructionList) {
if (hasComponents(instructions.primary())) {
fetchImageBaseUrls(instructions.primary());
}
if (hasComponents(instructions.secondary())) {
fetchImageBaseUrls(instructions.secondary());
}
}
}
use of com.mapbox.api.directions.v5.models.LegStep in project mapbox-navigation-android by mapbox.
the class BaseTest method createCoordinatesFromCurrentStep.
@NonNull
protected List<Point> createCoordinatesFromCurrentStep(RouteProgress progress) {
LegStep currentStep = progress.currentLegProgress().currentStep();
LineString lineString = LineString.fromPolyline(currentStep.geometry(), Constants.PRECISION_6);
return lineString.coordinates();
}
Aggregations