Search in sources :

Example 51 with Point

use of com.mapbox.geojson.Point in project mapbox-navigation-android by mapbox.

the class NavigationHelperTest method stepDistanceRemaining_returnsZeroWhenPositionsEqualEachOther.

@Test
public void stepDistanceRemaining_returnsZeroWhenPositionsEqualEachOther() throws Exception {
    Point snappedPoint = Point.fromLngLat(-77.062996, 38.798405);
    List<Point> coordinates = PolylineUtils.decode(route.legs().get(0).steps().get(1).geometry(), Constants.PRECISION_6);
    double distance = NavigationHelper.stepDistanceRemaining(snappedPoint, 0, 1, route, coordinates);
    assertEquals(0.0, distance);
}
Also used : Point(com.mapbox.geojson.Point) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest) Test(org.junit.Test)

Example 52 with Point

use of com.mapbox.geojson.Point in project mapbox-navigation-android by mapbox.

the class NavigationHelperTest method nextManeuverPosition_correctlyReturnsNextManeuverPositionInNextLeg.

@Test
public void nextManeuverPosition_correctlyReturnsNextManeuverPositionInNextLeg() throws Exception {
    int stepIndex = route.legs().get(0).steps().size() - 1;
    List<Point> coordinates = PolylineUtils.decode(route.legs().get(0).steps().get(stepIndex).geometry(), Constants.PRECISION_6);
    Point nextManeuver = NavigationHelper.nextManeuverPosition(stepIndex, route.legs().get(0).steps(), coordinates);
    assertTrue(nextManeuver.equals(route.legs().get(1).steps().get(0).maneuver().location()));
}
Also used : Point(com.mapbox.geojson.Point) Point(com.mapbox.geojson.Point) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest) Test(org.junit.Test)

Example 53 with Point

use of com.mapbox.geojson.Point in project mapbox-navigation-android by mapbox.

the class NavigationRouteProcessorTest method onStepDistanceRemainingZeroAndNoBearingMatch_stepIndexForceIncreased.

@Test
public void onStepDistanceRemainingZeroAndNoBearingMatch_stepIndexForceIncreased() throws Exception {
    RouteProgress firstProgress = routeProcessor.buildNewRouteProgress(navigation, mock(Location.class));
    int firstProgressIndex = firstProgress.currentLegProgress().stepIndex();
    List<Point> coordinates = createCoordinatesFromCurrentStep(firstProgress);
    Point lastPointInCurrentStep = coordinates.remove(coordinates.size() - 1);
    Location rawLocation = buildDefaultLocationUpdate(lastPointInCurrentStep.longitude(), lastPointInCurrentStep.latitude());
    RouteProgress secondProgress = routeProcessor.buildNewRouteProgress(navigation, rawLocation);
    int secondProgressIndex = secondProgress.currentLegProgress().stepIndex();
    assertTrue(firstProgressIndex != secondProgressIndex);
}
Also used : Point(com.mapbox.geojson.Point) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) Point(com.mapbox.geojson.Point) Location(android.location.Location) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 54 with Point

use of com.mapbox.geojson.Point in project mapbox-navigation-android by mapbox.

the class NavigationRouteProcessorTest method onSnapToRouteEnabledAndUserOffRoute_rawLocationReturns.

@Test
public void onSnapToRouteEnabledAndUserOffRoute_rawLocationReturns() throws Exception {
    RouteProgress progress = routeProcessor.buildNewRouteProgress(navigation, mock(Location.class));
    boolean snapEnabled = false;
    boolean userOffRoute = false;
    List<Point> coordinates = createCoordinatesFromCurrentStep(progress);
    Point lastPointInCurrentStep = coordinates.remove(coordinates.size() - 1);
    Location rawLocation = buildDefaultLocationUpdate(lastPointInCurrentStep.longitude(), lastPointInCurrentStep.latitude());
    Location snappedLocation = routeProcessor.buildSnappedLocation(navigation, snapEnabled, rawLocation, progress, userOffRoute);
    assertTrue(rawLocation.equals(snappedLocation));
}
Also used : Point(com.mapbox.geojson.Point) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) Location(android.location.Location) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 55 with Point

use of com.mapbox.geojson.Point in project mapbox-navigation-android by mapbox.

the class NavigationRouteProcessorTest method onSnapToRouteDisabledAndUserOnRoute_rawLocationReturns.

@Test
public void onSnapToRouteDisabledAndUserOnRoute_rawLocationReturns() throws Exception {
    RouteProgress progress = routeProcessor.buildNewRouteProgress(navigation, mock(Location.class));
    boolean snapEnabled = false;
    boolean userOffRoute = false;
    List<Point> coordinates = createCoordinatesFromCurrentStep(progress);
    Point lastPointInCurrentStep = coordinates.remove(coordinates.size() - 1);
    Location rawLocation = buildDefaultLocationUpdate(lastPointInCurrentStep.longitude(), lastPointInCurrentStep.latitude());
    Location snappedLocation = routeProcessor.buildSnappedLocation(navigation, snapEnabled, rawLocation, progress, userOffRoute);
    assertTrue(rawLocation.equals(snappedLocation));
}
Also used : Point(com.mapbox.geojson.Point) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) Location(android.location.Location) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Aggregations

Point (com.mapbox.geojson.Point)72 Test (org.junit.Test)31 BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)29 Location (android.location.Location)18 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)17 LineString (com.mapbox.geojson.LineString)15 ArrayList (java.util.ArrayList)10 LegStep (com.mapbox.api.directions.v5.models.LegStep)9 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)7 Feature (com.mapbox.geojson.Feature)4 NavigationRoute (com.mapbox.services.android.navigation.v5.navigation.NavigationRoute)4 DirectionsResponse (com.mapbox.api.directions.v5.models.DirectionsResponse)3 DirectionsRoute (com.mapbox.api.directions.v5.models.DirectionsRoute)3 CameraPosition (com.mapbox.mapboxsdk.camera.CameraPosition)3 LatLngBounds (com.mapbox.mapboxsdk.geometry.LatLngBounds)3 Gson (com.google.gson.Gson)2 GsonBuilder (com.google.gson.GsonBuilder)2 RouteOptions (com.mapbox.api.directions.v5.models.RouteOptions)2 MarkerOptions (com.mapbox.mapboxsdk.annotations.MarkerOptions)2 BaseTest (com.mapbox.services.android.navigation.ui.v5.BaseTest)2