-
Notifications
You must be signed in to change notification settings - Fork 319
Kyv onboard route #2300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Kyv onboard route #2300
Changes from all commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
d2e847e
Moved classes to base modules
RingerJK 9f23835
moved classes to another module
RingerJK c34f400
NavigationRouteCallback, NavigationWalkingOptions, NavigationRoute: m…
RingerJK ffe2b88
StepManeuverNavigation, RouteLegNavigation, Route, LegStepNavigation:…
RingerJK 3c1944b
moved classes to `libderections-common` module
RingerJK a4b76d6
Return dependecies to core api
RingerJK 3a1e075
- renamed module `libderections-common` -> `libdirections-common`; - …
RingerJK 1f03b07
fix merge issues
RingerJK 9b71906
- restrict mapboxSdkService dependency from `libnavigation-base` and …
RingerJK ba191db
Revert using Location -> Point
RingerJK c5a074c
removed `libdirections-common` module; added `Gson` impl for `JsonMap…
RingerJK 049e205
Moved classes to base modules
RingerJK b57ee94
moved classes to another module
RingerJK 8f3d20e
NavigationRouteCallback, NavigationWalkingOptions, NavigationRoute: m…
RingerJK cd4cc01
StepManeuverNavigation, RouteLegNavigation, Route, LegStepNavigation:…
RingerJK 6e1b83a
Fix tests and import
RingerJK 8c51647
NavigationRoute: replace import to internal usage
RingerJK 1057139
route common module
RingerJK f654ae5
moved classes to `libderections-common` module
RingerJK 5e51803
minor changes
RingerJK 400c49e
DefaultDirectionsSession: lint refactored
RingerJK 100fa92
Router: removed redundant func
RingerJK 630611b
DirectionsSession: change api, fix tests
RingerJK 042e013
Return dependecies to core api
RingerJK 09c1507
- renamed module `libderections-common` -> `libdirections-common`; - …
RingerJK fcb2e43
Navigation onboard: initial setup
RingerJK 8e461db
Navigator make public
RingerJK 70bd384
ktlint format
RingerJK 0e76d8a
ktlint format
RingerJK 0bb1a31
MapboxOnboardRouter: fetch route
RingerJK 391541e
fix rebase issues
RingerJK 3a4db40
fix pr issues: removed common module
RingerJK 6b957b6
removed mapboxSdkServices; added mapboxSdkGeoJSON dependency
RingerJK ed6813a
removed unused class
RingerJK 419b823
removed common module dependency
RingerJK ecd36c5
Restore Metric Reporter
RingerJK c6c2ef8
Restore Missing classes after rebase
RingerJK dba35f6
Onboard route: restrict Directions API dependency; added config
RingerJK 207e761
fix rebase
RingerJK 31bae21
rebase fixes
RingerJK b3ff9cd
temp commit
RingerJK 58f1e19
fix tests
RingerJK e7b904a
Navigation: Models + DTO classes
RingerJK c5c012a
removed PointNavigation
RingerJK 144d8f6
- JsonMapper: revert to Gson; - fix lint issues; - minor rename
RingerJK a8aede1
initial Activities test
RingerJK a671dfa
Direction API to Navigation models mappers
RingerJK 6ab3e4d
fix lint
RingerJK 55aa6b1
fix pr issues
RingerJK ca2b671
Dto classes: make public; introduces RouteResponse/Dto
RingerJK 2188dfd
RouteUrl: minor fixes; OfflineRouteRetrievalTask: retrive `RouteRespo…
RingerJK 5c0eb8d
- Onboard router: sample Activity Java + Kotlin; - make Dto classes p…
RingerJK 5d688a7
Mappers: explicitly specify return types
RingerJK 6af8bf9
Mappers: explicitly specify return types
RingerJK fa17213
- RouteUrl: test; - lint issues
RingerJK 29798f9
- Rebase fixes; lint fix
RingerJK 95d01ec
lint issue
RingerJK 7ea6a79
RouteResponse: minor improves
RingerJK da535b4
pr issues
RingerJK 0613138
fix rebase issue
RingerJK b4e6207
- Provide HttpClient for native; - Onboard test activities: comment d…
RingerJK d03aa2a
exclude `OnboardRouterActivityJava.java` from check style
RingerJK e607054
fix pr issue
RingerJK 9f4f033
fix rebase issues
RingerJK e8f5a44
rebase fixes
RingerJK f944279
rebase fix
RingerJK be05ab0
rebase fix
RingerJK 4220d03
fix pr issues: - moved OnBoard's Activities to `examples` module; - r…
RingerJK 551be46
Cleanup test and Test Onboard Activities
RingerJK a4117b3
cleanup code; fix pr issues
RingerJK 9bc2ab9
pr issue fixes
RingerJK f103784
rebase issues
RingerJK 18df0e7
rebase fixes
RingerJK 0beeb13
Fix rebase issues. Remove unused resources. Fix tests and naming
2d4a090
Fix rebase issues and some nits. Fix default values for route options…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
214 changes: 214 additions & 0 deletions
214
...ples/src/main/java/com/mapbox/navigation/examples/activity/OnboardRouterActivityJava.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,214 @@ | ||
| package com.mapbox.navigation.examples.activity; | ||
|
|
||
| import android.os.Bundle; | ||
| import android.os.Environment; | ||
| import android.widget.Toast; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
| import androidx.annotation.Nullable; | ||
| import androidx.appcompat.app.AppCompatActivity; | ||
|
|
||
| import com.google.android.material.snackbar.Snackbar; | ||
| import com.mapbox.api.directions.v5.models.DirectionsRoute; | ||
| import com.mapbox.geojson.Point; | ||
| import com.mapbox.mapboxsdk.annotations.MarkerOptions; | ||
| 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.maps.Style; | ||
| import com.mapbox.navigation.base.route.Router; | ||
| import com.mapbox.navigation.base.route.model.Route; | ||
| import com.mapbox.navigation.base.route.model.RouteOptionsNavigation; | ||
| import com.mapbox.navigation.examples.R; | ||
| import com.mapbox.navigation.examples.utils.Utils; | ||
| import com.mapbox.navigation.examples.utils.extensions.Mappers; | ||
| import com.mapbox.navigation.route.onboard.MapboxOnboardRouter; | ||
| import com.mapbox.navigation.route.onboard.model.Config; | ||
| import com.mapbox.services.android.navigation.ui.v5.route.NavigationMapRoute; | ||
|
|
||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| import java.io.File; | ||
| import java.util.List; | ||
|
|
||
| import butterknife.BindView; | ||
| import butterknife.ButterKnife; | ||
| import butterknife.OnClick; | ||
| import timber.log.Timber; | ||
|
|
||
| public class OnboardRouterActivityJava extends AppCompatActivity implements OnMapReadyCallback, | ||
| MapboxMap.OnMapClickListener { | ||
|
|
||
| private Router onboardRouter; | ||
| private MapboxMap mapboxMap; | ||
|
|
||
| private DirectionsRoute route; | ||
| private NavigationMapRoute navigationMapRoute; | ||
| private Point origin; | ||
| private Point destination; | ||
| private Point waypoint; | ||
|
|
||
| @BindView(R.id.mapView) | ||
| MapView mapView; | ||
|
|
||
| @Override | ||
| protected void onCreate(@Nullable Bundle savedInstanceState) { | ||
| super.onCreate(savedInstanceState); | ||
| setContentView(R.layout.activity_mock_navigation); | ||
| ButterKnife.bind(this); | ||
|
|
||
| setupRouter(); | ||
|
|
||
| mapView.onCreate(savedInstanceState); | ||
| mapView.getMapAsync(this); | ||
| } | ||
|
|
||
| private void setupRouter() { | ||
| File file = new File( | ||
| Environment.getExternalStoragePublicDirectory("Offline").getAbsolutePath(), | ||
| "2019_04_13-00_00_11"); | ||
| File fileTiles = new File(file, "tiles"); | ||
| Config config = new Config( | ||
| fileTiles.getAbsolutePath(), | ||
| null, | ||
| null, | ||
| null, | ||
| null // working with pre-fetched tiles only | ||
| ); | ||
|
|
||
| onboardRouter = new MapboxOnboardRouter(config, null); | ||
| } | ||
|
|
||
|
|
||
| @OnClick(R.id.newLocationFab) | ||
| public void onNewLocationClick() { | ||
| newOrigin(); | ||
| } | ||
|
|
||
| private void newOrigin() { | ||
| if (mapboxMap != null) { | ||
| clearMap(); | ||
| LatLng latLng = new LatLng(47.05991, 9.49183); | ||
| origin = Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()); | ||
| mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 12)); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onMapReady(@NonNull MapboxMap mapboxMap) { | ||
| this.mapboxMap = mapboxMap; | ||
| this.mapboxMap.addOnMapClickListener(this); | ||
| mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> { | ||
| navigationMapRoute = new NavigationMapRoute(mapView, mapboxMap); | ||
| Snackbar.make(findViewById(R.id.container), "Tap map to place waypoint", Snackbar.LENGTH_LONG).show(); | ||
| newOrigin(); | ||
| }); | ||
| } | ||
|
|
||
| private void clearMap() { | ||
| if (mapboxMap != null) { | ||
| mapboxMap.clear(); | ||
| route = null; | ||
| destination = null; | ||
| waypoint = null; | ||
| navigationMapRoute.updateRouteVisibilityTo(false); | ||
| navigationMapRoute.updateRouteArrowVisibilityTo(false); | ||
| } | ||
| } | ||
|
|
||
| private void findRoute() { | ||
| RouteOptionsNavigation.Builder optionsBuilder = new RouteOptionsNavigation.Builder() | ||
| .accessToken(Utils.getMapboxAccessToken(this)) | ||
| .origin(origin) | ||
| .destination(destination); | ||
| if (waypoint != null) { | ||
| optionsBuilder.addWaypoint(waypoint); | ||
| } | ||
| onboardRouter.getRoute(optionsBuilder.build(), new Router.Callback() { | ||
| @Override | ||
| public void onResponse(@NotNull List<Route> routes) { | ||
| if (!routes.isEmpty()) { | ||
| route = Mappers.mapToDirectionsRoute(routes.get(0)); | ||
| navigationMapRoute.addRoute(route); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void onFailure(@NotNull Throwable throwable) { | ||
| Timber.e(throwable, "onRoutesRequestFailure: navigation.getRoute()"); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean onMapClick(@NonNull LatLng point) { | ||
| if (destination == null) { | ||
| destination = Point.fromLngLat(point.getLongitude(), point.getLatitude()); | ||
| mapboxMap.addMarker(new MarkerOptions().position(point)); | ||
| findRoute(); | ||
| } else if (waypoint == null) { | ||
| waypoint = Point.fromLngLat(point.getLongitude(), point.getLatitude()); | ||
| mapboxMap.addMarker(new MarkerOptions().position(point)); | ||
| findRoute(); | ||
| } else { | ||
| Toast.makeText(this, "Only 2 waypoints supported for this example", Toast.LENGTH_LONG).show(); | ||
| clearMap(); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| /* | ||
| * Activity lifecycle methods | ||
| */ | ||
|
|
||
| @Override | ||
| public void onResume() { | ||
| super.onResume(); | ||
| mapView.onResume(); | ||
| } | ||
|
|
||
| @Override | ||
| public void onPause() { | ||
| super.onPause(); | ||
| mapView.onPause(); | ||
| } | ||
|
|
||
| @Override | ||
| protected void onStart() { | ||
| super.onStart(); | ||
| mapView.onStart(); | ||
| } | ||
|
|
||
| @Override | ||
| protected void onStop() { | ||
| super.onStop(); | ||
| mapView.onStop(); | ||
| } | ||
|
|
||
| @Override | ||
| public void onLowMemory() { | ||
| super.onLowMemory(); | ||
| mapView.onLowMemory(); | ||
| } | ||
|
|
||
| @Override | ||
| protected void onDestroy() { | ||
| super.onDestroy(); | ||
| if (onboardRouter != null) { | ||
| onboardRouter.cancel(); | ||
| onboardRouter = null; | ||
| } | ||
| if (mapboxMap != null) { | ||
| mapboxMap.removeOnMapClickListener(this); | ||
| mapView.onDestroy(); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected void onSaveInstanceState(Bundle outState) { | ||
| super.onSaveInstanceState(outState); | ||
| mapView.onSaveInstanceState(outState); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.