public abstract static class MapboxOptimization.Builder
extends java.lang.Object
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
abstract MapboxOptimization.Builder |
accessToken(java.lang.String accessToken)
Required to call when this is being built.
|
MapboxOptimization.Builder |
annotations(java.lang.String... annotations)
Whether or not to return additional metadata along the route.
|
abstract MapboxOptimization.Builder |
baseUrl(java.lang.String baseUrl)
Optionally change the APIs base URL to something other then the default Mapbox one.
|
MapboxOptimization.Builder |
bearing(double angle,
double tolerance)
Optionally, Use to filter the road segment the waypoint will be placed on by direction and
dictates the angle of approach.
|
MapboxOptimization |
build()
This uses the provided parameters set using the
MapboxOptimization.Builder and first checks that all
values are valid, formats the values as strings for easier consumption by the API, and lastly
creates a new MapboxOptimization object with the values provided. |
abstract MapboxOptimization.Builder |
clientAppName(java.lang.String clientAppName)
Base package name or other simple string identifier.
|
MapboxOptimization.Builder |
coordinate(com.mapbox.geojson.Point coordinate)
This will add a single
Point to the coordinate list which is used to determine the
most optimal route. |
MapboxOptimization.Builder |
coordinates(java.util.List<com.mapbox.geojson.Point> coordinates)
Add a list of
Point 's which define the route which will become optimized. |
abstract MapboxOptimization.Builder |
destination(java.lang.String destination)
Returned route ends at
DirectionsCriteria.DESTINATION_ANY or
DirectionsCriteria.DESTINATION_LAST coordinate. |
MapboxOptimization.Builder |
distribution(java.lang.Integer pickup,
java.lang.Integer dropOff)
Specify pick-up and drop-off locations for a trip by providing a
pickup and
dropOff value correspond with the coordinates list. |
abstract MapboxOptimization.Builder |
geometries(java.lang.String geometries)
alter the default geometry being returned for the directions route.
|
MapboxOptimization.Builder |
language(java.util.Locale language)
Set the instruction language for the directions request, the default is english.
|
abstract MapboxOptimization.Builder |
language(java.lang.String language)
Set the instruction language for the directions request, the default is english.
|
abstract MapboxOptimization.Builder |
overview(java.lang.String overview)
Type of returned overview geometry.
|
abstract MapboxOptimization.Builder |
profile(java.lang.String profile)
This selects which mode of transportation the user will be using while navigating from the
origin to the final destination.
|
MapboxOptimization.Builder |
radiuses(double... radiuses)
Optionally, set the maximum distance in meters that each coordinate is allowed to move when
snapped to a nearby road segment.
|
abstract MapboxOptimization.Builder |
roundTrip(java.lang.Boolean roundTrip)
Returned route is a roundtrip (route returns to first location).
|
abstract MapboxOptimization.Builder |
source(java.lang.String source)
Returned route starts at
DirectionsCriteria.SOURCE_ANY or
DirectionsCriteria.SOURCE_FIRST coordinate. |
abstract MapboxOptimization.Builder |
steps(java.lang.Boolean steps)
Setting this will determine whether to return steps and turn-by-turn instructions.
|
abstract MapboxOptimization.Builder |
user(java.lang.String user)
The username for the account that the directions engine runs on.
|
public abstract MapboxOptimization.Builder user(@NonNull java.lang.String user)
DirectionsCriteria.PROFILE_DEFAULT_USER
.user
- a non-null string which will replace the default user used in the directions
requestpublic MapboxOptimization.Builder coordinates(@NonNull java.util.List<com.mapbox.geojson.Point> coordinates)
Point
's which define the route which will become optimized. The minimum
points is 2 and the maximum points allowed in totals 12. You can use this method in
conjunction with coordinate(Point)
.coordinates
- a List full of Point
s which define the routepublic MapboxOptimization.Builder coordinate(@NonNull com.mapbox.geojson.Point coordinate)
Point
to the coordinate list which is used to determine the
most optimal route. This can be called up to 12 times until you hit the maximum allowed
points. You can use this method in conjunction with coordinates(List)
.coordinate
- a Point
which you'd like the optimized route to pass throughpublic abstract MapboxOptimization.Builder profile(@NonNull java.lang.String profile)
profile
- required to be one of the String values found in the DirectionsCriteria.ProfileCriteria
public abstract MapboxOptimization.Builder roundTrip(@Nullable java.lang.Boolean roundTrip)
true
(default), false
and null (to reset to the default value). If the
roundtrip is set to false, then MapboxOptimization.source()
and MapboxOptimization.destination()
parameters are
required but not all combinations are possible.
It is possible to explicitly set the start or end coordinate of the trip. When source? is set
to first, the first coordinate is used as the start coordinate of the trip in the output.
When destination is set to last, the last coordinate will be used as destination of the trip
in the returned output. If you specify DirectionsCriteria.DESTINATION_ANY
/
DirectionsCriteria.SOURCE_ANY
, any of the coordinates can be used as the first or
last coordinate in the output.
roundTrip
- true if you'd like the route to return to the origin, else falsepublic abstract MapboxOptimization.Builder source(@Nullable java.lang.String source)
DirectionsCriteria.SOURCE_ANY
or
DirectionsCriteria.SOURCE_FIRST
coordinate. Null can also be passed in to reset
this value back to the API default if needed.source
- one of the values in DirectionsCriteria.SourceCriteria
public abstract MapboxOptimization.Builder destination(@Nullable java.lang.String destination)
DirectionsCriteria.DESTINATION_ANY
or
DirectionsCriteria.DESTINATION_LAST
coordinate.destination
- either "any" or "last"
public abstract MapboxOptimization.Builder geometries(@Nullable java.lang.String geometries)
DirectionsCriteria.GEOMETRY_POLYLINE6
.
Note that while the API supports GeoJson as an option for geometry, this SDK intentionally removes this as an option since an encoded string for the geometry significantly reduces bandwidth on mobile devices and speeds up response time.
geometries
- null if you'd like the default geometry, else one of the options found in
DirectionsCriteria.GeometriesCriteria
.public abstract MapboxOptimization.Builder overview(@Nullable java.lang.String overview)
DirectionsCriteria.OVERVIEW_FULL
(the most
detailed geometry available), DirectionsCriteria.OVERVIEW_SIMPLIFIED
(a simplified
version of the full geometry), or DirectionsCriteria.OVERVIEW_FALSE
(no overview
geometry). The default is simplified. Passing in null will use the APIs default setting for
the overview field.overview
- null or one of the options found in DirectionsCriteria.OverviewCriteria
public MapboxOptimization.Builder radiuses(double... radiuses)
Double.POSITIVE_INFINITY
.
If no routable road is found within the radius, a NoSegment
error is returned.
radiuses
- double array containing the radiuses defined in unit meters.public MapboxOptimization.Builder bearing(double angle, double tolerance)
radiuses(double...)
parameter.
The parameter takes two values per waypoint: the first is an angle clockwise from true north between 0 and 360. The second is the range of degrees the angle can deviate by. We recommend a value of 45 degrees or 90 degrees for the range, as bearing measurements tend to be inaccurate. This is useful for making sure we reroute vehicles on new routes that continue traveling in their current direction. A request that does this would provide bearing and radius values for the first waypoint and leave the remaining values empty. If provided, the list of bearings must be the same length as the list of waypoints, but you can skip a coordinate and show its position by passing in null value for both the angle and tolerance values.
Each bearing value gets associated with the same order which coordinates are arranged in this
builder. For example, the first bearing added in this builder will be associated with the
origin Point
, the nth bearing being associated with the nth waypoint added (if added)
and the last bearing being added will be associated with the destination.
angle
- double value used for setting the corresponding coordinate's angle of travel
when determining the routetolerance
- the deviation the bearing angle can vary while determining the route,
recommended to be either 45 or 90 degree tolerancepublic abstract MapboxOptimization.Builder steps(@Nullable java.lang.Boolean steps)
steps
- true if you'd like step informationpublic MapboxOptimization.Builder annotations(@Nullable java.lang.String... annotations)
DirectionsCriteria.ANNOTATION_DISTANCE
,
DirectionsCriteria.ANNOTATION_DURATION
,
DirectionsCriteria.ANNOTATION_DURATION
and
DirectionsCriteria.ANNOTATION_CONGESTION
. Several annotation can be used by
separating them with ,
.annotations
- string referencing one of the annotation direction criteria's. The strings
restricted to one or multiple values inside the DirectionsCriteria.AnnotationCriteria
or null which will result in no annotations being usedpublic MapboxOptimization.Builder language(@Nullable java.util.Locale language)
language
- a Locale value representing the language you'd like the instructions to be
written in when returnedpublic abstract MapboxOptimization.Builder language(@Nullable java.lang.String language)
language(Locale)
method to prevent errors
when making the request.language
- a String value representing the language you'd like the instructions to be
written in when returnedpublic abstract MapboxOptimization.Builder clientAppName(@NonNull java.lang.String clientAppName)
clientAppName
- base package name or other simple string identifierpublic abstract MapboxOptimization.Builder accessToken(@NonNull java.lang.String accessToken)
ServicesException
will be thrown.accessToken
- Mapbox access token, You must have a Mapbox account inorder to use
the Optimization APIpublic abstract MapboxOptimization.Builder baseUrl(@NonNull java.lang.String baseUrl)
baseUrl
- base url used as end pointpublic MapboxOptimization.Builder distribution(@Nullable java.lang.Integer pickup, @Nullable java.lang.Integer dropOff)
pickup
and
dropOff
value correspond with the coordinates list. The first number indicates what
place the coordinate of the pick-up location is in the coordinates list, and the second
number indicates what place the coordinate of the drop-off location is in the coordinates
list. Pick-up and drop-off locations in one pair cannot be the same. The returned solution
will visit pick-up locations before visiting drop-off locations. The depot (first location)
can only be a pick-up location but not a drop-off location.dropOff
- the coordinate index in the coordinates list which should be the drop off
locationpickup
- the coordinate index in the coordinates list which should be the pick-up
locationpublic MapboxOptimization build()
MapboxOptimization.Builder
and first checks that all
values are valid, formats the values as strings for easier consumption by the API, and lastly
creates a new MapboxOptimization
object with the values provided.