Package com.azure.maps.route
Class MapsRouteClient
java.lang.Object
com.azure.maps.route.MapsRouteClient
Initializes a new instance of the synchronous RouteClient type.
Creating a sync client using a
AzureKeyCredential
:
// Authenticates using subscription key AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY")); // Creates a builder MapsRouteClientBuilder builder = new MapsRouteClientBuilder(); builder.credential(keyCredential); builder.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)); // Builds the client MapsRouteClient client = builder.buildClient();Creating a sync client using a
TokenCredential
:
// Authenticates using Azure AD building a default credential // This will look for AZURE_CLIENT_ID, AZURE_TENANT_ID, and AZURE_CLIENT_SECRET env variables DefaultAzureCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); // Creates a builder MapsRouteClientBuilder builder = new MapsRouteClientBuilder(); builder.credential(tokenCredential); builder.mapsClientId(System.getenv("MAPS_CLIENT_ID")); builder.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)); // Builds a client MapsRouteClient client = builder.buildClient();
-
Method Summary
Modifier and TypeMethodDescriptioncom.azure.core.util.polling.SyncPoller<RouteDirectionsBatchResult,
RouteDirectionsBatchResult> beginGetRouteDirectionsBatch
(String batchId) Get Route Directions Batch Idcom.azure.core.util.polling.SyncPoller<RouteDirectionsBatchResult,
RouteDirectionsBatchResult> beginGetRouteDirectionsBatch
(String batchId, com.azure.core.util.Context context) Get Route Directions Batch Idcom.azure.core.util.polling.SyncPoller<RouteMatrixResult,
RouteMatrixResult> beginGetRouteMatrix
(RouteMatrixOptions options) Request Route Matrixcom.azure.core.util.polling.SyncPoller<RouteMatrixResult,
RouteMatrixResult> beginGetRouteMatrix
(RouteMatrixOptions options, com.azure.core.util.Context context) Request Route Matrixcom.azure.core.util.polling.SyncPoller<RouteMatrixResult,
RouteMatrixResult> beginGetRouteMatrix
(String matrixId) Get Route Matrix Batchcom.azure.core.util.polling.SyncPoller<RouteMatrixResult,
RouteMatrixResult> beginGetRouteMatrix
(String matrixId, com.azure.core.util.Context context) Get Route Matrix Batchcom.azure.core.util.polling.SyncPoller<RouteDirectionsBatchResult,
RouteDirectionsBatchResult> beginRequestRouteDirectionsBatch
(List<RouteDirectionsOptions> optionsList) Get Route Directions Batchcom.azure.core.util.polling.SyncPoller<RouteDirectionsBatchResult,
RouteDirectionsBatchResult> beginRequestRouteDirectionsBatch
(List<RouteDirectionsOptions> optionsList, com.azure.core.util.Context context) Get Route Directions BatchgetRouteDirections
(RouteDirectionsOptions options) Get Route DirectionsgetRouteDirections
(RouteDirectionsOptions options, RouteDirectionsParameters parameters) Get Route Directionscom.azure.core.http.rest.Response<RouteDirections>
getRouteDirectionsWithResponse
(RouteDirectionsOptions options, com.azure.core.util.Context context) Get Route Directionscom.azure.core.http.rest.Response<RouteDirections>
getRouteDirectionsWithResponse
(RouteDirectionsOptions options, RouteDirectionsParameters parameters, com.azure.core.util.Context context) Get Route DirectionsgetRouteRange
(RouteRangeOptions options) Get Route Rangecom.azure.core.http.rest.Response<RouteRangeResult>
getRouteRangeWithResponse
(RouteRangeOptions options, com.azure.core.util.Context context) Get Route Range
-
Method Details
-
beginGetRouteMatrix
public com.azure.core.util.polling.SyncPoller<RouteMatrixResult,RouteMatrixResult> beginGetRouteMatrix(RouteMatrixOptions options) Request Route MatrixSystem.out.println("Request route matrix"); RouteMatrixQuery matrixQuery = new RouteMatrixQuery(); // origins GeoPointCollection origins = new GeoPointCollection(Arrays.asList( new GeoPoint(52.36006, 4.85106), new GeoPoint(52.36187, 4.85056) )); // destinations GeoPointCollection destinations = new GeoPointCollection(Arrays.asList( new GeoPoint(52.36241, 4.85003), new GeoPoint(52.50931, 13.42937) )); matrixQuery.setDestinations(destinations); matrixQuery.setOrigins(origins); RouteMatrixOptions matrixOptions = new RouteMatrixOptions(matrixQuery); client.beginGetRouteMatrix(matrixOptions).getFinalResult();
- Parameters:
options
- theRouteMatrixOptions
applicable to this query.- Returns:
- this object is returned from a successful Route Matrix call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
beginGetRouteMatrix
public com.azure.core.util.polling.SyncPoller<RouteMatrixResult,RouteMatrixResult> beginGetRouteMatrix(RouteMatrixOptions options, com.azure.core.util.Context context) Request Route MatrixSystem.out.println("Request route matrix"); RouteMatrixQuery matrixQuery = new RouteMatrixQuery(); // origins GeoPointCollection origins = new GeoPointCollection(Arrays.asList( new GeoPoint(52.36006, 4.85106), new GeoPoint(52.36187, 4.85056) )); // destinations GeoPointCollection destinations = new GeoPointCollection(Arrays.asList( new GeoPoint(52.36241, 4.85003), new GeoPoint(52.50931, 13.42937) )); matrixQuery.setDestinations(destinations); matrixQuery.setOrigins(origins); RouteMatrixOptions matrixOptions = new RouteMatrixOptions(matrixQuery); client.beginGetRouteMatrix(matrixOptions).getFinalResult();
- Parameters:
options
- theRouteMatrixOptions
applicable to this query.context
- the context to associate with this operation.- Returns:
- this object is returned from a successful Route Matrix call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
beginGetRouteMatrix
public com.azure.core.util.polling.SyncPoller<RouteMatrixResult,RouteMatrixResult> beginGetRouteMatrix(String matrixId) Get Route Matrix Batch- Parameters:
matrixId
- Matrix id received after the Matrix Route request was accepted successfully.- Returns:
- this object is returned from a successful Route Matrix call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
beginGetRouteMatrix
public com.azure.core.util.polling.SyncPoller<RouteMatrixResult,RouteMatrixResult> beginGetRouteMatrix(String matrixId, com.azure.core.util.Context context) Get Route Matrix Batch- Parameters:
matrixId
- Matrix id received after the Matrix Route request was accepted successfully.context
- the context to associate with this operation.- Returns:
- this object is returned from a successful Route Matrix call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getRouteDirections
Get Route DirectionsSystem.out.println("Get route directions"); List<GeoPosition> routePoints = Arrays.asList( new GeoPosition(13.42936, 52.50931), new GeoPosition(13.43872, 52.50274)); RouteDirectionsOptions routeOptions = new RouteDirectionsOptions(routePoints); RouteDirections directions = client.getRouteDirections(routeOptions); RouteReport report = directions.getReport(); // get the report and use it
- Parameters:
options
- theRouteDirectionsOptions
applicable to this query- Returns:
- this object is returned from a successful Route Directions call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getRouteDirectionsWithResponse
public com.azure.core.http.rest.Response<RouteDirections> getRouteDirectionsWithResponse(RouteDirectionsOptions options, com.azure.core.util.Context context) Get Route DirectionsSystem.out.println("Get route directions"); List<GeoPosition> routePoints = Arrays.asList( new GeoPosition(13.42936, 52.50931), new GeoPosition(13.43872, 52.50274)); RouteDirectionsOptions routeOptions = new RouteDirectionsOptions(routePoints); RouteDirections directions = client.getRouteDirections(routeOptions); RouteReport report = directions.getReport(); // get the report and use it
- Parameters:
options
- theRouteDirectionsOptions
applicable to this querycontext
- the context to associate with this operation.- Returns:
- this object is returned from a successful Route Directions call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getRouteDirections
public RouteDirections getRouteDirections(RouteDirectionsOptions options, RouteDirectionsParameters parameters) Get Route DirectionsSystem.out.println("Get route parameters"); // supporting points GeoCollection supportingPoints = new GeoCollection( Arrays.asList( new GeoPoint(13.42936, 52.5093), new GeoPoint(13.42859, 52.50844) )); // avoid areas List<GeoPolygon> polygons = Arrays.asList( new GeoPolygon( new GeoLinearRing(Arrays.asList( new GeoPosition(-122.39456176757811, 47.489368981370724), new GeoPosition(-122.00454711914061, 47.489368981370724), new GeoPosition(-122.00454711914061, 47.65151268066222), new GeoPosition(-122.39456176757811, 47.65151268066222), new GeoPosition(-122.39456176757811, 47.489368981370724) )) ), new GeoPolygon( new GeoLinearRing(Arrays.asList( new GeoPosition(100.0, 0.0), new GeoPosition(101.0, 0.0), new GeoPosition(101.0, 1.0), new GeoPosition(100.0, 1.0), new GeoPosition(100.0, 0.0) )) ) ); GeoPolygonCollection avoidAreas = new GeoPolygonCollection(polygons); RouteDirectionsParameters parameters = new RouteDirectionsParameters() .setSupportingPoints(supportingPoints) .setAvoidVignette(Arrays.asList("AUS", "CHE")) .setAvoidAreas(avoidAreas); client.getRouteDirections(routeOptions, parameters);
- Parameters:
options
- theRouteDirectionsOptions
applicable to this queryparameters
- theRouteDirectionsParameters
applicable to this query- Returns:
- this object is returned from a successful Route Directions call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getRouteDirectionsWithResponse
public com.azure.core.http.rest.Response<RouteDirections> getRouteDirectionsWithResponse(RouteDirectionsOptions options, RouteDirectionsParameters parameters, com.azure.core.util.Context context) Get Route DirectionsSystem.out.println("Get route parameters"); // supporting points GeoCollection supportingPoints = new GeoCollection( Arrays.asList( new GeoPoint(13.42936, 52.5093), new GeoPoint(13.42859, 52.50844) )); // avoid areas List<GeoPolygon> polygons = Arrays.asList( new GeoPolygon( new GeoLinearRing(Arrays.asList( new GeoPosition(-122.39456176757811, 47.489368981370724), new GeoPosition(-122.00454711914061, 47.489368981370724), new GeoPosition(-122.00454711914061, 47.65151268066222), new GeoPosition(-122.39456176757811, 47.65151268066222), new GeoPosition(-122.39456176757811, 47.489368981370724) )) ), new GeoPolygon( new GeoLinearRing(Arrays.asList( new GeoPosition(100.0, 0.0), new GeoPosition(101.0, 0.0), new GeoPosition(101.0, 1.0), new GeoPosition(100.0, 1.0), new GeoPosition(100.0, 0.0) )) ) ); GeoPolygonCollection avoidAreas = new GeoPolygonCollection(polygons); RouteDirectionsParameters parameters = new RouteDirectionsParameters() .setSupportingPoints(supportingPoints) .setAvoidVignette(Arrays.asList("AUS", "CHE")) .setAvoidAreas(avoidAreas); client.getRouteDirections(routeOptions, parameters);
- Parameters:
options
- theRouteDirectionsOptions
applicable to this queryparameters
- theRouteDirectionsParameters
applicable to this querycontext
- the context to associate with this operation.- Returns:
- this object is returned from a successful Route Directions call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getRouteRange
Get Route RangeSystem.out.println("Get route range"); RouteRangeOptions rangeOptions = new RouteRangeOptions(new GeoPosition(5.86605, 50.97452), Duration.ofSeconds(6000)); client.getRouteRange(rangeOptions);
- Parameters:
options
- theRouteRangeOptions
applicable to this query- Returns:
- this object is returned from a successful Route Range call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getRouteRangeWithResponse
public com.azure.core.http.rest.Response<RouteRangeResult> getRouteRangeWithResponse(RouteRangeOptions options, com.azure.core.util.Context context) Get Route RangeSystem.out.println("Get route range"); RouteRangeOptions rangeOptions = new RouteRangeOptions(new GeoPosition(5.86605, 50.97452), Duration.ofSeconds(6000)); client.getRouteRange(rangeOptions);
- Parameters:
options
- theRouteRangeOptions
applicable to this querycontext
- the context to associate with this operation.- Returns:
- this object is returned from a successful Route Range call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
beginRequestRouteDirectionsBatch
public com.azure.core.util.polling.SyncPoller<RouteDirectionsBatchResult,RouteDirectionsBatchResult> beginRequestRouteDirectionsBatch(List<RouteDirectionsOptions> optionsList) Get Route Directions BatchRouteDirectionsOptions options1 = new RouteDirectionsOptions( Arrays.asList(new GeoPosition(-122.128384, 47.639987), new GeoPosition(-122.184408, 47.621252), new GeoPosition(-122.332000, 47.596437))) .setRouteType(RouteType.FASTEST) .setTravelMode(TravelMode.CAR) .setMaxAlternatives(5); RouteDirectionsOptions options2 = new RouteDirectionsOptions( Arrays.asList(new GeoPosition(-122.348934, 47.620659), new GeoPosition(-122.342015, 47.610101))) .setRouteType(RouteType.ECONOMY) .setTravelMode(TravelMode.BICYCLE) .setUseTrafficData(false); RouteDirectionsOptions options3 = new RouteDirectionsOptions( Arrays.asList(new GeoPosition(-73.985108, 40.759856), new GeoPosition(-73.973506, 40.771136))) .setRouteType(RouteType.SHORTEST) .setTravelMode(TravelMode.PEDESTRIAN); System.out.println("Get Route Directions Batch"); List<RouteDirectionsOptions> optionsList = Arrays.asList(options1, options2, options3); SyncPoller<RouteDirectionsBatchResult, RouteDirectionsBatchResult> poller = client.beginRequestRouteDirectionsBatch(optionsList); poller.getFinalResult();
- Parameters:
optionsList
- the list ofRouteDirectionsOptions
used in this query- Returns:
- this object is returned from a successful Route Directions call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
beginRequestRouteDirectionsBatch
public com.azure.core.util.polling.SyncPoller<RouteDirectionsBatchResult,RouteDirectionsBatchResult> beginRequestRouteDirectionsBatch(List<RouteDirectionsOptions> optionsList, com.azure.core.util.Context context) Get Route Directions BatchRouteDirectionsOptions options1 = new RouteDirectionsOptions( Arrays.asList(new GeoPosition(-122.128384, 47.639987), new GeoPosition(-122.184408, 47.621252), new GeoPosition(-122.332000, 47.596437))) .setRouteType(RouteType.FASTEST) .setTravelMode(TravelMode.CAR) .setMaxAlternatives(5); RouteDirectionsOptions options2 = new RouteDirectionsOptions( Arrays.asList(new GeoPosition(-122.348934, 47.620659), new GeoPosition(-122.342015, 47.610101))) .setRouteType(RouteType.ECONOMY) .setTravelMode(TravelMode.BICYCLE) .setUseTrafficData(false); RouteDirectionsOptions options3 = new RouteDirectionsOptions( Arrays.asList(new GeoPosition(-73.985108, 40.759856), new GeoPosition(-73.973506, 40.771136))) .setRouteType(RouteType.SHORTEST) .setTravelMode(TravelMode.PEDESTRIAN); System.out.println("Get Route Directions Batch"); List<RouteDirectionsOptions> optionsList = Arrays.asList(options1, options2, options3); SyncPoller<RouteDirectionsBatchResult, RouteDirectionsBatchResult> poller = client.beginRequestRouteDirectionsBatch(optionsList); poller.getFinalResult();
- Parameters:
optionsList
- the list ofRouteDirectionsOptions
used in this querycontext
- the context to associate with this operation.- Returns:
- this object is returned from a successful Route Directions call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
beginGetRouteDirectionsBatch
public com.azure.core.util.polling.SyncPoller<RouteDirectionsBatchResult,RouteDirectionsBatchResult> beginGetRouteDirectionsBatch(String batchId) Get Route Directions Batch Id- Parameters:
batchId
- the batch id received from a previous call to route directions batch.- Returns:
- this object is returned from a successful Route Directions call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
beginGetRouteDirectionsBatch
public com.azure.core.util.polling.SyncPoller<RouteDirectionsBatchResult,RouteDirectionsBatchResult> beginGetRouteDirectionsBatch(String batchId, com.azure.core.util.Context context) Get Route Directions Batch Id- Parameters:
batchId
- the batch id received from a previous call to route directions batch.context
- the context to associate with this operation.- Returns:
- this object is returned from a successful Route Directions call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.route.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-