Add support for directions responses with "geojson" geometries
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia dal punto di ingresso DirectionsRoute.fromJson(String json) e dal modello di risposta MapboxDirections descritto nel report. Traccia come viene analizzata la geometria di uno step delle indicazioni e come viene serializzata una DirectionsRoute; il lavoro è completato quando i percorsi con geometria GeoJSON possono essere analizzati e serializzati per l’uso da parte del client senza l’eccezione segnalata o JSON vuoto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I am working on a project where our users will be sharing the same route and use Mapbox in their client apps for navigation.
Since it is important for us to use the same route, it was decided to generate route on a backend side and clients were suppose to download route in json format, parse it and give route to Mapbox Navigation SDK.
I tried to solve this task in 2 ways.
1. Using REST API
I tried to use your REST API for generating a route and it works well, but when I try to parse JSON using DirectionsRoute.fromJson(String json) method I am getting an exception
Expected a string but was BEGIN_OBJECT at line 1 column 969 path $.legs[0].steps[0].geometry
although JSON itself has a valid format.
2. Using Java SDK
On a backed side I was generating a route, but using Mapbox SDK:
String accessToken =
"accees_token";
Point originPoint = Point.fromLngLat(**, **);
Point destinationPoint = Point.fromLngLat(**, **);
MapboxDirections client = MapboxDirections.builder()
.origin(originPoint)
.destination(destinationPoint)
.overview(DirectionsCriteria.OVERVIEW_FULL)
.profile(DirectionsCriteria.PROFILE_WALKING)
.accessToken(accessToken)
.build();
client.enqueueCall(new Callback<>() {
@Override
public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
DirectionsRoute directionsRoute = response.body().routes().get(0);
Gson gson = new Gson();
String json = gson.toJson(directionsRoute, DirectionsRoute.class);
}
@Override
public void onFailure(Call<DirectionsResponse> call, Throwable throwable) {
System.out.println("Error: " + throwable.getMessage());
}
});
But this time converting DirectionsRoute to json returns {}, although route array is not empty.
I only need to generate route on backend side as json and use that route on client side.
Any of these solutions are suitable for us if they will work properly.
Could you help me resolve any of them?
- Lingua principale
- Java
- Stelle
- 438
- Fork
- 117
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di mapbox/mapbox-java
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
mapbox/mapbox-java#1640 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
mapbox/mapbox-java#1635 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
mapbox/mapbox-java#1619 ·
-
Mapbox-java incompatible with gson 2.13.0 and up - call to internal GSON classes that were renamed Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 48/100
mapbox/mapbox-java#1614 · 2 commenti · 1 reazione ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
mapbox/mapbox-java#1612 · 1 reazione ·