@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
156 lines (154 loc) • 7.19 kB
TypeScript
import type { ClonableMixin } from "../../core/Clonable.js";
import type { JSONSupport } from "../../core/JSONSupport.js";
import type { AttributeParameterValue, LengthUnit, TraveModeType, UTurnRestriction } from "./types.js";
export interface TravelModeProperties extends Partial<Pick<TravelMode, "attributeParameterValues" | "description" | "distanceAttributeName" | "id" | "impedanceAttributeName" | "name" | "restrictionAttributeNames" | "simplificationTolerance" | "simplificationToleranceUnits" | "timeAttributeName" | "type" | "useHierarchy" | "uturnAtJunctions">> {}
/**
* A TravelMode is a set of characteristics that define how an object like a
* vehicle, bicycle, or pedestrian moves along a street network.
* Those characteristics are considered when finding directions to determine
* how the vehicle or pedestrian travels, and where they can go.
* To get a list of supported travel modes, find the default travel
* mode, and to find and use a specific travel mode, you can use the
* [fetchServiceDescription()](https://developers.arcgis.com/javascript/latest/references/core/rest/networkService/#fetchServiceDescription)
* method:
*
* ```js
* // 1. Get the default and supported travel modes of a route service
* const apiKey = "<your api key>";
* const url = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";
* const serviceDescription = await fetchServiceDescription(url, apiKey);
* const { defaultTravelMode, supportedTravelModes } = serviceDescription;
* console.log(`The name of the default travel mode is: ${defaultTravelMode.name}.`);
* console.log(`This service has ${supportedTravelModes.length} preset travel modes`);
* ```
* ```js
* // 2. Find and use the "Driving Time" travel mode
* const apiKey = "<your api key>";
* const url = "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World";
* const serviceDescription = await fetchServiceDescription(url, apiKey);
* const { supportedTravelModes } = serviceDescription;
* const driveTimeTravelMode = supportedTravelModes.find(({ name }) => name === "Driving Time");
*
* // Solve a route using the "Driving Time" travel mode
* const routeParameters = {
* stops: stopsFeatureSet, // route stops
* travelMode: driveTimeTravelMode
* };
* const result = await solve(url, routeParameters);
* ```
*
* For ArcGIS Enterprise services, the default value for a travel mode is based on the layer
* setting when the map service is published with the network analysis capabilities. Open the
* service description page to see the default values for the parameters.
*
* @since 4.20
* @see [Introduction to travel modes](https://doc.arcgis.com/en/arcgis-online/reference/travel-modes.htm)
* @see [Default ArcGIS Online travel modes](https://doc.arcgis.com/en/arcgis-online/reference/travel-modes.htm#GUID-96DF7F50-E0B2-4BF3-8271-EB515D3F0107)
* @see [DirectionsViewModel.selectedTravelMode](https://developers.arcgis.com/javascript/latest/references/core/widgets/Directions/DirectionsViewModel/#selectedTravelMode)
* @see [ClosestFacilityParameters.travelMode](https://developers.arcgis.com/javascript/latest/references/core/rest/support/ClosestFacilityParameters/#travelMode)
* @see [RouteParameters.travelMode](https://developers.arcgis.com/javascript/latest/references/core/rest/support/RouteParameters/#travelMode)
* @see [ServiceAreaParameters.travelMode](https://developers.arcgis.com/javascript/latest/references/core/rest/support/ServiceAreaParameters/#travelMode)
* @see [fetchServiceDescription()](https://developers.arcgis.com/javascript/latest/references/core/rest/networkService/#fetchServiceDescription)
*/
export default class TravelMode extends TravelModeSuperclass {
constructor(properties?: TravelModeProperties);
/** Lists the parameterized attributes used by the travel mode. */
accessor attributeParameterValues: AttributeParameterValue[];
/** A short text description of the travel mode. */
accessor description: string | null | undefined;
/**
* Indicates the distance-based cost attribute for reporting directions and for solving vehicle routing problems.
*
* Known Value |
* ------------|
* kilometers |
* miles |
* meters |
*/
distanceAttributeName: string;
/** The unique identifier. */
accessor id: string;
/**
* The network cost attribute used as impedance. This cost attribute is minimized while solving network analysis problems.
*
* Known Value |
* ------------|
* kilometers |
* miles |
* meters |
* minutes |
* time-at-1kph
* travel-time |
* truck-minutes |
* truck-travel-time |
* walk-time |
*/
impedanceAttributeName: string;
/** The unique name of the travel mode. */
accessor name: string;
/**
* The list of the restriction attributes used when solving network analysis problems with this travel mode.
*
* Known Value |
* ------------|
* any-hazmat-prohibited |
* avoid-carpool-roads |
* avoid-express-lanes |
* avoid-ferries |
* avoid-gates |
* avoid-limited-access-roads |
* avoid-private-roads |
* avoid-roads-unsuitable-for-pedestrians |
* avoid-stairways |
* avoid-toll-roads |
* avoid-toll-roads-for-trucks |
* avoid-truck-restricted-roads |
* avoid-unpaved-roads |
* axle-count-restriction |
* driving-a-bus |
* driving-a-taxi |
* driving-a-truck |
* driving-an-automobile |
* driving-an-emergency-vehicle |
* height-restriction |
* kingpin-to-rear-axle-length-restriction |
* length-restriction |
* preferred-for-pedestrians |
* riding-a-motorcycle |
* roads-under-construction-prohibited |
* semi-or-tractor-with-one-or-more-trailers-prohibited |
* single-axle-vehicles-prohibited |
* tandem-axle-vehicles-prohibited |
* through-traffic-prohibited |
* truck-with-trailers-restriction |
* use-preferred-hazmat-routes |
* use-preferred-truck-routes |
* walking |
* weight-restriction |
*/
accessor restrictionAttributeNames: string[];
/** Specifies whether the travel mode generalizes the geometry of analysis results and by how much. */
accessor simplificationTolerance: number;
/** The linear units associated with [simplificationTolerance](https://developers.arcgis.com/javascript/latest/references/core/rest/support/TravelMode/#simplificationTolerance). */
simplificationToleranceUnits: LengthUnit;
/**
* Indicates the time-based cost attribute for reporting directions.
*
* Known Value |
* ------------|
* minutes |
* time-at-1-kph |
* travel-time |
* truck-minutes |
* truck-travel-time |
* walk-time
*/
timeAttributeName: string;
/** Indicates the category of travel or vehicle represented by this travel mode. */
type: TraveModeType;
/** Indicates whether the travel mode uses a hierarchy attribute while performing the analysis. */
accessor useHierarchy: boolean;
/** Indicates how the U-turns at junctions that could occur during network traversal are handled by the solver. */
uturnAtJunctions: UTurnRestriction;
}
declare const TravelModeSuperclass: typeof JSONSupport & typeof ClonableMixin