Add support for directions responses with "geojson" geometries
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Java
- Estrellas
- 438
- Forks
- 117
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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?
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con el punto de entrada DirectionsRoute.fromJson(String json) y el modelo de respuesta MapboxDirections descrito en el informe. Rastrea cómo se analiza la geometría de un paso de indicaciones y cómo se serializa una DirectionsRoute; el trabajo estará terminado cuando las rutas con geometría GeoJSON puedan analizarse y serializarse para su uso por el cliente sin la excepción reportada ni JSON vacío.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- api
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100