Search in sources :

Example 6 with LegStep

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);
}
Also used : ArrayList(java.util.ArrayList) Point(com.mapbox.geojson.Point) LegStep(com.mapbox.api.directions.v5.models.LegStep) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest) Test(org.junit.Test)

Example 7 with LegStep

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);
    }
}
Also used : LegStep(com.mapbox.api.directions.v5.models.LegStep)

Example 8 with LegStep

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());
}
Also used : LegStep(com.mapbox.api.directions.v5.models.LegStep)

Example 9 with LegStep

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());
        }
    }
}
Also used : BannerInstructions(com.mapbox.api.directions.v5.models.BannerInstructions) ArrayList(java.util.ArrayList)

Example 10 with LegStep

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();
}
Also used : LineString(com.mapbox.geojson.LineString) LegStep(com.mapbox.api.directions.v5.models.LegStep) NonNull(android.support.annotation.NonNull)

Aggregations

LegStep (com.mapbox.api.directions.v5.models.LegStep)18 Point (com.mapbox.geojson.Point)9 LineString (com.mapbox.geojson.LineString)5 BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)5 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)3 Location (android.location.Location)2 RouteLeg (com.mapbox.api.directions.v5.models.RouteLeg)2 NonNull (android.support.annotation.NonNull)1 SpannableString (android.text.SpannableString)1 BannerInstructions (com.mapbox.api.directions.v5.models.BannerInstructions)1 DirectionsRoute (com.mapbox.api.directions.v5.models.DirectionsRoute)1 IntersectionLanes (com.mapbox.api.directions.v5.models.IntersectionLanes)1 StepIntersection (com.mapbox.api.directions.v5.models.StepIntersection)1 StepManeuver (com.mapbox.api.directions.v5.models.StepManeuver)1 CameraPosition (com.mapbox.mapboxsdk.camera.CameraPosition)1 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)1 LatLngBounds (com.mapbox.mapboxsdk.geometry.LatLngBounds)1