Skip to content

Commit c5d2525

Browse files
author
Cameron Mace
authored
added support for languages (#504)
1 parent 3fe0caa commit c5d2525

11 files changed

Lines changed: 8492 additions & 8188 deletions

File tree

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,18 @@ directions-fixtures:
9797
-o mapbox/libjava-services/src/test/fixtures/directions_v5.json
9898

9999
# Directions: request annotations
100-
curl "https://api.mapbox.com/directions/v5/mapbox/driving/-122.416667,37.783333;-121.900000,37.333333?geometries=polyline&steps=true&annotations=distance,duration,speed&access_token=$(MAPBOX_ACCESS_TOKEN)" \
100+
curl "https://api.mapbox.com/directions/v5/mapbox/driving/-122.416667,37.783333;-121.900000,37.333333?geometries=polyline&language=sv&steps=true&annotations=distance,duration,speed&access_token=$(MAPBOX_ACCESS_TOKEN)" \
101101
-o mapbox/libjava-services/src/test/fixtures/directions_annotations_v5.json
102102

103103
# Directions: polyline geometry with precision 6
104104
curl "https://api.mapbox.com/directions/v5/mapbox/driving/-122.416667,37.783333;-121.900000,37.333333?geometries=polyline6&steps=true&access_token=$(MAPBOX_ACCESS_TOKEN)" \
105105
-o mapbox/libjava-services/src/test/fixtures/directions_v5_precision_6.json
106106

107-
directions-fixtures-rotary:
107+
# Directions: route with a rotary
108108
curl "https://api.mapbox.com/directions/v5/mapbox/driving/-77.04430818557739,38.908650612656864;-77.04192638397217,38.90963574367117?geometries=polyline&steps=true&access_token=$(MAPBOX_ACCESS_TOKEN)" \
109109
-o mapbox/libjava-services/src/test/fixtures/directions_v5_fixtures_rotary.json
110110

111-
directions-traffic-fixtures:
111+
# Directions: route with traffic
112112
curl "https://api.mapbox.com/directions/v5/mapbox/driving-traffic/-122.416667,37.783333;-121.900000,37.333333?geometries=polyline&steps=true&access_token=$(MAPBOX_ACCESS_TOKEN)" \
113113
-o mapbox/libjava-services/src/test/fixtures/directions_v5_traffic.json
114114

mapbox/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99

1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:2.3.2'
11+
classpath 'com.android.tools.build:gradle:2.3.3'
1212
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.2'
1313

1414
// NOTE: Do not place your application dependencies here; they belong

mapbox/libjava-services-rx/src/main/java/com/mapbox/services/api/rx/directions/v5/DirectionsServiceRx.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ public interface DirectionsServiceRx {
3232
* the angle of approach
3333
* @param continueStraight Define whether the route should continue straight even if the route
3434
* will be slower.
35-
* @param annotations An annotations object that contains additional details about each line segment along the
35+
* @param annotations An annotations object that contains additional details about each line segment along the
3636
* route geometry. Each entry in an annotations field corresponds to a coordinate along the
3737
* route geometry.
38+
* @param language Language of returned turn-by-turn text instructions.
3839
* @return A retrofit Observable object
3940
* @since 2.0.0
4041
*/
@@ -52,6 +53,7 @@ Observable<DirectionsResponse> getObservable(
5253
@Query("steps") Boolean steps,
5354
@Query("bearings") String bearings,
5455
@Query("continue_straight") Boolean continueStraight,
55-
@Query("annotations") String annotations
56+
@Query("annotations") String annotations,
57+
@Query("language") String language
5658
);
5759
}

mapbox/libjava-services-rx/src/main/java/com/mapbox/services/api/rx/directions/v5/MapboxDirectionsRx.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public Observable<DirectionsResponse> getObservable() {
6565
builder.isSteps(),
6666
builder.getBearings(),
6767
builder.isContinueStraight(),
68-
builder.getAnnotation());
68+
builder.getAnnotation(),
69+
builder.getLanguage());
6970

7071
// Done
7172
return observable;

mapbox/libjava-services/src/main/java/com/mapbox/services/api/directions/v5/DirectionsService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public interface DirectionsService {
3535
* @param annotations An annotations object that contains additional details about each line segment along the
3636
* route geometry. Each entry in an annotations field corresponds to a coordinate along the
3737
* route geometry.
38+
* @param language Language of returned turn-by-turn text instructions.
3839
* @return The {@link DirectionsResponse} in a Call wrapper.
3940
* @since 1.0.0
4041
*/
@@ -53,6 +54,7 @@ Call<DirectionsResponse> getCall(
5354
@Query("steps") Boolean steps,
5455
@Query("bearings") String bearings,
5556
@Query("continue_straight") Boolean continueStraight,
56-
@Query("annotations") String annotations
57+
@Query("annotations") String annotations,
58+
@Query("language") String language
5759
);
5860
}

mapbox/libjava-services/src/main/java/com/mapbox/services/api/directions/v5/MapboxDirections.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ private Call<DirectionsResponse> getCall() {
7575
builder.isSteps(),
7676
builder.getBearings(),
7777
builder.isContinueStraight(),
78-
builder.getAnnotation());
78+
builder.getAnnotation(),
79+
builder.getLanguage());
7980

8081
// Done
8182
return call;
@@ -147,6 +148,7 @@ public static class Builder<T extends Builder> extends MapboxBuilder {
147148
private Position origin = null;
148149
private Position destination = null;
149150
private String[] annotation = null;
151+
private String language = null;
150152

151153
/**
152154
* Constructor
@@ -157,7 +159,7 @@ public Builder() {
157159
// Set defaults
158160
this.user = DirectionsCriteria.PROFILE_DEFAULT_USER;
159161

160-
// by defauly the geometry is polyline with precision 6.
162+
// by default the geometry is polyline with precision 6.
161163
this.geometries = DirectionsCriteria.GEOMETRY_POLYLINE6;
162164
}
163165

@@ -358,6 +360,19 @@ public T setAnnotation(String... annotation) {
358360
return (T) this;
359361
}
360362

363+
/**
364+
* Optionally set the language of returned turn-by-turn text instructions. The default is {@code en} for English.
365+
*
366+
* @param language The locale in which results should be returned.
367+
* @return Builder
368+
* @see <a href="https://www.mapbox.com/api-documentation/#instructions-languages">Supported languages</a>
369+
* @since 2.2.0
370+
*/
371+
public T setLanguage(String language) {
372+
this.language = language;
373+
return (T) this;
374+
}
375+
361376
/*
362377
* Getters, they return the value in a format ready for the API to consume
363378
*/
@@ -543,6 +558,14 @@ public String getAnnotation() {
543558
return TextUtils.join(",", annotation);
544559
}
545560

561+
/**
562+
* @return The language the turn-by-turn directions will be in.
563+
* @since 2.2.0
564+
*/
565+
public String getLanguage() {
566+
return language;
567+
}
568+
546569
/**
547570
* Base package name or other simple string identifier
548571
*

0 commit comments

Comments
 (0)