public abstract static class NbmapDirections.Builder
extends java.lang.Object
By default, the directions profile is set to driving (without traffic) but can be changed to reflect your users use-case.
Note to contributors: All optional booleans in this builder use the object Boolean
rather than the primitive to allow for unset (null) values.
| Constructor and Description |
|---|
Builder() |
| Modifier and Type | Method and Description |
|---|---|
abstract NbmapDirections.Builder |
accessToken(java.lang.String accessToken)
Required to call when this is being built.
|
NbmapDirections.Builder |
addAnnotation(java.lang.String annotation)
Whether or not to return additional metadata along the route.
|
NbmapDirections.Builder |
addApproach(java.lang.String approach)
Indicates from which side of the road to approach a waypoint.
|
NbmapDirections.Builder |
addApproaches(java.lang.String... approaches)
Deprecated.
use
approaches(List) |
NbmapDirections.Builder |
addBearing(java.lang.Double angle,
java.lang.Double tolerance)
Optionally, Use to filter the road segment the waypoint will be placed on by direction and
dictates the angle of approach.
|
NbmapDirections.Builder |
addRadius(java.lang.Double radius)
Optionally, set the maximum distance in meters that each coordinate is allowed to move when
snapped to a nearby road segment.
|
NbmapDirections.Builder |
addSnappingClosure(java.lang.Boolean snappingClosure)
A boolean affecting snapping of waypoint location to the road segment.
|
NbmapDirections.Builder |
addWaypoint(com.nbmap.geojson.Point waypoint)
This can be used to set up to 23 additional in-between points which will act as pit-stops
along the users route.
|
NbmapDirections.Builder |
addWaypointIndex(java.lang.Integer waypointIndex)
Optionally, set which input coordinates should be treated as waypoints / separate legs.
|
NbmapDirections.Builder |
addWaypointIndices(java.lang.Integer... waypointIndices)
Deprecated.
|
NbmapDirections.Builder |
addWaypointName(java.lang.String waypointName)
Custom names for waypoints used for the arrival instruction.
|
NbmapDirections.Builder |
addWaypointNames(java.lang.String... waypointNames)
Deprecated.
|
NbmapDirections.Builder |
addWaypointTarget(com.nbmap.geojson.Point waypointTarget)
A point to specify drop-off locations that are distinct from the locations specified in
coordinates.
|
NbmapDirections.Builder |
addWaypointTargets(com.nbmap.geojson.Point... waypointTargets)
Deprecated.
|
abstract NbmapDirections.Builder |
alternatives(java.lang.Boolean alternatives)
Optionally set whether to try to return alternative routes.
|
NbmapDirections.Builder |
annotations(java.util.List<java.lang.String> annotations)
Whether or not to return additional metadata along the route.
|
NbmapDirections.Builder |
annotations(java.lang.String... annotations)
Deprecated.
|
NbmapDirections.Builder |
approaches(java.util.List<java.lang.String> approaches)
Indicates from which side of the road to approach a waypoint.
|
abstract NbmapDirections.Builder |
bannerInstructions(java.lang.Boolean bannerInstructions)
Request banner instructions object to be returned in your response.
|
abstract NbmapDirections.Builder |
baseUrl(java.lang.String baseUrl)
Optionally change the APIs base URL to something other then the default Nbmap one.
|
NbmapDirections.Builder |
bearings(java.util.List<java.util.List<java.lang.Double>> bearings)
Optionally, Use to filter the road segment the waypoint will be placed on by direction and
dictates the angle of approach.
|
NbmapDirections |
build()
This uses the provided parameters set using the
NbmapDirections.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 NbmapDirections object with the values provided. |
abstract NbmapDirections.Builder |
clientAppName(java.lang.String clientAppName)
Base package name or other simple string identifier.
|
abstract NbmapDirections.Builder |
continueStraight(java.lang.Boolean continueStraight)
Sets allowed direction of travel when departing intermediate waypoints.
|
NbmapDirections.Builder |
destination(com.nbmap.geojson.Point destination)
This sets the ending point on the map where the route will end.
|
abstract NbmapDirections.Builder |
enableRefresh(java.lang.Boolean enableRefresh)
Whether the routes should be refreshable via the directions refresh API.
|
abstract NbmapDirections.Builder |
eventListener(okhttp3.EventListener eventListener)
Adds an optional event listener to set in the OkHttp client.
|
abstract NbmapDirections.Builder |
exclude(java.lang.String exclude)
Exclude certain road types from routing.
|
abstract NbmapDirections.Builder |
geometries(java.lang.String geometries)
alter the default geometry being returned for the directions route.
|
NbmapDirections.Builder |
get()
Use GET method to request data.
|
abstract NbmapDirections.Builder |
interceptor(okhttp3.Interceptor interceptor)
Adds an optional interceptor to set in the OkHttp client.
|
NbmapDirections.Builder |
language(java.util.Locale language)
Set the instruction language for the directions request, the default is english.
|
abstract NbmapDirections.Builder |
networkInterceptor(okhttp3.Interceptor interceptor)
Adds an optional network interceptor to set in the OkHttp client.
|
NbmapDirections.Builder |
origin(com.nbmap.geojson.Point origin)
This sets the starting point on the map where the route will begin.
|
abstract NbmapDirections.Builder |
overview(java.lang.String overview)
Type of returned overview geometry.
|
NbmapDirections.Builder |
post()
Use POST method to request data.
|
abstract NbmapDirections.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.
|
NbmapDirections.Builder |
radiuses(java.lang.Double... radiuses)
Deprecated.
use
radiuses(List) |
NbmapDirections.Builder |
radiuses(java.util.List<java.lang.Double> radiuses)
Optionally, set the maximum distance in meters that each coordinate is allowed to move when
snapped to a nearby road segment.
|
abstract NbmapDirections.Builder |
roundaboutExits(java.lang.Boolean roundaboutExits)
Optionally, set this to true if you want to enable instructions while exiting roundabouts
and rotaries.
|
NbmapDirections.Builder |
snappingClosures(java.util.List<java.lang.Boolean> snappingClosures)
A list of booleans affecting snapping of waypoint locations to road segments.
|
abstract NbmapDirections.Builder |
steps(java.lang.Boolean steps)
Setting this will determine whether to return steps and turn-by-turn instructions.
|
abstract NbmapDirections.Builder |
user(java.lang.String user)
The username for the account that the directions engine runs on.
|
abstract NbmapDirections.Builder |
voiceInstructions(java.lang.Boolean voiceInstructions)
Request voice instructions objects to be returned in your response.
|
abstract NbmapDirections.Builder |
voiceUnits(java.lang.String voiceUnits)
Specify what unit you'd like voice and banner instructions to use.
|
abstract NbmapDirections.Builder |
walkingOptions(com.nbmap.api.directions.v5.WalkingOptions walkingOptions)
To be used to specify settings for use with the walking profile.
|
NbmapDirections.Builder |
waypointIndices(java.util.List<java.lang.Integer> waypointIndices)
Optionally, set which input coordinates should be treated as waypoints / separate legs.
|
NbmapDirections.Builder |
waypointNames(java.util.List<java.lang.String> waypointNames)
Custom names for waypoints used for the arrival instruction.
|
NbmapDirections.Builder |
waypoints(java.util.List<com.nbmap.geojson.Point> waypoints)
This can be used to set up to 23 additional in-between points which will act as pit-stops
along the users route.
|
NbmapDirections.Builder |
waypointTargets(java.util.List<com.nbmap.geojson.Point> waypointTargets)
A list of points used to specify drop-off locations that are distinct from the locations
specified in coordinates.
|
public abstract NbmapDirections.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 abstract NbmapDirections.Builder profile(@NonNull java.lang.String profile)
profile - required to be one of the String values found in the DirectionsCriteria.ProfileCriteriapublic NbmapDirections.Builder origin(@NonNull com.nbmap.geojson.Point origin)
origin - a GeoJson Point object representing the starting location for the routepublic NbmapDirections.Builder destination(@NonNull com.nbmap.geojson.Point destination)
destination - a GeoJson Point object representing the starting location for the
routepublic NbmapDirections.Builder addWaypoint(@NonNull com.nbmap.geojson.Point waypoint)
DirectionsCriteria.PROFILE_DRIVING_TRAFFIC that the max number of waypoints allowed
in the request is currently limited to 1.waypoint - a Point which represents the pit-stop or waypoint where you'd like
one of the RouteLeg to navigate the user topublic NbmapDirections.Builder waypoints(@NonNull java.util.List<com.nbmap.geojson.Point> waypoints)
DirectionsCriteria.PROFILE_DRIVING_TRAFFIC that the max number of waypoints allowed
in the request is currently limited to 1.waypoints - a list which represents the pit-stops or waypoints where
you'd like one of the RouteLeg to navigate the user topublic abstract NbmapDirections.Builder alternatives(@Nullable java.lang.Boolean alternatives)
alternatives - true if you'd like to receive an alternative route, otherwise false or
null to use the APIs default valuepublic abstract NbmapDirections.Builder geometries(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 NbmapDirections.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.OverviewCriteriapublic abstract NbmapDirections.Builder steps(@Nullable java.lang.Boolean steps)
steps - true if you'd like step informationpublic abstract NbmapDirections.Builder continueStraight(@Nullable java.lang.Boolean continueStraight)
DirectionsCriteria.PROFILE_DRIVING and false for
DirectionsCriteria.PROFILE_WALKING and DirectionsCriteria.PROFILE_CYCLING.continueStraight - boolean true if you want to always continue straight, else false.
Null can also be passed in here to use the APIs default optionpublic NbmapDirections.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 NbmapDirections.Builder roundaboutExits(@Nullable java.lang.Boolean roundaboutExits)
roundaboutExits - true if you'd like extra roundabout instructions@Deprecated public NbmapDirections.Builder annotations(@NonNull java.lang.String... annotations)
annotations(List)DirectionsCriteria.ANNOTATION_DISTANCE,
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 NbmapDirections.Builder annotations(@NonNull java.util.List<java.lang.String> annotations)
DirectionsCriteria.ANNOTATION_DISTANCE,
DirectionsCriteria.ANNOTATION_DURATION and
DirectionsCriteria.ANNOTATION_CONGESTIONannotations - a list of annotationspublic NbmapDirections.Builder addAnnotation(@NonNull java.lang.String annotation)
DirectionsCriteria.ANNOTATION_DISTANCE,
DirectionsCriteria.ANNOTATION_DURATION and
DirectionsCriteria.ANNOTATION_CONGESTIONannotation - string referencing one of the annotation direction criteria's.public NbmapDirections.Builder addBearing(@Nullable java.lang.Double angle, @Nullable java.lang.Double tolerance)
radiuses 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 NbmapDirections.Builder bearings(@NonNull java.util.List<java.util.List<java.lang.Double>> bearings)
radiuses parameter.bearings - a list of list of doubles. Every list has two values:
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.@Deprecated public NbmapDirections.Builder radiuses(@NonNull java.lang.Double... radiuses)
radiuses(List)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 NbmapDirections.Builder radiuses(@NonNull java.util.List<java.lang.Double> radiuses)
Double.POSITIVE_INFINITY.
If no routable road is found within the radius, a NoSegment error is returned.
radiuses - a list with radiuses defined in unit meters.public NbmapDirections.Builder addRadius(@NonNull java.lang.Double radius)
Double.POSITIVE_INFINITY.
If no routable road is found within the radius, a NoSegment error is returned.
radius - double param defined in unit meters.public abstract NbmapDirections.Builder exclude(java.lang.String exclude)
exclude - one of the constants defined in DirectionsCriteria.ExcludeCriteriapublic abstract NbmapDirections.Builder voiceInstructions(@Nullable java.lang.Boolean voiceInstructions)
It's important to note that the steps(Boolean) should be true or else these results
wont be returned.
voiceInstructions - true if you'd like voice instruction objects be attached to your
responsepublic abstract NbmapDirections.Builder bannerInstructions(@Nullable java.lang.Boolean bannerInstructions)
bannerInstructions - true if you'd like the receive banner objects within your response
objectpublic abstract NbmapDirections.Builder voiceUnits(@Nullable java.lang.String voiceUnits)
voiceUnits - either Imperial (default) or Metricpublic abstract NbmapDirections.Builder clientAppName(@NonNull java.lang.String clientAppName)
clientAppName - base package name or other simple string identifierpublic abstract NbmapDirections.Builder accessToken(@NonNull java.lang.String accessToken)
ServicesException will be thrown.accessToken - Nbmap access token, You must have a Nbmap account inorder to use
the Optimization APIpublic abstract NbmapDirections.Builder baseUrl(java.lang.String baseUrl)
baseUrl - base url used as end pointpublic abstract NbmapDirections.Builder interceptor(okhttp3.Interceptor interceptor)
interceptor - to set for OkHttppublic abstract NbmapDirections.Builder networkInterceptor(okhttp3.Interceptor interceptor)
interceptor - to set for OkHttppublic abstract NbmapDirections.Builder eventListener(okhttp3.EventListener eventListener)
eventListener - to set for OkHttp@Deprecated public NbmapDirections.Builder addApproaches(@NonNull java.lang.String... approaches)
approaches(List)approaches - null if you'd like the default approaches,
else one of the options found in
DirectionsCriteria.ApproachesCriteria.public NbmapDirections.Builder approaches(@NonNull java.util.List<java.lang.String> approaches)
approaches - empty if you'd like the default approaches,
else one of the options found in
DirectionsCriteria.ApproachesCriteria.public NbmapDirections.Builder addApproach(@Nullable java.lang.String approach)
approach - null if you'd like the default approaches, else one of the options found in
DirectionsCriteria.ApproachesCriteria.@Deprecated public NbmapDirections.Builder addWaypointIndices(@NonNull java.lang.Integer... waypointIndices)
waypointIndices(List)
Most useful in combination with steps=true and requests based on traces
with high sample rates. Can be an index corresponding to any of the input coordinates,
but must contain the first ( 0 ) and last coordinates' indices.
NbmapDirections.steps()
waypointIndices - integer array of coordinate indices to be used as waypointspublic NbmapDirections.Builder waypointIndices(@NonNull java.util.List<java.lang.Integer> waypointIndices)
Most useful in combination with steps=true and requests based on traces
with high sample rates. Can be an index corresponding to any of the input coordinates,
but must contain the first ( 0 ) and last coordinates' indices.
NbmapDirections.steps()
waypointIndices - a list of coordinate indices to be used as waypointspublic NbmapDirections.Builder addWaypointIndex(@NonNull java.lang.Integer waypointIndex)
Most useful in combination with steps=true and requests based on traces
with high sample rates. Can be an index corresponding to any of the input coordinates,
but must contain the first ( 0 ) and last coordinates' indices.
NbmapDirections.steps()
waypointIndex - integer index to be used as waypoint@Deprecated public NbmapDirections.Builder addWaypointNames(@NonNull java.lang.String... waypointNames)
waypointNames(List)waypointNames - Custom names for waypoints used for the arrival instruction.public NbmapDirections.Builder waypointNames(@NonNull java.util.List<java.lang.String> waypointNames)
waypointNames - a list of custom names for waypoints used for the arrival instruction.public NbmapDirections.Builder addWaypointName(@Nullable java.lang.String waypointName)
waypointName - Custom name for waypoint used for the arrival instruction.@Deprecated public NbmapDirections.Builder addWaypointTargets(@NonNull com.nbmap.geojson.Point... waypointTargets)
waypointTargets(List)waypointTargets - list of coordinate points for drop-off locationspublic NbmapDirections.Builder waypointTargets(@NonNull java.util.List<com.nbmap.geojson.Point> waypointTargets)
waypointTargets - list of coordinate points for drop-off locationspublic NbmapDirections.Builder addWaypointTarget(@Nullable com.nbmap.geojson.Point waypointTarget)
waypointTarget - a point for drop-off locationspublic NbmapDirections.Builder snappingClosures(@NonNull java.util.List<java.lang.Boolean> snappingClosures)
DirectionsCriteria.PROFILE_DRIVING_TRAFFICsnappingClosures - a list of booleanspublic NbmapDirections.Builder addSnappingClosure(@Nullable java.lang.Boolean snappingClosure)
DirectionsCriteria.PROFILE_DRIVING_TRAFFICsnappingClosure - a boolean affecting snapping of waypoint location to the road segment.public abstract NbmapDirections.Builder enableRefresh(java.lang.Boolean enableRefresh)
enableRefresh - whether the routes should be refreshablepublic NbmapDirections.Builder post()
public NbmapDirections.Builder get()
public abstract NbmapDirections.Builder walkingOptions(@NonNull com.nbmap.api.directions.v5.WalkingOptions walkingOptions)
walkingOptions - options to use for walking profilepublic NbmapDirections build()
NbmapDirections.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 NbmapDirections object with the values provided.