Search in sources :

Example 31 with Point

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

the class NavigationView method initMapPadding.

/**
 * Create a top map padding value that pushes the focal point
 * of the map to the bottom of the screen (above the bottom sheet).
 */
private void initMapPadding() {
    int mapViewHeight = mapView.getHeight();
    int bottomSheetHeight = summaryBottomSheet.getHeight();
    int topPadding = mapViewHeight - (bottomSheetHeight * 4);
    map.setPadding(0, topPadding, 0, 0);
}
Also used : Point(com.mapbox.geojson.Point)

Example 32 with Point

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

the class LocationLayer method onNewLatLngValue.

@Override
public void onNewLatLngValue(LatLng latLng) {
    Point point = Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude());
    setLocationPoint(point);
}
Also used : Point(com.mapbox.geojson.Point)

Example 33 with Point

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

the class MeasurementUtilsTest method userTrueDistanceFromStep_onePointStepGeometryWithDifferentRawPoint.

@Test
public void userTrueDistanceFromStep_onePointStepGeometryWithDifferentRawPoint() {
    Point futurePoint = Point.fromLngLat(-95.3676974, 29.7589382);
    List<Point> geometryPoints = new ArrayList<>();
    geometryPoints.add(Point.fromLngLat(-95.8427, 29.7757));
    geometryPoints.add(futurePoint);
    double[] rawLocation = { 0, 0 };
    LegStep step = getLegStep(rawLocation, geometryPoints);
    double distance = MeasurementUtils.userTrueDistanceFromStep(futurePoint, step);
    assertEquals(0.04457271773629306d, 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 34 with Point

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

the class ToleranceUtilsTest method dynamicRerouteDistanceTolerance_userJustPastTheIntersection.

@Test
public void dynamicRerouteDistanceTolerance_userJustPastTheIntersection() throws Exception {
    RouteProgress routeProgress = RouteProgress.builder().directionsRoute(response.routes().get(0)).legDistanceRemaining(0).distanceRemaining(0).stepIndex(0).legIndex(0).build();
    double distanceToIntersection = response.routes().get(0).distance();
    LineString lineString = LineString.fromPolyline(response.routes().get(0).geometry(), Constants.PRECISION_6);
    Point closePoint = TurfMeasurement.along(lineString, distanceToIntersection, TurfConstants.UNIT_METERS);
    double tolerance = ToleranceUtils.dynamicRerouteDistanceTolerance(closePoint, routeProgress);
    assertEquals(25.0, tolerance, DELTA);
}
Also used : LineString(com.mapbox.geojson.LineString) Point(com.mapbox.geojson.Point) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 35 with Point

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

the class ToleranceUtilsTest method dynamicRerouteDistanceTolerance_userFarAwayFromIntersection.

@Test
public void dynamicRerouteDistanceTolerance_userFarAwayFromIntersection() throws Exception {
    RouteProgress routeProgress = RouteProgress.builder().directionsRoute(response.routes().get(0)).legDistanceRemaining(0).distanceRemaining(0).stepIndex(0).legIndex(0).build();
    // Get a point on the route step which isn't close to an intersection.
    List<Point> stepPoints = PolylineUtils.decode(response.routes().get(0).geometry(), PRECISION_6);
    Point midPoint = TurfMeasurement.midpoint(stepPoints.get(0), stepPoints.get(1));
    double tolerance = ToleranceUtils.dynamicRerouteDistanceTolerance(midPoint, routeProgress);
    assertEquals(50.0, tolerance, DELTA);
}
Also used : Point(com.mapbox.geojson.Point) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) 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