Skip to content

Commit f724bfd

Browse files
Seth BourgetSeth Bourget
andauthored
Added route index to the MapMpatchingMatching class to include the field from the DirectionsRoute. (#1385)
Co-authored-by: Seth Bourget <seth@cafesilencio.net>
1 parent 534e97e commit f724bfd

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

services-matching/src/main/java/com/mapbox/api/matching/v5/models/MapMatchingMatching.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ public static Builder builder() {
3333
return new AutoValue_MapMatchingMatching.Builder();
3434
}
3535

36+
/**
37+
* The index of this route in the original network response.
38+
*
39+
* @return string of an int value representing the index
40+
*/
41+
@Nullable
42+
public abstract String routeIndex();
43+
3644
/**
3745
* The distance traveled from origin to destination.
3846
*
@@ -153,6 +161,7 @@ public DirectionsRoute toDirectionRoute() {
153161
.routeOptions(routeOptions())
154162
.voiceLanguage(voiceLanguage())
155163
.requestUuid(requestUuid())
164+
.routeIndex(routeIndex())
156165
.build();
157166
}
158167

@@ -271,6 +280,15 @@ public abstract static class Builder {
271280
@NonNull
272281
public abstract Builder requestUuid(@Nullable String requestUuid);
273282

283+
/**
284+
* The index of the route in the list of routes returned by the original response.
285+
*
286+
* @param routeIndex string of an int value representing the index
287+
* @return this builder for chaining options together
288+
*/
289+
@NonNull
290+
public abstract Builder routeIndex(String routeIndex);
291+
274292
/**
275293
* Build a new {@link MapMatchingMatching} object.
276294
*

services-matching/src/test/java/com/mapbox/api/matching/v5/models/MapMatchingMatchingTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
public class MapMatchingMatchingTest extends TestUtils {
1111

12+
private static final String MAP_MATCHING_V5_ROUTE_INDEX_JSON = "map_matching_v5_post.json";
1213
private static final String MAP_MATCHING_V5_VOICE_LANGUAGE_JSON = "map_matching_v5_voice_language.json";
1314
private static final String MAP_MATCHING_V5_INVALID_VOICE_LANGUAGE_JSON = "map_matching_v5_invalid_voice_language.json";
1415
private static final int FIRST_ROUTE = 0;
@@ -34,4 +35,13 @@ public void directionsRouteWithInvalidLanguage_doesReturnNullVoiceLanguage() thr
3435

3536
assertNull(voiceLanguage);
3637
}
38+
39+
@Test
40+
public void directionsRoute_includesRouteIndex() throws Exception {
41+
String json = loadJsonFixture(MAP_MATCHING_V5_ROUTE_INDEX_JSON);
42+
43+
MapMatchingResponse response = MapMatchingResponse.fromJson(json);
44+
45+
assertEquals("0", response.matchings().get(0).routeIndex());
46+
}
3747
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"matchings":[{"confidence":0.8646240884788093,"geometry":"{qeiHayhMjDkSOm@cDaB{R}I","legs":[{"summary":"Quai de la Mégisserie, Boulevard de Sébastopol","weight":204.3,"duration":140.5,"steps":[{"intersections":[{"out":0,"entry":[true],"bearings":[112],"location":[2.344011,48.858064]},{"out":1,"in":2,"entry":[false,true,false],"bearings":[30,105,285],"location":[2.344384,48.857963]},{"out":1,"in":2,"entry":[true,true,false],"bearings":[15,105,285],"location":[2.345408,48.857687]},{"out":0,"in":1,"entry":[true,false,false],"bearings":[120,285,330],"location":[2.346993,48.857275]},{"out":0,"in":2,"entry":[true,false,false],"bearings":[105,195,300],"location":[2.34712,48.857239]}],"driving_side":"right","geometry":"{qeiHayhMRiAt@mEReADUTqARqA@EJu@FYF]","mode":"driving","maneuver":{"bearing_after":112,"bearing_before":0,"location":[2.344011,48.858064],"type":"depart","instruction":"Head southeast on Quai de la Mégisserie"},"weight":59.099999999999994,"duration":43.800000000000004,"name":"Quai de la Mégisserie","distance":257.2},{"intersections":[{"out":0,"in":2,"entry":[true,true,false],"bearings":[60,120,285],"location":[2.347272,48.857201]},{"out":0,"in":2,"entry":[true,false,false,true],"bearings":[15,120,195,300],"location":[2.347777,48.857724]},{"out":0,"in":2,"entry":[true,false,false,true],"bearings":[15,120,195,300],"location":[2.348211,48.8585]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[15,105,195],"location":[2.34833,48.858721]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[15,120,195],"location":[2.348758,48.859525]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[15,90,195],"location":[2.349062,48.860069]}],"driving_side":"right","geometry":"oleiHmmiMIa@EKGGCCCAc@SQIQKWKs@]{@a@EAMGGCSKOGuCoAKE}As@MGaBs@eAi@_Ac@IE","mode":"driving","maneuver":{"bearing_after":66,"bearing_before":109,"location":[2.347272,48.857201],"modifier":"left","type":"turn","instruction":"Turn left onto Place du Châtelet"},"weight":145.2,"duration":96.7,"name":"Place du Châtelet","distance":493.20000000000005},{"intersections":[{"in":0,"entry":[true],"bearings":[200],"location":[2.349738,48.861278]}],"driving_side":"right","geometry":"_ffiH{|iM","mode":"driving","maneuver":{"bearing_after":0,"bearing_before":20,"location":[2.349738,48.861278],"modifier":"right","type":"arrive","instruction":"You have arrived at your destination, on the right"},"weight":0,"duration":0,"name":"Boulevard de Sébastopol","distance":0}],"distance":750.4}],"weight_name":"routability","weight":204.3,"duration":140.5,"distance":750.4}],"tracepoints":[{"alternatives_count":0,"waypoint_index":0,"matchings_index":0,"distance":1.4298733755647755,"name":"Quai de la Mégisserie","location":[2.344011,48.858064]},{"alternatives_count":0,"waypoint_index":null,"matchings_index":0,"distance":6.317472000209194,"name":"Quai de la Mégisserie","location":[2.346781,48.857328]},{"alternatives_count":0,"waypoint_index":null,"matchings_index":0,"distance":0.6275897933079265,"name":"Boulevard de Sébastopol","location":[2.348674,48.859367]},{"alternatives_count":0,"waypoint_index":null,"matchings_index":0,"distance":3.765538759196103,"name":"Boulevard de Sébastopol","location":[2.349503,48.860859]},null,{"alternatives_count":0,"waypoint_index":null,"matchings_index":0,"distance":2.090012803498222,"name":"Boulevard de Sébastopol","location":[2.349599,48.861029]},{"alternatives_count":0,"waypoint_index":1,"matchings_index":0,"distance":7.178624584475835,"name":"Boulevard de Sébastopol","location":[2.349738,48.861278]}],"code":"Ok"}
1+
{"matchings":[{"confidence":0.8646240884788093, "routeIndex": "0", "geometry":"{qeiHayhMjDkSOm@cDaB{R}I","legs":[{"summary":"Quai de la Mégisserie, Boulevard de Sébastopol","weight":204.3,"duration":140.5,"steps":[{"intersections":[{"out":0,"entry":[true],"bearings":[112],"location":[2.344011,48.858064]},{"out":1,"in":2,"entry":[false,true,false],"bearings":[30,105,285],"location":[2.344384,48.857963]},{"out":1,"in":2,"entry":[true,true,false],"bearings":[15,105,285],"location":[2.345408,48.857687]},{"out":0,"in":1,"entry":[true,false,false],"bearings":[120,285,330],"location":[2.346993,48.857275]},{"out":0,"in":2,"entry":[true,false,false],"bearings":[105,195,300],"location":[2.34712,48.857239]}],"driving_side":"right","geometry":"{qeiHayhMRiAt@mEReADUTqARqA@EJu@FYF]","mode":"driving","maneuver":{"bearing_after":112,"bearing_before":0,"location":[2.344011,48.858064],"type":"depart","instruction":"Head southeast on Quai de la Mégisserie"},"weight":59.099999999999994,"duration":43.800000000000004,"name":"Quai de la Mégisserie","distance":257.2},{"intersections":[{"out":0,"in":2,"entry":[true,true,false],"bearings":[60,120,285],"location":[2.347272,48.857201]},{"out":0,"in":2,"entry":[true,false,false,true],"bearings":[15,120,195,300],"location":[2.347777,48.857724]},{"out":0,"in":2,"entry":[true,false,false,true],"bearings":[15,120,195,300],"location":[2.348211,48.8585]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[15,105,195],"location":[2.34833,48.858721]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[15,120,195],"location":[2.348758,48.859525]},{"out":0,"in":2,"entry":[true,true,false],"bearings":[15,90,195],"location":[2.349062,48.860069]}],"driving_side":"right","geometry":"oleiHmmiMIa@EKGGCCCAc@SQIQKWKs@]{@a@EAMGGCSKOGuCoAKE}As@MGaBs@eAi@_Ac@IE","mode":"driving","maneuver":{"bearing_after":66,"bearing_before":109,"location":[2.347272,48.857201],"modifier":"left","type":"turn","instruction":"Turn left onto Place du Châtelet"},"weight":145.2,"duration":96.7,"name":"Place du Châtelet","distance":493.20000000000005},{"intersections":[{"in":0,"entry":[true],"bearings":[200],"location":[2.349738,48.861278]}],"driving_side":"right","geometry":"_ffiH{|iM","mode":"driving","maneuver":{"bearing_after":0,"bearing_before":20,"location":[2.349738,48.861278],"modifier":"right","type":"arrive","instruction":"You have arrived at your destination, on the right"},"weight":0,"duration":0,"name":"Boulevard de Sébastopol","distance":0}],"distance":750.4}],"weight_name":"routability","weight":204.3,"duration":140.5,"distance":750.4}],"tracepoints":[{"alternatives_count":0,"waypoint_index":0,"matchings_index":0,"distance":1.4298733755647755,"name":"Quai de la Mégisserie","location":[2.344011,48.858064]},{"alternatives_count":0,"waypoint_index":null,"matchings_index":0,"distance":6.317472000209194,"name":"Quai de la Mégisserie","location":[2.346781,48.857328]},{"alternatives_count":0,"waypoint_index":null,"matchings_index":0,"distance":0.6275897933079265,"name":"Boulevard de Sébastopol","location":[2.348674,48.859367]},{"alternatives_count":0,"waypoint_index":null,"matchings_index":0,"distance":3.765538759196103,"name":"Boulevard de Sébastopol","location":[2.349503,48.860859]},null,{"alternatives_count":0,"waypoint_index":null,"matchings_index":0,"distance":2.090012803498222,"name":"Boulevard de Sébastopol","location":[2.349599,48.861029]},{"alternatives_count":0,"waypoint_index":1,"matchings_index":0,"distance":7.178624584475835,"name":"Boulevard de Sébastopol","location":[2.349738,48.861278]}],"code":"Ok"}

0 commit comments

Comments
 (0)