Skip to content

Commit 5e2630a

Browse files
authored
Introduce PRECISION_5 and PRECISION_6 constants (#312)
* add PRECISION_5 and PRECISION_6 to be explicit about precision values * use Constants.PRECISION_6 as an example in MapMatchingActivity
1 parent 7b609cc commit 5e2630a

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

mapbox/app/src/main/java/com/mapbox/services/android/testapp/utils/MapMatchingActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,10 @@ public void onResponse(Call<MapMatchingResponse> call, Response<MapMatchingRespo
176176
// Check that the map matching API response is "OK".
177177
if (response.code() == 200) {
178178
// Convert the map matched response list from position to latlng coordinates.
179+
// By default, the SDK uses MapMatchingCriteria.GEOMETRY_POLYLINE_6, therefore
180+
// you need Constants.PRECISION_6 for the decode to be right
179181
String geometry = response.body().getMatchings().get(0).getGeometry();
180-
List<Position> positions = PolylineUtils.decode(geometry, Constants.OSRM_PRECISION_V4);
182+
List<Position> positions = PolylineUtils.decode(geometry, Constants.PRECISION_6);
181183
if (positions == null) {
182184
return;
183185
}

mapbox/libjava-core/src/main/java/com/mapbox/services/Constants.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@ public class Constants {
2323
/**
2424
* Constants for polyline encoding/decoding
2525
*/
26+
27+
// Use these if you want to be explicit about the vendor
2628
public static final int GOOGLE_PRECISION = 5;
2729
public static final int OSRM_PRECISION_V4 = 6;
2830
public static final int OSRM_PRECISION_V5 = 5;
2931

32+
// Use these if you want to be explicit about the precision
33+
public static final int PRECISION_5 = 5;
34+
public static final int PRECISION_6 = 6;
35+
3036
/**
3137
* Default user for services
3238
*/

0 commit comments

Comments
 (0)