RoutePlannerResult
The RoutePlannerResult class is the main entry point for working with the output of the Geoapify Route Planner API. It allows you to access planned agent routes, job and shipment assignments, and unassigned tasks.
You can also extract structured timelines, detailed routing actions, and generate enriched visualizations or dashboards using its convenience methods.
Purpose
Use RoutePlannerResult to:
- Parse the raw result from the Geoapify Route Planner API
- Access planned agent routes and actions
- Retrieve assignment info for jobs and shipments
- Handle unassigned tasks
- Fetch additional routing details for visualization
Constructor
new RoutePlannerResult(options: RoutePlannerOptions, rawData: RoutePlannerResultResponseData)
Initializes the result handler with routing options and the raw API response.
Core Methods
| Method |
Description |
getData() |
Returns structured planner result (processed via converter) |
getRawData() |
Returns the raw JSON from the API response |
getOptions() |
Returns the RoutePlannerOptions used to make the request |
Agent Routes
| Method |
Description |
getAgentSolutions() |
Returns a list of AgentSolution for all assigned agents |
getAgentSolutionsByIndex() |
Returns agent solutions in array indexed by input agent list |
getAgentSolution(agentIdOrIndex) |
Retrieves a specific agent's solution |
getAgentWaypoints(agentIdOrIndex) |
Returns that agent's Waypoints |
getAgentRouteActions(agentIdOrIndex) |
Returns that agent's RouteActions |
getAgentRouteLegs(agentIdOrIndex) |
Returns that agent's RouteLegs |
Assignments
| Method |
Description |
getJobSolutions() |
Returns a list of JobSolutions for all assigned jobs |
getJobSolution(jobIdOrIndex) |
Finds a job solution by its ID or index |
getAgentJobs(agentIdOrIndex) |
Returns indexes of jobs assigned to an agent |
getShipmentSolutions() |
Returns a list of ShipmentSolutions |
getShipmentSolution(shipmentIdOrIndex) |
Finds a shipment solution by ID or index |
getAgentShipments(agentIdOrIndex) |
Returns shipment indexes assigned to the agent |
Unassigned Tasks
| Method |
Description |
getUnassignedAgents() |
Returns a list of unassigned AgentData entries |
getUnassignedJobs() |
Returns a list of unassigned JobData entries |
getUnassignedShipments() |
Returns a list of unassigned ShipmentData entries |
Job & Shipment Info
| Method |
Description |
getJobInfo(jobIdOrIndex) |
Returns RouteActionInfo for a job (agent, actions, timeline) |
getShipmentInfo(shipmentIdOrIndex) |
Returns RouteActionInfo for a shipment |
External Routing Fetch
| Method |
Description |
getAgentRoute(agentIdOrIndex, options) |
Fetches enriched routing details using agent waypoints and RoutingOptions |
This triggers an HTTP request and returns additional polyline/route info from Geoapify Routing API.
Example
const result = new RoutePlannerResult(options, rawResponse);
// Use ID
const agent = result.getAgentSolution("agent-1");
const waypoints = result.getAgentWaypoints("agent-1");
// Or use index
const agentByIndex = result.getAgentSolution(0);
const waypointsByIndex = result.getAgentWaypoints(0);
const unassignedJobs = result.getUnassignedJobs();