AgentPlan
AgentPlan represents one agent route in result data.
You usually get it from:
RoutePlannerResult.getAgentPlan(agentIdOrIndex)RoutePlannerResult.getAgentPlans()
Methods
| Method | Signature | Purpose |
|---|---|---|
getRaw |
getRaw(): AgentPlanData |
Return raw agent plan payload |
getAgentIndex |
getAgentIndex(): number |
Get agent index |
getAgentId |
getAgentId(): string |
Get agent id |
getTime |
getTime(): number |
Get total route time |
getStartTime |
getStartTime(): number |
Get plan start time |
getEndTime |
getEndTime(): number |
Get plan end time |
getDistance |
getDistance(): number |
Get total route distance |
getMode |
getMode(): string |
Get travel mode |
getLegs |
getLegs(): RouteLeg[] |
Get route legs |
getActions |
getActions(): RouteAction[] |
Get all route actions |
getDelays |
getDelays(): RouteAction[] |
Get delay actions only |
getWaypoints |
getWaypoints(): Waypoint[] |
Get route waypoints |
getPlannedShipments |
getPlannedShipments(): number[] |
Get assigned shipment indexes |
getPlannedJobs |
getPlannedJobs(): number[] |
Get assigned job indexes |
getAgentInputData |
getAgentInputData(): AgentData \| undefined |
Get original input agent payload |
containsShipment |
containsShipment(shipmentIdOrIndex: string \| number): boolean |
Check whether shipment is in plan |
containsJob |
containsJob(jobIdOrIndex: string \| number): boolean |
Check whether job is in plan |
getViolations |
getViolations(): Violation[] |
Get validation violations |
getRoute |
getRoute(routingOptions?): Promise<any \| undefined> |
Fetch route geometry from Routing API |
getRaw()
Returns raw AgentPlanData.
getAgentIndex()
Returns agent index from input agents[].
getAgentId()
Returns agent ID.
getTime()
Returns total route time.
getStartTime()
Returns route start time.
getEndTime()
Returns route end time.
getDistance()
Returns total route distance.
getMode()
Returns travel mode.
getLegs()
Returns all route legs.
getActions()
Returns all route actions.
getDelays()
Returns actions with type === 'delay'.
getWaypoints()
Returns route waypoints.
getPlannedShipments()
Returns unique shipment indexes present in actions.
getPlannedJobs()
Returns unique job indexes present in actions.
getAgentInputData()
Returns original AgentData from input.
containsShipment(shipmentIdOrIndex)
Checks if shipment is present in plan actions.
containsJob(jobIdOrIndex)
Checks if job is present in plan actions.
getViolations()
Returns validation violations attached after edits.
getRoute(routingOptions?)
Fetches route geometry for current waypoints.
If routingOptions is not provided, the method uses routing options from the original
Route Planner input (result.getRoutingOptions()).
If provided, values override those defaults for this route request.
const routeFeature = await agentPlan.getRoute();
const truckRoute = await agentPlan.getRoute({
mode: 'truck',
type: 'less_maneuvers',
traffic: 'approximated'
});
Routing Options Interfaces
These interfaces are used by AgentPlan.getRoute(...).
RoutingOptions Interface
interface RoutingOptions {
mode?: TravelMode;
type?: RouteType;
avoid?: AvoidData[];
traffic?: TrafficType;
max_speed?: number;
units?: DistanceUnitType;
}
| Field | Type | Description |
|---|---|---|
mode |
TravelMode |
Travel mode for route calculation. |
type |
RouteType |
Route preference (balanced, short, less_maneuvers). |
avoid |
AvoidData[] |
Avoid rules passed to Routing API. |
traffic |
TrafficType |
Traffic model used in travel time estimation. |
max_speed |
number |
Optional speed cap for route calculation. |
units |
DistanceUnitType |
Output unit system (metric or imperial). |
RoutingOptionsExtended Interface
interface RoutingOptionsExtended extends RoutingOptions {
lang?: string;
details?: RouteDetailsType[];
}
| Field | Type | Description |
|---|---|---|
lang |
string |
Language for instruction text in route details. |
details |
RouteDetailsType[] |
Extra details to include: instruction_details, route_details, elevation. |
Travel/route-related value sets are listed in
RoutePlanner.
Example
const result = await planner.plan();
const agentPlan = result.getAgentPlan('agent-1');
if (agentPlan) {
console.log(agentPlan.getDistance(), agentPlan.getTime());
console.log(agentPlan.getWaypoints().length);
console.log(agentPlan.getViolations());
}
AgentPlanData Interface
This is the original plain data object shape used in API payloads (request/response), not the SDK wrapper class.
interface AgentPlanData {
agent_index: number;
agent_id: string;
time: number;
start_time: number;
end_time: number;
distance: number;
mode: string;
legs: RouteLegData[];
actions: RouteActionData[];
waypoints: WaypointData[];
}
Referenced interfaces:
- RouteLegData
- RouteActionData
- WaypointData