Skip to content

Commit d7380c5

Browse files
authored
Merge pull request #14 from baato/update/maplibreRouteOptionsCompatible
route options compatible to maplibre
2 parents c1dbe1c + a9bd548 commit d7380c5

2 files changed

Lines changed: 44 additions & 18 deletions

File tree

baatolibrary/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ publishing {
5959
release(MavenPublication) {
6060
groupId = 'com.github.baato'
6161
artifactId = 'java-client'
62-
version = '1.4.10'
62+
version = '1.4.11'
6363

6464
afterEvaluate {
6565
from project.components.findByName('release')

baatolibrary/src/main/java/com/baato/baatolibrary/navigation/NavigateResponseConverterMapLibre.java

Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.util.Log;
1111

1212
import com.baato.baatolibrary.models.NavResponse;
13+
import com.fasterxml.jackson.databind.ObjectMapper;
1314
import com.fasterxml.jackson.databind.node.ArrayNode;
1415
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
1516
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -211,36 +212,61 @@ private static void putRouteInformation(ObjectNode pathJson, int routeNr, Locale
211212
pathJson.put("weight", Helper.round(weight, 1));
212213
pathJson.put("duration", convertToSeconds(ghResponse.getTimeInMs()));
213214
pathJson.put("distance", Helper.round(ghResponse.getDistanceInMeters(), 1));
214-
pathJson.put("routeOptions",getRouteOptions("pk.xxx"));
215+
pathJson.set("routeOptions",getRouteOptions("pk.xxx"));
215216

216217
pathJson.put("voiceLocale", locale.toLanguageTag());
217218
}
218-
private static ObjectNode getRouteOptions(String accessKey){
219-
ObjectNode json = JsonNodeFactory.instance.objectNode();
219+
// private static ObjectNode getRouteOptions(String accessKey){
220+
// ObjectNode json = JsonNodeFactory.instance.objectNode();
221+
// json.put("baseUrl", "https://api.baato.io");
222+
// json.put("user", "mapbox");
223+
// json.put("profile", mode);
224+
// ArrayNode coordinates = json.putArray("coordinates");
225+
// getCord(coordinates);
226+
//// json.put("coordinates",getCord(coordinates));
227+
//// json.put("language", String.valueOf(Locale.ENGLISH));
228+
// json.put("language", String.valueOf(locale));
229+
// json.put("bearings", ";");
230+
// json.put("continueStraight", true);
231+
// json.put("roundaboutExits", true);
232+
// json.put("geometries", "polyline6");
233+
// json.put("overview", "full");
234+
// json.put("steps", true);
235+
// json.put("annotations", "");
236+
// json.put("voiceInstructions", true);
237+
// json.put("bannerInstructions", true);
238+
// json.put("voiceUnits", String.valueOf(DistanceUtils.Unit.METRIC));
239+
// json.put("access_token",accessKey);
240+
// json.put("uuid",uuid);
241+
// return json;
242+
//// json.put("coordinates", path.)
243+
//
244+
// }
245+
private static ObjectNode getRouteOptions(String accessKey) {
246+
ObjectMapper mapper = new ObjectMapper();
247+
ObjectNode json = mapper.createObjectNode();
220248
json.put("baseUrl", "https://api.baato.io");
221249
json.put("user", "mapbox");
222250
json.put("profile", mode);
223251
ArrayNode coordinates = json.putArray("coordinates");
224252
getCord(coordinates);
225-
// json.put("coordinates",getCord(coordinates));
226-
// json.put("language", String.valueOf(Locale.ENGLISH));
227253
json.put("language", String.valueOf(locale));
228-
json.put("bearings", ";");
229-
json.put("continueStraight", true);
230-
json.put("roundaboutExits", true);
254+
json.put("bearings", ";;");
255+
json.put("continue_straight", true);
256+
json.put("roundabout_exits", true);
231257
json.put("geometries", "polyline6");
232258
json.put("overview", "full");
233259
json.put("steps", true);
234260
json.put("annotations", "");
235-
json.put("voiceInstructions", true);
236-
json.put("bannerInstructions", true);
237-
json.put("voiceUnits", String.valueOf(DistanceUtils.Unit.METRIC));
238-
json.put("access_token",accessKey);
239-
json.put("uuid",uuid);
240-
return json;
241-
// json.put("coordinates", path.)
242-
261+
json.put("alternatives", true);
262+
json.put("voice_instructions", true);
263+
json.put("banner_instructions", true);
264+
json.put("voice_units", String.valueOf(DistanceUtils.Unit.METRIC));
265+
json.put("access_token", accessKey);
266+
json.put("uuid", uuid);
267+
return json;
243268
}
269+
244270
private static void getCord(ArrayNode coordinates){
245271
double a1 = allCord.get(0).get(1);
246272
double a2 = allCord.get(0).get(0);
@@ -941,4 +967,4 @@ public static ObjectNode convertFromGHResponseError(GHResponse ghResponse) {
941967
json.put("message", ghResponse.getErrors().get(0).getMessage());
942968
return json;
943969
}
944-
}
970+
}

0 commit comments

Comments
 (0)