mapbox / mapbox/mapbox-java

Add support for directions responses with "geojson" geometries

オープン
#1,219 コメント 7 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

jira-sync-complete
主要言語
Java
スター
438
フォーク
117
PR マージ指標
30日以内にマージされた PR はありません

説明

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?

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

エントリーポイント DirectionsRoute.fromJson(String json) と、レポートで説明されている MapboxDirections レスポンスモデルから始めます。経路案内のステップのジオメトリがどのようにパースされ、DirectionsRoute がどのようにシリアライズされるかを追跡します。GeoJSON ジオメトリを持つルートを、報告されている例外や空の JSON を発生させずにクライアントで利用できる形でパースおよびシリアライズできれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
api
issue の種類
機能追加
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。