pub struct RoutingServiceClient<'a> { /* private fields */ }Expand description
Client for interacting with an ArcGIS Routing Service (Network Analyst Server).
Provides operations for routing, service areas, closest facility, and origin-destination matrices.
§Example
use arcgis::{ApiKeyAuth, ArcGISClient, RoutingServiceClient};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let routing_service = RoutingServiceClient::new(
"https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",
&client,
);Implementations§
Source§impl<'a> RoutingServiceClient<'a>
impl<'a> RoutingServiceClient<'a>
Sourcepub fn new(base_url: impl Into<String>, client: &'a ArcGISClient) -> Self
pub fn new(base_url: impl Into<String>, client: &'a ArcGISClient) -> Self
Creates a new Routing Service client.
§Arguments
base_url- The base URL of the routing service (e.g.,https://route.arcgis.com/.../Route_World)client- Reference to an authenticated ArcGIS client
§Example
use arcgis::{ApiKeyAuth, ArcGISClient, RoutingServiceClient};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let routing_service = RoutingServiceClient::new(
"https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",
&client
);Sourcepub async fn solve_route(&self, params: RouteParameters) -> Result<RouteResult>
pub async fn solve_route(&self, params: RouteParameters) -> Result<RouteResult>
Solves a route between multiple stops.
Calculates the optimal route connecting all stops, with options for turn-by-turn directions, barriers, and traffic-aware routing.
§Arguments
params- Route parameters including stops and routing options
§Example
use arcgis::{ApiKeyAuth, ArcGISClient, RoutingServiceClient, ArcGISPoint, ArcGISGeometry};
use arcgis::{RouteParameters, NALocation};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let routing_service = RoutingServiceClient::new(
"https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",
&client
);
let stop1 = NALocation::new(ArcGISGeometry::Point(ArcGISPoint {
x: -122.4194,
y: 37.7749,
z: None,
m: None,
spatial_reference: None,
})).with_name("San Francisco");
let stop2 = NALocation::new(ArcGISGeometry::Point(ArcGISPoint {
x: -118.2437,
y: 34.0522,
z: None,
m: None,
spatial_reference: None,
})).with_name("Los Angeles");
let params = RouteParameters::builder()
.stops(vec![stop1, stop2])
.return_directions(true)
.return_routes(true)
.return_stops(true)
.build()
.expect("Valid parameters");
let result = routing_service.solve_route(params).await?;Sourcepub async fn solve_service_area(
&self,
params: ServiceAreaParameters,
) -> Result<ServiceAreaResult>
pub async fn solve_service_area( &self, params: ServiceAreaParameters, ) -> Result<ServiceAreaResult>
Calculates service areas (drive-time or distance polygons).
Generates polygons showing areas reachable from facilities within specified break values (time or distance).
§Arguments
params- Service area parameters including facilities and break values
§Example
use arcgis::{ApiKeyAuth, ArcGISClient, RoutingServiceClient, ArcGISPoint, ArcGISGeometry};
use arcgis::{ServiceAreaParameters, NALocation};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let routing_service = RoutingServiceClient::new(
"https://route.arcgis.com/arcgis/rest/services/World/ServiceAreas/NAServer/ServiceArea_World",
&client
);
let facility = NALocation::new(ArcGISGeometry::Point(ArcGISPoint {
x: -122.4194,
y: 37.7749,
z: None,
m: None,
spatial_reference: None,
})).with_name("Store");
let params = ServiceAreaParameters::builder()
.facilities(vec![facility])
.default_breaks(vec![5.0, 10.0, 15.0]) // 5, 10, 15 minute drive times
.build()
.expect("Valid parameters");
let result = routing_service.solve_service_area(params).await?;Sourcepub async fn solve_closest_facility(
&self,
params: ClosestFacilityParameters,
) -> Result<ClosestFacilityResult>
pub async fn solve_closest_facility( &self, params: ClosestFacilityParameters, ) -> Result<ClosestFacilityResult>
Finds the closest facilities from incidents.
Calculates routes from incidents to the N nearest facilities, useful for emergency response, service allocation, etc.
§Arguments
params- Closest facility parameters including incidents and facilities
§Example
use arcgis::{ApiKeyAuth, ArcGISClient, RoutingServiceClient, ArcGISPoint, ArcGISGeometry};
use arcgis::{ClosestFacilityParameters, NALocation};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let routing_service = RoutingServiceClient::new(
"https://route.arcgis.com/arcgis/rest/services/World/ClosestFacility/NAServer/ClosestFacility_World",
&client
);
let incident = NALocation::new(ArcGISGeometry::Point(ArcGISPoint {
x: -122.4194,
y: 37.7749,
z: None,
m: None,
spatial_reference: None,
})).with_name("Emergency");
let facility = NALocation::new(ArcGISGeometry::Point(ArcGISPoint {
x: -122.4,
y: 37.8,
z: None,
m: None,
spatial_reference: None,
})).with_name("Hospital");
let params = ClosestFacilityParameters::builder()
.incidents(vec![incident])
.facilities(vec![facility])
.default_target_facility_count(1)
.return_routes(true)
.build()
.expect("Valid parameters");
let result = routing_service.solve_closest_facility(params).await?;Sourcepub async fn generate_od_cost_matrix(
&self,
params: ODCostMatrixParameters,
) -> Result<ODCostMatrixResult>
pub async fn generate_od_cost_matrix( &self, params: ODCostMatrixParameters, ) -> Result<ODCostMatrixResult>
Generates an origin-destination cost matrix.
Calculates travel costs between all origin-destination pairs, useful for logistics, fleet management, and coverage analysis.
§Arguments
params- OD cost matrix parameters including origins and destinations
§Example
use arcgis::{ApiKeyAuth, ArcGISClient, RoutingServiceClient, ArcGISPoint, ArcGISGeometry};
use arcgis::{ODCostMatrixParameters, NALocation};
let auth = ApiKeyAuth::new("YOUR_API_KEY");
let client = ArcGISClient::new(auth);
let routing_service = RoutingServiceClient::new(
"https://route.arcgis.com/arcgis/rest/services/World/OriginDestinationCostMatrix/NAServer/OriginDestinationCostMatrix_World",
&client
);
let origin = NALocation::new(ArcGISGeometry::Point(ArcGISPoint {
x: -122.4194,
y: 37.7749,
z: None,
m: None,
spatial_reference: None,
})).with_name("Warehouse");
let destination = NALocation::new(ArcGISGeometry::Point(ArcGISPoint {
x: -118.2437,
y: 34.0522,
z: None,
m: None,
spatial_reference: None,
})).with_name("Customer");
let params = ODCostMatrixParameters::builder()
.origins(vec![origin])
.destinations(vec![destination])
.build()
.expect("Valid parameters");
let result = routing_service.generate_od_cost_matrix(params).await?;Auto Trait Implementations§
impl<'a> Freeze for RoutingServiceClient<'a>
impl<'a> !RefUnwindSafe for RoutingServiceClient<'a>
impl<'a> Send for RoutingServiceClient<'a>
impl<'a> Sync for RoutingServiceClient<'a>
impl<'a> Unpin for RoutingServiceClient<'a>
impl<'a> !UnwindSafe for RoutingServiceClient<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more