Class MapsRouteAsyncClient

java.lang.Object
com.azure.maps.route.MapsRouteAsyncClient

public final class MapsRouteAsyncClient extends Object
Initializes a new instance of the asynchronous RouteAsyncClient type. Creating an async 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
 MapsRouteAsyncClient client = builder.buildAsyncClient();
 
Creating an async 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
 MapsRouteAsyncClient client = builder.buildAsyncClient();
 
  • Method Details

    • beginGetRouteMatrix

      public com.azure.core.util.polling.PollerFlux<RouteMatrixResult,RouteMatrixResult> beginGetRouteMatrix(RouteMatrixOptions options)
      Request Route Matrix
       System.out.println("Request route matrix");
       RouteMatrixQuery matrixQuery3 = new RouteMatrixQuery();
      
       // origins
       GeoPointCollection origins3 = new GeoPointCollection(Arrays.asList(
           new GeoPoint(52.36006, 4.85106),
           new GeoPoint(52.36187, 4.85056)
       ));
      
       // destinations
       GeoPointCollection destinations3 = new GeoPointCollection(Arrays.asList(
           new GeoPoint(52.36241, 4.85003),
           new GeoPoint(52.50931, 13.42937)
       ));
      
       matrixQuery3.setDestinations(destinations3);
       matrixQuery3.setOrigins(origins3);
      
       RouteMatrixOptions matrixOptions2 = new RouteMatrixOptions(matrixQuery3);
       asyncClient.beginGetRouteMatrix(matrixOptions2).blockFirst().getFinalResult();
       
      Parameters:
      options - the RouteMatrixOptions 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.PollerFlux<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.
    • getRouteDirections

      public Mono<RouteDirections> getRouteDirections(RouteDirectionsOptions options)
      Get Route Directions
       System.out.println("Get route directions");
       List<GeoPosition> routePoints2 = Arrays.asList(
           new GeoPosition(13.42936, 52.50931),
           new GeoPosition(13.43872, 52.50274));
       RouteDirectionsOptions routeOptions2 = new RouteDirectionsOptions(routePoints2);
       RouteDirections directions4 = asyncClient.getRouteDirections(routeOptions2).block();
       RouteReport report2 = directions4.getReport(); // get the report and use it
       
      Parameters:
      options - the RouteDirectionsOptions 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 Mono<com.azure.core.http.rest.Response<RouteDirections>> getRouteDirectionsWithResponse(RouteDirectionsOptions options)
      Get Route Directions
       System.out.println("Get route directions");
       List<GeoPosition> routePoints2 = Arrays.asList(
           new GeoPosition(13.42936, 52.50931),
           new GeoPosition(13.43872, 52.50274));
       RouteDirectionsOptions routeOptions2 = new RouteDirectionsOptions(routePoints2);
       RouteDirections directions4 = asyncClient.getRouteDirections(routeOptions2).block();
       RouteReport report2 = directions4.getReport(); // get the report and use it
       
      Parameters:
      options - the RouteDirectionsOptions 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.
    • getRouteDirections

      public Mono<RouteDirections> getRouteDirections(RouteDirectionsOptions options, RouteDirectionsParameters parameters)
      Get Route Directions
       System.out.println("Get route parameters");
       // supporting points
       GeoCollection supportingPoints2 = new GeoCollection(
           Arrays.asList(
               new GeoPoint(13.42936, 52.5093),
               new GeoPoint(13.42859, 52.50844)
               ));
      
       // avoid areas
       List<GeoPolygon> polygons2 = 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 avoidAreas2 = new GeoPolygonCollection(polygons2);
       RouteDirectionsParameters parameters2 = new RouteDirectionsParameters()
           .setSupportingPoints(supportingPoints2)
           .setAvoidVignette(Arrays.asList("AUS", "CHE"))
           .setAvoidAreas(avoidAreas2);
       asyncClient.getRouteDirections(routeOptions2,
           parameters2).block();
       
      Parameters:
      options - the RouteDirectionsOptions applicable to this query
      parameters - the RouteDirectionsParameters 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 Mono<com.azure.core.http.rest.Response<RouteDirections>> getRouteDirectionsWithResponse(RouteDirectionsOptions options, RouteDirectionsParameters parameters)
      Get Route Directions
       System.out.println("Get route parameters");
       // supporting points
       GeoCollection supportingPoints2 = new GeoCollection(
           Arrays.asList(
               new GeoPoint(13.42936, 52.5093),
               new GeoPoint(13.42859, 52.50844)
               ));
      
       // avoid areas
       List<GeoPolygon> polygons2 = 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 avoidAreas2 = new GeoPolygonCollection(polygons2);
       RouteDirectionsParameters parameters2 = new RouteDirectionsParameters()
           .setSupportingPoints(supportingPoints2)
           .setAvoidVignette(Arrays.asList("AUS", "CHE"))
           .setAvoidAreas(avoidAreas2);
       asyncClient.getRouteDirections(routeOptions2,
           parameters2).block();
       
      Parameters:
      options - the RouteDirectionsOptions applicable to this query
      parameters - the RouteDirectionsParameters 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.
    • getRouteRange

      public Mono<RouteRangeResult> getRouteRange(RouteRangeOptions options)
      Get Route Range
       System.out.println("Get route range");
       RouteRangeOptions rangeOptions2 = new RouteRangeOptions(new GeoPosition(5.86605, 50.97452), Duration.ofSeconds(6000));
       asyncClient.getRouteRange(rangeOptions2).block();
       
      Parameters:
      options - the RouteRangeOptions 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 Mono<com.azure.core.http.rest.Response<RouteRangeResult>> getRouteRangeWithResponse(RouteRangeOptions options)
      Get Route Range
       System.out.println("Get route range");
       RouteRangeOptions rangeOptions2 = new RouteRangeOptions(new GeoPosition(5.86605, 50.97452), Duration.ofSeconds(6000));
       asyncClient.getRouteRange(rangeOptions2).block();
       
      Parameters:
      options - the RouteRangeOptions 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.
    • beginRequestRouteDirectionsBatch

      public com.azure.core.util.polling.PollerFlux<RouteDirectionsBatchResult,RouteDirectionsBatchResult> beginRequestRouteDirectionsBatch(List<RouteDirectionsOptions> optionsList)
      Get Route Directions Batch
       RouteDirectionsOptions options5 = 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 options6 = 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 options7 = 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> optionsList2 = Arrays.asList(options5, options6, options7);
       SyncPoller<RouteDirectionsBatchResult, RouteDirectionsBatchResult> poller2 =
           asyncClient.beginRequestRouteDirectionsBatch(optionsList2).getSyncPoller();
       poller2.getFinalResult();
       
      Parameters:
      optionsList - the list of RouteDirectionsOptions 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.
    • beginGetRouteDirectionsBatch

      public com.azure.core.util.polling.PollerFlux<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.