Agent
Agent defines a worker/vehicle that can execute jobs and shipments.
Constructor
Signature: new Agent(raw?: AgentData)
Creates an agent instance. If raw is omitted, empty arrays for capabilities, time_windows, and breaks are initialized.
Methods
| Method | Signature | Purpose |
|---|---|---|
getRaw |
getRaw(): AgentData |
Return current raw payload |
setRaw |
setRaw(value: AgentData): this |
Replace raw payload |
setId |
setId(value: string): this |
Set agent ID |
setDescription |
setDescription(value: string): this |
Set description |
setStartLocation |
setStartLocation(lon: number, lat: number): this |
Set start coordinates |
setStartLocationIndex |
setStartLocationIndex(value: number): this |
Set start location index |
setEndLocation |
setEndLocation(lon: number, lat: number): this |
Set end coordinates |
setEndLocationIndex |
setEndLocationIndex(value: number): this |
Set end location index |
setPickupCapacity |
setPickupCapacity(value: number): this |
Set pickup capacity |
setDeliveryCapacity |
setDeliveryCapacity(value: number): this |
Set delivery capacity |
addCapability |
addCapability(value: string): this |
Add required capability tag |
addTimeWindow |
addTimeWindow(start: number, end: number): this |
Add availability window |
addBreak |
addBreak(value: Break): this |
Add break window/duration |
getRaw()
Returns current AgentData.
setRaw(value)
Replaces the whole agent payload.
setId(value)
Sets a custom agent ID.
setDescription(value)
Sets human-readable description.
setStartLocation(lon, lat)
Sets start location coordinates.
setStartLocationIndex(value)
Sets start location by locations[] index.
setEndLocation(lon, lat)
Sets end location coordinates.
setEndLocationIndex(value)
Sets end location by locations[] index.
setPickupCapacity(value)
Sets max pickup amount.
setDeliveryCapacity(value)
Sets max delivery amount.
addCapability(value)
Adds one capability tag.
addTimeWindow(start, end)
Adds one availability interval in seconds.
addBreak(value)
Adds one break definition.
Example
import { Agent, Break } from '@geoapify/route-planner-sdk';
const agent = new Agent()
.setId('agent-1')
.setStartLocation(13.38, 52.52)
.setEndLocation(13.40, 52.50)
.setPickupCapacity(1000)
.setDeliveryCapacity(1000)
.addCapability('refrigerated')
.addTimeWindow(0, 28800)
.addBreak(new Break().setDuration(1800).addTimeWindow(14400, 18000));
AgentData Interface
This is the original plain data object shape used in API payloads (request/response), not the SDK wrapper class.
interface AgentData {
start_location?: [number, number];
start_location_index?: number;
end_location?: [number, number];
end_location_index?: number;
pickup_capacity?: number;
delivery_capacity?: number;
capabilities: string[];
time_windows: [number, number][];
breaks: BreakData[];
id?: string;
description?: string;
}
Referenced nested interface: BreakData.