Show / Hide Table of Contents

Class RoutesClient

Routes client wrapper, for convenient use.

Inheritance
object
RoutesClient
RoutesClientImpl
Inherited Members
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ToString()
Namespace: Google.Maps.Routing.V2
Assembly: Google.Maps.Routing.V2.dll
Syntax
public abstract class RoutesClient
Remarks

The Routes API.

Properties

DefaultEndpoint

The default endpoint for the Routes service, which is a host of "routes.googleapis.com" and a port of 443.

Declaration
public static string DefaultEndpoint { get; }
Property Value
Type Description
string

DefaultScopes

The default Routes scopes.

Declaration
public static IReadOnlyList<string> DefaultScopes { get; }
Property Value
Type Description
IReadOnlyList<string>
Remarks

The default Routes scopes are:

    GrpcClient

    The underlying gRPC Routes client

    Declaration
    public virtual Routes.RoutesClient GrpcClient { get; }
    Property Value
    Type Description
    Routes.RoutesClient

    ServiceMetadata

    The service metadata associated with this client type.

    Declaration
    public static ServiceMetadata ServiceMetadata { get; }
    Property Value
    Type Description
    ServiceMetadata

    Methods

    ComputeRouteMatrix(ComputeRouteMatrixRequest, CallSettings)

    Takes in a list of origins and destinations and returns a stream containing route information for each combination of origin and destination.

    NOTE: This method requires that you specify a response field mask in the input. You can provide the response field mask by using the URL parameter $fields or fields, or by using the HTTP/gRPC header X-Goog-FieldMask (see the available URL parameters and headers. The value is a comma separated list of field paths. See this detailed documentation about how to construct the field paths.

    For example, in this method:

    • Field mask of all available fields (for manual inspection): X-Goog-FieldMask: *
    • Field mask of route durations, distances, element status, condition, and element indices (an example production setup): X-Goog-FieldMask: originIndex,destinationIndex,status,condition,distanceMeters,duration

    It is critical that you include status in your field mask as otherwise all messages will appear to be OK. Google discourages the use of the wildcard (*) response field mask, because:

    • Selecting only the fields that you need helps our server save computation cycles, allowing us to return the result to you with a lower latency.
    • Selecting only the fields that you need in your production job ensures stable latency performance. We might add more response fields in the future, and those new fields might require extra computation time. If you select all fields, or if you select all fields at the top level, then you might experience performance degradation because any new field we add will be automatically included in the response.
    • Selecting only the fields that you need results in a smaller response size, and thus higher network throughput.
    Declaration
    public virtual RoutesClient.ComputeRouteMatrixStream ComputeRouteMatrix(ComputeRouteMatrixRequest request, CallSettings callSettings = null)
    Parameters
    Type Name Description
    ComputeRouteMatrixRequest request

    The request object containing all of the parameters for the API call.

    CallSettings callSettings

    If not null, applies overrides to this RPC call.

    Returns
    Type Description
    RoutesClient.ComputeRouteMatrixStream

    The server stream.

    Sample code
    // Create client
    RoutesClient routesClient = RoutesClient.Create();
    // Initialize request argument(s)
    ComputeRouteMatrixRequest request = new ComputeRouteMatrixRequest
    {
        Origins =
        {
            new RouteMatrixOrigin(),
        },
        Destinations =
        {
            new RouteMatrixDestination(),
        },
        TravelMode = RouteTravelMode.TravelModeUnspecified,
        RoutingPreference = RoutingPreference.Unspecified,
        DepartureTime = new Timestamp(),
        LanguageCode = "",
        ExtraComputations =
        {
            ComputeRouteMatrixRequest.Types.ExtraComputation.Unspecified,
        },
        RegionCode = "",
        TrafficModel = TrafficModel.Unspecified,
        ArrivalTime = new Timestamp(),
        TransitPreferences = new TransitPreferences(),
    };
    // Make the request, returning a streaming response
    using RoutesClient.ComputeRouteMatrixStream response = routesClient.ComputeRouteMatrix(request);
    
    // Read streaming responses from server until complete
    // Note that C# 8 code can use await foreach
    AsyncResponseStream<RouteMatrixElement> responseStream = response.GetResponseStream();
    while (await responseStream.MoveNextAsync())
    {
        RouteMatrixElement responseItem = responseStream.Current;
        // Do something with streamed response
    }
    // The response stream has completed
    

    ComputeRoutes(ComputeRoutesRequest, CallSettings)

    Returns the primary route along with optional alternate routes, given a set of terminal and intermediate waypoints.

    NOTE: This method requires that you specify a response field mask in the input. You can provide the response field mask by using URL parameter $fields or fields, or by using an HTTP/gRPC header X-Goog-FieldMask (see the available URL parameters and headers. The value is a comma separated list of field paths. See detailed documentation about how to construct the field paths.

    For example, in this method:

    • Field mask of all available fields (for manual inspection): X-Goog-FieldMask: *
    • Field mask of Route-level duration, distance, and polyline (an example production setup): X-Goog-FieldMask: routes.duration,routes.distanceMeters,routes.polyline.encodedPolyline

    Google discourage the use of the wildcard (*) response field mask, or specifying the field mask at the top level (routes), because:

    • Selecting only the fields that you need helps our server save computation cycles, allowing us to return the result to you with a lower latency.
    • Selecting only the fields that you need in your production job ensures stable latency performance. We might add more response fields in the future, and those new fields might require extra computation time. If you select all fields, or if you select all fields at the top level, then you might experience performance degradation because any new field we add will be automatically included in the response.
    • Selecting only the fields that you need results in a smaller response size, and thus higher network throughput.
    Declaration
    public virtual ComputeRoutesResponse ComputeRoutes(ComputeRoutesRequest request, CallSettings callSettings = null)
    Parameters
    Type Name Description
    ComputeRoutesRequest request

    The request object containing all of the parameters for the API call.

    CallSettings callSettings

    If not null, applies overrides to this RPC call.

    Returns
    Type Description
    ComputeRoutesResponse

    The RPC response.

    Sample code
    // Create client
    RoutesClient routesClient = RoutesClient.Create();
    // Initialize request argument(s)
    ComputeRoutesRequest request = new ComputeRoutesRequest
    {
        Origin = new Waypoint(),
        Destination = new Waypoint(),
        Intermediates = { new Waypoint(), },
        TravelMode = RouteTravelMode.TravelModeUnspecified,
        RoutingPreference = RoutingPreference.Unspecified,
        PolylineQuality = PolylineQuality.Unspecified,
        DepartureTime = new Timestamp(),
        ComputeAlternativeRoutes = false,
        RouteModifiers = new RouteModifiers(),
        LanguageCode = "",
        Units = Units.Unspecified,
        PolylineEncoding = PolylineEncoding.Unspecified,
        OptimizeWaypointOrder = false,
        RequestedReferenceRoutes =
        {
            ComputeRoutesRequest.Types.ReferenceRoute.Unspecified,
        },
        ExtraComputations =
        {
            ComputeRoutesRequest.Types.ExtraComputation.Unspecified,
        },
        RegionCode = "",
        TrafficModel = TrafficModel.Unspecified,
        ArrivalTime = new Timestamp(),
        TransitPreferences = new TransitPreferences(),
    };
    // Make the request
    ComputeRoutesResponse response = routesClient.ComputeRoutes(request);
    

    ComputeRoutesAsync(ComputeRoutesRequest, CallSettings)

    Returns the primary route along with optional alternate routes, given a set of terminal and intermediate waypoints.

    NOTE: This method requires that you specify a response field mask in the input. You can provide the response field mask by using URL parameter $fields or fields, or by using an HTTP/gRPC header X-Goog-FieldMask (see the available URL parameters and headers. The value is a comma separated list of field paths. See detailed documentation about how to construct the field paths.

    For example, in this method:

    • Field mask of all available fields (for manual inspection): X-Goog-FieldMask: *
    • Field mask of Route-level duration, distance, and polyline (an example production setup): X-Goog-FieldMask: routes.duration,routes.distanceMeters,routes.polyline.encodedPolyline

    Google discourage the use of the wildcard (*) response field mask, or specifying the field mask at the top level (routes), because:

    • Selecting only the fields that you need helps our server save computation cycles, allowing us to return the result to you with a lower latency.
    • Selecting only the fields that you need in your production job ensures stable latency performance. We might add more response fields in the future, and those new fields might require extra computation time. If you select all fields, or if you select all fields at the top level, then you might experience performance degradation because any new field we add will be automatically included in the response.
    • Selecting only the fields that you need results in a smaller response size, and thus higher network throughput.
    Declaration
    public virtual Task<ComputeRoutesResponse> ComputeRoutesAsync(ComputeRoutesRequest request, CallSettings callSettings = null)
    Parameters
    Type Name Description
    ComputeRoutesRequest request

    The request object containing all of the parameters for the API call.

    CallSettings callSettings

    If not null, applies overrides to this RPC call.

    Returns
    Type Description
    Task<ComputeRoutesResponse>

    A Task containing the RPC response.

    Sample code
    // Create client
    RoutesClient routesClient = await RoutesClient.CreateAsync();
    // Initialize request argument(s)
    ComputeRoutesRequest request = new ComputeRoutesRequest
    {
        Origin = new Waypoint(),
        Destination = new Waypoint(),
        Intermediates = { new Waypoint(), },
        TravelMode = RouteTravelMode.TravelModeUnspecified,
        RoutingPreference = RoutingPreference.Unspecified,
        PolylineQuality = PolylineQuality.Unspecified,
        DepartureTime = new Timestamp(),
        ComputeAlternativeRoutes = false,
        RouteModifiers = new RouteModifiers(),
        LanguageCode = "",
        Units = Units.Unspecified,
        PolylineEncoding = PolylineEncoding.Unspecified,
        OptimizeWaypointOrder = false,
        RequestedReferenceRoutes =
        {
            ComputeRoutesRequest.Types.ReferenceRoute.Unspecified,
        },
        ExtraComputations =
        {
            ComputeRoutesRequest.Types.ExtraComputation.Unspecified,
        },
        RegionCode = "",
        TrafficModel = TrafficModel.Unspecified,
        ArrivalTime = new Timestamp(),
        TransitPreferences = new TransitPreferences(),
    };
    // Make the request
    ComputeRoutesResponse response = await routesClient.ComputeRoutesAsync(request);
    

    ComputeRoutesAsync(ComputeRoutesRequest, CancellationToken)

    Returns the primary route along with optional alternate routes, given a set of terminal and intermediate waypoints.

    NOTE: This method requires that you specify a response field mask in the input. You can provide the response field mask by using URL parameter $fields or fields, or by using an HTTP/gRPC header X-Goog-FieldMask (see the available URL parameters and headers. The value is a comma separated list of field paths. See detailed documentation about how to construct the field paths.

    For example, in this method:

    • Field mask of all available fields (for manual inspection): X-Goog-FieldMask: *
    • Field mask of Route-level duration, distance, and polyline (an example production setup): X-Goog-FieldMask: routes.duration,routes.distanceMeters,routes.polyline.encodedPolyline

    Google discourage the use of the wildcard (*) response field mask, or specifying the field mask at the top level (routes), because:

    • Selecting only the fields that you need helps our server save computation cycles, allowing us to return the result to you with a lower latency.
    • Selecting only the fields that you need in your production job ensures stable latency performance. We might add more response fields in the future, and those new fields might require extra computation time. If you select all fields, or if you select all fields at the top level, then you might experience performance degradation because any new field we add will be automatically included in the response.
    • Selecting only the fields that you need results in a smaller response size, and thus higher network throughput.
    Declaration
    public virtual Task<ComputeRoutesResponse> ComputeRoutesAsync(ComputeRoutesRequest request, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    ComputeRoutesRequest request

    The request object containing all of the parameters for the API call.

    CancellationToken cancellationToken

    A CancellationToken to use for this RPC.

    Returns
    Type Description
    Task<ComputeRoutesResponse>

    A Task containing the RPC response.

    Sample code
    // Create client
    RoutesClient routesClient = await RoutesClient.CreateAsync();
    // Initialize request argument(s)
    ComputeRoutesRequest request = new ComputeRoutesRequest
    {
        Origin = new Waypoint(),
        Destination = new Waypoint(),
        Intermediates = { new Waypoint(), },
        TravelMode = RouteTravelMode.TravelModeUnspecified,
        RoutingPreference = RoutingPreference.Unspecified,
        PolylineQuality = PolylineQuality.Unspecified,
        DepartureTime = new Timestamp(),
        ComputeAlternativeRoutes = false,
        RouteModifiers = new RouteModifiers(),
        LanguageCode = "",
        Units = Units.Unspecified,
        PolylineEncoding = PolylineEncoding.Unspecified,
        OptimizeWaypointOrder = false,
        RequestedReferenceRoutes =
        {
            ComputeRoutesRequest.Types.ReferenceRoute.Unspecified,
        },
        ExtraComputations =
        {
            ComputeRoutesRequest.Types.ExtraComputation.Unspecified,
        },
        RegionCode = "",
        TrafficModel = TrafficModel.Unspecified,
        ArrivalTime = new Timestamp(),
        TransitPreferences = new TransitPreferences(),
    };
    // Make the request
    ComputeRoutesResponse response = await routesClient.ComputeRoutesAsync(request);
    

    Create()

    Synchronously creates a RoutesClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use RoutesClientBuilder.

    Declaration
    public static RoutesClient Create()
    Returns
    Type Description
    RoutesClient

    The created RoutesClient.

    CreateAsync(CancellationToken)

    Asynchronously creates a RoutesClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use RoutesClientBuilder.

    Declaration
    public static Task<RoutesClient> CreateAsync(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    The CancellationToken to use while creating the client.

    Returns
    Type Description
    Task<RoutesClient>

    The task representing the created RoutesClient.

    ShutdownDefaultChannelsAsync()

    Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

    Declaration
    public static Task ShutdownDefaultChannelsAsync()
    Returns
    Type Description
    Task

    A task representing the asynchronous shutdown operation.

    Remarks

    After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.

    In This Article
    Back to top Generated by DocFX