1. Stubmation
  2. Travel Distance and Time

Stubmation

Travel Distance and Time

Calculates the driving distance and travel time between two locations. Useful for delivery scheduling, dispatch planning, and route based workflows.

Uses

A scenario for this could be:

  • You have a start and end address and need to know how far apart they are and how long the drive takes
  • You know what time a driver must arrive and need to work out when they should leave
  • You know what time a driver leaves and need to work out when they will arrive
  • You have coordinates instead of addresses and want a single workflow to handle both

This stubmation supports all of those patterns.

Basic Usage

Use this when you have a start and end address and want the distance and travel time between them.

loading...

Flow Data Explained

action_params
required
json object

Contains the start_point and end_point for the trip.


action_params.start_point
required
json object

The location the trip starts from. Supply either an address or coordinates.


action_params.start_point.address
optional
string

The full address string to start from. An address takes precedence over coordinates when both are supplied.

Example:

editor
        "Cape Town";

      

action_params.start_point.coordinates
optional
json object | string

The start coordinates, used when no address is supplied. See Coordinate Formats for the supported shapes.


action_params.start_point.leave_by
optional
string

The departure time. When supplied, the workflow calculates the arrival time. This takes precedence over end_point.arrive_by.

Accepts a HH:mm time, which is applied to the current date, or a full ISO timestamp.

Example:

editor
        "08:15";

      

action_params.end_point
required
json object

The location the trip ends at. Supply either an address or coordinates.


action_params.end_point.address
optional
string

The full address string to end at. An address takes precedence over coordinates when both are supplied.

Example:

editor
        "Bellville";

      

action_params.end_point.coordinates
optional
json object | string

The end coordinates, used when no address is supplied. See Coordinate Formats for the supported shapes.


action_params.end_point.arrive_by
optional
string

The required arrival time. When supplied, and start_point.leave_by is not, the workflow calculates the departure time.

Accepts a HH:mm time, which is applied to the current date, or a full ISO timestamp.

Example:

editor
        "14:40";

      

Coordinate Formats

Instead of an address, either point can be supplied with coordinates. The following shapes are supported.

Coordinates as an object

Latitude and longitude keys can be latitude/longitude, lat/lng or y/x.

loading...

Coordinates as a comma separated string

A single "latitude,longitude" string.

loading...

Result

The task returns the distance and duration for the trip, along with the calculated timing, under payload.stubmation_result.result:

loading...

The result object contains the following fields.

distance_meters
number

The travel distance in meters.

distance_kilometers
number

The travel distance in kilometers, rounded to two decimals.

duration_in_seconds
number

The travel time in seconds.

duration_in_minutes
number

The travel time in minutes, rounded to two decimals.

duration_in_hours
number

The travel time in hours, rounded to two decimals.

leave_by
string

The departure timestamp, as an ISO timestamp with timezone offset.

arrive_by
string

The arrival timestamp, as an ISO timestamp with timezone offset.

Notes

  • Supply an address or coordinates for each point. When both are present, the address is used.
  • Supply leave_by to calculate the arrival time, or arrive_by to calculate the departure time.
  • When both leave_by and arrive_by are supplied, leave_by takes precedence.
  • When neither is supplied, the current time is used as the departure time.
  • Routes are calculated for driving and are traffic aware.