Skip to content

Table

Compute distance/duration table between coordinates.

Parameters:

Name Type Description Default
coordinates

List of (lon, lat) tuples or TableParameters object

None
sources

Indices of source coordinates

required
destinations

Indices of destination coordinates

required
annotations

'duration', 'distance', or both

required
fallback_speed

Fallback speed in km/h

required
fallback_coordinate

Coordinate fallback: 'input' or 'snapped'

required
scale_factor

Scale factor for durations

required
radiuses

Search radius in meters for each coordinate

required
bearings

Bearing constraints

required
hints

Hints from previous request

required
approaches

Approach constraints

required
exclude

Road classes to avoid

required
generate_hints

Generate hints for response

required
snapping

Snapping mode

required

Returns:

Type Description

Table result as osrm.Object

Source code in osrm/__init__.py
def Table(self, coordinates=None, **kwargs):
    """
    Compute distance/duration table between coordinates.

    Args:
        coordinates: List of (lon, lat) tuples or TableParameters object
        sources: Indices of source coordinates
        destinations: Indices of destination coordinates
        annotations: 'duration', 'distance', or both
        fallback_speed: Fallback speed in km/h
        fallback_coordinate: Coordinate fallback: 'input' or 'snapped'
        scale_factor: Scale factor for durations
        radiuses: Search radius in meters for each coordinate
        bearings: Bearing constraints
        hints: Hints from previous request
        approaches: Approach constraints
        exclude: Road classes to avoid
        generate_hints: Generate hints for response
        snapping: Snapping mode

    Returns:
        Table result as osrm.Object
    """
    # Support traditional usage with TableParameters object
    if isinstance(coordinates, TableParameters):
        return self._engine.Table(coordinates).to_dict()

    # Convenience method: build parameters from kwargs
    params = TableParameters()

    # Set coordinates
    if coordinates is not None:
        params.coordinates = coordinates

    # Set other parameters with automatic enum conversion
    for key, value in kwargs.items():
        _set_param(params, key, value)

    return self._engine.Table(params).to_dict()

Table Parameters

Bases: osrm.osrm_ext.BaseParameters

Overloaded function.

  1. __init__(self) -> None

Instantiates an instance of TableParameters.

Examples:

>>> table_params = osrm.TableParameters(
        coordinates = [(7.41337, 43.72956), (7.41546, 43.73077)],
        sources = [0],
        destinations = [1],
        annotations = ['duration'],
        fallback_speed = 1,
        fallback_coordinate_type = 'input',
        scale_factor = 0.9
    )
>>> table_params.IsValid()
True

Parameters:

Name Type Description Default
sources list of int

Use location with given index as source. (default [])

required
destinations list of int

Use location with given index as destination. (default [])

required
annotations list of 'none' | 'duration' | 'distance' | 'all'

Returns additional metadata for each coordinate along the route geometry. (default [])

required
fallback_speed float

If no route found between a source/destination pair, calculate the as-the-crow-flies distance, then use this speed to estimate duration. (default INVALID_FALLBACK_SPEED)

required
fallback_coordinate_type string 'input' | 'snapped'

When using a fallback_speed, use the user-supplied coordinate (input), or the snapped location (snapped) for calculating distances. (default '')

required
scale_factor

Scales the table duration values by this number (use in conjunction with annotations=durations). (default 1.0)

required
BaseParameters BaseParameters

Keyword arguments from parent class.

required

Returns:

Name Type Description
__init__ TableParameters

A TableParameters object, for usage in Table.

IsValid bool

A bool value denoting validity of parameter values.

Attributes:

Name Type Description
sources list of int

Use location with given index as source.

destinations list of int

Use location with given index as destination.

annotations string

Returns additional metadata for each coordinate along the route geometry.

fallback_speed float

If no route found between a source/destination pair, calculate the as-the-crow-flies distance, then use this speed to estimate duration.

fallback_coordinate_type string

When using a fallback_speed, use the user-supplied coordinate (input), or the snapped location (snapped) for calculating distances.

scale_factor string

Scales the table duration values by this number (use in conjunction with annotations=durations).

BaseParameters BaseParameters

Attributes from parent class.

  1. __init__(self, sources: collections.abc.Sequence[int] = [], destinations: collections.abc.Sequence[int] = [], annotations: collections.abc.Sequence[osrm.osrm_ext.TableAnnotationsType] = [], fallback_speed: float = 3.4028234663852886e+38, fallback_coordinate_type: osrm.osrm_ext.TableFallbackCoordinateType = '', scale_factor: float = 1.0, coordinates: collections.abc.Sequence[osrm.osrm_ext.Coordinate] = [], hints: collections.abc.Sequence[std::optional<osrm::engine::Hint>] = [], radiuses: collections.abc.Sequence[osrm.osrm_ext.OptionalDouble] = [], bearings: collections.abc.Sequence[osrm.osrm_ext.OptionalBearing] = [], approaches: collections.abc.Sequence[osrm.osrm_ext.OptionalApproach] = [], generate_hints: bool = True, exclude: collections.abc.Sequence[str] = [], snapping: osrm.osrm_ext.SnappingType = '') -> None