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);
}
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()));
}
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);
}
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));
}
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));
}
Aggregations