Skip to content

Commit

Permalink
Merge branch 'grs-fix-offroute-false-positive' into fix-build
Browse files Browse the repository at this point in the history
* grs-fix-offroute-false-positive: (50 commits)
  add missing imports
  offroute detector should get the right upComingStep instead of the last step of the leg to do the calculation
  Resolves several code issues (mapbox#287)
  removed OSRM-Text-Instructions (mapbox#288)
  readme bump to 0.6.1 (mapbox#282)
  0.6.1 Release (mapbox#283)
  fix navigation events so that use the correct sdk identifier depending on where they come from (navigation or navigation-ui) (mapbox#277)
  fix a bug where the snappedPoint lat/lng values are infinity if the step geometry is a single point (for example the last step of a leg) instead of a line string
  we don't need to enter in this condition if isOffRoute is false
  fix mockNavigation activity waypoints adding order + zoom level for easier testing
  add offroute event listener on mockLocation activity, so we can test this
  bumped version # in readme (mapbox#267)
  Release 0.6 (mapbox#262)
  Don't remove milestone listener on arrival / adjust arrival verbiage
  Update Camera tilt and MAS dependency (mapbox#261)
  unknown profile (mapbox#259)
  Bump up Navigation UI example / change log position (mapbox#260)
  Reduce Reroute Threshold (mapbox#251)
  Camera and location layer ignore null location (mapbox#252)
  User agent plus exit roundabout (mapbox#250)
  ...

# Conflicts:
#	navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/DefaultMilestones.java
#	navigation/libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationHelper.java
  • Loading branch information
Adrien Grsmto committed Oct 3, 2017
2 parents 4075ecd + 0830285 commit a4f786e
Show file tree
Hide file tree
Showing 538 changed files with 6,697 additions and 8,015 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

Mapbox welcomes participation and contributions from everyone.

### v0.6.1 - September 28, 2017
* Telemetry Updates

### v0.6.0 - September 21, 2017
* First iteration of the Navigation UI
* Optimized Navigation features which were causing slowdowns on long steps - [219](https://github.com/mapbox/mapbox-navigation-android/pull/219)
* Only decode step geometry when needed - [215](https://github.com/mapbox/mapbox-navigation-android/pull/215)
* Introduced metrics
* Cleaned up code and fixed several bugs

### v0.5.0 - August 30, 2017
* use followonstep inside routeprogress for instruction - [#188](https://github.com/mapbox/mapbox-navigation-android/pull/188)
* Persistent notification [#177](https://github.com/mapbox/mapbox-navigation-android/pull/177)
* Fixes crash occurring ocasionally at end of route - [#175](https://github.com/mapbox/mapbox-navigation-android/pull/175)
* Cleaned up RouteProgress object to use AutoValue builders - [#164](https://github.com/mapbox/mapbox-navigation-android/pull/164)
* Run calculations and cleaned up `MapboxNavigation` class - [#151](https://github.com/mapbox/mapbox-navigation-android/pull/151)

### v0.4.0 - August 1, 2017
* Add new alert level concept called, milestones [#84](https://github.com/mapbox/mapbox-navigation-android/pull/84)
* Multiple way point support added [#76](https://github.com/mapbox/mapbox-navigation-android/pull/76)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The snippet to add to your `build.gradle` file to use this SDK is the following:
```
// Mapbox Navigation SDK for Android
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.4.0'
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.1'
```

Expand All @@ -45,7 +45,7 @@ repositories {
}
dependencies {
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.5.0-SNAPSHOT'
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.7.0-SNAPSHOT'
}
```

Expand Down
1 change: 0 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ jobs:
docker:
- image: mbgl/ci@sha256:c34e221294d81da80918d3e9a9df5de795b067e88f86d7c9a5e262763332536e
working_directory: ~/code
environment:
environment:
BUILDTYPE: Release
IS_LOCAL_DEVELOPMENT: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.view.View;

import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute;

import org.hamcrest.Matcher;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.services.android.navigation.testapp.activity.navigationui.NavigationMapRouteActivity;
import com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute;
import com.mapbox.services.android.utils.OnMapReadyIdlingResource;

import org.junit.After;
Expand All @@ -24,9 +25,9 @@
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static com.mapbox.services.android.navigation.ui.v5.NavigationMapRoute.NavigationMapLayers.NAVIGATION_ROUTE_LAYER;
import static com.mapbox.services.android.navigation.ui.v5.NavigationMapRoute.NavigationMapLayers.NAVIGATION_ROUTE_SHIELD_LAYER;
import static com.mapbox.services.android.navigation.ui.v5.NavigationMapRoute.NavigationMapSources.NAVIGATION_ROUTE_SOURCE;
import static com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute.NavigationMapLayers.NAVIGATION_ROUTE_LAYER;
import static com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute.NavigationMapLayers.NAVIGATION_ROUTE_SHIELD_LAYER;
import static com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute.NavigationMapSources.NAVIGATION_ROUTE_SOURCE;
import static junit.framework.Assert.assertTrue;

@RunWith(AndroidJUnit4.class)
Expand Down
9 changes: 9 additions & 0 deletions navigation/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,14 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
</activity>

<activity
android:name=".activity.navigationui.NavigationViewActivity"
android:label="@string/title_navigation_view_ui">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
</activity>

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.mapbox.services.android.navigation.testapp.activity.RerouteActivity;
import com.mapbox.services.android.navigation.testapp.activity.SnapToRouteActivity;
import com.mapbox.services.android.navigation.testapp.activity.navigationui.NavigationMapRouteActivity;
import com.mapbox.services.android.navigation.testapp.activity.navigationui.NavigationViewActivity;
import com.mapbox.services.android.telemetry.permissions.PermissionsListener;
import com.mapbox.services.android.telemetry.permissions.PermissionsManager;

Expand All @@ -36,6 +37,11 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_main);

final List<SampleItem> samples = new ArrayList<>(Arrays.asList(
new SampleItem(
getString(R.string.title_navigation_view_ui),
getString(R.string.description_navigation_view_ui),
NavigationViewActivity.class
),
new SampleItem(
getString(R.string.title_mock_navigation),
getString(R.string.description_mock_navigation),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
import android.view.View;

import com.google.gson.Gson;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.annotations.PolylineOptions;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerMode;
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
import com.mapbox.services.android.location.MockLocationEngine;
import com.mapbox.services.android.navigation.testapp.R;
Expand Down Expand Up @@ -60,9 +62,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
MapboxNavigationOptions options = MapboxNavigationOptions.builder()
.defaultMilestonesEnabled(false)
.snapToRoute(false)
.enableOffRouteDetection(false)
.build();
navigation = new MapboxNavigation(this, options);

navigation = new MapboxNavigation(this, Mapbox.getAccessToken(), options);
navigation.addProgressChangeListener(this);
locationEngine = new MockLocationEngine();
locationEngine.activate();
Expand All @@ -71,11 +73,12 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
@Override
public void onMapReady(MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.42067211454105, -122.26105120655842), 10));
locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, null);
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(38.00287907761617, -121.8483493917405), 10));
mapboxMap.addPolyline(new PolylineOptions()
.add(new LatLng(37.42067211454105, -122.26105120655842))
.add(new LatLng(38.00287907761617, -121.8483493917405)).color(Color.BLUE).width(5f));
locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, null);
locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.NAVIGATION);
}

@Override
Expand All @@ -85,9 +88,9 @@ public void onProgressChange(Location location, RouteProgress routeProgress) {

@OnClick(R.id.startNavigationFab)
public void onFabClick(View view) {
((MockLocationEngine) locationEngine).setRoute(route);
navigation.addProgressChangeListener(this);
navigation.setLocationEngine(locationEngine);
mapboxMap.setLocationSource(locationEngine);
((MockLocationEngine) locationEngine).setRoute(route);
navigation.startNavigation(route);
}

Expand All @@ -107,12 +110,18 @@ public void onPause() {
protected void onStart() {
super.onStart();
mapView.onStart();
if (locationLayerPlugin != null) {
locationLayerPlugin.onStart();
}
}

@Override
protected void onStop() {
super.onStop();
mapView.onStop();
if (locationLayerPlugin != null) {
locationLayerPlugin.onStop();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import com.mapbox.services.android.location.MockLocationEngine;
import com.mapbox.services.android.navigation.testapp.R;
import com.mapbox.services.android.navigation.testapp.Utils;
import com.mapbox.services.android.navigation.ui.v5.NavigationMapRoute;
import com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute;
import com.mapbox.services.android.navigation.v5.instruction.Instruction;
import com.mapbox.services.android.navigation.v5.milestone.MilestoneEventListener;
import com.mapbox.services.android.navigation.v5.milestone.RouteMilestone;
Expand All @@ -34,6 +34,7 @@
import com.mapbox.services.android.navigation.v5.navigation.NavigationConstants;
import com.mapbox.services.android.navigation.v5.navigation.NavigationEventListener;
import com.mapbox.services.android.navigation.v5.navigation.NavigationRoute;
import com.mapbox.services.android.navigation.v5.offroute.OffRouteListener;
import com.mapbox.services.android.navigation.v5.routeprogress.ProgressChangeListener;
import com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress;
import com.mapbox.services.android.telemetry.location.LocationEngine;
Expand All @@ -52,7 +53,7 @@
import timber.log.Timber;

public class MockNavigationActivity extends AppCompatActivity implements OnMapReadyCallback,
MapboxMap.OnMapClickListener, ProgressChangeListener, NavigationEventListener, MilestoneEventListener {
MapboxMap.OnMapClickListener, ProgressChangeListener, NavigationEventListener, MilestoneEventListener, OffRouteListener {

private static final int BEGIN_ROUTE_MILESTONE = 1001;

Expand All @@ -67,6 +68,7 @@ public class MockNavigationActivity extends AppCompatActivity implements OnMapRe
Button startRouteButton;

private MapboxMap mapboxMap;
private boolean running;

// Navigation related variables
private LocationEngine locationEngine;
Expand All @@ -86,7 +88,7 @@ protected void onCreate(Bundle savedInstanceState) {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);

navigation = new MapboxNavigation(this);
navigation = new MapboxNavigation(this, Mapbox.getAccessToken());

navigation.addMilestone(new RouteMilestone.Builder()
.setIdentifier(BEGIN_ROUTE_MILESTONE)
Expand All @@ -111,6 +113,7 @@ public void onStartRouteClick() {
navigation.addNavigationEventListener(this);
navigation.addProgressChangeListener(this);
navigation.addMilestoneEventListener(this);
navigation.addOffRouteListener(this);

((MockLocationEngine) locationEngine).setRoute(route);
navigation.setLocationEngine(locationEngine);
Expand All @@ -130,7 +133,7 @@ private void newOrigin() {
((MockLocationEngine) locationEngine).setLastLocation(
Position.fromLngLat(latLng.getLongitude(), latLng.getLatitude())
);
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 12));
mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 17));
mapboxMap.setMyLocationEnabled(true);
mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
}
Expand Down Expand Up @@ -159,7 +162,8 @@ public void onMapClick(@NonNull LatLng point) {
if (destination == null) {
destination = Position.fromLngLat(point.getLongitude(), point.getLatitude());
} else if (waypoint == null) {
waypoint = Position.fromLngLat(point.getLongitude(), point.getLatitude());
waypoint = destination;
destination = Position.fromLngLat(point.getLongitude(), point.getLatitude());
} else {
Toast.makeText(this, "Only 2 waypoints supported", Toast.LENGTH_LONG).show();
}
Expand Down Expand Up @@ -247,8 +251,14 @@ public void onMilestoneEvent(RouteProgress routeProgress, String instruction, in
}
}

@Override
public void userOffRoute(Location location) {
Timber.d("offRoute");
}

@Override
public void onRunning(boolean running) {
this.running = running;
if (running) {
Timber.d("onRunning: Started");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected void onCreate(Bundle savedInstanceState) {
mapView.getMapAsync(this);

// Initialize MapboxNavigation and add listeners
navigation = new MapboxNavigation(this);
navigation = new MapboxNavigation(this, Mapbox.getAccessToken());
navigation.addNavigationEventListener(this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void onClick(View view) {
}
});

mapView = (MapView) findViewById(R.id.mapview);
mapView = findViewById(R.id.mapview);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
}
Expand Down Expand Up @@ -133,8 +133,9 @@ public void onMapClick(@NonNull LatLng point) {
.stepDistanceRemaining(currentRoute.getLegs().get(0).getSteps().get(stepCount).getDistance())
.build();

List<Position> positions = PolylineUtils.decode(currentRoute.getGeometry(), Constants.PRECISION_6);
SnapToRoute snapToRoute = new SnapToRoute();
Location snappedLocation = snapToRoute.getSnappedLocation(location, routeProgress);
Location snappedLocation = snapToRoute.getSnappedLocation(location, routeProgress, positions);

if (snappedLocation == null) {
Log.i(TAG, "snappedLocation is null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.services.android.navigation.testapp.R;
import com.mapbox.services.android.navigation.ui.v5.NavigationMapRoute;
import com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute;
import com.mapbox.services.api.directions.v5.DirectionsCriteria;
import com.mapbox.services.api.directions.v5.MapboxDirections;
import com.mapbox.services.api.directions.v5.models.DirectionsResponse;
Expand Down
Loading

0 comments on commit a4f786e

Please sign in to comment.