Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@ geocoding-batch-fixtures:
-o mapbox/libjava-services/src/test/fixtures/geocoding_batch.json

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

# Directions: polyline geometry with precision 6
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)" \
-o mapbox/libjava-services/src/test/fixtures/directions_v5_precision_6.json

directions-traffic-fixtures:
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)" \
-o mapbox/libjava-services/src/test/fixtures/directions_v5_traffic.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ public class DirectionsCriteria {
public static final String PROFILE_CYCLING = "cycling";

/**
* Format to return route geometry will be encoded polyline.
* Format to return route geometry will be an encoded polyline.
*
* @since 1.0.0
*/
public static final String GEOMETRY_POLYLINE = "polyline";

/**
* Format to return route geometry will be an encoded polyline with precision 6.
*
* @since 2.0.0
*/
public static final String GEOMETRY_POLYLINE6 = "polyline6";

/**
* Format to return route geometry will be geojson. Note that this isn't supported by the SDK.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,22 @@ public Builder() {
// Set defaults
this.user = DirectionsCriteria.PROFILE_DEFAULT_USER;

// We only support polyline encoded geometries to reduce the size of the response.
// If we need the corresponding LineString object, this SDK can do the decoding with
// LineString.fromPolyline(String polyline, int precision).
this.geometries = DirectionsCriteria.GEOMETRY_POLYLINE;
// by defauly the geometry is polyline with precision 6.
this.geometries = DirectionsCriteria.GEOMETRY_POLYLINE6;
}

/**
* The SDK currently only supports {@code Polyline} geometry (not GeoJSON) to simplify the response. You do have
* the option on whether the precision is 5 or 6 using either {@link DirectionsCriteria#GEOMETRY_POLYLINE} or
* {@link DirectionsCriteria#GEOMETRY_POLYLINE6}.
*
* @param geometries A {@code String} constant which equals either {@code "polyline"} or {@code "polyline6"}.
* @return Builder
* @since 2.0.0
*/
public Builder setGeometry(String geometries) {
this.geometries = geometries;
return this;
}

/*
Expand Down Expand Up @@ -378,7 +390,8 @@ public Boolean isAlternatives() {

/**
* @return {@link com.mapbox.services.api.directions.v5.DirectionsCriteria#GEOMETRY_GEOJSON},
* {@link com.mapbox.services.api.directions.v5.DirectionsCriteria#GEOMETRY_POLYLINE}
* {@link com.mapbox.services.api.directions.v5.DirectionsCriteria#GEOMETRY_POLYLINE},
* or {@link com.mapbox.services.api.directions.v5.DirectionsCriteria#GEOMETRY_POLYLINE6}
* @since 1.0.0
*/
public String getGeometries() {
Expand Down
2,957 changes: 2,956 additions & 1 deletion mapbox/libjava-services/src/test/fixtures/directions_v5.json

Large diffs are not rendered by default.

Loading